1.1 --- a/vymmodel.cpp Thu Apr 30 11:52:49 2009 +0000
1.2 +++ b/vymmodel.cpp Fri May 01 10:30:29 2009 +0000
1.3 @@ -1186,7 +1186,7 @@
1.4 mainWindow->updateHistory (undoSet);
1.5 updateActions();
1.6 selection.update();
1.7 - ensureSelectionVisible();
1.8 + emitShowSelection();
1.9 }
1.10
1.11 bool VymModel::isUndoAvailable()
1.12 @@ -1521,7 +1521,7 @@
1.13
1.14 reposition();
1.15 // selection.update(); //FIXME-4
1.16 - ensureSelectionVisible();
1.17 + emitShowSelection();
1.18 }
1.19 }
1.20
1.21 @@ -1554,7 +1554,7 @@
1.22 if (getSelectedBranch()!=itFind)
1.23 {
1.24 select(itFind);
1.25 - ensureSelectionVisible();
1.26 + emitShowSelection();
1.27 }
1.28 */
1.29 if (textEditor->findText(s,flags))
1.30 @@ -1615,7 +1615,7 @@
1.31 updateActions();
1.32 reposition();
1.33 selection.update();
1.34 - ensureSelectionVisible();
1.35 + emitShowSelection();
1.36 }
1.37 */
1.38 }
1.39 @@ -1969,7 +1969,7 @@
1.40 reposition();
1.41 //FIXME-3 VM needed? scene()->update();
1.42 selection.update();
1.43 - ensureSelectionVisible();
1.44 + emitShowSelection();
1.45 }
1.46 */
1.47 }
1.48 @@ -1988,7 +1988,7 @@
1.49 reposition();
1.50 //FIXME-3 VM needed? scene()->update();
1.51 selection.update();
1.52 - ensureSelectionVisible();
1.53 + emitShowSelection();
1.54 }
1.55 */
1.56 }
1.57 @@ -2004,7 +2004,7 @@
1.58 saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getObjectName(bo)));
1.59 bo->sortChildren();
1.60 reposition();
1.61 - ensureSelectionVisible();
1.62 + emitShowSelection();
1.63 }
1.64 }
1.65 */
1.66 @@ -2055,7 +2055,7 @@
1.67 MapCenterItem *mci=addMapCenter (contextPos);
1.68 //FIXME-3 selection.select (mco);
1.69 updateActions();
1.70 - ensureSelectionVisible();
1.71 + emitShowSelection();
1.72 saveState (
1.73 mci,
1.74 "delete()",
1.75 @@ -2120,52 +2120,59 @@
1.76 // -2 add branch to selection
1.77 // -1 insert in children of parent below selection
1.78 // 0..n insert in children of parent at pos
1.79 - BranchObj *newbo=NULL;
1.80 - BranchObj *bo=getSelectedBranchObj(); //FIXME-2
1.81 - BranchItem *bi=getSelectedBranchItem();
1.82 - if (bo)
1.83 + BranchItem *selbi=getSelectedBranchItem();
1.84 + if (selbi)
1.85 {
1.86 + // Create TreeItem
1.87 + QList<QVariant> cData;
1.88 + cData << "new" << "undef"<<"undef";
1.89 +
1.90 + BranchItem *parbi;
1.91 + QModelIndex parix;
1.92 + int n;
1.93 + BranchItem *newbi=new BranchItem (cData);
1.94 + newbi->setHeading (QApplication::translate("Heading of new branch in map", "new"));
1.95 +
1.96 + emit (layoutAboutToBeChanged() );
1.97 +
1.98 if (num==-2)
1.99 {
1.100 - // Create TreeItem
1.101 - QList<QVariant> cData;
1.102 - cData << "new" << "undef"<<"undef";
1.103 -
1.104 - BranchItem *parbi=bi;
1.105 - QModelIndex parix=index(parbi);
1.106 - int n=parbi->childCount();
1.107 -
1.108 - emit (layoutAboutToBeChanged() );
1.109 - beginInsertRows (parix,n,n+1); //FIXME-1 check if n is correct: should be index below _last_ branch...
1.110 - bi=new BranchItem (cData);
1.111 - bi->setHeading (QApplication::translate("Heading of new branch in map", "new"));
1.112 -
1.113 - parbi->appendChild (bi);
1.114 + parbi=selbi;
1.115 + parix=index(parbi);
1.116 + n=parbi->childCount();
1.117 + cout <<"n="<<n<<endl;
1.118 + beginInsertRows (parix,n,n+1);
1.119 + parbi->appendChild (newbi);
1.120 endInsertRows ();
1.121 - emit (newChildObject (parix));
1.122 - emit (layoutChanged() );
1.123 -
1.124 - // save scroll state. If scrolled, automatically select
1.125 - // new branch in order to tmp unscroll parent...
1.126 - newbo=bi->createMapObj(mapScene);
1.127 - select (bi);
1.128 }else if (num==-1)
1.129 {
1.130 - /*
1.131 - num=bi->num()+1;
1.132 - bo=(BranchObj*)bo->getParObj();
1.133 - if (bo) newbo=bo->insertBranch(num); //FIXME-1 VM still missing
1.134 - */
1.135 + // insert below selection
1.136 + parbi=(BranchItem*)selbi->parent();
1.137 + parix=index(parbi);
1.138 + n=selbi->childNumber()+1;
1.139 + beginInsertRows (parix,n,n);
1.140 + parbi->insertBranch(n,newbi);
1.141 + endInsertRows ();
1.142 }else if (num==-3)
1.143 {
1.144 - /*
1.145 - num=bi->num();
1.146 - bo=(BranchObj*)bo->getParObj();
1.147 - if (bo) newbo=bo->insertBranch(num); //FIXME-1 VM still missing
1.148 - */
1.149 + // insert above selection
1.150 + parbi=(BranchItem*)selbi->parent();
1.151 + parix=index(parbi);
1.152 + n=selbi->childNumber();
1.153 + beginInsertRows (parix,n,n);
1.154 + parbi->insertBranch(n,newbi);
1.155 + endInsertRows ();
1.156 }
1.157 + emit (newChildObject (parix));
1.158 + emit (layoutChanged() );
1.159 +
1.160 + // save scroll state. If scrolled, automatically select
1.161 + // new branch in order to tmp unscroll parent...
1.162 + newbi->createMapObj(mapScene);
1.163 + select (newbi);
1.164 + return newbi;
1.165 }
1.166 - return bi;
1.167 + return NULL;
1.168 }
1.169
1.170 BranchItem* VymModel::addNewBranch(int pos)
1.171 @@ -2179,7 +2186,7 @@
1.172
1.173 if (selbi)
1.174 {
1.175 - // FIXME-2 VM do we still need this in model? setCursor (Qt::ArrowCursor);
1.176 + // FIXME-3 VM do we still need this in model? setCursor (Qt::ArrowCursor);
1.177
1.178 newbi=addNewBranchInt (pos-2);
1.179
1.180 @@ -2295,7 +2302,7 @@
1.181 removeRows (n,1,parentIndex);
1.182 endRemoveRows();
1.183 select (pi);
1.184 - ensureSelectionVisible();
1.185 + emitShowSelection();
1.186 reposition();
1.187
1.188 emit (layoutChanged() );
1.189 @@ -2317,7 +2324,7 @@
1.190 par->removeFloatImage(fio);
1.191 select (par);
1.192 reposition();
1.193 - ensureSelectionVisible();
1.194 + emitShowSelection();
1.195 return;
1.196 }
1.197 */
1.198 @@ -2400,8 +2407,7 @@
1.199 );
1.200 */
1.201 bi->toggleScroll();
1.202 - //selection.update();
1.203 - // FIXME-3 VM needed? scene()->update();
1.204 + mapScene->update(); //Needed for _quick_ update
1.205 return true;
1.206 }
1.207 return false;
1.208 @@ -2411,7 +2417,7 @@
1.209 {
1.210 if (bi)
1.211 {
1.212 - if (bi->isScrolled()) return false;
1.213 + if (!bi->isScrolled()) return false;
1.214 if (bi->branchCount()==0) return false;
1.215 if (bi->depth()==0) return false;
1.216
1.217 @@ -2428,8 +2434,7 @@
1.218 );
1.219 */
1.220 bi->toggleScroll();
1.221 - // selection.update();
1.222 - // FIXME-3 VM needed? scene()->update();
1.223 + mapScene->update(); // Needed for _quick_ update
1.224 return true;
1.225 }
1.226 return false;
1.227 @@ -2447,7 +2452,7 @@
1.228 }
1.229 }
1.230
1.231 -void VymModel::unscrollChildren() // FIXME-1 first, next moved to vymmodel
1.232 +void VymModel::unscrollChildren() // FIXME-2 first, next moved to vymmodel
1.233
1.234 {
1.235 /*
1.236 @@ -2464,6 +2469,11 @@
1.237 */
1.238 }
1.239
1.240 +void VymModel::emitExpandAll()
1.241 +{
1.242 + emit (expandAll() );
1.243 +}
1.244 +
1.245 void VymModel::addFloatImage (const QPixmap &img) //FIXME-2
1.246 {
1.247 /*
1.248 @@ -2660,7 +2670,7 @@
1.249 reposition();
1.250 updateActions();
1.251 //selection.update();
1.252 - ensureSelectionVisible();
1.253 + emitShowSelection();
1.254 }
1.255 }
1.256
1.257 @@ -2725,7 +2735,7 @@
1.258 if (bo)
1.259 {
1.260 selection.select(bo);
1.261 - ensureSelectionVisible();
1.262 + emitShowSelection();
1.263 }
1.264 }
1.265 */
1.266 @@ -4517,7 +4527,7 @@
1.267 void VymModel::updateSelection(const QItemSelection &newsel)
1.268 {
1.269 emit (selectionChanged(newsel,newsel)); // needed e.g. to update geometry in editor
1.270 - ensureSelectionVisible();
1.271 + emitShowSelection();
1.272 sendSelection();
1.273 }
1.274
1.275 @@ -4642,10 +4652,10 @@
1.276 selection.reselect();
1.277 }
1.278
1.279 -void VymModel::ensureSelectionVisible() //FIXME-3 needed? in vymmodel.h commented...
1.280 -{
1.281 - LinkableMapObj *lmo=getSelectedLMO();
1.282 - if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() );
1.283 +void VymModel::emitShowSelection()
1.284 +{
1.285 + if (!blockReposition)
1.286 + emit (showSelection() );
1.287 }
1.288
1.289 void VymModel::emitNoteHasChanged (TreeItem *ti)
1.290 @@ -4909,7 +4919,7 @@
1.291 if (ti2) {
1.292 select(ti2);
1.293 selection.update();
1.294 - ensureSelectionVisible();
1.295 + emitShowSelection();
1.296 sendSelection();
1.297 }
1.298 }
1.299 @@ -4926,7 +4936,7 @@
1.300 if (ti2) {
1.301 select(ti2);
1.302 selection.update();
1.303 - ensureSelectionVisible();
1.304 + emitShowSelection();
1.305 sendSelection();
1.306 }
1.307 }
1.308 @@ -4952,7 +4962,7 @@
1.309 if (!par) return;
1.310 select(par);
1.311 selection.update();
1.312 - ensureSelectionVisible();
1.313 + emitShowSelection();
1.314 sendSelection();
1.315 }
1.316 }