1.1 --- a/vymmodel.cpp Wed Apr 29 18:46:31 2009 +0000
1.2 +++ b/vymmodel.cpp Wed Apr 29 21:40:37 2009 +0000
1.3 @@ -992,6 +992,7 @@
1.4 mapChanged=true;
1.5 mapDefault=false;
1.6 mapUnsaved=true;
1.7 + latestAddedItem=NULL;
1.8 findReset();
1.9 }
1.10
1.11 @@ -1401,28 +1402,33 @@
1.12 return mapScene;
1.13 }
1.14
1.15 -TreeItem* VymModel::findBySelectString(const QString &s) //FIXME-0
1.16 -{
1.17 - return NULL;
1.18 - if (!s.isEmpty() )
1.19 +TreeItem* VymModel::findBySelectString(QString s)
1.20 +{
1.21 + if (s.isEmpty() ) return NULL;
1.22 +
1.23 + // Old maps don't have multiple mapcenters and don't save full path
1.24 + if (s.left(2) !="mc")
1.25 + s="mc:0,"+s;
1.26 +
1.27 + QStringList parts=s.split (",");
1.28 + QString typ;
1.29 + int n;
1.30 + TreeItem *ti=rootItem;
1.31 +
1.32 + while (!parts.isEmpty() )
1.33 {
1.34 - QString part;
1.35 - QString typ;
1.36 - QString num;
1.37 - part=s.section(",",0,0);
1.38 - typ=part.left (2);
1.39 - num=part.right(part.length() - 3);
1.40 - if (typ=="mc" && num.toInt()>=0 && num.toInt() <rootItem->branchCount() )
1.41 - return rootItem->getBranchNum (num.toInt() );
1.42 - }
1.43 -
1.44 - TreeItem *ti;
1.45 - for (int i=0; i<rootItem->branchCount(); i++)
1.46 - {
1.47 - // ti=rootItem->getBranchNum(i)->findBySelectString(s);
1.48 - if (ti) return ti;
1.49 - }
1.50 - return NULL;
1.51 + typ=parts.first().left(2);
1.52 + n=parts.first().right(parts.first().length() - 3).toInt();
1.53 + parts.removeFirst();
1.54 + if (typ=="mc" || typ=="bo")
1.55 + ti=ti->getBranchNum (n);
1.56 + /* FIXME-2
1.57 + else
1.58 + if (typ="fi")
1.59 + ti=ti->getImageNum (n);
1.60 + */
1.61 + }
1.62 + return ti;
1.63 }
1.64
1.65 TreeItem* VymModel::findID (const QString &s)
1.66 @@ -2044,7 +2050,7 @@
1.67
1.68 MapCenterItem* VymModel::addMapCenter ()
1.69 {
1.70 - MapCenterItem *mci=addMapCenter (contextPos); //FIXME-2 get rid of MCO here
1.71 + MapCenterItem *mci=addMapCenter (contextPos);
1.72 //FIXME-3 selection.select (mco);
1.73 updateActions();
1.74 ensureSelectionVisible();
1.75 @@ -2186,7 +2192,7 @@
1.76
1.77 reposition();
1.78 // selection.update(); FIXME-3
1.79 - latestSelectionString=getSelectString(newbi);
1.80 + latestAddedItem=newbi;
1.81 // In Network mode, the client needs to know where the new branch is,
1.82 // so we have to pass on this information via saveState.
1.83 // TODO: Get rid of this positioning workaround
1.84 @@ -2268,7 +2274,6 @@
1.85
1.86 void VymModel::deleteSelection()
1.87 {
1.88 - BranchObj *bo = getSelectedBranchObj(); // FIXME-2 VM should not be necessary
1.89 BranchItem *selbi=getSelectedBranchItem();
1.90
1.91 if (!selbi) return;
1.92 @@ -3351,13 +3356,13 @@
1.93 /////////////////////////////////////////////////////////////////////
1.94 } else */ if (com=="selectLatestAdded")
1.95 {
1.96 - if (latestSelectionString.isEmpty() )
1.97 + if (!latestAddedItem)
1.98 {
1.99 parser.setError (Aborted,"No latest added object");
1.100 } else
1.101 {
1.102 - if (!select (latestSelectionString))
1.103 - parser.setError (Aborted,"Could not select latest added object "+latestSelectionString);
1.104 + if (!select (latestAddedItem))
1.105 + parser.setError (Aborted,"Could not select latest added object ");
1.106 }
1.107 /////////////////////////////////////////////////////////////////////
1.108 } else if (com=="setFrameType")
1.109 @@ -3882,10 +3887,6 @@
1.110 void VymModel::registerEditor(QWidget *me)
1.111 {
1.112 mapEditor=(MapEditor*)me;
1.113 - /* FIXME-3
1.114 - for (int i=0; i<rootItem->branchCount(); i++)
1.115 - rootItem->getBranchNum(i)->setMapEditor(mapEditor);
1.116 - */
1.117 }
1.118
1.119 void VymModel::unregisterEditor(QWidget *)
1.120 @@ -3924,9 +3925,11 @@
1.121 ((MapCenterObj*)rootItem->getBranchObjNum(i))->updateRelPositions();
1.122 }
1.123
1.124 -void VymModel::reposition() //FIXME-2 VM should have no need to reposition, this is done in views???
1.125 -{
1.126 - //cout << "VM::reposition ...\n";
1.127 +void VymModel::reposition() //FIXME-3 VM should have no need to reposition, this is done in views???
1.128 +{
1.129 + //cout << "VM::reposition blocked="<<blockReposition<<endl;
1.130 + if (blockReposition) return;
1.131 +
1.132 for (int i=0;i<rootItem->branchCount(); i++)
1.133 rootItem->getBranchObjNum(i)->reposition(); // for positioning heading
1.134 }
1.135 @@ -4998,19 +5001,6 @@
1.136 return NULL;
1.137 }
1.138
1.139 -MapCenterItem* VymModel::getSelectedMapCenterItem()
1.140 -{
1.141 - QModelIndexList list=selModel->selectedIndexes();
1.142 - if (!list.isEmpty() )
1.143 - {
1.144 - TreeItem *ti = getItem (list.first() );
1.145 - TreeItem::Type type=ti->getType();
1.146 - if (ti->getType()==TreeItem::MapCenter)
1.147 - return (MapCenterItem*)ti;
1.148 - }
1.149 - return NULL;
1.150 -}
1.151 -
1.152 TreeItem* VymModel::getSelectedItem()
1.153 {
1.154 QModelIndexList list=selModel->selectedIndexes();