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); } }