1.1 --- a/vymmodel.cpp Tue Apr 28 20:53:44 2009 +0000
1.2 +++ b/vymmodel.cpp Wed Apr 29 18:46:31 2009 +0000
1.3 @@ -240,6 +240,7 @@
1.4 // TODO constr. of FIO creates lots of objects, better do this in some other way...
1.5 FloatImageObj (mapScene).resetSaveCounter();// FIXME-2 this can be done local to vymmodel maybe...
1.6
1.7 + cout << "VM::saveToDir 0 " <<saveSel<<endl;
1.8 // Build xml recursivly
1.9 if (!saveSel || saveSel->getType()==TreeItem::MapCenter)
1.10 // Save all mapcenters as complete map, if saveSel not set
1.11 @@ -254,9 +255,11 @@
1.12 //s+=((FloatImageObj*)(saveSel))->saveToDir(tmpdir,prefix);
1.13 }
1.14
1.15 + cout << "VM::saveToDir 1 \n";
1.16 // Save local settings
1.17 s+=settings.getDataXML (destPath);
1.18
1.19 + cout << "VM::saveToDir 2 \n";
1.20 // Save selection
1.21 if (getSelectedItem() && !saveSel )
1.22 s+=xml.valueElement("select",getSelectString());
1.23 @@ -1232,7 +1235,7 @@
1.24
1.25 if (blockSaveState) return;
1.26
1.27 - if (debug) cout << "ME::saveState() for "<<qPrintable (mapName)<<endl;
1.28 + if (debug) cout << "VM::saveState() for "<<qPrintable (mapName)<<endl;
1.29
1.30 // Find out current undo directory
1.31 if (undosAvail<stepsTotal) undosAvail++;
1.32 @@ -1263,6 +1266,7 @@
1.33 undoCommand.replace ("PATH",bakMapPath);
1.34 }
1.35
1.36 +
1.37 if (!backupXML.isEmpty())
1.38 // Write XML Data to disk
1.39 saveStringToDisk (bakMapPath,backupXML);
1.40 @@ -1329,7 +1333,7 @@
1.41 undoSel);
1.42 }
1.43
1.44 -void VymModel::saveStateRemovingPart(TreeItem*redoSel, const QString &comment)
1.45 +void VymModel::saveStateRemovingPart(TreeItem* redoSel, const QString &comment)
1.46 {
1.47 if (!redoSel)
1.48 {
1.49 @@ -1397,8 +1401,9 @@
1.50 return mapScene;
1.51 }
1.52
1.53 -TreeItem* VymModel::findBySelectString(const QString &s)
1.54 -{
1.55 +TreeItem* VymModel::findBySelectString(const QString &s) //FIXME-0
1.56 +{
1.57 + return NULL;
1.58 if (!s.isEmpty() )
1.59 {
1.60 QString part;
1.61 @@ -1414,7 +1419,7 @@
1.62 TreeItem *ti;
1.63 for (int i=0; i<rootItem->branchCount(); i++)
1.64 {
1.65 - ti=rootItem->getBranchNum(i)->findBySelectString(s);
1.66 + // ti=rootItem->getBranchNum(i)->findBySelectString(s);
1.67 if (ti) return ti;
1.68 }
1.69 return NULL;
1.70 @@ -2066,8 +2071,7 @@
1.71
1.72 QList<QVariant> cData;
1.73 cData << "VM:addMapCenter" << "undef"<<"undef";
1.74 - MapCenterItem *mci=new MapCenterItem (cData,rootItem);
1.75 - mci->setType (TreeItem::MapCenter);
1.76 + MapCenterItem *mci=new MapCenterItem (cData);
1.77 mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
1.78 rootItem->appendChild (mci);
1.79
1.80 @@ -2076,7 +2080,20 @@
1.81 emit (layoutChanged() );
1.82
1.83 // Create MapObj
1.84 - MapCenterObj *mapCenter = new MapCenterObj(mapScene,this);
1.85 + BranchObj *newbo=mci->createMapObj(mapScene);
1.86 +
1.87 + /*
1.88 +
1.89 + if (!mci->getHeading().isEmpty() )
1.90 + {
1.91 + newbo->updateHeading();
1.92 + newbo->setColor (headingColor);
1.93 + }
1.94 +*/
1.95 +
1.96 + //newbo->updateLink(); //FIXME-3
1.97 +
1.98 +/*
1.99 //mapCenter->setMapEditor(mapEditor); //FIXME-3 VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects
1.100 mapCenter->setTreeItem (mci); // TreeItem needs to exist before setVisibility
1.101 mci->setLMO (mapCenter);
1.102 @@ -2084,39 +2101,10 @@
1.103 mapCenter->move (absPos);
1.104 mapCenter->setVisibility (true);
1.105 //mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map"));
1.106 - // Testing
1.107 -/*
1.108 - qWarning ("MW::insertRow a");
1.109 - if (!insertRow(0, parix))
1.110 - {
1.111 - std::cout << " war nix...\n";
1.112 - }
1.113 - qWarning ("MW::insertRow b");
1.114 */
1.115 -
1.116 return mci;
1.117 }
1.118
1.119 -MapCenterItem* VymModel::removeMapCenter(MapCenterItem* mci) //FIXME-2
1.120 -{
1.121 -/*
1.122 - int i=mapCenters.indexOf (mco);
1.123 - if (i>=0)
1.124 - {
1.125 - mapCenters.removeAt (i);
1.126 - delete (mco);
1.127 - if (i>0) return rootItem->getBranchNum(i-1); // Return previous MCO
1.128 - }
1.129 -*/
1.130 - return NULL;
1.131 -}
1.132 -
1.133 -MapCenterObj* VymModel::getLastMapCenter() // FIXME-3 still needed?
1.134 -{
1.135 - return (MapCenterObj*)rootItem->getLastBranch();
1.136 -}
1.137 -
1.138 -
1.139 BranchItem* VymModel::addNewBranchInt(int num)
1.140 {
1.141 // Depending on pos:
1.142 @@ -2142,7 +2130,6 @@
1.143 emit (layoutAboutToBeChanged() );
1.144 beginInsertRows (parix,n,n+1); //FIXME-1 check if n is correct: should be index below _last_ branch...
1.145 bi=new BranchItem (cData);
1.146 - bi->setType (TreeItem::Branch);
1.147 bi->setHeading (QApplication::translate("Heading of new branch in map", "new"));
1.148
1.149 parbi->appendChild (bi);
1.150 @@ -2286,60 +2273,21 @@
1.151
1.152 if (!selbi) return;
1.153
1.154 - QModelIndex ix=index (selbi);
1.155 - if (!ix.isValid() ) return;
1.156 -
1.157 - QModelIndex parentIndex=parent(ix);
1.158 -/*
1.159 - if (!parentIndex.isValid())
1.160 - {
1.161 - cout << "VM::delete no valid parent ix\n";
1.162 - return;
1.163 - }
1.164 -*/
1.165 + TreeItem *pi=selbi->parent();
1.166 + QModelIndex parentIndex=index(pi);
1.167
1.168 - /*
1.169 - if (selbi->getType()==TreeItem::MapCenter)
1.170 - {
1.171 - // BranchObj* par=(BranchObj*)(bo->getParObj());
1.172 - //selection.unselect();
1.173 - // FIXME-1 VM Note: does saveStateRemovingPart work for MCO? (No parent!)
1.174 - //saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
1.175 - emit (layoutAboutToBeChanged() );
1.176 -
1.177 - parentIndex=parent(index(selbi));
1.178 - cout << "VM::delete selbi="<<selbi<<" row="<<ix.row()<<" parIndex.valid="<<parentIndex.isValid()<<endl;
1.179 - int n=ix.row();
1.180 - beginRemoveRows (parentIndex,n,n);
1.181 - removeRows (n,1,parentIndex);
1.182 - MapCenterItem *mci=removeMapCenter (selbi);
1.183 - endRemoveRows();
1.184 - if (mci)
1.185 - {
1.186 - select (mci);
1.187 - ensureSelectionVisible();
1.188 - reposition();
1.189 - }
1.190 -
1.191 - emit (layoutChanged() );
1.192 - }
1.193 - if (selbi->getType()==TreeItem::Branch)
1.194 - */
1.195 if (selbi->isBranchLikeType() )
1.196 {
1.197 -
1.198 - BranchObj* par=(BranchObj*)bo->getParObj();
1.199 unselect();
1.200 - saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(bo)));
1.201 + saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi)));
1.202
1.203 emit (layoutAboutToBeChanged() );
1.204
1.205 - parentIndex=parent(index(selbi));
1.206 - int n=ix.row();
1.207 + int n=selbi->childNum();
1.208 beginRemoveRows (parentIndex,n,n);
1.209 removeRows (n,1,parentIndex);
1.210 endRemoveRows();
1.211 - select (par);
1.212 + select (pi);
1.213 ensureSelectionVisible();
1.214 reposition();
1.215
1.216 @@ -3971,7 +3919,7 @@
1.217
1.218 void VymModel::updateRelPositions() //FIXME-2 VM should have no need to updateRelPos
1.219 {
1.220 - cout << "VM::updateRelPos...\n";
1.221 + //cout << "VM::updateRelPos...\n";
1.222 for (int i=0; i<rootItem->branchCount(); i++)
1.223 ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions();
1.224 }