# HG changeset patch # User insilmaril # Date 1244061437 0 # Node ID 6e4b586aa88a7ea9f1a77c66728bfb3c97c94adb # Parent 2f002657dada9375f77b905529d3bdb96e1168ca Unscrolling temporary works again diff -r 2f002657dada -r 6e4b586aa88a branchitem.cpp --- a/branchitem.cpp Tue May 26 11:24:51 2009 +0000 +++ b/branchitem.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -61,22 +61,24 @@ else scrolledAttr=""; - /* - // save area, if not scrolled // FIXME-3 not needed if HTML is rewritten... + // save area, if not scrolled // FIXME-5 not needed if HTML is rewritten... // also we should check if _any_ of parents is scrolled QString areaAttr; - if (!((BranchObj*)(parObj))->isScrolled() ) + if (lmo && parentItem->isBranchLikeType() && !((BranchItem*)parentItem)->isScrolled() ) { + qreal x=lmo->getAbsPos().x(); + qreal y=lmo->getAbsPos().y(); areaAttr= - attribut("x1",QString().setNum(absPos.x()-offset.x())) + - attribut("y1",QString().setNum(absPos.y()-offset.y())) + - attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) + - attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); + attribut("x1",QString().setNum(x-offset.x())) + + attribut("y1",QString().setNum(y-offset.y())) + + attribut("x2",QString().setNum(x+lmo->width()-offset.x())) + + attribut("y2",QString().setNum(y+lmo->height()-offset.y())); } else areaAttr=""; - // Providing an ID for a branch makes export to XHTML easier + /* + // FIXME-3 Providing an ID for a branch makes export to XHTML easier QString idAttr; if (countXLinks()>0) idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model @@ -104,8 +106,8 @@ s+=valueElement("heading", getHeading(), attribut ("textColor",QColor( bo->getColor()).name())); -/* - // Save frame +/* + // Save frame //FIXME-2 if (frame->getFrameType()!=FrameObj::NoFrame) s+=frame->saveToDir (); */ @@ -255,7 +257,7 @@ if (this !=start && scrolled) return true; BranchItem* bi=(BranchItem*)parentItem; - if (bi) + if (bi && bi->isBranchLikeType() ) return bi->hasScrolledParent(start); else return false; @@ -264,30 +266,32 @@ void BranchItem::tmpUnscroll() { // Unscroll parent (recursivly) - BranchItem * bi=(BranchItem*)parentItem; - if (bi) bi->tmpUnscroll(); + BranchItem * pi=(BranchItem*)parentItem; + if (pi && pi->isBranchLikeType() ) pi->tmpUnscroll(); // Unscroll myself if (scrolled) { tmpUnscrolled=true; - // FIXME-1 systemFlags->activate("tmpUnscrolledright"); + systemFlags.activate("system-tmpUnscrolledRight"); toggleScroll(); + model->emitDataHasChanged (this); } } void BranchItem::resetTmpUnscroll() { // Unscroll parent (recursivly) - BranchItem * bi=(BranchItem*)parentItem; - if (bi) bi->resetTmpUnscroll(); + BranchItem * pi=(BranchItem*)parentItem; + if (pi && pi->isBranchLikeType() ) pi->resetTmpUnscroll(); // Unscroll myself if (tmpUnscrolled) { tmpUnscrolled=false; - // FIXME-1 systemFlags->deactivate("tmpUnscrolledright"); + systemFlags.deactivate("system-tmpUnscrolledRight"); toggleScroll(); + model->emitDataHasChanged (this); } } @@ -361,51 +365,29 @@ BranchObj* BranchItem::createMapObj(QGraphicsScene *scene) { BranchObj *newbo; - cout << "BI::createMO "<setParObj(NULL); - newbo->setTreeItem (this); - newbo->setDefAttr(BranchObj::NewBranch); + newbo->setFrameType (FrameObj::Rectangle); } else { - // Initialize BranchObj, order of things is important... - cout << "BI::createMO (BO) "<getLMO()); - newbo->setParObj(parbo); - newbo->setTreeItem (this); - newbo->setDefAttr(BranchObj::NewBranch); - - if (parentItem->isBranchLikeType()) - { - // Set visibility depending on parents - if (((BranchItem*)parentItem)->scrolled || !parbo->isVisibleObj() ) - { - if (parentItem && parentItem->isBranchLikeType()) - cout <<" scrolled="<<((BranchItem*)parentItem)->scrolled<vis="<isVisibleObj()<setVisibility (false); - } - } else - cout <<" pI=no branch!\n"; - + newbo->setParObj(parentItem->getLMO() ); + // Set visibility depending on parents + if (((BranchItem*)parentItem)->scrolled || !parentItem->getLMO()->isVisibleObj() ) + newbo->setVisibility (false); } + newbo->setDefAttr(BranchObj::NewBranch); initLMO(); if (!getHeading().isEmpty() ) { - ((BranchObj*)lmo)->updateData(); //FIXME-3 maybe better model->emitDataHasChanged()? - ((BranchObj*)lmo)->setColor (headingColor); + newbo->updateData(); //FIXME-3 maybe better model->emitDataHasChanged()? + newbo->setColor (headingColor); } - //newbo->updateLink(); //FIXME-3 diff -r 2f002657dada -r 6e4b586aa88a branchobj.cpp --- a/branchobj.cpp Tue May 26 11:24:51 2009 +0000 +++ b/branchobj.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -130,13 +130,14 @@ // m is position of mouse pointer // offset 0: default 1: below lmo -1 above lmo (if possible) - + BranchItem *pi=(BranchItem*)(lmo->getTreeItem()->parent()); + int pi_depth=pi->depth(); BranchObj* o=(BranchObj*)(lmo); if (!parObjTmpBuf) parObjTmpBuf=parObj; // ignore mapcenter and mainbranch - if (treeItem->depth()<2) off=0; + if (pi_depth<2) off=0; if (off==0) link2ParPos=false; else @@ -385,24 +386,36 @@ void BranchObj::setDockPos() { - // Sets childpos and parpos depending on orientation - if (getOrientation()==LinkableMapObj::LeftOfCenter ) - { - childPos=QPointF ( - ornamentsBBox.bottomLeft().x(), - bottomlineY); - parPos=QPointF ( - ornamentsBBox.bottomRight().x(), - bottomlineY); - } else - { - childPos=QPointF ( - ornamentsBBox.bottomRight().x(), - bottomlineY); - parPos=QPointF ( - ornamentsBBox.bottomLeft().x(), - bottomlineY); - } + if (treeItem->getType()==TreeItem::MapCenter) + { + // set childPos to middle of MapCenterObj + childPos.setX( clickBox.topLeft().x() + clickBox.width()/2 ); + childPos.setY( clickBox.topLeft().y() + clickBox.height()/2 ); + parPos=childPos; + for (int i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->updateLink(); + + } else + { + // Sets childpos and parpos depending on orientation + if (getOrientation()==LinkableMapObj::LeftOfCenter ) + { + childPos=QPointF ( + ornamentsBBox.bottomLeft().x(), + bottomlineY); + parPos=QPointF ( + ornamentsBBox.bottomRight().x(), + bottomlineY); + } else + { + childPos=QPointF ( + ornamentsBBox.bottomRight().x(), + bottomlineY); + parPos=QPointF ( + ornamentsBBox.bottomLeft().x(), + bottomlineY); + } + } } void BranchObj::updateData() diff -r 2f002657dada -r 6e4b586aa88a demos/vym-projectplan.vym Binary file demos/vym-projectplan.vym has changed diff -r 2f002657dada -r 6e4b586aa88a editxlinkdialog.ui --- a/editxlinkdialog.ui Tue May 26 11:24:51 2009 +0000 +++ b/editxlinkdialog.ui Wed Jun 03 20:37:17 2009 +0000 @@ -234,7 +234,6 @@ qPixmapFromMimeSource xlinkobj.h - mapcenterobj.h linkablemapobj.h diff -r 2f002657dada -r 6e4b586aa88a exports.h --- a/exports.h Tue May 26 11:24:51 2009 +0000 +++ b/exports.h Wed Jun 03 20:37:17 2009 +0000 @@ -5,7 +5,6 @@ #include #include -#include "mapcenterobj.h" #include "settings.h" #include "vymmodel.h" diff -r 2f002657dada -r 6e4b586aa88a imports.cpp --- a/imports.cpp Tue May 26 11:24:51 2009 +0000 +++ b/imports.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -34,11 +34,6 @@ inputFile=p; } -void ImportBase::setMapCenter(MapCenterObj *mc) -{ - mapCenter=mc; -} - bool ImportBase::transform() { return true; diff -r 2f002657dada -r 6e4b586aa88a imports.h --- a/imports.h Tue May 26 11:24:51 2009 +0000 +++ b/imports.h Wed Jun 03 20:37:17 2009 +0000 @@ -5,7 +5,6 @@ #include #include -#include "mapcenterobj.h" #include "settings.h" @@ -18,14 +17,12 @@ virtual ~ImportBase(); virtual void setDir(const QString &); virtual void setFile(const QString &); - virtual void setMapCenter (MapCenterObj*); virtual bool transform(); virtual QString getTransformedFile(); protected: QDir tmpDir; QString inputDir; QString inputFile; - MapCenterObj *mapCenter; QString transformedFile; }; diff -r 2f002657dada -r 6e4b586aa88a linkablemapobj.cpp --- a/linkablemapobj.cpp Tue May 26 11:24:51 2009 +0000 +++ b/linkablemapobj.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -447,6 +447,19 @@ // updateLink is called from move, but called from constructor we don't // have parents yet... + + if (!parObj) + { + // If I am a mapcenter, set childPos to middle of MapCenterObj + childPos.setX( clickBox.topLeft().x() + clickBox.width()/2 ); + childPos.setY( clickBox.topLeft().y() + clickBox.height()/2 ); + parPos=childPos; + // Redraw links to children + for (int i=0; ibranchCount(); ++i) + treeItem->getBranchObjNum(i)->updateLink(); + return; + } + if (style==UndefinedStyle) return; switch (linkpos) diff -r 2f002657dada -r 6e4b586aa88a mainwindow.cpp --- a/mainwindow.cpp Tue May 26 11:24:51 2009 +0000 +++ b/mainwindow.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -1131,7 +1131,7 @@ setupFlag (flag,tb,"system-scrolledright",tr("subtree is scrolled","SystemFlag")); flag->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png")); - setupFlag (flag,tb,"system-tmpUnscrolledright",tr("subtree is temporary scrolled","SystemFlag")); + setupFlag (flag,tb,"system-tmpUnscrolledRight",tr("subtree is temporary scrolled","SystemFlag")); flag->load(QPixmap(flagsPath+"flag-hideexport.png")); setupFlag (flag,tb,"system-hideInExport",tr("Hide object in exported maps","SystemFlag")); @@ -2770,22 +2770,21 @@ VymModel *m=currentModel(); if (m) { - BranchItem *bi=m->createBranch(); - - if (bi) + BranchItem *bi=m->addNewBranch(); + if (!bi) return; + + if (actionSettingsAutoEditNewBranch->isOn() + && !actionSettingsAutoSelectNewBranch->isOn() ) + prevSelection=m->getSelectString(); + else + prevSelection=QString(); + + if (actionSettingsAutoSelectNewBranch->isOn() + || actionSettingsAutoEditNewBranch->isOn()) + { m->select (bi); - else - return; - - if (actionSettingsAutoEditNewBranch->isOn()) - { - currentMapEditor()->editHeading(); - return; - } - if (!prevSelection.isEmpty()) - { - m->select(prevSelection); - prevSelection=""; + if (actionSettingsAutoEditNewBranch->isOn()) + currentMapEditor()->editHeading(); } } } diff -r 2f002657dada -r 6e4b586aa88a mapcenterobj.cpp --- a/mapcenterobj.cpp Tue May 26 11:24:51 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -#include - -#include "floatimageobj.h" -#include "geometry.h" -#include "mapcenterobj.h" - -///////////////////////////////////////////////////////////////// -// MapCenterObj -///////////////////////////////////////////////////////////////// -MapCenterObj::MapCenterObj() : BranchObj () -{ -// cout << "Const MapCenterObj\n"; - init(); -} - -MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s) -{ -// cout << "Const MapCenterObj canvas="<setFont(font); - //FIXME-2 no treeitem yet: setDefAttr(MovedBranch); and already in BI::createMapObj ?!? - - frame->setFrameType (FrameObj::Rectangle); -} - - -void MapCenterObj::updateLink() -{ - // set childPos to middle of MapCenterObj - childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 ); - childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 ); - parPos=childPos; - for (int i=0; ibranchCount(); ++i) - treeItem->getBranchObjNum(i)->updateLink(); -} - -void MapCenterObj::updateRelPositions() -{ - if (repositionRequest) unsetAllRepositionRequests(); - - // update relative Positions of branches and floats - for (int i=0; ibranchCount(); ++i) - { - treeItem->getBranchObjNum(i)->setRelPos(); - treeItem->getBranchObjNum(i)->setOrientation(); - } - - for (int i=0; isetRelPos(); - - if (repositionRequest) reposition(); -} - diff -r 2f002657dada -r 6e4b586aa88a mapcenterobj.h --- a/mapcenterobj.h Tue May 26 11:24:51 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#ifndef MAPCENTEROBJ_H -#define MAPCENTEROBJ_H - - -#include - -#include "branchobj.h" - - -class VymModel; - -/*! \brief The center of the map is a special branch. */ - -///////////////////////////////////////////////////////////////////////////// -class MapCenterObj:public BranchObj { -public: - MapCenterObj (); - MapCenterObj (QGraphicsScene *); - ~MapCenterObj (); - void clear(); - void init(); - virtual void updateLink(); - virtual void updateRelPositions(); -}; -#endif diff -r 2f002657dada -r 6e4b586aa88a mapeditor.cpp --- a/mapeditor.cpp Tue May 26 11:24:51 2009 +0000 +++ b/mapeditor.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -858,7 +858,7 @@ fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fio->setRelPos(); fio->updateLink(); //no need for reposition, if we update link here - model->updateSelection(); // position has changed + model->emitSelectionChanged(); // position has changed // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent @@ -1147,7 +1147,7 @@ model->reposition(); } } - model->updateSelection(); //FIXME-3 needed? at least not after pos of selection has changed... + model->emitSelectionChanged(); //FIXME-3 needed? at least not after pos of selection has changed... // Finally resize scene, if needed scene()->update(); movingObj=NULL; @@ -1236,7 +1236,7 @@ // Workaround to avoid adding empty branches if (!uris.at(i).toString().isEmpty()) { - bi=model->createBranch(); + bi=model->addNewBranch(); if (bi) { /* FIXME-2 @@ -1270,8 +1270,40 @@ event->acceptProposedAction(); } -void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &) +void MapEditor::updateSelection(const QItemSelection &newsel,const QItemSelection &oldsel) { + // Take care to tmp scroll/unscroll + if (!oldsel.isEmpty()) + { + QModelIndex ix=oldsel.indexes().first(); + if (ix.isValid() ) + { + TreeItem *ti= static_cast(ix.internalPointer()); + if (ti && ti->isBranchLikeType() ) + { + BranchItem *bi=(BranchItem*)ti; + bi->resetTmpUnscroll(); + } + } + } + + if (!newsel.isEmpty()) + { + QModelIndex ix=newsel.indexes().first(); + if (ix.isValid() ) + { + // Temporary unscroll if necessary + TreeItem *ti= static_cast(ix.internalPointer()); + if (ti->isBranchLikeType() ) + { + BranchItem *bi=(BranchItem*)ti; + if (bi->hasScrolledParent(bi) ) + bi->tmpUnscroll(); + } + scrollTo (ix); + } + } + // Reduce rectangles while (newsel.indexes().count() < selboxList.count() ) delete selboxList.takeFirst(); @@ -1309,6 +1341,8 @@ sb->setBrush (selectionColor); i++; } + + scene()->update(); } void MapEditor::updateData (const QModelIndex &sel) diff -r 2f002657dada -r 6e4b586aa88a mapeditor.h --- a/mapeditor.h Tue May 26 11:24:51 2009 +0000 +++ b/mapeditor.h Wed Jun 03 20:37:17 2009 +0000 @@ -10,6 +10,7 @@ #include "ornamentedobj.h" #include "settings.h" #include "vymmodel.h" +#include "xlinkobj.h" /*! \brief Main widget in vym to display and edit a map */ diff -r 2f002657dada -r 6e4b586aa88a mapitem.cpp --- a/mapitem.cpp Tue May 26 11:24:51 2009 +0000 +++ b/mapitem.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -30,6 +30,11 @@ if (lmo) lmo->move (p); } +void MapItem::setPositionMode (PositionMode mode) +{ + posMode=mode; +} + LinkableMapObj* MapItem::getLMO() { return lmo; diff -r 2f002657dada -r 6e4b586aa88a mapitem.h --- a/mapitem.h Tue May 26 11:24:51 2009 +0000 +++ b/mapitem.h Wed Jun 03 20:37:17 2009 +0000 @@ -17,8 +17,9 @@ class MapItem: public XMLObj { +public: + enum PositionMode {Unused,Absolute,Relative}; protected: - enum PositionMode {Unused,Absolute,Relative}; QPointF pos; PositionMode posMode; @@ -31,6 +32,10 @@ /*! Used to save absolute position while map is not in QGraphicsView */ virtual void setAbsPos(const QPointF&); + /*! Tell object to use e.g. absolute positioning for mapcenter. + Defaulst is MapItem::Unused */ + void setPositionMode (PositionMode mode); + protected: LinkableMapObj *lmo; public: diff -r 2f002657dada -r 6e4b586aa88a version.h --- a/version.h Tue May 26 11:24:51 2009 +0000 +++ b/version.h Wed Jun 03 20:37:17 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version, not for production!" -#define __VYM_BUILD_DATE "2009-05-26" +#define __VYM_BUILD_DATE "2009-06-03" bool checkVersion(const QString &); diff -r 2f002657dada -r 6e4b586aa88a vym.pro --- a/vym.pro Tue May 26 11:24:51 2009 +0000 +++ b/vym.pro Wed Jun 03 20:37:17 2009 +0000 @@ -63,7 +63,6 @@ imports.h \ linkablemapobj.h \ mainwindow.h \ - mapcenterobj.h \ mapeditor.h \ mapitem.h \ mapobj.h \ @@ -124,7 +123,6 @@ linkablemapobj.cpp \ main.cpp \ mainwindow.cpp \ - mapcenterobj.cpp \ mapeditor.cpp \ mapitem.cpp \ mapobj.cpp \ diff -r 2f002657dada -r 6e4b586aa88a vymmodel.cpp --- a/vymmodel.cpp Tue May 26 11:24:51 2009 +0000 +++ b/vymmodel.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -11,7 +11,6 @@ #include "file.h" #include "geometry.h" // for addBBox #include "mainwindow.h" -#include "mapcenterobj.h" #include "misc.h" #include "parser.h" @@ -463,7 +462,7 @@ if ( ok ) { reposition(); // FIXME-2 VM reposition the view instead... - updateSelection(); + emitSelectionChanged(); if (lmode==NewMap) { mapDefault=false; @@ -701,9 +700,9 @@ */ } -FloatImageObj* VymModel::loadFloatImageInt (QString fn) -{ - TreeItem *fi=createImage(); +FloatImageObj* VymModel::loadFloatImageInt (BranchItem *dst,QString fn) +{ + TreeItem *fi=createImage(dst); if (fi) { FloatImageObj *fio= ((FloatImageObj*)fi->getLMO()); @@ -714,14 +713,13 @@ return NULL; } -void VymModel::loadFloatImage () // FIXME-2 -{ -/* - BranchObj *bo=getSelectedBranch(); - if (bo) +void VymModel::loadFloatImage () +{ + BranchItem *selbi=getSelectedBranchItem(); + if (selbi) { - Q3FileDialog *fd=new Q3FileDialog( NULL); + Q3FileDialog *fd=new Q3FileDialog( NULL); // FIXME-4 get rid of Q3FileDialog fd->setMode (Q3FileDialog::ExistingFiles); fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)")); ImagePreview *p =new ImagePreview (fd); @@ -741,24 +739,26 @@ for (int j=0; jselectedFiles().count(); j++) { s=fd->selectedFiles().at(j); - fio=loadFloatImageInt (s); + fio=loadFloatImageInt (selbi,s); + //FIXME-1 savestate for loadImage missing + /* if (fio) saveState( (LinkableMapObj*)fio, "delete ()", - bo, + selbi, QString ("loadImage (%1)").arg(s ), - QString("Add image %1 to %2").arg(s).arg(getObjectName(bo)) + QString("Add image %1 to %2").arg(s).arg(getObjectName(selbi)) ); else // TODO loadFIO error handling qWarning ("Failed to load "+s); + */ } } delete (p); delete (fd); } -*/ } void VymModel::saveFloatImageInt (FloatImageObj *fio, const QString &type, const QString &fn) @@ -1179,7 +1179,7 @@ mainWindow->updateHistory (undoSet); updateActions(); - updateSelection(); + emitSelectionChanged(); } bool VymModel::isUndoAvailable() @@ -1509,7 +1509,7 @@ emitDataHasChanged ( selbi); //FIXME-3 maybe emit signal from TreeItem? reposition(); - updateSelection(); + emitSelectionChanged(); } } @@ -1829,7 +1829,7 @@ ); updateActions(); reposition(); - // updateSelection(); + // emitSelectionChanged(); // FIXME-3 VM needed? scene()->update(); } } @@ -1960,25 +1960,22 @@ BranchItem* VymModel::createMapCenter() { BranchItem *newbi=addMapCenter (QPointF (0,0) ); - select (newbi); return newbi; } -BranchItem* VymModel::createBranch() -{ - BranchItem *selbi=getSelectedBranchItem(); - if (selbi) - return addNewBranchInt (selbi,-2); +BranchItem* VymModel::createBranch(BranchItem *dst) +{ + if (dst) + return addNewBranchInt (dst,-2); else return NULL; } -TreeItem* VymModel::createImage() //FIXME-1 +TreeItem* VymModel::createImage(BranchItem *dst) //FIXME-1 { return NULL; /* - BranchObj *bo=getSelectedBranch(); - if (bo) + if (dst) { FloatImageObj *newfio=bo->addFloatImage(); // FIXME-1 VM Old model, merge with below @@ -2017,6 +2014,7 @@ } BranchItem* VymModel::addMapCenter(QPointF absPos) //FIXME-2 absPos not used in context menu?! +// createMapCenter could then probably be merged with createBranch { // Create TreeItem @@ -2037,12 +2035,13 @@ emit (layoutChanged() ); // Create MapObj + newbi->setPositionMode (MapItem::Absolute); newbi->createMapObj(mapScene); return newbi; } -BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num) //FIXME-4 simplify... +BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num) { // Depending on pos: // -3 insert in children of parent above selection @@ -2086,7 +2085,6 @@ // new branch in order to tmp unscroll parent... newbi->createMapObj(mapScene); reposition(); - select (newbi); return newbi; } @@ -2103,7 +2101,6 @@ { // FIXME-3 setCursor (Qt::ArrowCursor); //Still needed? - newbi=addNewBranchInt (selbi,pos-2); if (newbi) @@ -2116,7 +2113,7 @@ QString ("Add new branch to %1").arg(getObjectName(selbi))); reposition(); - // updateSelection(); FIXME-3 + // emitSelectionChanged(); FIXME-3 latestAddedItem=newbi; // In Network mode, the client needs to know where the new branch is, // so we have to pass on this information via saveState. @@ -2156,10 +2153,9 @@ QString ("Add branch before %1").arg(getObjectName(selbi))); // FIXME-3 needed? reposition(); - // updateSelection(); FIXME-3 + // emitSelectionChanged(); FIXME-3 } } - //FIXME-3 needed? latestSelectionString=selection.getSelectString(); return newbi; } @@ -2250,43 +2246,46 @@ */ } -void VymModel::deleteKeepChildren() //FIXME-2 VM still missing - -{ -/* - BranchObj *bo=getSelectedBranch(); - BranchObj *par; - if (bo) +void VymModel::deleteKeepChildren() + +{ + BranchItem *selbi=getSelectedBranchItem(); + BranchItem *pi; + if (selbi) { - par=(BranchObj*)(bo->getParObj()); - // Don't use this on mapcenter - if (!par) return; - + if (selbi->depth()<2) return; + + pi=(BranchItem*)(selbi->parent()); // Check if we have childs at all to keep - if (bo->getTreeItem()->branchCount()==0) + if (selbi->branchCount()==0) { deleteSelection(); return; } - QPointF p=bo->getRelPos(); + QPointF p; + if (selbi->getLMO()) p=selbi->getLMO()->getRelPos(); saveStateChangingPart( - bo->getParObj(), - bo, + pi, + selbi, "deleteKeepChildren ()", - QString("Remove %1 and keep its children").arg(getObjectName(bo)) + QString("Remove %1 and keep its children").arg(getObjectName(selbi)) ); - QString sel=getSelectString(bo); + QString sel=getSelectString(selbi); unselect(); - par->removeBranchHere(bo); + //FIXME-0 missing in VM pi->removeBranchHere(selbi); reposition(); select (sel); - getSelectedBranch()->move2RelPos (p); - reposition(); + BranchObj *bo=getSelectedBranchObj(); + if (bo) + { + bo->move2RelPos (p); + reposition(); + } } -*/} +} void VymModel::deleteChildren() @@ -2332,7 +2331,7 @@ QString ("%1 %2").arg(r).arg(getObjectName(bi)) ); emitDataHasChanged(bi); - updateSelection(); + emitSelectionChanged(); mapScene->update(); //Needed for _quick_ update, even in 1.13.x //FIXME-3 force update via signal... return true; } @@ -2360,7 +2359,7 @@ ); bi->toggleScroll(); emitDataHasChanged(bi); - updateSelection(); + emitSelectionChanged(); mapScene->update(); //Needed for _quick_ update, even in 1.13.x //FIXME-3 force update via signal... return true; @@ -2427,7 +2426,7 @@ QString("Toggling standard flag \"%1\" of %2").arg(name).arg(getObjectName(bi))); bi->toggleStandardFlag (name, master); reposition(); - updateSelection(); + emitSelectionChanged(); } } @@ -2617,7 +2616,7 @@ bi->setVymLink(s); reposition(); updateActions(); - //updateSelection(); + //emitSelectionChanged(); } } @@ -3034,7 +3033,7 @@ if (ok) { selb->linkTo ((BranchObj*)(dst),n); - updateSelection(); + emitSelectionChanged(); } } else if (typid(*dst) == typid(MapCenterObj) ) { @@ -3047,7 +3046,7 @@ if (ok) { selbi->move (x,y); - updateSelection(); + emitSelectionChanged(); } } } @@ -3082,7 +3081,7 @@ } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); - if (ok) loadFloatImageInt (s); + if (ok) loadFloatImageInt (selbi,s); } ///////////////////////////////////////////////////////////////////// } else if (com=="moveUp") @@ -3859,16 +3858,36 @@ else selti->setNote (textEditor->getText()); emitDataHasChanged(selti); - updateSelection(); + emitSelectionChanged(); } } void VymModel::updateRelPositions() //FIXME-3 VM should have no need to updateRelPos { - //cout << "VM::updateRelPos...\n"; + cout << "VM::updateRelPos...\n"; + /* FIXME-3 ??? for (int i=0; ibranchCount(); i++) ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions(); + */ + /* + void MapCenterObj::updateRelPositions() + { + if (repositionRequest) unsetAllRepositionRequests(); + + // update relative Positions of branches and floats + for (int i=0; ibranchCount(); ++i) + { + treeItem->getBranchObjNum(i)->setRelPos(); + treeItem->getBranchObjNum(i)->setOrientation(); + } + + for (int i=0; isetRelPos(); + + if (repositionRequest) reposition(); + } + */ } void VymModel::reposition() //FIXME-3 VM should have no need to reposition, this is done in views??? @@ -4201,7 +4220,7 @@ QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps)); bo->move(x,y); reposition(); - updateSelection(); + emitSelectionChanged(); } } */ @@ -4232,7 +4251,7 @@ ((OrnamentedObj*)bo)->move2RelPos (x,y); reposition(); bo->updateLink(); - updateSelection(); + emitSelectionChanged(); } } */ @@ -4455,17 +4474,21 @@ } */ -void VymModel::updateSelection(const QItemSelection &newsel) +void VymModel::updateSelection (const QItemSelection &newsel,const QItemSelection &oldsel) //FIXME-4 connected but not used so far +{ +} + +void VymModel::emitSelectionChanged(const QItemSelection &newsel) { emit (selectionChanged(newsel,newsel)); // needed e.g. to update geometry in editor emitShowSelection(); sendSelection(); } -void VymModel::updateSelection() +void VymModel::emitSelectionChanged() { QItemSelection newsel=selModel->selection(); - updateSelection (newsel); + emitSelectionChanged (newsel); } void VymModel::setSelectionColor(QColor col) @@ -4610,7 +4633,7 @@ { if (selection.select(lmo)) { - //updateSelection(); + //emitSelectionChanged(); } } @@ -4618,7 +4641,7 @@ { if (selection.select(lmo)) { - //updateSelection(); + //emitSelectionChanged(); } } */ @@ -4840,7 +4863,7 @@ TreeItem *ti2=par->getFirstBranch(); if (ti2) { select(ti2); - updateSelection(); + emitSelectionChanged(); } } } @@ -4855,7 +4878,7 @@ TreeItem *ti2=par->getLastBranch(); if (ti2) { select(ti2); - updateSelection(); + emitSelectionChanged(); } } } @@ -4879,7 +4902,7 @@ par=ti->parent(); if (!par) return; select(par); - updateSelection(); + emitSelectionChanged(); } } @@ -4955,11 +4978,7 @@ QString VymModel::getSelectString () { - LinkableMapObj *lmo=getSelectedLMO(); - if (lmo) - return getSelectString(lmo); - else - return QString(); + return getSelectString (getSelectedItem()); } QString VymModel::getSelectString (LinkableMapObj *lmo) // FIXME-2 VM needs to use TreeModel. Port all calls to this funtion to the one using TreeItem below... diff -r 2f002657dada -r 6e4b586aa88a vymmodel.h --- a/vymmodel.h Tue May 26 11:24:51 2009 +0000 +++ b/vymmodel.h Wed Jun 03 20:37:17 2009 +0000 @@ -5,7 +5,7 @@ #include #include "file.h" -#include "mapcenterobj.h" +#include "floatimageobj.h" #include "mapeditor.h" #include "parser.h" #include "treeitem.h" @@ -107,7 +107,7 @@ void addMapReplaceInt(const QString & undoSel, const QString & path); void addMapInsertInt (const QString & path, int pos); - FloatImageObj* loadFloatImageInt (QString); + FloatImageObj* loadFloatImageInt (BranchItem *dst,QString); void saveFloatImageInt (FloatImageObj*, const QString &, const QString &); public: void loadFloatImage (); @@ -280,9 +280,9 @@ void sortChildren(); //!< Sort children lexically // The create methods are used to quickly parse a XML file - BranchItem* createMapCenter(); //!< Create and select MapCenter // FIXME-3 maybe join this also with createBranch - BranchItem* createBranch(); //!< Create and select Branch - TreeItem* createImage(); //!< Create and select image + BranchItem* createMapCenter(); //!< Create MapCenter + BranchItem* createBranch(BranchItem *dst); //!< Create Branch + TreeItem* createImage(BranchItem *dst); //!< Create image /*! \brief Add new mapcenter @@ -313,7 +313,7 @@ 0 as child of selection 1 below selection */ - BranchItem* addNewBranch(int pos); + BranchItem* addNewBranch(int pos=0); BranchItem* addNewBranchBefore(); //!< Insert branch between selection and its parent /*! \brief Relink a branch to a new destination dst Relinks branch to dst at branch position pos. There is no saveState @@ -539,9 +539,6 @@ private: TreeItem *latestAddedItem; // latest added object, reset on setChanged() -signals: - void selectionChanged(const QItemSelection &, const QItemSelection &); - public: void setSelectionModel(QItemSelectionModel *); // Set common selectionModel QItemSelectionModel* getSelectionModel(); @@ -591,14 +588,15 @@ QString getSelectString (TreeItem *item); - /* +signals: + void selectionChanged(const QItemSelection &newsel, const QItemSelection &oldsel); + public slots: - void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel); - */ + void updateSelection (const QItemSelection &newSel, const QItemSelection &delSel); public: - void updateSelection(const QItemSelection &oldsel); - void updateSelection(); + void emitSelectionChanged(const QItemSelection &oldsel); + void emitSelectionChanged(); void selectMapLinkColor(); void selectMapSelectionColor(); private: diff -r 2f002657dada -r 6e4b586aa88a vymview.cpp --- a/vymview.cpp Tue May 26 11:24:51 2009 +0000 +++ b/vymview.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -35,6 +35,10 @@ mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); connect ( + selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), + model,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); + + connect ( model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)), mapEditor,SLOT (updateData(const QModelIndex &) ) ); @@ -102,7 +106,7 @@ { // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...) mainWindow->changeSelection (model,newsel,oldsel); // FIXME-3 maybe connect VymModel <-> MainWindow directly? - showSelection(); + //showSelection(); } void VymView::expandAll() diff -r 2f002657dada -r 6e4b586aa88a xml-base.h --- a/xml-base.h Tue May 26 11:24:51 2009 +0000 +++ b/xml-base.h Wed Jun 03 20:37:17 2009 +0000 @@ -6,7 +6,6 @@ #include #include "file.h" -#include "mapcenterobj.h" #include "mapeditor.h" #include "vymmodel.h" diff -r 2f002657dada -r 6e4b586aa88a xml-freemind.cpp --- a/xml-freemind.cpp Tue May 26 11:24:51 2009 +0000 +++ b/xml-freemind.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -78,7 +78,7 @@ //cout <<"model="<getSelectedBranchItem(); if (lastBranchItem) { - lastBranchItem=model->createBranch(); + lastBranchItem=model->createBranch(lastBranchItem); readNodeAttr (atts); } } else if (atts.value ("POSITION")=="right") @@ -105,7 +105,7 @@ lastBranchItem=model->getSelectedBranchItem(); if (lastBranchItem) { - lastBranchItem=model->createBranch(); + lastBranchItem=model->createBranch(lastBranchItem); readNodeAttr (atts); } } @@ -113,7 +113,7 @@ { if (state!=StateMap) { - lastBranchItem=model->createBranch(); + lastBranchItem=model->createBranch(lastBranchItem); } readNodeAttr (atts); } diff -r 2f002657dada -r 6e4b586aa88a xml-vym.cpp --- a/xml-vym.cpp Tue May 26 11:24:51 2009 +0000 +++ b/xml-vym.cpp Wed Jun 03 20:37:17 2009 +0000 @@ -151,8 +151,7 @@ lastBranchItem=bi; if (loadMode==ImportAdd) { - model->createBranch(); - lastBranchItem=model->getSelectedBranchItem(); + lastBranchItem=model->createBranch(lastBranchItem); } //else //FIXME-3 lastBranch->clear(); } else @@ -212,8 +211,7 @@ state=StateBranch; if (loadMode==ImportAdd) { - model->createBranch(); - lastBranchItem=model->getSelectedBranchItem(); + lastBranchItem=model->createBranch(lastBranchItem); } else //FIXME-2 lastBranch->clear(); @@ -229,7 +227,7 @@ } else if ( eName == "branch" && state == StateMapCenter) { state=StateBranch; - lastBranchItem=model->createBranch(); + lastBranchItem=model->createBranch(lastBranchItem); readBranchAttr (atts); } else if ( eName == "htmlnote" && state == StateBranch) { @@ -249,7 +247,7 @@ if (!readXLinkAttr (atts)) return false; } else if ( eName == "branch" && state == StateBranch ) { - lastBranchItem=model->createBranch(); + lastBranchItem=model->createBranch(lastBranchItem); readBranchAttr (atts); } else if ( eName == "html" && state == StateHtmlNote ) { @@ -285,13 +283,13 @@ case StateMapCenter: model->selectParent(); model->emitDataHasChanged (lastBranchItem); - lastBranchItem=model->getSelectedBranchItem(); + lastBranchItem=(BranchItem*)(lastBranchItem->parent()); lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch break; case StateBranch: model->selectParent(); model->emitDataHasChanged (lastBranchItem); - lastBranchItem=model->getSelectedBranchItem(); + lastBranchItem=(BranchItem*)(lastBranchItem->parent()); lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch break; case StateHtml: @@ -341,7 +339,7 @@ htmldata+=ch_org; break; case StateHeading: - model->setHeading(ch_simplified); + lastBranchItem->setHeading(ch_simplified); break; default: return false;