diff -r 914f330b6aa8 -r 25a77484ec72 vymmodel.cpp --- a/vymmodel.cpp Thu Apr 02 09:57:47 2009 +0000 +++ b/vymmodel.cpp Tue Apr 07 16:15:53 2009 +0000 @@ -3,6 +3,7 @@ #include "vymmodel.h" +#include "treeitem.h" #include "branchitem.h" #include "mapcenteritem.h" #include "editxlinkdialog.h" @@ -147,7 +148,7 @@ defXLinkWidth=1; defXLinkColor=QColor (230,230,230); - hidemode=HideNone; + hidemode=TreeItem::HideNone; // Network netstate=Offline; @@ -186,7 +187,7 @@ -QString VymModel::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel) +QString VymModel::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, TreeItem *saveSel) { // tmpdir temporary directory to which data will be written // prefix mapname, which will be appended to images etc. @@ -357,20 +358,20 @@ // (map state is set later at end of load...) } else { - BranchObj *bo=getSelectedBranch(); - if (!bo) return aborted; + BranchItem *bi=getSelectedBranchItem(); + if (!bi) return aborted; if (lmode==ImportAdd) saveStateChangingPart( - bo, - bo, + bi, + bi, QString("addMapInsert (%1)").arg(fname), - QString("Add map %1 to %2").arg(fname).arg(getObjectName(bo))); + QString("Add map %1 to %2").arg(fname).arg(getObjectName(bi))); else saveStateChangingPart( - bo, - bo, + bi, + bi, QString("addMapReplace(%1)").arg(fname), - QString("Add map %1 to %2").arg(fname).arg(getObjectName(bo))); + QString("Add map %1 to %2").arg(fname).arg(getObjectName(bi))); } @@ -602,7 +603,7 @@ if (selectionType()==TreeItem::Image) saveFloatImage(); else - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranch()); + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranchItem()); // TODO take care of multiselections } @@ -719,8 +720,9 @@ return NULL; } -void VymModel::loadFloatImage () -{ +void VymModel::loadFloatImage () // FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -762,6 +764,7 @@ delete (p); delete (fd); } +*/ } void VymModel::saveFloatImageInt (FloatImageObj *fio, const QString &type, const QString &fn) @@ -867,8 +870,9 @@ */ } -void VymModel::importDirInt (const QString &s) -{ +void VymModel::importDirInt (const QString &s) // FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -877,10 +881,12 @@ QDir d(s); importDirInt (bo,d); } +*/ } -void VymModel::importDir() -{ +void VymModel::importDir() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -900,6 +906,7 @@ //FIXME-3 VM needed? scene()->update(); } } +*/ } @@ -993,8 +1000,7 @@ findReset(); } - -QString VymModel::getObjectName (const LinkableMapObj *lmo) +QString VymModel::getObjectName (const LinkableMapObj *lmo) // FIXME-3 should be obsolete { QString s; if (!lmo) return QString("Error: NULL has no name!"); @@ -1003,7 +1009,7 @@ typeid(*lmo) == typeid(MapCenterObj))) { - s=(((BranchObj*)lmo)->getHeading()); + s=lmo->getTreeItem()->getHeading(); if (s=="") s="unnamed"; return QString("branch (%1)").arg(s); } @@ -1012,6 +1018,25 @@ return QString("Unknown type has no name!"); } + +QString VymModel::getObjectName (const TreeItem *ti) +{ + QString s; + if (!ti) return QString("Error: NULL has no name!"); + + if (ti->isBranchLikeType() ) + { + s=ti->getHeading(); + if (s=="") s="unnamed"; + return QString("branch (%1)").arg(s); + } + /* FIXME-2 move floatimage to TreeModel first + if (type==TreeItem::Image) + return QString ("floatimage [%1]").arg(((FloatImageObj*)lmo)->getOriginalFilename()); + */ + return QString("Unknown type has no name!"); +} + void VymModel::redo() { // Can we undo at all? @@ -1206,7 +1231,7 @@ return (tmpMapDir+"/"+histName); } -void VymModel::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, LinkableMapObj *saveSel) +void VymModel::saveState(const SaveMode &savemode, const QString &undoSelection, const QString &undoCom, const QString &redoSelection, const QString &redoCom, const QString &comment, TreeItem *saveSel) { sendData(redoCom); //FIXME-3 testing @@ -1290,7 +1315,7 @@ } -void VymModel::saveStateChangingPart(LinkableMapObj *undoSel, LinkableMapObj* redoSel, const QString &rc, const QString &comment) +void VymModel::saveStateChangingPart(TreeItem *undoSel, TreeItem* redoSel, const QString &rc, const QString &comment) { // save the selected part of the map, Undo will replace part of map QString undoSelection=""; @@ -1312,20 +1337,20 @@ undoSel); } -void VymModel::saveStateRemovingPart(LinkableMapObj *redoSel, const QString &comment) +void VymModel::saveStateRemovingPart(TreeItem*redoSel, const QString &comment) { if (!redoSel) { qWarning ("VymModel::saveStateRemovingPart no redoSel given!"); return; } - QString undoSelection=getSelectString (redoSel->getParObj()); + QString undoSelection=getSelectString (redoSel->parent() ); QString redoSelection=getSelectString(redoSel); - if (typeid(*redoSel) == typeid(BranchObj) ) + if (redoSel->getType()==TreeItem::Branch) { // save the selected branch of the map, Undo will insert part of map saveState (PartOfMap, - undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(redoSel->getTreeItem()->num()), + undoSelection, QString("addMapInsert (\"PATH\",%1)").arg(redoSel->num()), redoSelection, "delete ()", comment, redoSel); @@ -1333,7 +1358,7 @@ } -void VymModel::saveState(LinkableMapObj *undoSel, const QString &uc, LinkableMapObj *redoSel, const QString &rc, const QString &comment) +void VymModel::saveState(TreeItem *undoSel, const QString &uc, TreeItem *redoSel, const QString &rc, const QString &comment) { // "Normal" savestate: save commands, selections and comment // so just save commands for undo and redo @@ -1489,42 +1514,28 @@ void VymModel::setHeading(const QString &s) { - BranchObj *sel=getSelectedBranch(); - if (sel) + BranchItem *selbi=getSelectedBranchItem(); + if (selbi) { saveState( - sel, - "setHeading (\""+sel->getHeading()+"\")", - sel, + selbi, + "setHeading (\""+selbi->getHeading()+"\")", + selbi, "setHeading (\""+s+"\")", - QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) ); - sel->setHeading(s ); + QString("Set heading of %1 to \"%2\"").arg(getObjectName(selbi)).arg(s) ); + selbi->setHeading(s ); + QModelIndex ix2=index (selbi); + emit (dataChanged ( ix2,ix2)); /* FIXME-3 testing only */ - TreeItem *ti=getSelectedItem(); - if (ti) - { - ti->setHeading (s); - //FIXME-3 VM ix is wrong ModelIndex below, ix2 is (hopefully) correct: - //QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) ); - //FIXME-3 VM testing only cout <<"VM::setHeading s="<row()<<","<column()<<")"<getHeading())<getURL(); else return ""; +*/ } QStringList VymModel::getURLs() // FIXME-1 first, next moved to vymmodel @@ -1678,8 +1693,9 @@ } -void VymModel::setFrameType(const FrameObj::FrameType &t) -{ +void VymModel::setFrameType(const FrameObj::FrameType &t) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1690,10 +1706,12 @@ reposition(); bo->updateLink(); } +*/ } -void VymModel::setFrameType(const QString &s) -{ +void VymModel::setFrameType(const QString &s) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1703,10 +1721,12 @@ reposition(); bo->updateLink(); } +*/ } -void VymModel::setFramePenColor(const QColor &c) -{ +void VymModel::setFramePenColor(const QColor &c) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1714,10 +1734,12 @@ bo, QString ("setFramePenColor (\"%1\")").arg(c.name() ),QString ("set pen color of frame to %1").arg(c.name() )); bo->setFramePenColor (c); } +*/ } -void VymModel::setFrameBrushColor(const QColor &c) -{ +void VymModel::setFrameBrushColor(const QColor &c) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1725,10 +1747,11 @@ bo, QString ("setFrameBrushColor (\"%1\")").arg(c.name() ),QString ("set brush color of frame to %1").arg(c.name() )); bo->setFrameBrushColor (c); } -} - -void VymModel::setFramePadding (const int &i) -{ +*/} + +void VymModel::setFramePadding (const int &i) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1738,10 +1761,12 @@ reposition(); bo->updateLink(); } + */ } -void VymModel::setFrameBorderWidth(const int &i) -{ +void VymModel::setFrameBorderWidth(const int &i) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1751,10 +1776,12 @@ reposition(); bo->updateLink(); } +*/ } -void VymModel::setIncludeImagesVer(bool b) -{ +void VymModel::setIncludeImagesVer(bool b) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1771,10 +1798,11 @@ bo->setIncludeImagesVer(b); reposition(); } -} - -void VymModel::setIncludeImagesHor(bool b) -{ +*/} + +void VymModel::setIncludeImagesHor(bool b) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -1791,10 +1819,12 @@ bo->setIncludeImagesHor(b); reposition(); } + */ } -void VymModel::setHideLinkUnselected (bool b) -{ +void VymModel::setHideLinkUnselected (bool b)//FIXME-2 +{ +/* LinkableMapObj *sel=getSelectedLMO(); if (sel && (selectionType() == TreeItem::Branch || @@ -1813,41 +1843,43 @@ ); sel->setHideLinkUnselected(b); } +*/ } void VymModel::setHideExport(bool b) { - BranchObj *bo=getSelectedBranch(); - if (bo) + BranchItem *bi=getSelectedBranchItem(); + if (bi) { - bo->setHideInExport (b); + bi->setHideInExport (b); QString u= b ? "false" : "true"; QString r=!b ? "false" : "true"; saveState( - bo, + bi, QString ("setHideExport (%1)").arg(u), - bo, + bi, QString ("setHideExport (%1)").arg(r), - QString ("Set HideExport flag of %1 to %2").arg(getObjectName(bo)).arg (r) + QString ("Set HideExport flag of %1 to %2").arg(getObjectName(bi)).arg (r) ); updateActions(); reposition(); - selection.update(); + // selection.update(); // FIXME-3 VM needed? scene()->update(); } } void VymModel::toggleHideExport() { - BranchObj *bo=getSelectedBranch(); - if (bo) - setHideExport ( !bo->hideInExport() ); + BranchItem *selbi=getSelectedBranchItem(); + if (selbi) + setHideExport ( !selbi->hideInExport() ); } -void VymModel::copy() -{ +void VymModel::copy() //FIXME-2 +{ +/* LinkableMapObj *sel=getSelectedLMO(); if (sel && (selectionType() == TreeItem::Branch || @@ -1870,11 +1902,13 @@ clipboardEmpty=false; updateActions(); } +*/ } -void VymModel::pasteNoSave(const int &n) -{ +void VymModel::pasteNoSave(const int &n) //FIXME-2 +{ +/* bool old=blockSaveState; blockSaveState=true; bool zippedOrg=zipped; @@ -1889,10 +1923,12 @@ load (clipboardDir+"/"+clipboardFile,ImportAdd, VymMap); zipped=zippedOrg; blockSaveState=old; +*/ } -void VymModel::paste() +void VymModel::paste() //FIXME-2 { +/* BranchObj *sel=getSelectedBranch(); if (sel) { @@ -1905,15 +1941,18 @@ pasteNoSave(0); reposition(); } +*/ } -void VymModel::cut() -{ +void VymModel::cut() //FIXME-2 +{ +/* LinkableMapObj *sel=getSelectedLMO(); if ( sel && (selectionType() == TreeItem::Branch || selectionType()==TreeItem::MapCenter || selectionType()==TreeItem::Image)) { +*/ /* No savestate! savestate is called in cutNoSave saveStateChangingPart( sel->getParObj(), @@ -1922,14 +1961,16 @@ QString("Cut %1").arg(getObjectName(sel )) ); */ +/* copy(); deleteSelection(); reposition(); } -} - -void VymModel::moveBranchUp() -{ +*/} + +void VymModel::moveBranchUp() //FIXME-2 +{ +/* BranchObj* bo=getSelectedBranch(); BranchObj* par; if (bo) @@ -1943,10 +1984,12 @@ selection.update(); ensureSelectionVisible(); } + */ } -void VymModel::moveBranchDown() -{ +void VymModel::moveBranchDown() //FIXME-2 +{ +/* BranchObj* bo=getSelectedBranch(); BranchObj* par; if (bo) @@ -1960,9 +2003,10 @@ selection.update(); ensureSelectionVisible(); } +*/ } -void VymModel::sortChildren() // FIXME-1 not implemented yet +void VymModel::sortChildren() // FIXME-2 not implemented yet { /* BranchObj* bo=getSelectedBranch(); @@ -1979,10 +2023,11 @@ */ } -void VymModel::createMapCenter() -{ - MapCenterObj *mco=addMapCenter (QPointF (0,0) ); - select (mco); +MapCenterItem* VymModel::createMapCenter() +{ + MapCenterItem *mci=addMapCenter (QPointF (0,0) ); + select (mci); + return mci; } BranchItem* VymModel::createBranch() // FIXME-2 switcht addNewBrancInt to BranchItem... @@ -1991,8 +2036,9 @@ return (BranchItem*)bo->getTreeItem(); } -TreeItem* VymModel::createImage() -{ +TreeItem* VymModel::createImage() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2015,25 +2061,26 @@ } } return NULL; +*/ } -MapCenterObj* VymModel::addMapCenter () -{ - MapCenterObj *mco=addMapCenter (contextPos); +MapCenterItem* VymModel::addMapCenter () +{ + MapCenterItem *mci=addMapCenter (contextPos); //FIXME-2 get rid of MCO here //FIXME-3 selection.select (mco); updateActions(); ensureSelectionVisible(); saveState ( - mco, + mci, "delete()", NULL, QString ("addMapCenter (%1,%2)").arg (contextPos.x()).arg(contextPos.y()), QString ("Adding MapCenter to (%1,%2)").arg (contextPos.x()).arg(contextPos.y()) ); - return mco; + return mci; } -MapCenterObj* VymModel::addMapCenter(QPointF absPos) +MapCenterItem* VymModel::addMapCenter(QPointF absPos) { // Create TreeItem @@ -2046,10 +2093,11 @@ QList cData; cData << "VM:addMapCenter" << "undef"<<"undef"; - MapCenterItem *ti=new MapCenterItem (cData,rootItem); - cout << "VM::addMapCenter ti="<setType (TreeItem::MapCenter); - rootItem->appendChild (ti); + MapCenterItem *mci=new MapCenterItem (cData,rootItem); + cout << "VM::addMapCenter mci="<setType (TreeItem::MapCenter); + mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); + rootItem->appendChild (mci); endInsertRows(); emit (newChildObject (parix)); @@ -2058,12 +2106,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->setTreeItem (ti); // TreeItem needs to exist before setVisibility - ti->setLMO (mapCenter); + 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); + //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"); @@ -2074,11 +2123,12 @@ qWarning ("MW::insertRow b"); */ - return mapCenter; + return mci; } -MapCenterObj* VymModel::removeMapCenter(MapCenterObj* mco) -{ +MapCenterItem* VymModel::removeMapCenter(MapCenterItem* mci) //FIXME-2 +{ +/* int i=mapCenters.indexOf (mco); if (i>=0) { @@ -2086,6 +2136,7 @@ delete (mco); if (i>0) return mapCenters.at(i-1); // Return previous MCO } +*/ return NULL; } @@ -2107,7 +2158,7 @@ // -1 insert in children of parent below selection // 0..n insert in children of parent at pos BranchObj *newbo=NULL; - BranchObj *bo=getSelectedBranch(); + BranchObj *bo=getSelectedBranchObj(); //FIXME-2 BranchItem *bi=getSelectedBranchItem(); if (bo) { @@ -2125,6 +2176,7 @@ beginInsertRows (parix,n,n+1); bi=new BranchItem (cData,parbi); bi->setType (TreeItem::Branch); + bi->setHeading (QApplication::translate("Heading of new branch in map", "new")); parbi->appendChild (bi); endInsertRows (); @@ -2139,7 +2191,7 @@ { bi->setLMO (newbo); newbo->setTreeItem (bi); - select (newbo); // FIXME-2 VM really needed here? + select (bi); } }else if (num==-1) @@ -2163,7 +2215,7 @@ // -1 add above // 0 add as child // +1 add below - BranchObj *bo = getSelectedBranch(); + BranchObj *bo = getSelectedBranchObj(); //FIXME-2 BranchObj *newbo=NULL; if (bo) @@ -2175,9 +2227,9 @@ if (newbo) { saveState( - newbo, + newbo->getTreeItem(), "delete ()", - bo, + bo->getTreeItem(), QString ("addBranch (%1)").arg(pos), QString ("Add new branch to %1").arg(getObjectName(bo))); @@ -2197,8 +2249,9 @@ } -BranchObj* VymModel::addNewBranchBefore() -{ +BranchObj* VymModel::addNewBranchBefore() //FIXME-2 +{ +/* BranchObj *newbo=NULL; BranchObj *bo = getSelectedBranch(); if (bo && selectionType()==TreeItem::Branch) @@ -2228,14 +2281,18 @@ } latestSelectionString=selection.getSelectString(); return newbo; + */ + return NULL; } void VymModel::deleteSelection() { - BranchObj *bo = getSelectedBranch(); // FIXME-2 VM should not be necessary - if (!bo) return; - - QModelIndex ix=getSelectedIndex(); + BranchObj *bo = getSelectedBranchObj(); // FIXME-2 VM should not be necessary + BranchItem *selbi=getSelectedBranchItem(); + + if (!selbi) return; + + QModelIndex ix=index (selbi); if (!ix.isValid() ) return; QModelIndex parentIndex=parent(ix); @@ -2246,45 +2303,45 @@ return; } */ - TreeItem *ti=bo->getTreeItem(); - if (selectionType()==TreeItem::MapCenter) + /* + if (selbi->getType()==TreeItem::MapCenter) { // BranchObj* par=(BranchObj*)(bo->getParObj()); //selection.unselect(); - /* FIXME-1 VM Note: does saveStateRemovingPart work for MCO? (No parent!) - saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo))); - */ + // FIXME-1 VM Note: does saveStateRemovingPart work for MCO? (No parent!) + //saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo))); emit (layoutAboutToBeChanged() ); - parentIndex=parent(index(ti)); - cout << "VM::delete ti="<update(); } +*/ } -void VymModel::colorBranch (QColor c) -{ +void VymModel::colorBranch (QColor c) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2489,10 +2551,12 @@ ); bo->setColor(c); // color branch } +*/ } -void VymModel::colorSubtree (QColor c) -{ +void VymModel::colorSubtree (QColor c) //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2504,21 +2568,25 @@ ); bo->setColorSubtree (c); // color links, color children } +*/ } -QColor VymModel::getCurrentHeadingColor() -{ +QColor VymModel::getCurrentHeadingColor() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) return bo->getColor(); QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected"); + */ return Qt::black; } -void VymModel::editURL() -{ +void VymModel::editURL() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2530,10 +2598,12 @@ // user entered something and pressed OK setURL(text); } +*/ } -void VymModel::editLocalURL() -{ +void VymModel::editLocalURL() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2557,28 +2627,34 @@ setURL (fd->selectedFile() ); } } + */ } -void VymModel::editHeading2URL() -{ +void VymModel::editHeading2URL() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) setURL (bo->getHeading()); +*/ } -void VymModel::editBugzilla2URL() -{ +void VymModel::editBugzilla2URL() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); setURL (url); } +*/ } -void VymModel::editFATE2URL() -{ +void VymModel::editFATE2URL() //FIXME-2 +{ +/* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2593,12 +2669,13 @@ bo->setURL (url); updateActions(); } +*/ } void VymModel::editVymLink() { - BranchObj *bo=getSelectedBranch(); - if (bo) + BranchItem *bi=getSelectedBranchItem(); + if (bi) { QStringList filters; filters <<"VYM map (*.vym)"; @@ -2606,8 +2683,8 @@ fd->setFilters (filters); fd->setCaption(vymName+" - " +tr("Link to another map")); fd->setDirectory (lastFileDir); - if (! bo->getVymLink().isEmpty() ) - fd->selectFile( bo->getVymLink() ); + if (! bi->getVymLink().isEmpty() ) + fd->selectFile( bi->getVymLink() ); fd->show(); QString fn; @@ -2615,44 +2692,45 @@ { lastFileDir=QDir (fd->directory().path()); saveState( - bo, - "setVymLink (\""+bo->getVymLink()+"\")", - bo, + bi, + "setVymLink (\""+bi->getVymLink()+"\")", + bi, "setVymLink (\""+fd->selectedFile()+"\")", - QString("Set vymlink of %1 to %2").arg(getObjectName(bo)).arg(fd->selectedFile()) + QString("Set vymlink of %1 to %2").arg(getObjectName(bi)).arg(fd->selectedFile()) ); setVymLink (fd->selectedFile() ); // FIXME-2 ok? } } } -void VymModel::setVymLink (const QString &s) +void VymModel::setVymLink (const QString &s) // FIXME-3 no savestate? { // Internal function, no saveState needed - BranchObj *bo=getSelectedBranch(); - if (bo) + BranchItem *bi=getSelectedBranchItem(); + if (bi) { - bo->setVymLink(s); + bi->getBranchObj()->setVymLink(s); //FIXME-3 check getBO reposition(); updateActions(); - selection.update(); + //selection.update(); ensureSelectionVisible(); } } void VymModel::deleteVymLink() { - BranchObj *bo=getSelectedBranch(); - if (bo) + BranchItem *bi=getSelectedBranchItem(); + if (bi) { saveState( - bo, - "setVymLink (\""+bo->getVymLink()+"\")", - bo, + bi, + "setVymLink (\""+bi->getBranchObj()->getVymLink()+"\")", //FIXME-3 check getBO + + bi, "setVymLink (\"\")", - QString("Unset vymlink of %1").arg(getObjectName(bo)) + QString("Unset vymlink of %1").arg(getObjectName(bi)) ); - bo->setVymLink ("" ); + bi->getBranchObj()->setVymLink ("" ); //FIXME-3 check getBO updateActions(); reposition(); // FIXME-3 VM needed? scene()->update(); @@ -2661,9 +2739,9 @@ QString VymModel::getVymLink() { - BranchObj *bo=getSelectedBranch(); - if (bo) - return bo->getVymLink(); + BranchItem *bi=getSelectedBranchItem(); + if (bi) + return bi->getBranchObj()->getVymLink(); //FIXME-3 check getBO here... else return ""; @@ -2689,8 +2767,10 @@ } -void VymModel::followXLink(int i) -{ +void VymModel::followXLink(int i) // FIXME-2 +{ + i=0; + /* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2701,10 +2781,13 @@ ensureSelectionVisible(); } } + */ } -void VymModel::editXLink(int i) // FIXME-1 VM missing saveState -{ +void VymModel::editXLink(int i) // FIXME-2 VM missing saveState +{ + i=0; + /* BranchObj *bo=getSelectedBranch(); if (bo) { @@ -2726,6 +2809,7 @@ } } } +*/ } @@ -2738,7 +2822,7 @@ void VymModel::parseAtom(const QString &atom) { - BranchObj *selb=getSelectedBranch(); + //BranchObj *selb=getSelectedBranch(); // FIXME-4 TreeItem* selti=getSelectedItem(); BranchItem *selbi=getSelectedBranchItem(); QString s,t; @@ -2757,7 +2841,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else @@ -2781,7 +2865,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else @@ -2809,7 +2893,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -2817,7 +2901,7 @@ //s=parser.parString (ok,0); // selection t=parser.parString (ok,0); // path to map if (QDir::isRelativePath(t)) t=(tmpMapDir + "/"+t); - addMapReplaceInt(getSelectString(selb),t); + addMapReplaceInt(getSelectString(selbi),t); } ///////////////////////////////////////////////////////////////////// } else if (com==QString("addMapInsert")) @@ -2825,7 +2909,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else @@ -2839,12 +2923,12 @@ } } ///////////////////////////////////////////////////////////////////// - } else if (com=="clearFlags") + } else /*if (com=="clearFlags") // FIXME-2 { if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -2853,12 +2937,12 @@ selb->updateFlagsToolbar(); } ///////////////////////////////////////////////////////////////////// - } else if (com=="colorBranch") + } else */ if (com=="colorBranch") { if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -2872,7 +2956,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -2886,7 +2970,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -2930,7 +3014,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -2943,7 +3027,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb) + } else if (! selbi) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3021,7 +3105,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3030,12 +3114,12 @@ if (ok) importDirInt(s); } ///////////////////////////////////////////////////////////////////// - } else if (com=="linkTo") + } else /* FIXME-2 if (com=="linkTo") { if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if ( selb) + } else if ( selbi) { if (parser.checkParCount(4)) { @@ -3065,7 +3149,7 @@ y=parser.parDouble(ok,3); if (ok) { - selb->move (x,y); + selbi->move (x,y); selection.update(); } } @@ -3090,12 +3174,12 @@ } else parser.setError (Aborted,"Type of selection is not a floatimage or branch"); ///////////////////////////////////////////////////////////////////// - } else if (com=="loadImage") + } else */ if (com=="loadImage") { if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3109,7 +3193,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3122,7 +3206,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3178,7 +3262,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3192,7 +3276,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(4)) @@ -3232,12 +3316,12 @@ parser.setError (Aborted,"Unknown operator: "+t); } else { - if (! selb ) + if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else { - if (selb->getHeading() == u) + if (selbi->getHeading() == u) { cout << "PASSED: " << qPrintable (c) << endl; } else @@ -3296,7 +3380,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3308,12 +3392,12 @@ } ///////////////////////////////////////////////////////////////////// - } else if (com=="selectLastImage") + } else /* FIXME-2 if (com=="selectLastImage") { if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3325,7 +3409,7 @@ } ///////////////////////////////////////////////////////////////////// - } else if (com=="selectLatestAdded") + } else */ if (com=="selectLatestAdded") { if (latestSelectionString.isEmpty() ) { @@ -3417,7 +3501,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! getSelectedBranch() ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3431,7 +3515,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3453,7 +3537,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3482,7 +3566,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb) + } else if (! selbi) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3496,7 +3580,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb) + } else if (! selbi) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3532,7 +3616,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3546,7 +3630,7 @@ if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3556,12 +3640,12 @@ } } ///////////////////////////////////////////////////////////////////// - else if (com=="setFlag") + else /* FIXME-2 if (com=="setFlag") { if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3574,7 +3658,7 @@ } } ///////////////////////////////////////////////////////////////////// - } else if (com=="setFrameType") + } else */ /* FIXME-2 if (com=="setFrameType") { if (!selti ) { @@ -3589,12 +3673,12 @@ setFrameType (s); } ///////////////////////////////////////////////////////////////////// - } else if (com=="sortChildren") + } else*/ if (com=="sortChildren") { if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3602,12 +3686,12 @@ sortChildren(); } ///////////////////////////////////////////////////////////////////// - } else if (com=="toggleFlag") + } else /* FIXME-2 if (com=="toggleFlag") { if (!selti ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3615,17 +3699,17 @@ s=parser.parString(ok,0); if (ok) { - selb->toggleStandardFlag(s); + selbi->toggleStandardFlag(s); selb->updateFlagsToolbar(); } } ///////////////////////////////////////////////////////////////////// - } else if (com=="unscroll") + } else */ if (com=="unscroll") { if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3639,7 +3723,7 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) @@ -3647,12 +3731,12 @@ unscrollChildren (); } ///////////////////////////////////////////////////////////////////// - } else if (com=="unsetFlag") + } else /* FIXME-2 if (com=="unsetFlag") { if (selection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selb ) + } else if (! selbi ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3664,7 +3748,7 @@ selb->updateFlagsToolbar(); } } - } else + } else */ parser.setError (Aborted,"Unknown command"); // Any errors? @@ -3694,9 +3778,9 @@ // should be called before and after exports // depending on the settings if (b && settings.value("/export/useHideExport","true")=="true") - setHideTmpMode (HideExport); + setHideTmpMode (TreeItem::HideExport); else - setHideTmpMode (HideNone); + setHideTmpMode (TreeItem::HideNone); } void VymModel::exportImage(QString fname, bool askName, QString format) @@ -3897,7 +3981,7 @@ mapCenters.at(i)->updateRelPositions(); } -void VymModel::reposition() +void VymModel::reposition() //FIXME-2 get rid of mapCenters... { for (int i=0;ireposition(); // for positioning heading @@ -3937,7 +4021,7 @@ } -void VymModel::moveAway(LinkableMapObj *lmo) +void VymModel::moveAway(LinkableMapObj *lmo) //FIXME-5 { // Autolayout: // @@ -3955,6 +4039,7 @@ pA=shape (boA); pB=shape (boB); PolygonCollisionResult r = PolygonCollision(pA, pB, QPoint(0,0)); + /* cout <<"------->" <<"="<getHeading() )<<")" @@ -3962,6 +4047,7 @@ <<") willIntersect" <getDepth(); + int d=getSelectedBranchItem()->depth(); int oldDepth=d; int i; bool found=false; @@ -4766,7 +4864,7 @@ } else { // Special case, look at orientation - if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter) + if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter) // FIXME-3 check access to LMO num=QString ("%1").arg(num.toInt()-1); else num=QString ("%1").arg(num.toInt()+1); @@ -4799,13 +4897,13 @@ { if (selection.isBlocked() ) return; - BranchObj *bo=getSelectedBranch(); - if (bo && selectionType()==TreeItem::Branch) + BranchItem *bi=getSelectedBranchItem(); + if (bi && bi->getType()==TreeItem::Branch) { - if (bo->getOrientation()==LinkableMapObj::RightOfCenter) + if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO selectPrevBranchInt(); else - if (bo->getDepth()==1) + if (bi->depth()==1) selectNextBranchInt(); else selectPrevBranchInt(); @@ -4816,13 +4914,13 @@ { if (selection.isBlocked() ) return; - BranchObj *bo=getSelectedBranch(); - if (bo && selectionType()==TreeItem::Branch) + BranchItem *bi=getSelectedBranchItem(); + if (bi && bi->getType()==TreeItem::Branch) { - if (bo->getOrientation()==LinkableMapObj::RightOfCenter) + if (bi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO selectNextBranchInt(); else - if (bo->getDepth()==1) + if (bi->depth()==1) selectPrevBranchInt(); else selectNextBranchInt(); @@ -4836,31 +4934,31 @@ QItemSelection oldsel=selModel->selection(); - BranchObj* par; - LinkableMapObj *sel=getSelectedBranch(); - if (sel) + BranchItem* par; + BranchItem *selbi=getSelectedBranchItem(); + TreeItem::Type type=selbi->getType(); + if (selbi) { - if (selectionType()== TreeItem::MapCenter) + if (type == TreeItem::MapCenter) { - QModelIndex ix=getSelectedIndex(); + QModelIndex ix=index(selbi); selModel->select (index (rowCount(ix)-1,0,ix),QItemSelectionModel::ClearAndSelect ); } else { - par=(BranchObj*)(sel->getParObj()); - if (sel->getOrientation()==LinkableMapObj::RightOfCenter) + par=(BranchItem*)selbi->parent(); + if (selbi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO... { // right of center - if (selectionType() == TreeItem::Branch || - selectionType() == TreeItem::Image) + if (type == TreeItem::Branch || + type == TreeItem::Image) { - QModelIndex ix=getSelectedIndex(); - ix=parent(ix); + QModelIndex ix=index (selbi->parent()); selModel->select (ix,QItemSelectionModel::ClearAndSelect ); } } else { // left of center - if (selectionType() == TreeItem::Branch ) + if (type == TreeItem::Branch ) { selectLastSelectedBranch(); return; @@ -4877,21 +4975,22 @@ QItemSelection oldsel=selModel->selection(); - BranchObj* par; - LinkableMapObj *sel=getSelectedBranch(); - if (sel) + BranchItem* par; + BranchItem *selbi=getSelectedBranchItem(); + TreeItem::Type type=selbi->getType(); + if (selbi) { - if (selectionType()== TreeItem::MapCenter) + if (type==TreeItem::MapCenter) { - QModelIndex ix=getSelectedIndex(); + QModelIndex ix=index(selbi); selModel->select (index (0,0,ix),QItemSelectionModel::ClearAndSelect ); } else { - par=(BranchObj*)(sel->getParObj()); - if (sel->getOrientation()==LinkableMapObj::RightOfCenter) + par=(BranchItem*)selbi->parent(); + if (selbi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO { // right of center - if (selectionType() == TreeItem::Branch ) + if ( type== TreeItem::Branch ) { selectLastSelectedBranch(); return; @@ -4899,11 +4998,10 @@ } else { // left of center - if (selectionType() == TreeItem::Branch || - selectionType() == TreeItem::Image) + if (type == TreeItem::Branch || + type == TreeItem::Image) { - QModelIndex ix=getSelectedIndex(); - ix=parent(ix); + QModelIndex ix=index(selbi->parent()); selModel->select (ix,QItemSelectionModel::ClearAndSelect ); } } @@ -4995,7 +5093,7 @@ return NULL; } -BranchObj* VymModel::getSelectedBranch() +BranchObj* VymModel::getSelectedBranchObj() // FIXME-3 this should not be needed in the end!!! { TreeItem *ti = getSelectedBranchItem(); if (ti) @@ -5017,6 +5115,19 @@ return NULL; } +MapCenterItem* VymModel::getSelectedMapCenterItem() +{ + QModelIndexList list=selModel->selectedIndexes(); + if (!list.isEmpty() ) + { + TreeItem *ti = getItem (list.first() ); + TreeItem::Type type=ti->getType(); + if (ti->getType()==TreeItem::MapCenter) + return (MapCenterItem*)ti; + } + return NULL; +} + TreeItem* VymModel::getSelectedItem() { QModelIndexList list=selModel->selectedIndexes();