diff -r bf3ea1f1520b -r 59614eaf5fbb vymmodel.cpp --- a/vymmodel.cpp Tue Apr 28 20:53:44 2009 +0000 +++ b/vymmodel.cpp Wed Apr 29 18:46:31 2009 +0000 @@ -240,6 +240,7 @@ // TODO constr. of FIO creates lots of objects, better do this in some other way... FloatImageObj (mapScene).resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe... + cout << "VM::saveToDir 0 " <getType()==TreeItem::MapCenter) // Save all mapcenters as complete map, if saveSel not set @@ -254,9 +255,11 @@ //s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix); } + cout << "VM::saveToDir 1 \n"; // Save local settings s+=settings.getDataXML (destPath); + cout << "VM::saveToDir 2 \n"; // Save selection if (getSelectedItem() && !saveSel ) s+=xml.valueElement("select",getSelectString()); @@ -1232,7 +1235,7 @@ if (blockSaveState) return; - if (debug) cout << "ME::saveState() for "<branchCount(); i++) { - ti=rootItem->getBranchNum(i)->findBySelectString(s); + // ti=rootItem->getBranchNum(i)->findBySelectString(s); if (ti) return ti; } return NULL; @@ -2066,8 +2071,7 @@ QList cData; cData << "VM:addMapCenter" << "undef"<<"undef"; - MapCenterItem *mci=new MapCenterItem (cData,rootItem); - mci->setType (TreeItem::MapCenter); + MapCenterItem *mci=new MapCenterItem (cData); mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); rootItem->appendChild (mci); @@ -2076,7 +2080,20 @@ emit (layoutChanged() ); // Create MapObj - MapCenterObj *mapCenter = new MapCenterObj(mapScene,this); + BranchObj *newbo=mci->createMapObj(mapScene); + + /* + + if (!mci->getHeading().isEmpty() ) + { + newbo->updateHeading(); + newbo->setColor (headingColor); + } +*/ + + //newbo->updateLink(); //FIXME-3 + +/* //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); @@ -2084,39 +2101,10 @@ mapCenter->move (absPos); mapCenter->setVisibility (true); //mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); - // Testing -/* - qWarning ("MW::insertRow a"); - if (!insertRow(0, parix)) - { - std::cout << " war nix...\n"; - } - qWarning ("MW::insertRow b"); */ - return mci; } -MapCenterItem* VymModel::removeMapCenter(MapCenterItem* mci) //FIXME-2 -{ -/* - int i=mapCenters.indexOf (mco); - if (i>=0) - { - mapCenters.removeAt (i); - delete (mco); - if (i>0) return rootItem->getBranchNum(i-1); // Return previous MCO - } -*/ - return NULL; -} - -MapCenterObj* VymModel::getLastMapCenter() // FIXME-3 still needed? -{ - return (MapCenterObj*)rootItem->getLastBranch(); -} - - BranchItem* VymModel::addNewBranchInt(int num) { // Depending on pos: @@ -2142,7 +2130,6 @@ emit (layoutAboutToBeChanged() ); beginInsertRows (parix,n,n+1); //FIXME-1 check if n is correct: should be index below _last_ branch... bi=new BranchItem (cData); - bi->setType (TreeItem::Branch); bi->setHeading (QApplication::translate("Heading of new branch in map", "new")); parbi->appendChild (bi); @@ -2286,60 +2273,21 @@ if (!selbi) return; - QModelIndex ix=index (selbi); - if (!ix.isValid() ) return; - - QModelIndex parentIndex=parent(ix); -/* - if (!parentIndex.isValid()) - { - cout << "VM::delete no valid parent ix\n"; - return; - } -*/ + TreeItem *pi=selbi->parent(); + QModelIndex parentIndex=index(pi); - /* - 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))); - emit (layoutAboutToBeChanged() ); - - parentIndex=parent(index(selbi)); - cout << "VM::delete selbi="<childNum(); beginRemoveRows (parentIndex,n,n); removeRows (n,1,parentIndex); endRemoveRows(); - select (par); + select (pi); ensureSelectionVisible(); reposition(); @@ -3971,7 +3919,7 @@ void VymModel::updateRelPositions() //FIXME-2 VM should have no need to updateRelPos { - cout << "VM::updateRelPos...\n"; + //cout << "VM::updateRelPos...\n"; for (int i=0; ibranchCount(); i++) ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions(); }