# HG changeset patch # User insilmaril # Date 1240224125 0 # Node ID db0ec4bcf41629a0fe73a5a0cb6e18142c012dd4 # Parent 25a77484ec72e4c80b358d7783cabdf75d1c1aa7 minor fixes diff -r 25a77484ec72 -r db0ec4bcf416 branchitem.cpp --- a/branchitem.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/branchitem.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -249,6 +249,59 @@ } } +TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeLMO) +{ + // Search branches + TreeItem *ti; + for (int i=0; ifindMapItem(p, excludeLMO); + if (ti != NULL) return ti; + } + + + // Search myself + if (getBranchObj()->isInClickBox (p) && (this != excludeLMO) && getBranchObj()->isVisibleObj() ) + return this; + +/* FIXME-2 // Search float images + for (int i=0; iisInClickBox(p) && + (floatimage.at(i) != excludeLMO) && + floatimage.at(i)->getParObj()!= excludeLMO && + floatimage.at(i)->isVisibleObj() + ) return floatimage.at(i)->getTreeItem(); +*/ + return NULL; +} + +TreeItem* BranchItem::findID (QString sid) +{ + // Search branches + TreeItem *ti; + for (int i=0; ifindID (sid); + if (ti != NULL) return ti; + } + + // Search myself + if (sid==objID) return this; + + +/* + // Search float images + for (int i=0; iinBox(p) && + (floatimage.at(i) != excludeLMO) && + floatimage.at(i)->getParObj()!= excludeLMO && + floatimage.at(i)->isVisibleObj() + ) return floatimage.at(i); +*/ + return NULL; +} + + BranchObj* BranchItem::getBranchObj() // FIXME-3 only for transition BO->BI { return (BranchObj*)lmo; diff -r 25a77484ec72 -r db0ec4bcf416 branchitem.h --- a/branchitem.h Tue Apr 07 16:15:53 2009 +0000 +++ b/branchitem.h Mon Apr 20 10:42:05 2009 +0000 @@ -34,9 +34,10 @@ virtual void tmpUnscroll(); // unscroll scrolled parents temporary e.g. during "find" process virtual void resetTmpUnscroll(); // scroll all tmp scrolled parents again e.g. when unselecting + TreeItem* findMapItem (QPointF,TreeItem*); //! search map for branches or images + virtual TreeItem* findID (QString sid); //! search map for object with ID string + BranchObj* getBranchObj(); - - }; #endif diff -r 25a77484ec72 -r db0ec4bcf416 branchobj.cpp --- a/branchobj.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/branchobj.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -424,58 +424,6 @@ } } -LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO) -{ - // Search branches - LinkableMapObj *lmo; - for (int i=0; ibranchCount(); ++i) - { - lmo=treeItem->getBranchObjNum(i)->findMapObj(p, excludeLMO); - if (lmo != NULL) return lmo; - } - - - // Search myself - if (inBox (p,clickBox) && (this != excludeLMO) && isVisibleObj() ) - return this; - - // Search float images - for (int i=0; igetClickBox()) && - (floatimage.at(i) != excludeLMO) && - floatimage.at(i)->getParObj()!= excludeLMO && - floatimage.at(i)->isVisibleObj() - ) return floatimage.at(i); - - return NULL; -} - -LinkableMapObj* BranchObj::findID (QString sid) -{ - // Search branches - LinkableMapObj *lmo; - for (int i=0; ibranchCount(); ++i) - { - lmo=treeItem->getBranchObjNum(i)->findID (sid); - if (lmo != NULL) return lmo; - } - - // Search myself - if (sid==objID) return this; - - -/* - // Search float images - for (int i=0; iinBox(p) && - (floatimage.at(i) != excludeLMO) && - floatimage.at(i)->getParObj()!= excludeLMO && - floatimage.at(i)->isVisibleObj() - ) return floatimage.at(i); -*/ - return NULL; -} - void BranchObj::updateHeading() { if (!treeItem) @@ -743,7 +691,6 @@ BranchObj* BranchObj::addBranch() { BranchObj* newbo=new BranchObj(scene,this); - //FIXME-1 branch.append (newbo); newbo->setParObj(this); newbo->setDefAttr(NewBranch); /* FIXME-2 treeItem not set yet!!! diff -r 25a77484ec72 -r db0ec4bcf416 branchobj.h --- a/branchobj.h Tue Apr 07 16:15:53 2009 +0000 +++ b/branchobj.h Mon Apr 20 10:42:05 2009 +0000 @@ -45,8 +45,7 @@ virtual void positionBBox(); virtual void calcBBoxSize(); virtual void setDockPos(); - virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*); // find MapObj - virtual LinkableMapObj* findID (QString sid); // find Obj by ID string + virtual void updateHeading (); virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir diff -r 25a77484ec72 -r db0ec4bcf416 flagrowobj.cpp --- a/flagrowobj.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/flagrowobj.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -110,9 +110,9 @@ QString FlagRowObj::getFlagName (const QPointF &p) { - if (!inBox (p,clickBox)) return ""; + if (!isInBox (p,clickBox)) return ""; for (int i=0; igetClickBox ())) return flag.at(i)->getName(); + if (isInBox (p,flag.at(i)->getClickBox ())) return flag.at(i)->getName(); return ""; diff -r 25a77484ec72 -r db0ec4bcf416 geometry.cpp --- a/geometry.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/geometry.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -37,7 +37,7 @@ return n; } -bool inBox(const QPointF &p, const QRectF &box) +bool isInBox(const QPointF &p, const QRectF &box) { if (p.x() >= box.left() && p.x() <= box.right() && p.y() <= box.bottom() && p.y() >= box.top() ) diff -r 25a77484ec72 -r db0ec4bcf416 geometry.h --- a/geometry.h Tue Apr 07 16:15:53 2009 +0000 +++ b/geometry.h Mon Apr 20 10:42:05 2009 +0000 @@ -6,7 +6,7 @@ #include QRectF addBBox(QRectF r1, QRectF r2); -bool inBox(const QPointF &p, const QRectF &box); +bool isInBox(const QPointF &p, const QRectF &box); QPointF normalize (const QPointF &p); diff -r 25a77484ec72 -r db0ec4bcf416 linkablemapobj.cpp --- a/linkablemapobj.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/linkablemapobj.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -60,7 +60,6 @@ model=NULL; depth=-1; - mapEditor=NULL; childObj=NULL; parObj=NULL; parObjTmpBuf=NULL; @@ -98,9 +97,6 @@ useRelPos=false; useOrientation=true; - // Reset ID - objID=""; - // Crossreference to treemodel treeItem=NULL; } @@ -114,7 +110,6 @@ setLinkColor (other->linkcolor); relPos=other->relPos; useOrientation=other->useOrientation; - objID=other->objID; treeItem=other->treeItem; } @@ -146,7 +141,6 @@ void LinkableMapObj::setParObj(LinkableMapObj* o) { parObj=o; - mapEditor=parObj->getMapEditor(); model=parObj->getModel(); } @@ -334,16 +328,6 @@ return linkpos; } -void LinkableMapObj::setID (const QString &s) -{ - objID=s; -} - -QString LinkableMapObj::getID() -{ - return objID; -} - void LinkableMapObj::setLinkColor() { // Overloaded in BranchObj and children @@ -580,7 +564,7 @@ return parObj; } -LinkableMapObj* LinkableMapObj::findObjBySelect (QString s) // FIXME-2 port to TreeItem... +LinkableMapObj* LinkableMapObj::findObjBySelect (QString s) // FIXME-0 already in VM??? { LinkableMapObj *lmo=this; QString part; @@ -642,17 +626,6 @@ return depth; } -void LinkableMapObj::setMapEditor (MapEditor *me) -{ - mapEditor=me; - model=mapEditor->getModel(); -} - -MapEditor* LinkableMapObj::getMapEditor () -{ - return mapEditor; -} - QPointF LinkableMapObj::getRandPos() { // Choose a random position with given distance to parent: diff -r 25a77484ec72 -r db0ec4bcf416 linkablemapobj.h --- a/linkablemapobj.h Tue Apr 07 16:15:53 2009 +0000 +++ b/linkablemapobj.h Mon Apr 20 10:42:05 2009 +0000 @@ -9,7 +9,6 @@ #define MAX_DEPTH 999 -class MapEditor; class VymModel; @@ -87,9 +86,6 @@ void setLinkPos (Position); Position getLinkPos (); - virtual void setID (const QString &s); - virtual QString getID (); - virtual void setLinkColor(); // sets color according to colorhint, overloaded virtual void setLinkColor(QColor); QColor getLinkColor(); @@ -106,8 +102,6 @@ QPointF getParPos(); // returns pos where parents dock Orientation getOrientation(); // get orientation virtual int getDepth(); // return depth - virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) FIXME not needed - virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent); FIXME not needed virtual QPointF getRandPos(); // make randomised position virtual void reposition(); @@ -128,9 +122,6 @@ QPointF childPos; QPointF parPos; bool link2ParPos; // While moving around, sometimes link to parent - MapEditor* mapEditor; // for and toggleScroll(), get default styles FIXME should not be needed with model available - // and mapEditor->updateActions() - // and mapEditor->updateSelection() VymModel* model; Orientation orientation; @@ -168,8 +159,6 @@ bool useRelPos; bool useOrientation; - QString objID; // id set during load/save currently used for xLinks - TreeItem *treeItem; // Crossrefence to treemodel }; #endif diff -r 25a77484ec72 -r db0ec4bcf416 mainwindow.cpp --- a/mainwindow.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/mainwindow.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -3465,27 +3465,19 @@ if (m) m->updateNoteFlag(); } -/* -void Main::updateNoteInEditor (VymModel *model, const NoteObj ¬e) -{ - if (model&& model==currentModel() ) - { - textEditor->setNote (note); - } -} -*/ - void Main::updateNoteEditor(QModelIndex index ) { + TreeItem *ti=((VymModel*)sender())->getItem(index); + /* cout << "Main::updateNoteEditor model="<getItem(index); - cout << " item="<getHeading().toStdString()<<" ("<setNote (ti->getNoteObj() ); } void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel) { - //branchPropertyWindow->setModel (model ); //FIXME-1 this used to be called from BranchObj::select() + //branchPropertyWindow->setModel (model ); //FIXME-2 this used to be called from BranchObj::select() if (model && model==currentModel() ) { @@ -3507,9 +3499,7 @@ } else textEditor->setNote(NoteObj() ); } else - { textEditor->setInactive(); - } // Show URL and link in statusbar // FIXME-2 /* @@ -3524,7 +3514,6 @@ // Update Toolbar // FIXME-1, was so far in BranchObj //updateFlagsToolbar(); - // Update actions updateActions(); } } diff -r 25a77484ec72 -r db0ec4bcf416 mainwindow.h --- a/mainwindow.h Tue Apr 07 16:15:53 2009 +0000 +++ b/mainwindow.h Mon Apr 20 10:42:05 2009 +0000 @@ -215,7 +215,6 @@ public slots: void windowToggleSmoothPixmap(); void updateNoteFlag(); -// void updateNoteInEditor (VymModel *model, const NoteObj ¬e); void updateNoteEditor (QModelIndex index); void changeSelection (VymModel *model,const QItemSelection &newSel, const QItemSelection &delSel); diff -r 25a77484ec72 -r db0ec4bcf416 mapcenterobj.cpp --- a/mapcenterobj.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/mapcenterobj.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -3,8 +3,6 @@ #include "floatimageobj.h" #include "geometry.h" #include "mapcenterobj.h" -#include "mapeditor.h" - ///////////////////////////////////////////////////////////////// // MapCenterObj @@ -113,6 +111,7 @@ LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO) { + /* FIXME-1 should not be necessary LinkableMapObj *lmo; // Search through child branches @@ -129,6 +128,7 @@ if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i); // nothing found + */ return NULL; } @@ -144,19 +144,21 @@ attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); // Providing an ID for a branch makes export to XHTML easier + /* FIXME-3 QString idAttr; if (treeItem->xlinkCount()>0) idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model else idAttr=""; + */ QString linkAttr=getLinkAttr(); s=beginElement ("mapcenter" +getOrnXMLAttr() +areaAttr - +idAttr +// +idAttr +getIncludeImageAttr() ); incIndent(); if (heading->getColor()!=QColor("black")) diff -r 25a77484ec72 -r db0ec4bcf416 mapeditor.cpp --- a/mapeditor.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/mapeditor.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -279,6 +279,22 @@ } } +TreeItem* MapEditor::findMapItem (QPointF p,TreeItem *exclude) +{ + // Start with mapcenter, no images allowed at rootItem + int i=0; + BranchItem *bi=model->getRootItem()->getFirstBranch(); + TreeItem *found=NULL; + while (bi) + { + found=bi->findMapItem (p, exclude); + if (found) return found; + i++; + bi=model->getRootItem()->getBranchNum(i); + } + return NULL; +} + AttributeTable* MapEditor::attributeTable() { return attrTable; @@ -405,7 +421,9 @@ // mouseEvent, we don't need to close here. QPointF p = mapToScene(e->pos()); - LinkableMapObj* lmo=model->findMapObj(p, NULL); + TreeItem *ti=findMapItem (p, NULL); + LinkableMapObj* lmo=NULL; + if (ti) lmo=ti->getLMO(); //FIXME-2 get rid of lmo... if (lmo) { // MapObj was found @@ -487,7 +505,9 @@ } QPointF p = mapToScene(e->pos()); - LinkableMapObj* lmo=model->findMapObj(p, NULL); + TreeItem *ti=findMapItem (p, NULL); + LinkableMapObj* lmo=NULL; + if (ti) lmo=ti->getLMO(); //FIXME-2 get rid of lmo... e->accept(); @@ -629,7 +649,10 @@ void MapEditor::mouseMoveEvent(QMouseEvent* e) { QPointF p = mapToScene(e->pos()); - LinkableMapObj *lmosel=model->getSelectedLMO(); + TreeItem *seli=model->getSelectedItem(); + LinkableMapObj* lmosel=NULL; //FIXME-2 get rid of lmosel + if (seli) + lmosel=seli->getLMO(); // Move the selected MapObj if ( lmosel && movingObj) @@ -649,7 +672,9 @@ // of selection back to absPos) // Check if we could link - LinkableMapObj* lmo=model->findMapObj(p, lmosel); + TreeItem *dsti=findMapItem (p, seli); + LinkableMapObj* dst=NULL; + if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of lmo... FloatObj *fio=model->getSelectedFloatImage(); @@ -662,15 +687,15 @@ // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent - if ( (e->modifiers()==Qt::ShiftModifier) && lmo && - ( (typeid(*lmo)==typeid(BranchObj)) || - (typeid(*lmo)==typeid(MapCenterObj)) ) && - ( lmo != fio->getParObj()) + if ( (e->modifiers()==Qt::ShiftModifier) && dst && + ( (typeid(*dst)==typeid(BranchObj)) || + (typeid(*dst)==typeid(MapCenterObj)) ) && + ( dst != fio->getParObj()) ) { if (typeid(*fio) == typeid(FloatImageObj) && - ( (typeid(*lmo)==typeid(BranchObj) || - typeid(*lmo)==typeid(MapCenterObj)) )) + ( (typeid(*dst)==typeid(BranchObj) || + typeid(*dst)==typeid(MapCenterObj)) )) { // Also save the move which was done so far @@ -685,7 +710,7 @@ fio->getParObj()->requestReposition(); model->reposition(); - model->linkFloatImageTo (model->getSelectString(lmo)); + model->linkFloatImageTo (model->getSelectString(dst)); //movingObj=lmosel; //movingObj_orgRelPos=lmosel->getRelPos(); @@ -694,7 +719,7 @@ } } else { // selection != a FloatObj - if (lmosel->getDepth()==0) + if (lmosel->getDepth()==0) //FIXME-1 also moved mapcenters could be linked, but not working here... { // Move MapCenter if (e->buttons()== Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) @@ -722,20 +747,17 @@ } // Maybe we can relink temporary? - if (lmo && (lmo!=lmosel) && model->getSelectedBranchObj() && - (typeid(*lmo)==typeid(BranchObj) || - typeid(*lmo)==typeid(MapCenterObj)) ) - + if (dsti && (dst!=lmosel) && seli->isBranchLikeType() && dsti->isBranchLikeType() ) { if (e->modifiers()==Qt::ControlModifier) { - // Special case: CTRL to link below lmo - lmosel->setParObjTmp (lmo,p,+1); + // Special case: CTRL to link below dst + lmosel->setParObjTmp (dst,p,+1); } else if (e->modifiers()==Qt::ShiftModifier) - lmosel->setParObjTmp (lmo,p,-1); + lmosel->setParObjTmp (dst,p,-1); else - lmosel->setParObjTmp (lmo,p,0); + lmosel->setParObjTmp (dst,p,0); } else { lmosel->unsetParObjTmp(); @@ -775,16 +797,22 @@ void MapEditor::mouseReleaseEvent(QMouseEvent* e) { QPointF p = mapToScene(e->pos()); - LinkableMapObj *dst; - LinkableMapObj *lmosel=model->getSelectedLMO(); + TreeItem *dsti=findMapItem(p, NULL); + LinkableMapObj* dst=NULL; + if (dsti) dst=dsti->getLMO(); //FIXME-2 get rid of dst... + + TreeItem *seli=model->getSelectedItem(); + LinkableMapObj *lmosel=seli->getLMO(); // FIXME-2 get rid of lmosel + + + // Have we been picking color? if (pickingColor) { pickingColor=false; setCursor (Qt::ArrowCursor); // Check if we are over another branch - dst=model->findMapObj(p, NULL); - if (dst && lmosel) + if (dsti && lmosel) { if (e->state() & Qt::ShiftModifier) model->colorBranch (((BranchObj*)dst)->getColor()); @@ -799,8 +827,7 @@ { drawingLink=false; // Check if we are over another branch - dst=model->findMapObj(p, NULL); - if (dst && lmosel) + if (dsti && lmosel && dsti->isBranchLikeType() ) { tmpXLink->setEnd ( ((BranchObj*)(dst)) ); tmpXLink->updateXLink(); @@ -815,8 +842,13 @@ } // Have we been moving something? - if ( lmosel && movingObj ) + if ( seli && movingObj ) { + if (dsti==seli) + { + dsti=NULL; + dst=NULL; + } FloatImageObj *fo=model->getSelectedFloatImage(); if(fo) { @@ -836,10 +868,12 @@ // Check if we are over another branch, but ignore // any found LMOs, which are FloatObjs - dst=model->findMapObj(mapToScene(e->pos() ), lmosel); - if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) + if (dsti && (!dsti->isBranchLikeType() )) + { dst=NULL; + dsti=NULL; + } BranchItem *bi=model->getSelectedBranchItem(); if (bi && bi->depth()==0) @@ -858,7 +892,7 @@ } } - if (model->selectionType() == TreeItem::Branch ) + if (seli->getType() == TreeItem::Branch ) { // A branch was moved // save the position in case we link to mapcenter @@ -871,7 +905,7 @@ QString preSelStr=model->getSelectString(lmosel); copyingObj=false; - if (dst ) + if (dsti ) { // We have a destination, relink to that @@ -923,6 +957,7 @@ if (lmosel->getDepth()==1) { + cout << "ME::releaseMouse d=1\n"; // FIXME_1 better use depth // The select string might be different _after_ moving around. // Therefor reposition and then use string of old selection, too model->reposition(); @@ -979,10 +1014,10 @@ if (e->button() == Qt::LeftButton ) { QPointF p = mapToScene(e->pos()); - LinkableMapObj *lmo=model->findMapObj(p, NULL); - if (lmo) { // MapObj was found + TreeItem *ti=findMapItem (p, NULL); + if (ti) { // MapObj was found // First select the MapObj than edit heading - model->select (lmo); + model->select (ti); editHeading(); } } diff -r 25a77484ec72 -r db0ec4bcf416 mapeditor.h --- a/mapeditor.h Tue Apr 07 16:15:53 2009 +0000 +++ b/mapeditor.h Mon Apr 20 10:42:05 2009 +0000 @@ -26,8 +26,8 @@ void setAntiAlias (bool); //!< Set or unset antialiasing void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps public: - void toggleStandardFlag(QString); - + void toggleStandardFlag(QString); //FIXME-2 still needed? + TreeItem *findMapItem (QPointF p,TreeItem *exclude); //! find item in map at position p. Ignore item exclude AttributeTable* attributeTable(); void testFunction1(); // just testing new stuff diff -r 25a77484ec72 -r db0ec4bcf416 mapobj.cpp --- a/mapobj.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/mapobj.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -1,3 +1,4 @@ +#include "geometry.h" #include "mapobj.h" #include "misc.h" @@ -112,6 +113,10 @@ return clickBox; } +bool MapObj::isInClickBox (const QPointF &p) +{ + return isInBox (p,clickBox); +} QSizeF MapObj::getSize() { diff -r 25a77484ec72 -r db0ec4bcf416 mapobj.h --- a/mapobj.h Tue Apr 07 16:15:53 2009 +0000 +++ b/mapobj.h Mon Apr 20 10:42:05 2009 +0000 @@ -38,6 +38,7 @@ virtual void moveBy (double x,double y); // move to relative Position virtual QRectF getBBox(); // returns bounding box virtual QRectF getClickBox(); // returns box to click + virtual bool isInClickBox (const QPointF &p); //! Checks if p is in clickBox virtual QSizeF getSize(); // returns size of bounding box virtual bool isVisibleObj(); virtual void setVisibility(bool); diff -r 25a77484ec72 -r db0ec4bcf416 treeitem.cpp --- a/treeitem.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/treeitem.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -26,6 +26,11 @@ // isNoteInEditor=false; hidden=false; + + // Reset ID + objID=""; + + } TreeItem::~TreeItem() @@ -46,7 +51,8 @@ { note.copy (other->note); model=other->model; - hideExport=other->hideExport; + hideExport=officially + other->hideExport; } */ @@ -269,6 +275,17 @@ } } +void TreeItem::setID (const QString &s) +{ + objID=s; +} + +QString TreeItem::getID() +{ + return objID; +} + + TreeItem* TreeItem::getChildNum(const int &n) { if (n>=0 && nlastSelectedBranchNum=parentItem->childItems.indexOf(this); } +TreeItem* TreeItem::findBySelectString (const QString &s) //FIXME-1 +{ +/* + LinkableMapObj *lmo=this; + QString part; + QString typ; + QString num; + while (!s.isEmpty() ) + { + part=s.section(",",0,0); + typ=part.left (3); + num=part.right(part.length() - 3); + if (typ=="mc:") + { + if (depth>0) + return false; // in a subtree there is no center + else + break; + } else + if (typ=="bo:") + lmo=lmo->getTreeItem()->getBranchObjNum (num.toInt()); + else + if (typ=="fi:") + lmo=((BranchObj*)lmo)->getFloatImageNum (num.toUInt()); + if (!lmo) break; + + if (s.contains(",")) + s=s.right(s.length() - part.length() -1 ); + else + break; + } + */ + return NULL; +} + +void TreeItem::setLastSelectedBranch(int i) +{ + lastSelectedBranchNum=i; +} + TreeItem* TreeItem::getLastSelectedBranch() { return getBranchNum (lastSelectedBranchNum); diff -r 25a77484ec72 -r db0ec4bcf416 treeitem.h --- a/treeitem.h Tue Apr 07 16:15:53 2009 +0000 +++ b/treeitem.h Mon Apr 20 10:42:05 2009 +0000 @@ -76,14 +76,22 @@ bool isBranchLikeType() const; QString getTypeName (); +protected: + QString objID; //! id set during load/save currently used for xLinks +public: + virtual void setID (const QString &s); + virtual QString getID (); + // Navigation and selection TreeItem* getChildNum(const int &n); BranchItem* getFirstBranch(); BranchItem* getLastBranch(); BranchItem* getBranchNum(const int &n); BranchObj* getBranchObjNum(const int &n); - void setLastSelectedBranch(); + void setLastSelectedBranch(); //! Set myself as last selected in parent + void setLastSelectedBranch(int i); //! Set last selected branch directly TreeItem* getLastSelectedBranch(); + TreeItem* findBySelectString (const QString &); virtual void setHideTmp (HideTmpMode); virtual bool hasHiddenExportParent (); diff -r 25a77484ec72 -r db0ec4bcf416 treemodel.cpp --- a/treemodel.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/treemodel.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -208,6 +208,11 @@ return rootItem; } +TreeItem *TreeModel::getRootItem() +{ + return rootItem; +} + QModelIndex TreeModel::index (TreeItem* ti) { return createIndex (ti->row(),ti->column(),ti); diff -r 25a77484ec72 -r db0ec4bcf416 treemodel.h --- a/treemodel.h Tue Apr 07 16:15:53 2009 +0000 +++ b/treemodel.h Mon Apr 20 10:42:05 2009 +0000 @@ -36,8 +36,10 @@ const QModelIndex & parent = QModelIndex() ); TreeItem* getItem (const QModelIndex &index) const; + TreeItem* getRootItem(); QModelIndex index (TreeItem* ti); + protected: TreeItem *rootItem; }; diff -r 25a77484ec72 -r db0ec4bcf416 version.h --- a/version.h Tue Apr 07 16:15:53 2009 +0000 +++ b/version.h Mon Apr 20 10:42:05 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version" -#define __VYM_BUILD_DATE "2009-04-07" +#define __VYM_BUILD_DATE "2009-04-20" bool checkVersion(const QString &); diff -r 25a77484ec72 -r db0ec4bcf416 vymmodel.cpp --- a/vymmodel.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/vymmodel.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -72,11 +72,7 @@ { selModel->clearSelection(); - // Remove stuff - while (!mapCenters.isEmpty()) // FIXME-2 VM needs to be in treemodel only... - delete mapCenters.takeFirst(); - - QModelIndex ri=index(rootItem); + //QModelIndex ri=index(rootItem); //removeRows (0, rowCount(ri),ri); // FIXME-2 here should be at least a beginRemoveRows... } @@ -273,12 +269,12 @@ return s; } -QString VymModel::saveTreeToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset) +QString VymModel::saveTreeToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset) // FIXME-4 verbose not needed (used to write icons) { QString s; - for (int i=0; isaveToDir (tmpdir,prefix,verbose,offset); + for (int i=0; ibranchCount(); i++) // FIXME-0 remove mapCenters + s+=((MapCenterItem*)rootItem->getBranchNum(i))->saveToDir (tmpdir,prefix,offset); return s; } @@ -1405,21 +1401,8 @@ return mapScene; } -LinkableMapObj* VymModel::findMapObj(QPointF p, LinkableMapObj *excludeLMO) -{ - LinkableMapObj *lmo; - - for (int i=0;ifindMapObj (p,excludeLMO); - if (lmo) return lmo; - } - return NULL; -} - -LinkableMapObj* VymModel::findObjBySelect(const QString &s) -{ - LinkableMapObj *lmo; +TreeItem* VymModel::findBySelectString(const QString &s) +{ if (!s.isEmpty() ) { QString part; @@ -1428,25 +1411,26 @@ part=s.section(",",0,0); typ=part.left (2); num=part.right(part.length() - 3); - if (typ=="mc" && num.toInt()>=0 && num.toInt() =0 && num.toInt() branchCount() ) + return rootItem->getBranchNum (num.toInt() ); } - for (int i=0; ibranchCount(); i++) { - lmo=mapCenters.at(i)->findObjBySelect(s); - if (lmo) return lmo; + ti=rootItem->getBranchNum(i)->findBySelectString(s); + if (ti) return ti; } return NULL; } -LinkableMapObj* VymModel::findID (const QString &s) -{ - LinkableMapObj *lmo; - for (int i=0; ibranchCount(); i++) { - lmo=mapCenters.at(i)->findID (s); - if (lmo) return lmo; + ti=rootItem->getBranchNum(i)->findID (s); + if (ti) return ti; } return NULL; } @@ -1466,7 +1450,6 @@ QString ("setMapAuthor (\"%1\")").arg(s), QString ("Set author of map to \"%1\"").arg(s) ); - author=s; } @@ -1482,7 +1465,6 @@ QString ("setMapComment (\"%1\")").arg(s), QString ("Set comment of map") ); - comment=s; } @@ -1509,7 +1491,6 @@ next(cur,prev,d); } return c; - } void VymModel::setHeading(const QString &s) @@ -1600,8 +1581,6 @@ EOFind=false; } - - void VymModel::setScene (QGraphicsScene *s) { mapScene=s; // FIXME-2 VM should not be necessary anymore, move all occurences to MapEditor @@ -1662,26 +1641,25 @@ */ } -void VymModel::linkFloatImageTo(const QString &dstString) +void VymModel::linkFloatImageTo(const QString &dstString) // FIXME-2 { FloatImageObj *fio=selection.getFloatImage(); if (fio) { - BranchObj *dst=(BranchObj*)findObjBySelect(dstString); - if (dst && (typeid(*dst)==typeid (BranchObj) || - typeid(*dst)==typeid (MapCenterObj))) + TreeItem *dst=findBySelectString (dstString); + if (dst && dst->isBranchLikeType() ) { - LinkableMapObj *dstPar=dst->getParObj(); + TreeItem *dstPar=dst->parent(); QString parString=getSelectString(dstPar); QString fioPreSelectString=getSelectString(fio); QString fioPreParentSelectString=getSelectString (fio->getParObj()); - ((BranchObj*)dst)->addFloatImage (fio); - selection.unselect(); - ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio); + // FIXME-2 ((BranchObj*)dst)->addFloatImage (fio); + unselect(); + // ((BranchObj*)(fio->getParObj()))->removeFloatImage (fio); fio=((BranchObj*)dst)->getLastFloatImage(); fio->setRelPos(); fio->reposition(); - selection.select(fio); + // select (fio); saveState( getSelectString(fio), QString("linkTo (\"%1\")").arg(fioPreParentSelectString), @@ -2105,14 +2083,13 @@ // Create MapObj MapCenterObj *mapCenter = new MapCenterObj(mapScene,this); - mapCenter->setMapEditor(mapEditor); //FIXME-3 VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects + //mapCenter->setMapEditor(mapEditor); //FIXME-3 VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects mapCenter->setTreeItem (mci); // TreeItem needs to exist before setVisibility mci->setLMO (mapCenter); mapCenter->updateHeading(); mapCenter->move (absPos); mapCenter->setVisibility (true); //mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); - mapCenters.append(mapCenter); //FIXME-1 get rid of mapCenters... // Testing /* qWarning ("MW::insertRow a"); @@ -2134,19 +2111,15 @@ { mapCenters.removeAt (i); delete (mco); - if (i>0) return mapCenters.at(i-1); // Return previous MCO + if (i>0) return rootItem->getBranchNum(i-1); // Return previous MCO } */ return NULL; } -MapCenterObj* VymModel::getLastMapCenter() -{ - if (mapCenters.size()>0) - return mapCenters.last(); - else - return NULL; - +MapCenterObj* VymModel::getLastMapCenter() // FIXME-3 still needed? +{ + return (MapCenterObj*)rootItem->getLastBranch(); } @@ -3942,8 +3915,10 @@ void VymModel::registerEditor(QWidget *me) { mapEditor=(MapEditor*)me; - for (int i=0; isetMapEditor(mapEditor); + /* FIXME-3 + for (int i=0; ibranchCount(); i++) + rootItem->getBranchNum(i)->setMapEditor(mapEditor); + */ } void VymModel::unregisterEditor(QWidget *) @@ -3975,16 +3950,18 @@ */ } -void VymModel::updateRelPositions() -{ - for (int i=0; iupdateRelPositions(); +void VymModel::updateRelPositions() //FIXME-2 VM should have no need to updateRelPos +{ + cout << "VM::updateRelPos...\n"; + for (int i=0; ibranchCount(); i++) + ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions(); } -void VymModel::reposition() //FIXME-2 get rid of mapCenters... -{ - for (int i=0;ireposition(); // for positioning heading +void VymModel::reposition() //FIXME-2 VM should have no need to reposition, this is done in views??? +{ + cout << "VM::reposition ...\n"; + for (int i=0;ibranchCount(); i++) + rootItem->getBranchObjNum(i)->reposition(); // for positioning heading } QPolygonF VymModel::shape(BranchObj *bo) @@ -4028,18 +4005,18 @@ // Move all branches and MapCenters away from lmo // to avoid collisions + /* QPolygonF pA; QPolygonF pB; BranchObj *boA=(BranchObj*)lmo; BranchObj *boB; - for (int i=0; ibranchCount(); i++) { - boB=mapCenters.at(i); + boB=rootItem->getBranchNum(i); pA=shape (boA); pB=shape (boB); PolygonCollisionResult r = PolygonCollision(pA, pB, QPoint(0,0)); - /* cout <<"------->" <<"="<getHeading() )<<")" @@ -4047,8 +4024,8 @@ <<") willIntersect" <parent()); selModel->select (ix,QItemSelectionModel::ClearAndSelect ); } } } - updateSelection (oldsel); } } diff -r 25a77484ec72 -r db0ec4bcf416 vymmodel.h --- a/vymmodel.h Tue Apr 07 16:15:53 2009 +0000 +++ b/vymmodel.h Mon Apr 20 10:42:05 2009 +0000 @@ -14,6 +14,7 @@ class BranchItem; class MapCenterItem; +class MapEditor; class VymModel : public TreeModel { Q_OBJECT @@ -23,7 +24,6 @@ //////////////////////////////////////////// private: QGraphicsScene *mapScene; - QList mapCenters; QString version; //!< version string saved in vym file QString author; QString comment; @@ -36,7 +36,7 @@ void init(); void makeTmpDirectories(); //!< create temporary directories e.g. for history - MapEditor* getMapEditor(); // FIXME not necessary + MapEditor* getMapEditor(); // FIXME-2 still necessary? bool isRepositionBlocked(); //!< While load or undo there is no need to update graphicsview @@ -220,9 +220,8 @@ void setScene(QGraphicsScene *s); QGraphicsScene *getScene(); - LinkableMapObj* findMapObj(QPointF,LinkableMapObj*); // find MapObj - LinkableMapObj* findObjBySelect (const QString &s); // find MapObj by select string - LinkableMapObj* findID (const QString &s); // find MapObj by previously set ID + TreeItem* findBySelectString (const QString &s); + TreeItem* findID (const QString &s); // find MapObj by previously set ID //////////////////////////////////////////// @@ -555,7 +554,7 @@ void ensureSelectionVisible(); //!< Show selection in all views -// void selectInt(LinkableMapObj*); +// void selectInt(LinkableMapObj*); //FIXME-4 private: void selectNextBranchInt(); // Increment number of branch diff -r 25a77484ec72 -r db0ec4bcf416 xml-vym.cpp --- a/xml-vym.cpp Tue Apr 07 16:15:53 2009 +0000 +++ b/xml-vym.cpp Mon Apr 20 10:42:05 2009 +0000 @@ -287,6 +287,7 @@ case StateBranch: model->selectParent(); lastBranchItem=model->getSelectedBranchItem(); + lastBranchItem->setLastSelectedBranch (0); // Reset last selected to first child branch break; case StateHtml: htmldata+=""; @@ -441,7 +442,7 @@ } } if (!a.value( "id").isEmpty() ) - lastOO->setID (a.value ("id")); + lastBranchItem->setID (a.value ("id")); if (!a.value( "url").isEmpty() ) lastOO->setURL (a.value ("url")); if (!a.value( "vymLink").isEmpty() ) @@ -582,22 +583,25 @@ { if (!a.value( "endBranch").isEmpty() ) { - LinkableMapObj *lmo=model->findObjBySelect (a.value( "beginBranch")); - if (lmo && typeid (*lmo)==typeid (BranchObj)) + TreeItem *ti=model->findBySelectString (a.value( "beginBranch")); + if (ti && ti->isBranchLikeType()) { + /* FIXME-2 xLinks xlo->setBegin ((BranchObj*)lmo); - lmo=model->findObjBySelect (a.value( "endBranch")); + lmo=model->findBySelectString (a.value( "endBranch")); if (lmo && typeid (*lmo)==typeid (BranchObj)) { xlo->setEnd ((BranchObj*)(lmo)); xlo->activate(); success=true; } + */ } } } // object ID is used starting in version 1.8.76 + /* FIXME-2 xLinks if (!a.value( "beginID").isEmpty() ) { if (!a.value( "endID").isEmpty() ) @@ -616,6 +620,7 @@ } } } + */ if (!success) delete (xlo); return true; // xLinks can only be established at the "end branch", return true }