diff -r c2ce9944148c -r 0bba81dde1bc vymmodel.cpp --- a/vymmodel.cpp Wed Feb 10 13:48:42 2010 +0000 +++ b/vymmodel.cpp Fri Feb 19 13:47:03 2010 +0000 @@ -6,6 +6,7 @@ #include "attributeitem.h" #include "treeitem.h" #include "branchitem.h" +#include "bugagent.h" #include "editxlinkdialog.h" #include "exports.h" #include "exportxhtmldialog.h" @@ -48,9 +49,7 @@ extern Settings settings; - - -int VymModel::mapNum=0; // make instance +uint VymModel::idLast=0; // make instance VymModel::VymModel() { @@ -83,7 +82,8 @@ mapScene=NULL; // History - mapNum++; + idLast++; + mapID=idLast; mapChanged=false; mapDefault=true; mapUnsaved=false; @@ -145,14 +145,14 @@ //Initialize DBUS object adaptorModel=new AdaptorModel(this); // Created and not deleted as documented in Qt - if (!dbusConnection.registerObject (QString("/vymmodel_%1").arg(mapNum),this)) + if (!dbusConnection.registerObject (QString("/vymmodel_%1").arg(mapID),this)) qWarning ("VymModel: Couldn't register DBUS object!"); } void VymModel::makeTmpDirectories() { // Create unique temporary directories - tmpMapDir = tmpVymDir+QString("/model-%1").arg(mapNum); + tmpMapDir = tmpVymDir+QString("/model-%1").arg(mapID); histPath = tmpMapDir+"/history"; QDir d; d.mkdir (tmpMapDir); @@ -169,7 +169,7 @@ return blockReposition; } -void VymModel::updateActions() // FIXME-2 maybe don't update if blockReposition is set +void VymModel::updateActions() // FIXME-4 maybe don't update if blockReposition is set { //cout << "VM::updateActions \n"; // Tell mainwindow to update states of actions @@ -354,8 +354,6 @@ if (lmode==NewMap) { selModel->clearSelection(); - // FIXME-2 VM not needed??? model->setMapEditor(this); - // (map state is set later at end of load...) } else { BranchItem *bi=getSelectedBranch(); @@ -470,7 +468,7 @@ file.close(); if ( ok ) { - reposition(); // FIXME-2 VM reposition the view instead... + reposition(); emitSelectionChanged(); if (lmode==NewMap) { @@ -952,7 +950,7 @@ QDateTime tmod=QFileInfo (filePath).lastModified(); if (tmod>fileChangedTime) { - // FIXME-2 VM switch to current mapeditor and finish lineedits... + // FIXME-3 VM switch to current mapeditor and finish lineedits... QMessageBox mb( vymName, tr("The file of the map on disk has changed:\n\n" " %1\n\nDo you want to reload that map with the new file?").arg(filePath), @@ -1877,7 +1875,7 @@ } } -void VymModel::setHideLinkUnselected (bool b) // FIXME-2 Images still have visible link after load +void VymModel::setHideLinkUnselected (bool b) { TreeItem *ti=getSelectedItem(); if (ti && (ti->getType()==TreeItem::Image ||ti->isBranchLikeType())) @@ -2489,7 +2487,7 @@ return false; } -void VymModel::deleteSelection() +void VymModel::deleteSelection() //FIXME-2 xLinks in a deleted subtree are not restored on undo { BranchItem *selbi=getSelectedBranch(); @@ -2532,7 +2530,7 @@ emitShowSelection(); } else if (ti->getType()==TreeItem::XLink) { - //FIXME-2 savestate missing + //FIXME-2 savestate for deleting xlink missing deleteItem (ti); } else qWarning ("VymmModel::deleteSelection() unknown type?!"); @@ -2728,7 +2726,7 @@ // saveState & reposition are called in above functions } -void VymModel::unscrollChildren() //FIXME-2 does not update flag yet, possible segfault +void VymModel::unscrollChildren() { BranchItem *selbi=getSelectedBranch(); BranchItem *prev=NULL; @@ -2929,72 +2927,19 @@ void VymModel::getBugzillaData() { - TreeItem *selti=getSelectedItem(); - if (selti) + BranchItem *selbi=getSelectedBranch(); + if (selbi) { - QString url=selti->getURL(); + QString url=selbi->getURL(); if (!url.isEmpty()) { QRegExp rx("(\\d+)"); if (rx.indexIn(url) !=-1) { QString bugID=rx.cap(1); - cout << "VM::getBugzillaData bug="<selectedFile()+"\")", QString("Set vymlink of %1 to %2").arg(getObjectName(bi)).arg(fd->selectedFile()) ); - setVymLink (fd->selectedFile() ); // FIXME-2 ok? + setVymLink (fd->selectedFile() ); } } } -void VymModel::setVymLink (const QString &s) // FIXME-3 no savestate? +void VymModel::setVymLink (const QString &s) { // Internal function, no saveState needed TreeItem *selti=getSelectedItem(); @@ -3297,7 +3242,7 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(0)) { - selbi->deactivateAllStandardFlags(); + selbi->deactivateAllStandardFlags(); //FIXME-2 this probably should emitDataChanged and also setChanged. Similar all other direct changes should be done... } ///////////////////////////////////////////////////////////////////// } else if (com=="colorBranch") @@ -4151,7 +4096,6 @@ // Any errors? if (parser.errorLevel()==NoError) { - // setChanged(); FIXME-2 should not be called e.g. for export?! reposition(); errorMsg.clear(); noErr=true; @@ -4536,6 +4480,11 @@ return linkstyle; } +uint VymModel::getID() +{ + return mapID; +} + void VymModel::setMapDefLinkColor(QColor col) { if ( !col.isValid() ) return;