diff -r 7f43b93242aa -r 96402b172173 vymmodel.cpp --- a/vymmodel.cpp Mon Oct 06 11:10:20 2008 +0000 +++ b/vymmodel.cpp Wed Oct 29 17:42:34 2008 +0000 @@ -67,16 +67,24 @@ void VymModel::clear() { + cout << "VymModel::clear rows="<setMapEditor(this); + // FIXME VM not needed??? model->setMapEditor(this); // (map state is set later at end of load...) } else { @@ -443,7 +451,7 @@ file.close(); if ( ok ) { - reposition(); // FIXME reposition the view instead... + reposition(); // FIXME VM reposition the view instead... selection.update(); if (lmode==NewMap) { @@ -469,7 +477,6 @@ removeDir (QDir(tmpZipDir)); updateActions(); - return err; } @@ -688,7 +695,7 @@ fio=bo->getLastFloatImage(); fio->load(fn); reposition(); - // FIXME needed? scene()->update(); + // FIXME VM needed? scene()->update(); return fio; } return NULL; @@ -869,7 +876,7 @@ { importDirInt (fd->selectedFile() ); reposition(); - //FIXME needed? scene()->update(); + //FIXME VM needed? scene()->update(); } } } @@ -906,7 +913,7 @@ QDateTime tmod=QFileInfo (filePath).lastModified(); if (tmod>fileChangedTime) { - // FIXME switch to current mapeditor and finish lineedits... + // FIXME 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), @@ -1485,25 +1492,21 @@ QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) ); sel->setHeading(s ); TreeItem *ti=selection.getBranchItem(); - if (ti) ti->setHeading (s); - //FIXME ix is wrong ModelIndex below, ix2 is (hopefully) correct: - QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) ); - cout <<"VM::setHeading s="<row()<<","<column()<<")"<selectionModel(); - selectionModel->clear(); - QItemSelection sel (ix2,ix2); - selectionModel->select (sel, QItemSelectionModel::Select); + ti->setHeading (s); + //FIXME VM ix is wrong ModelIndex below, ix2 is (hopefully) correct: + QModelIndex ix=index( ti->row(), ti->column(), index (0,0,QModelIndex()) ); + //FIXME VM testing only cout <<"VM::setHeading s="<row()<<","<column()<<")"<update(); + // FIXME VM needed? scene()->update(); } } @@ -1926,7 +1929,7 @@ BranchObj *obo=par->moveBranchUp (bo); // bo will be the one below selection saveState (getSelectString(bo),"moveBranchDown ()",getSelectString(obo),"moveBranchUp ()",QString("Move up %1").arg(getObjectName(bo))); reposition(); - //FIXME needed? scene()->update(); + //FIXME VM needed? scene()->update(); selection.update(); ensureSelectionVisible(); } @@ -1943,7 +1946,7 @@ BranchObj *obo=par->moveBranchDown(bo); // bo will be the one above selection saveState(getSelectString(bo),"moveBranchUp ()",getSelectString(obo),"moveBranchDown ()",QString("Move down %1").arg(getObjectName(bo))); reposition(); - //FIXME needed? scene()->update(); + //FIXME VM needed? scene()->update(); selection.update(); ensureSelectionVisible(); } @@ -1975,7 +1978,7 @@ BranchObj *bo=selection.getBranch(); if (bo) { - BranchObj *newbo=addNewBranchInt (-2); // FIXME Old model, merge with below + BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below // Create TreeItem QList cData; @@ -1989,7 +1992,7 @@ if (newbo) { newbo->setTreeItem (ti); - selection.select (newbo); + selection.select (newbo); // FIXME VM really needed here? } } } @@ -2012,11 +2015,11 @@ MapCenterObj* VymModel::addMapCenter(QPointF absPos) { - MapCenterObj *mapCenter = new MapCenterObj(mapScene); + MapCenterObj *mapCenter = new MapCenterObj(mapScene,this); + mapCenter->setMapEditor(mapEditor); //FIXME VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects mapCenter->move (absPos); mapCenter->setVisibility (true); mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); - mapCenter->setMapEditor(mapEditor); //FIXME needed to get defLinkStyle, mapLinkColorHint ... for later added objects mapCenters.append(mapCenter); // Create TreeItem @@ -2097,7 +2100,7 @@ if (bo) { - // FIXME do we still need this in model? setCursor (Qt::ArrowCursor); + // FIXME VM do we still need this in model? setCursor (Qt::ArrowCursor); newbo=addNewBranchInt (pos-2); @@ -2165,7 +2168,7 @@ { // BranchObj* par=(BranchObj*)(bo->getParObj()); selection.unselect(); - /* FIXME Note: does saveStateRemovingPart work for MCO? (No parent!) + /* FIXME VM Note: does saveStateRemovingPart work for MCO? (No parent!) saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo))); */ bo=removeMapCenter ((MapCenterObj*)bo); @@ -2287,7 +2290,7 @@ ); bo->toggleScroll(); selection.update(); - // FIXME needed? scene()->update(); + // FIXME VM needed? scene()->update(); return true; } return false; @@ -2312,7 +2315,7 @@ ); bo->toggleScroll(); selection.update(); - // FIXME needed? scene()->update(); + // FIXME VM needed? scene()->update(); return true; } return false; @@ -2355,7 +2358,7 @@ saveState (PartOfMap, s, "nop ()", s, "copy ()","Copy dropped image to clipboard",fio ); saveState (fio,"delete ()", bo,QString("paste(%1)").arg(curStep),"Pasting dropped image"); reposition(); - // FIXME needed? scene()->update(); + // FIXME VM needed? scene()->update(); } } @@ -2540,7 +2543,7 @@ bo->setVymLink ("" ); updateActions(); reposition(); - // FIXME needed? scene()->update(); + // FIXME VM needed? scene()->update(); } } @@ -2585,7 +2588,7 @@ } } -void VymModel::editXLink(int i) // FIXME missing saveState +void VymModel::editXLink(int i) // FIXME VM missing saveState { BranchObj *bo=selection.getBranch(); if (bo) @@ -3867,14 +3870,24 @@ void VymModel::setMapLinkStyle (const QString & s) { QString snow; - if (linkstyle==LinkableMapObj::Line) - snow="StyleLine"; - else if (linkstyle==LinkableMapObj::Parabel) - snow="StyleParabel"; - else if (linkstyle==LinkableMapObj::PolyLine) - snow="StylePolyLine"; - else if (linkstyle==LinkableMapObj::PolyParabel) - snow="StyleParabel"; + switch (linkstyle) + { + case LinkableMapObj::Line : + snow="StyleLine"; + break; + case LinkableMapObj::Parabel: + snow="StyleParabel"; + break; + case LinkableMapObj::PolyLine: + snow="StylePolyLine"; + break; + case LinkableMapObj::PolyParabel: + snow="StylePolyParabel"; + break; + default: + snow="UndefinedStyle"; + break; + } saveState ( QString("setMapLinkStyle (\"%1\")").arg(s), @@ -3888,8 +3901,10 @@ linkstyle=LinkableMapObj::Parabel; else if (s=="StylePolyLine") linkstyle=LinkableMapObj::PolyLine; - else + else if (s=="StylePolyParabel") linkstyle=LinkableMapObj::PolyParabel; + else + linkstyle=LinkableMapObj::UndefinedStyle; BranchObj *bo; bo=first(); @@ -4341,6 +4356,11 @@ // Selection related ////////////////////////////////////////////// +void VymModel::setSelectionModel (QItemSelectionModel *sm) +{ + selModel=sm; +} + void VymModel::setSelectionBlocked (bool b) { if (b) @@ -4354,6 +4374,14 @@ return selection.isBlocked(); } +bool VymModel::select () +{ + QModelIndex index=selModel->selectedIndexes().first(); // TODO no multiselections yet + + TreeItem *item = static_cast(index.internalPointer()); + return select (item->getLMO() ); +} + bool VymModel::select (const QString &s) { if (selection.select(s))