1.1 --- a/vymmodel.cpp Thu Jan 15 00:52:35 2009 +0000
1.2 +++ b/vymmodel.cpp Tue Jan 20 15:23:16 2009 +0000
1.3 @@ -67,7 +67,7 @@
1.4 void VymModel::clear()
1.5 {
1.6 cout << "VymModel::clear rows="<<rowCount(index(rootItem))<<endl;
1.7 - selection.clear();
1.8 + selModel->clearSelection();
1.9
1.10 // Remove stuff
1.11 while (!mapCenters.isEmpty()) // FIXME VM needs to be in treemodel only...
1.12 @@ -123,8 +123,6 @@
1.13
1.14 // selections
1.15 selModel=NULL;
1.16 - selection.setModel (this);
1.17 - selection.unselect();
1.18
1.19 // find routine
1.20 itFind=NULL;
1.21 @@ -342,12 +340,12 @@
1.22
1.23 if (lmode==NewMap)
1.24 {
1.25 - selection.clear();
1.26 + selModel->clearSelection();
1.27 // FIXME VM not needed??? model->setMapEditor(this);
1.28 // (map state is set later at end of load...)
1.29 } else
1.30 {
1.31 - BranchObj *bo=selection.getBranch();
1.32 + BranchObj *bo=getSelectedBranch();
1.33 if (!bo) return aborted;
1.34 if (lmode==ImportAdd)
1.35 saveStateChangingPart(
1.36 @@ -589,10 +587,10 @@
1.37 else
1.38 {
1.39 // Save part of map
1.40 - if (selection.type()==Selection::FloatImage)
1.41 + if (selectionType()==TreeItem::Image)
1.42 saveFloatImage();
1.43 else
1.44 - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection.getBranch());
1.45 + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranch());
1.46 // TODO take care of multiselections
1.47 }
1.48
1.49 @@ -660,7 +658,7 @@
1.50
1.51 void VymModel::addMapInsertInt (const QString &path, int pos)
1.52 {
1.53 - BranchObj *sel=selection.getBranch();
1.54 + BranchObj *sel=getSelectedBranch();
1.55 if (sel)
1.56 {
1.57 QString pathDir=path.left(path.findRev("/"));
1.58 @@ -696,7 +694,7 @@
1.59
1.60 FloatImageObj* VymModel::loadFloatImageInt (QString fn)
1.61 {
1.62 - BranchObj *bo=selection.getBranch();
1.63 + BranchObj *bo=getSelectedBranch();
1.64 if (bo)
1.65 {
1.66 FloatImageObj *fio;
1.67 @@ -712,7 +710,7 @@
1.68
1.69 void VymModel::loadFloatImage ()
1.70 {
1.71 - BranchObj *bo=selection.getBranch();
1.72 + BranchObj *bo=getSelectedBranch();
1.73 if (bo)
1.74 {
1.75
1.76 @@ -810,7 +808,7 @@
1.77
1.78 void VymModel::importDirInt(BranchObj *dst, QDir d)
1.79 {
1.80 - BranchObj *bo=selection.getBranch();
1.81 + BranchObj *bo=getSelectedBranch();
1.82 if (bo)
1.83 {
1.84 // Traverse directories
1.85 @@ -857,7 +855,7 @@
1.86
1.87 void VymModel::importDirInt (const QString &s)
1.88 {
1.89 - BranchObj *bo=selection.getBranch();
1.90 + BranchObj *bo=getSelectedBranch();
1.91 if (bo)
1.92 {
1.93 saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s));
1.94 @@ -869,7 +867,7 @@
1.95
1.96 void VymModel::importDir()
1.97 {
1.98 - BranchObj *bo=selection.getBranch();
1.99 + BranchObj *bo=getSelectedBranch();
1.100 if (bo)
1.101 {
1.102 QStringList filters;
1.103 @@ -1490,7 +1488,7 @@
1.104
1.105 void VymModel::setHeading(const QString &s)
1.106 {
1.107 - BranchObj *sel=selection.getBranch();
1.108 + BranchObj *sel=getSelectedBranch();
1.109 if (sel)
1.110 {
1.111 saveState(
1.112 @@ -1500,7 +1498,8 @@
1.113 "setHeading (\""+s+"\")",
1.114 QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) );
1.115 sel->setHeading(s );
1.116 - TreeItem *ti=selection.getBranchItem();
1.117 + /* FIXME testing only
1.118 + TreeItem *ti=getSelectedBranchItem();
1.119 if (ti)
1.120 {
1.121 ti->setHeading (s);
1.122 @@ -1517,6 +1516,7 @@
1.123
1.124 //cout <<" (r,c)=("<<ix2.row()<<","<<ix2.column()<<")"<<endl;
1.125
1.126 + */
1.127 reposition();
1.128 selection.update();
1.129 ensureSelectionVisible();
1.130 @@ -1525,7 +1525,7 @@
1.131
1.132 void VymModel::setHeadingInt(const QString &s)
1.133 {
1.134 - BranchObj *bo=selection.getBranch();
1.135 + BranchObj *bo=getSelectedBranch();
1.136 if (bo)
1.137 {
1.138 bo->setHeading(s);
1.139 @@ -1556,9 +1556,9 @@
1.140 // Searching in Note
1.141 if (itFind->getNote().contains(s,cs))
1.142 {
1.143 - if (selection.single()!=itFind)
1.144 + if (getSelectedBranch()!=itFind)
1.145 {
1.146 - selection.select(itFind);
1.147 + select(itFind);
1.148 ensureSelectionVisible();
1.149 }
1.150 if (textEditor->findText(s,flags))
1.151 @@ -1570,7 +1570,7 @@
1.152 // Searching in Heading
1.153 if (searching && itFind->getHeading().contains (s,cs) )
1.154 {
1.155 - selection.select(itFind);
1.156 + select(itFind);
1.157 ensureSelectionVisible();
1.158 searching=false;
1.159 }
1.160 @@ -1583,7 +1583,7 @@
1.161 //cout <<"still searching... "<<qPrintable( itFind->getHeading())<<endl;
1.162 }
1.163 if (!searching)
1.164 - return selection.getBranch();
1.165 + return getSelectedBranch();
1.166 else
1.167 return NULL;
1.168 }
1.169 @@ -1606,7 +1606,7 @@
1.170
1.171 void VymModel::setURL(const QString &url)
1.172 {
1.173 - BranchObj *bo=selection.getBranch();
1.174 + BranchObj *bo=getSelectedBranch();
1.175 if (bo)
1.176 {
1.177 QString oldurl=bo->getURL();
1.178 @@ -1627,7 +1627,7 @@
1.179
1.180 QString VymModel::getURL()
1.181 {
1.182 - BranchObj *bo=selection.getBranch();
1.183 + BranchObj *bo=getSelectedBranch();
1.184 if (bo)
1.185 return bo->getURL();
1.186 else
1.187 @@ -1637,7 +1637,7 @@
1.188 QStringList VymModel::getURLs()
1.189 {
1.190 QStringList urls;
1.191 - BranchObj *bo=selection.getBranch();
1.192 + BranchObj *bo=getSelectedBranch();
1.193 if (bo)
1.194 {
1.195 bo=bo->first();
1.196 @@ -1683,7 +1683,7 @@
1.197
1.198 void VymModel::setFrameType(const FrameObj::FrameType &t)
1.199 {
1.200 - BranchObj *bo=selection.getBranch();
1.201 + BranchObj *bo=getSelectedBranch();
1.202 if (bo)
1.203 {
1.204 QString s=bo->getFrameTypeName();
1.205 @@ -1697,7 +1697,7 @@
1.206
1.207 void VymModel::setFrameType(const QString &s)
1.208 {
1.209 - BranchObj *bo=selection.getBranch();
1.210 + BranchObj *bo=getSelectedBranch();
1.211 if (bo)
1.212 {
1.213 saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),
1.214 @@ -1710,7 +1710,7 @@
1.215
1.216 void VymModel::setFramePenColor(const QColor &c)
1.217 {
1.218 - BranchObj *bo=selection.getBranch();
1.219 + BranchObj *bo=getSelectedBranch();
1.220 if (bo)
1.221 {
1.222 saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ),
1.223 @@ -1721,7 +1721,7 @@
1.224
1.225 void VymModel::setFrameBrushColor(const QColor &c)
1.226 {
1.227 - BranchObj *bo=selection.getBranch();
1.228 + BranchObj *bo=getSelectedBranch();
1.229 if (bo)
1.230 {
1.231 saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ),
1.232 @@ -1732,7 +1732,7 @@
1.233
1.234 void VymModel::setFramePadding (const int &i)
1.235 {
1.236 - BranchObj *bo=selection.getBranch();
1.237 + BranchObj *bo=getSelectedBranch();
1.238 if (bo)
1.239 {
1.240 saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ),
1.241 @@ -1745,7 +1745,7 @@
1.242
1.243 void VymModel::setFrameBorderWidth(const int &i)
1.244 {
1.245 - BranchObj *bo=selection.getBranch();
1.246 + BranchObj *bo=getSelectedBranch();
1.247 if (bo)
1.248 {
1.249 saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ),
1.250 @@ -1758,7 +1758,7 @@
1.251
1.252 void VymModel::setIncludeImagesVer(bool b)
1.253 {
1.254 - BranchObj *bo=selection.getBranch();
1.255 + BranchObj *bo=getSelectedBranch();
1.256 if (bo)
1.257 {
1.258 QString u= b ? "false" : "true";
1.259 @@ -1778,7 +1778,7 @@
1.260
1.261 void VymModel::setIncludeImagesHor(bool b)
1.262 {
1.263 - BranchObj *bo=selection.getBranch();
1.264 + BranchObj *bo=getSelectedBranch();
1.265 if (bo)
1.266 {
1.267 QString u= b ? "false" : "true";
1.268 @@ -1798,11 +1798,11 @@
1.269
1.270 void VymModel::setHideLinkUnselected (bool b)
1.271 {
1.272 - LinkableMapObj *sel=selection.single();
1.273 + LinkableMapObj *sel=getSelectedLMO();
1.274 if (sel &&
1.275 - (selection.type() == Selection::Branch ||
1.276 - selection.type() == Selection::MapCenter ||
1.277 - selection.type() == Selection::FloatImage ))
1.278 + (selectionType() == TreeItem::Branch ||
1.279 + selectionType() == TreeItem::MapCenter ||
1.280 + selectionType() == TreeItem::Image ))
1.281 {
1.282 QString u= b ? "false" : "true";
1.283 QString r=!b ? "false" : "true";
1.284 @@ -1820,7 +1820,7 @@
1.285
1.286 void VymModel::setHideExport(bool b)
1.287 {
1.288 - BranchObj *bo=selection.getBranch();
1.289 + BranchObj *bo=getSelectedBranch();
1.290 if (bo)
1.291 {
1.292 bo->setHideInExport (b);
1.293 @@ -1843,7 +1843,7 @@
1.294
1.295 void VymModel::toggleHideExport()
1.296 {
1.297 - BranchObj *bo=selection.getBranch();
1.298 + BranchObj *bo=getSelectedBranch();
1.299 if (bo)
1.300 setHideExport ( !bo->hideInExport() );
1.301 }
1.302 @@ -1851,8 +1851,11 @@
1.303
1.304 void VymModel::copy()
1.305 {
1.306 - LinkableMapObj *sel=selection.single();
1.307 - if (sel)
1.308 + LinkableMapObj *sel=getSelectedLMO();
1.309 + if (sel &&
1.310 + (selectionType() == TreeItem::Branch ||
1.311 + selectionType() == TreeItem::MapCenter ||
1.312 + selectionType() == TreeItem::Image ))
1.313 {
1.314 if (redosAvail == 0)
1.315 {
1.316 @@ -1893,7 +1896,7 @@
1.317
1.318 void VymModel::paste()
1.319 {
1.320 - BranchObj *sel=selection.getBranch();
1.321 + BranchObj *sel=getSelectedBranch();
1.322 if (sel)
1.323 {
1.324 saveStateChangingPart(
1.325 @@ -1909,10 +1912,10 @@
1.326
1.327 void VymModel::cut()
1.328 {
1.329 - LinkableMapObj *sel=selection.single();
1.330 - if ( sel && (selection.type() == Selection::Branch ||
1.331 - selection.type()==Selection::MapCenter ||
1.332 - selection.type()==Selection::FloatImage))
1.333 + LinkableMapObj *sel=getSelectedLMO();
1.334 + if ( sel && (selectionType() == TreeItem::Branch ||
1.335 + selectionType()==TreeItem::MapCenter ||
1.336 + selectionType()==TreeItem::Image))
1.337 {
1.338 /* No savestate! savestate is called in cutNoSave
1.339 saveStateChangingPart(
1.340 @@ -1930,7 +1933,7 @@
1.341
1.342 void VymModel::moveBranchUp()
1.343 {
1.344 - BranchObj* bo=selection.getBranch();
1.345 + BranchObj* bo=getSelectedBranch();
1.346 BranchObj* par;
1.347 if (bo)
1.348 {
1.349 @@ -1947,7 +1950,7 @@
1.350
1.351 void VymModel::moveBranchDown()
1.352 {
1.353 - BranchObj* bo=selection.getBranch();
1.354 + BranchObj* bo=getSelectedBranch();
1.355 BranchObj* par;
1.356 if (bo)
1.357 {
1.358 @@ -1964,7 +1967,7 @@
1.359
1.360 void VymModel::sortChildren()
1.361 {
1.362 - BranchObj* bo=selection.getBranch();
1.363 + BranchObj* bo=getSelectedBranch();
1.364 if (bo)
1.365 {
1.366 if(bo->countBranches()>1)
1.367 @@ -1980,12 +1983,12 @@
1.368 void VymModel::createMapCenter()
1.369 {
1.370 MapCenterObj *mco=addMapCenter (QPointF (0,0) );
1.371 - selection.select (mco);
1.372 + select (mco);
1.373 }
1.374
1.375 void VymModel::createBranch()
1.376 {
1.377 - BranchObj *bo=selection.getBranch();
1.378 + BranchObj *bo=getSelectedBranch();
1.379 if (bo)
1.380 {
1.381 BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
1.382 @@ -2002,7 +2005,7 @@
1.383 if (newbo)
1.384 {
1.385 newbo->setTreeItem (ti);
1.386 - selection.select (newbo); // FIXME VM really needed here?
1.387 + select (newbo); // FIXME VM really needed here?
1.388 }
1.389 }
1.390 }
1.391 @@ -2075,7 +2078,7 @@
1.392 // -1 insert in children of parent below selection
1.393 // 0..n insert in children of parent at pos
1.394 BranchObj *newbo=NULL;
1.395 - BranchObj *bo=selection.getBranch();
1.396 + BranchObj *bo=getSelectedBranch();
1.397 if (bo)
1.398 {
1.399 if (num==-2)
1.400 @@ -2106,7 +2109,7 @@
1.401 // -1 add above
1.402 // 0 add as child
1.403 // +1 add below
1.404 - BranchObj *bo = selection.getBranch();
1.405 + BranchObj *bo = getSelectedBranch();
1.406 BranchObj *newbo=NULL;
1.407
1.408 if (bo)
1.409 @@ -2143,8 +2146,8 @@
1.410 BranchObj* VymModel::addNewBranchBefore()
1.411 {
1.412 BranchObj *newbo=NULL;
1.413 - BranchObj *bo = selection.getBranch();
1.414 - if (bo && selection.type()==Selection::Branch)
1.415 + BranchObj *bo = getSelectedBranch();
1.416 + if (bo && selectionType()==TreeItem::Branch)
1.417 // We accept no MapCenterObj here, so we _have_ a parent
1.418 {
1.419 QPointF p=bo->getRelPos();
1.420 @@ -2174,9 +2177,9 @@
1.421
1.422 void VymModel::deleteSelection()
1.423 {
1.424 - BranchObj *bo = selection.getBranch();
1.425 + BranchObj *bo = getSelectedBranch();
1.426
1.427 - if (bo && selection.type()==Selection::MapCenter)
1.428 + if (bo && selectionType()==TreeItem::MapCenter)
1.429 {
1.430 // BranchObj* par=(BranchObj*)(bo->getParObj());
1.431 selection.unselect();
1.432 @@ -2193,15 +2196,15 @@
1.433 reposition();
1.434 return;
1.435 }
1.436 - if (bo && selection.type()==Selection::Branch)
1.437 + if (bo && selectionType()==TreeItem::Branch)
1.438 {
1.439 - QModelIndex ix=selection.getBranchIndex();
1.440 + QModelIndex ix=getSelectedIndex();
1.441
1.442 BranchObj* par=(BranchObj*)bo->getParObj();
1.443 - selection.unselect();
1.444 + unselect();
1.445 saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo)));
1.446 par->removeBranch(bo);
1.447 - selection.select (par);
1.448 + select (par);
1.449 ensureSelectionVisible();
1.450 reposition();
1.451 selection.update();
1.452 @@ -2217,9 +2220,9 @@
1.453 "delete ()",
1.454 QString("Delete %1").arg(getObjectName(fio))
1.455 );
1.456 - selection.unselect();
1.457 + unselect();
1.458 par->removeFloatImage(fio);
1.459 - selection.select (par);
1.460 + select (par);
1.461 reposition();
1.462 selection.update();
1.463 ensureSelectionVisible();
1.464 @@ -2229,7 +2232,7 @@
1.465
1.466 void VymModel::deleteKeepChildren()
1.467 {
1.468 - BranchObj *bo=selection.getBranch();
1.469 + BranchObj *bo=getSelectedBranch();
1.470 BranchObj *par;
1.471 if (bo)
1.472 {
1.473 @@ -2258,14 +2261,14 @@
1.474 par->removeBranchHere(bo);
1.475 reposition();
1.476 select (sel);
1.477 - selection.getBranch()->move2RelPos (p);
1.478 + getSelectedBranch()->move2RelPos (p);
1.479 reposition();
1.480 }
1.481 }
1.482
1.483 void VymModel::deleteChildren()
1.484 {
1.485 - BranchObj *bo=selection.getBranch();
1.486 + BranchObj *bo=getSelectedBranch();
1.487 if (bo)
1.488 {
1.489 saveStateChangingPart(
1.490 @@ -2332,8 +2335,8 @@
1.491
1.492 void VymModel::toggleScroll()
1.493 {
1.494 - BranchObj *bo=selection.getBranch();
1.495 - if (selection.type()==Selection::Branch )
1.496 + BranchObj *bo=getSelectedBranch();
1.497 + if (selectionType()==TreeItem::Branch )
1.498 {
1.499 if (bo->isScrolled())
1.500 unscrollBranch (bo);
1.501 @@ -2344,7 +2347,7 @@
1.502
1.503 void VymModel::unscrollChildren()
1.504 {
1.505 - BranchObj *bo=selection.getBranch();
1.506 + BranchObj *bo=getSelectedBranch();
1.507 if (bo)
1.508 {
1.509 bo->first();
1.510 @@ -2357,7 +2360,7 @@
1.511 }
1.512 void VymModel::addFloatImage (const QPixmap &img)
1.513 {
1.514 - BranchObj *bo=selection.getBranch();
1.515 + BranchObj *bo=getSelectedBranch();
1.516 if (bo)
1.517 {
1.518 FloatImageObj *fio=bo->addFloatImage();
1.519 @@ -2374,7 +2377,7 @@
1.520
1.521 void VymModel::colorBranch (QColor c)
1.522 {
1.523 - BranchObj *bo=selection.getBranch();
1.524 + BranchObj *bo=getSelectedBranch();
1.525 if (bo)
1.526 {
1.527 saveState(
1.528 @@ -2390,7 +2393,7 @@
1.529
1.530 void VymModel::colorSubtree (QColor c)
1.531 {
1.532 - BranchObj *bo=selection.getBranch();
1.533 + BranchObj *bo=getSelectedBranch();
1.534 if (bo)
1.535 {
1.536 saveStateChangingPart(
1.537 @@ -2405,7 +2408,7 @@
1.538
1.539 QColor VymModel::getCurrentHeadingColor()
1.540 {
1.541 - BranchObj *bo=selection.getBranch();
1.542 + BranchObj *bo=getSelectedBranch();
1.543 if (bo) return bo->getColor();
1.544
1.545 QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
1.546 @@ -2416,7 +2419,7 @@
1.547
1.548 void VymModel::editURL()
1.549 {
1.550 - BranchObj *bo=selection.getBranch();
1.551 + BranchObj *bo=getSelectedBranch();
1.552 if (bo)
1.553 {
1.554 bool ok;
1.555 @@ -2431,7 +2434,7 @@
1.556
1.557 void VymModel::editLocalURL()
1.558 {
1.559 - BranchObj *bo=selection.getBranch();
1.560 + BranchObj *bo=getSelectedBranch();
1.561 if (bo)
1.562 {
1.563 QStringList filters;
1.564 @@ -2459,14 +2462,14 @@
1.565
1.566 void VymModel::editHeading2URL()
1.567 {
1.568 - BranchObj *bo=selection.getBranch();
1.569 + BranchObj *bo=getSelectedBranch();
1.570 if (bo)
1.571 setURL (bo->getHeading());
1.572 }
1.573
1.574 void VymModel::editBugzilla2URL()
1.575 {
1.576 - BranchObj *bo=selection.getBranch();
1.577 + BranchObj *bo=getSelectedBranch();
1.578 if (bo)
1.579 {
1.580 QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
1.581 @@ -2476,7 +2479,7 @@
1.582
1.583 void VymModel::editFATE2URL()
1.584 {
1.585 - BranchObj *bo=selection.getBranch();
1.586 + BranchObj *bo=getSelectedBranch();
1.587 if (bo)
1.588 {
1.589 QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
1.590 @@ -2494,7 +2497,7 @@
1.591
1.592 void VymModel::editVymLink()
1.593 {
1.594 - BranchObj *bo=selection.getBranch();
1.595 + BranchObj *bo=getSelectedBranch();
1.596 if (bo)
1.597 {
1.598 QStringList filters;
1.599 @@ -2526,7 +2529,7 @@
1.600 void VymModel::setVymLink (const QString &s)
1.601 {
1.602 // Internal function, no saveState needed
1.603 - BranchObj *bo=selection.getBranch();
1.604 + BranchObj *bo=getSelectedBranch();
1.605 if (bo)
1.606 {
1.607 bo->setVymLink(s);
1.608 @@ -2539,7 +2542,7 @@
1.609
1.610 void VymModel::deleteVymLink()
1.611 {
1.612 - BranchObj *bo=selection.getBranch();
1.613 + BranchObj *bo=getSelectedBranch();
1.614 if (bo)
1.615 {
1.616 saveState(
1.617 @@ -2558,7 +2561,7 @@
1.618
1.619 QString VymModel::getVymLink()
1.620 {
1.621 - BranchObj *bo=selection.getBranch();
1.622 + BranchObj *bo=getSelectedBranch();
1.623 if (bo)
1.624 return bo->getVymLink();
1.625 else
1.626 @@ -2569,7 +2572,7 @@
1.627 QStringList VymModel::getVymLinks()
1.628 {
1.629 QStringList links;
1.630 - BranchObj *bo=selection.getBranch();
1.631 + BranchObj *bo=getSelectedBranch();
1.632 if (bo)
1.633 {
1.634 bo=bo->first();
1.635 @@ -2585,7 +2588,7 @@
1.636
1.637 void VymModel::followXLink(int i)
1.638 {
1.639 - BranchObj *bo=selection.getBranch();
1.640 + BranchObj *bo=getSelectedBranch();
1.641 if (bo)
1.642 {
1.643 bo=bo->XLinkTargetAt(i);
1.644 @@ -2599,7 +2602,7 @@
1.645
1.646 void VymModel::editXLink(int i) // FIXME VM missing saveState
1.647 {
1.648 - BranchObj *bo=selection.getBranch();
1.649 + BranchObj *bo=getSelectedBranch();
1.650 if (bo)
1.651 {
1.652 XLinkObj *xlo=bo->XLinkAt(i);
1.653 @@ -2632,7 +2635,7 @@
1.654
1.655 void VymModel::parseAtom(const QString &atom)
1.656 {
1.657 - BranchObj *selb=selection.getBranch();
1.658 + BranchObj *selb=getSelectedBranch();
1.659 QString s,t;
1.660 double x,y;
1.661 int n;
1.662 @@ -2791,9 +2794,9 @@
1.663 if (selection.isEmpty())
1.664 {
1.665 parser.setError (Aborted,"Nothing selected");
1.666 - } else if ( selection.type()!=Selection::Branch &&
1.667 - selection.type()!=Selection::MapCenter &&
1.668 - selection.type()!=Selection::FloatImage )
1.669 + } else if ( selectionType()!=TreeItem::Branch &&
1.670 + selectionType()!=TreeItem::MapCenter &&
1.671 + selectionType()!=TreeItem::Image )
1.672 {
1.673 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.674 } else if (parser.checkParCount(0))
1.675 @@ -2807,7 +2810,7 @@
1.676 {
1.677 parser.setError (Aborted,"Nothing selected");
1.678 }
1.679 - /*else if (selection.type() != Selection::Branch && selection.type() != Selection::FloatImage )
1.680 + /*else if (selectionType() != TreeItem::Branch && selectionType() != TreeItem::Image )
1.681 {
1.682 parser.setError (Aborted,"Type of selection is wrong.");
1.683 }
1.684 @@ -2964,7 +2967,7 @@
1.685 }
1.686 }
1.687 }
1.688 - } else if ( selection.type() == Selection::FloatImage)
1.689 + } else if ( selectionType() == TreeItem::Image)
1.690 {
1.691 if (parser.checkParCount(1))
1.692 {
1.693 @@ -3027,9 +3030,9 @@
1.694 if (selection.isEmpty() )
1.695 {
1.696 parser.setError (Aborted,"Nothing selected");
1.697 - } else if ( selection.type()!=Selection::Branch &&
1.698 - selection.type()!=Selection::MapCenter &&
1.699 - selection.type()!=Selection::FloatImage )
1.700 + } else if ( selectionType()!=TreeItem::Branch &&
1.701 + selectionType()!=TreeItem::MapCenter &&
1.702 + selectionType()!=TreeItem::Image )
1.703 {
1.704 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.705 } else if (parser.checkParCount(2))
1.706 @@ -3047,9 +3050,9 @@
1.707 if (selection.isEmpty() )
1.708 {
1.709 parser.setError (Aborted,"Nothing selected");
1.710 - } else if ( selection.type()!=Selection::Branch &&
1.711 - selection.type()!=Selection::MapCenter &&
1.712 - selection.type()!=Selection::FloatImage )
1.713 + } else if ( selectionType()!=TreeItem::Branch &&
1.714 + selectionType()!=TreeItem::MapCenter &&
1.715 + selectionType()!=TreeItem::Image )
1.716 {
1.717 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.718 } else if (parser.checkParCount(2))
1.719 @@ -3230,7 +3233,7 @@
1.720 /////////////////////////////////////////////////////////////////////
1.721 } else if (com=="setFrameType")
1.722 {
1.723 - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
1.724 + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
1.725 {
1.726 parser.setError (Aborted,"Type of selection does not allow setting frame type");
1.727 }
1.728 @@ -3242,7 +3245,7 @@
1.729 /////////////////////////////////////////////////////////////////////
1.730 } else if (com=="setFramePenColor")
1.731 {
1.732 - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
1.733 + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
1.734 {
1.735 parser.setError (Aborted,"Type of selection does not allow setting of pen color");
1.736 }
1.737 @@ -3254,7 +3257,7 @@
1.738 /////////////////////////////////////////////////////////////////////
1.739 } else if (com=="setFrameBrushColor")
1.740 {
1.741 - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
1.742 + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
1.743 {
1.744 parser.setError (Aborted,"Type of selection does not allow setting brush color");
1.745 }
1.746 @@ -3266,7 +3269,7 @@
1.747 /////////////////////////////////////////////////////////////////////
1.748 } else if (com=="setFramePadding")
1.749 {
1.750 - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
1.751 + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
1.752 {
1.753 parser.setError (Aborted,"Type of selection does not allow setting frame padding");
1.754 }
1.755 @@ -3278,7 +3281,7 @@
1.756 /////////////////////////////////////////////////////////////////////
1.757 } else if (com=="setFrameBorderWidth")
1.758 {
1.759 - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
1.760 + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
1.761 {
1.762 parser.setError (Aborted,"Type of selection does not allow setting frame border width");
1.763 }
1.764 @@ -3309,7 +3312,7 @@
1.765 if (selection.isEmpty() )
1.766 {
1.767 parser.setError (Aborted,"Nothing selected");
1.768 - } else if (! selection.getBranch() )
1.769 + } else if (! getSelectedBranch() )
1.770 {
1.771 parser.setError (Aborted,"Type of selection is not a branch");
1.772 } else if (parser.checkParCount(1))
1.773 @@ -3360,7 +3363,7 @@
1.774 if (selection.isEmpty() )
1.775 {
1.776 parser.setError (Aborted,"Nothing selected");
1.777 - } else if (selection.type()!=Selection::Branch && selection.type() != Selection::MapCenter &&selection.type()!=Selection::FloatImage)
1.778 + } else if (selectionType()!=TreeItem::Branch && selectionType() != TreeItem::MapCenter &&selectionType()!=TreeItem::Image)
1.779 {
1.780 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.781 } else if (parser.checkParCount(1))
1.782 @@ -3402,7 +3405,7 @@
1.783 if (selection.isEmpty() )
1.784 {
1.785 parser.setError (Aborted,"Nothing selected");
1.786 - } else if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage)
1.787 + } else if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
1.788 {
1.789 parser.setError (Aborted,"Type of selection does not allow hiding the link");
1.790 } else if (parser.checkParCount(1))
1.791 @@ -3772,7 +3775,7 @@
1.792 void VymModel::updateNoteFlag()
1.793 {
1.794 setChanged();
1.795 - BranchObj *bo=selection.getBranch();
1.796 + BranchObj *bo=getSelectedBranch();
1.797 if (bo)
1.798 {
1.799 bo->updateNoteFlag();
1.800 @@ -4077,20 +4080,24 @@
1.801
1.802 void VymModel::move(const double &x, const double &y)
1.803 {
1.804 - LinkableMapObj *sel=selection.single();
1.805 - if (sel)
1.806 + BranchObj *bo = getSelectedBranch();
1.807 + if (bo &&
1.808 + (selectionType()==TreeItem::Branch ||
1.809 + selectionType()==TreeItem::MapCenter ||
1.810 + selectionType()==TreeItem::Image
1.811 + ))
1.812 {
1.813 - QPointF ap(sel->getAbsPos());
1.814 + QPointF ap(bo->getAbsPos());
1.815 QPointF to(x, y);
1.816 if (ap != to)
1.817 {
1.818 QString ps=qpointfToString(ap);
1.819 - QString s=selection.getSelectString();
1.820 + QString s=getSelectString();
1.821 saveState(
1.822 s, "move "+ps,
1.823 s, "move "+qpointfToString(to),
1.824 - QString("Move %1 to %2").arg(getObjectName(sel)).arg(ps));
1.825 - sel->move(x,y);
1.826 + QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps));
1.827 + bo->move(x,y);
1.828 reposition();
1.829 selection.update();
1.830 }
1.831 @@ -4099,22 +4106,27 @@
1.832
1.833 void VymModel::moveRel (const double &x, const double &y)
1.834 {
1.835 - LinkableMapObj *sel=selection.single();
1.836 - if (sel)
1.837 + BranchObj *bo = getSelectedBranch();
1.838 + if (bo &&
1.839 + (selectionType()==TreeItem::Branch ||
1.840 + selectionType()==TreeItem::MapCenter ||
1.841 + selectionType()==TreeItem::Image
1.842 + ))
1.843 + if (bo)
1.844 {
1.845 - QPointF rp(sel->getRelPos());
1.846 + QPointF rp(bo->getRelPos());
1.847 QPointF to(x, y);
1.848 if (rp != to)
1.849 {
1.850 - QString ps=qpointfToString (sel->getRelPos());
1.851 - QString s=getSelectString(sel);
1.852 + QString ps=qpointfToString (bo->getRelPos());
1.853 + QString s=getSelectString(bo);
1.854 saveState(
1.855 s, "moveRel "+ps,
1.856 s, "moveRel "+qpointfToString(to),
1.857 - QString("Move %1 to relative position %2").arg(getObjectName(sel)).arg(ps));
1.858 - ((OrnamentedObj*)sel)->move2RelPos (x,y);
1.859 + QString("Move %1 to relative position %2").arg(getObjectName(bo)).arg(ps));
1.860 + ((OrnamentedObj*)bo)->move2RelPos (x,y);
1.861 reposition();
1.862 - sel->updateLink();
1.863 + bo->updateLink();
1.864 selection.update();
1.865 }
1.866 }
1.867 @@ -4140,7 +4152,9 @@
1.868 bo->reposition();
1.869 i++;
1.870 }
1.871 - emit (selectionChanged(selModel->selection(), selModel->selection()) );
1.872 + QItemSelection sel=selModel->selection();
1.873 + emit (selectionChanged(sel,sel));
1.874 +
1.875 mapScene->update();
1.876 if (!animObjList.isEmpty()) animationTimer->start();
1.877 }
1.878 @@ -4324,7 +4338,24 @@
1.879
1.880 void VymModel::updateSelection()
1.881 {
1.882 - selection.update();
1.883 + cout << "VM::updateSelection ()\n";
1.884 + QItemSelection newsel=selModel->selection();
1.885 + updateSelection (newsel);
1.886 +}
1.887 +
1.888 +void VymModel::updateSelection(const QItemSelection &oldsel)
1.889 +{
1.890 + QItemSelection newsel=selModel->selection();
1.891 + cout << "VM::updateSelection new=";
1.892 + if (!newsel.indexes().isEmpty() )
1.893 + cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column();
1.894 + cout << " old=";
1.895 + if (!oldsel.indexes().isEmpty() )
1.896 + cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column();
1.897 + cout <<endl;
1.898 + //emit (selectionChanged(newsel,oldsel));
1.899 + ensureSelectionVisible();
1.900 + sendSelection();
1.901 }
1.902
1.903 void VymModel::setSelectionColor(QColor col)
1.904 @@ -4399,24 +4430,28 @@
1.905
1.906 bool VymModel::select (const QString &s)
1.907 {
1.908 - if (selection.select(s))
1.909 + LinkableMapObj *lmo=findObjBySelect(s);
1.910 +
1.911 + // Finally select the found object
1.912 + if (lmo)
1.913 {
1.914 - selection.update();
1.915 - ensureSelectionVisible();
1.916 - sendSelection ();
1.917 + unselect();
1.918 + select (lmo);
1.919 return true;
1.920 - }
1.921 + }
1.922 return false;
1.923 -
1.924 }
1.925
1.926 bool VymModel::select (LinkableMapObj *lmo)
1.927 {
1.928 - if (selection.select(lmo))
1.929 + QItemSelection oldsel=selModel->selection();
1.930 +
1.931 + if (lmo)
1.932 {
1.933 - selection.update();
1.934 - ensureSelectionVisible();
1.935 - sendSelection ();
1.936 + TreeItem *ti=lmo->getTreeItem();
1.937 + QModelIndex ix=index(ti);
1.938 + selModel->select (ix,QItemSelectionModel::ClearAndSelect );
1.939 + //updateSelection(oldsel);
1.940 return true;
1.941 }
1.942 return false;
1.943 @@ -4424,7 +4459,7 @@
1.944
1.945 void VymModel::unselect()
1.946 {
1.947 - selection.unselect();
1.948 + selModel->clearSelection();
1.949 }
1.950
1.951 void VymModel::reselect()
1.952 @@ -4434,7 +4469,7 @@
1.953
1.954 void VymModel::ensureSelectionVisible()
1.955 {
1.956 - LinkableMapObj *lmo=selection.single();
1.957 + LinkableMapObj *lmo=getSelectedLMO();
1.958 if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() );
1.959
1.960 }
1.961 @@ -4452,10 +4487,10 @@
1.962 void VymModel::selectNextBranchInt()
1.963 {
1.964 // Increase number of branch
1.965 - LinkableMapObj *sel=selection.single();
1.966 + LinkableMapObj *sel=getSelectedBranch();
1.967 if (sel)
1.968 {
1.969 - QString s=selection.getSelectString();
1.970 + QString s=getSelectString();
1.971 QString part;
1.972 QString typ;
1.973 QString num;
1.974 @@ -4479,7 +4514,7 @@
1.975 // try to increase the parental number in order to
1.976 // find a successor with same depth
1.977
1.978 - int d=selection.single()->getDepth();
1.979 + int d=getSelectedLMO()->getDepth();
1.980 int oldDepth=d;
1.981 int i;
1.982 bool found=false;
1.983 @@ -4500,7 +4535,7 @@
1.984 } else
1.985 {
1.986 // Special case, look at orientation
1.987 - if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
1.988 + if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter)
1.989 num=QString ("%1").arg(num.toUInt()+1);
1.990 else
1.991 num=QString ("%1").arg(num.toUInt()-1);
1.992 @@ -4514,7 +4549,7 @@
1.993 b=select (s);
1.994 if (b)
1.995 {
1.996 - if ( selection.getBranch()->countBranches()>0)
1.997 + if ( getSelectedBranch()->countBranches()>0)
1.998 s+=",bo:0";
1.999 else
1.1000 break;
1.1001 @@ -4533,7 +4568,7 @@
1.1002 void VymModel::selectPrevBranchInt()
1.1003 {
1.1004 // Decrease number of branch
1.1005 - BranchObj *bo=selection.getBranch();
1.1006 + BranchObj *bo=getSelectedBranch();
1.1007 if (bo)
1.1008 {
1.1009 QString s=selection.getSelectString();
1.1010 @@ -4561,7 +4596,7 @@
1.1011 // try to decrease the parental number in order to
1.1012 // find a precessor with same depth
1.1013
1.1014 - int d=selection.single()->getDepth();
1.1015 + int d=getSelectedLMO()->getDepth();
1.1016 int oldDepth=d;
1.1017 int i;
1.1018 bool found=false;
1.1019 @@ -4582,7 +4617,7 @@
1.1020 } else
1.1021 {
1.1022 // Special case, look at orientation
1.1023 - if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter)
1.1024 + if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter)
1.1025 num=QString ("%1").arg(num.toInt()-1);
1.1026 else
1.1027 num=QString ("%1").arg(num.toInt()+1);
1.1028 @@ -4595,8 +4630,8 @@
1.1029 {
1.1030 b=select (s);
1.1031 if (b)
1.1032 - if ( selection.getBranch()->countBranches()>0)
1.1033 - s+=",bo:"+ QString ("%1").arg( selection.getBranch()->countBranches()-1 );
1.1034 + if ( getSelectedBranch()->countBranches()>0)
1.1035 + s+=",bo:"+ QString ("%1").arg( getSelectedBranch()->countBranches()-1 );
1.1036 else
1.1037 break;
1.1038 else
1.1039 @@ -4615,8 +4650,8 @@
1.1040 {
1.1041 if (selection.isBlocked() ) return;
1.1042
1.1043 - BranchObj *bo=selection.getBranch();
1.1044 - if (bo && selection.type()==Selection::Branch)
1.1045 + BranchObj *bo=getSelectedBranch();
1.1046 + if (bo && selectionType()==TreeItem::Branch)
1.1047 {
1.1048 if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
1.1049 selectPrevBranchInt();
1.1050 @@ -4632,8 +4667,8 @@
1.1051 {
1.1052 if (selection.isBlocked() ) return;
1.1053
1.1054 - BranchObj *bo=selection.getBranch();
1.1055 - if (bo && selection.type()==Selection::Branch)
1.1056 + BranchObj *bo=getSelectedBranch();
1.1057 + if (bo && selectionType()==TreeItem::Branch)
1.1058 {
1.1059 if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
1.1060 selectNextBranchInt();
1.1061 @@ -4650,57 +4685,40 @@
1.1062 {
1.1063 if (selection.isBlocked() ) return;
1.1064
1.1065 - BranchObj* bo;
1.1066 + QItemSelection oldsel=selModel->selection();
1.1067 +
1.1068 BranchObj* par;
1.1069 - LinkableMapObj *sel=selection.single();
1.1070 + LinkableMapObj *sel=getSelectedBranch();
1.1071 if (sel)
1.1072 {
1.1073 - if (selection.type()== Selection::MapCenter)
1.1074 + if (selectionType()== TreeItem::MapCenter)
1.1075 {
1.1076 - par=selection.getBranch();
1.1077 - bo=par->getLastSelectedBranch();
1.1078 - if (bo)
1.1079 - {
1.1080 - // Workaround for reselecting on left and right side
1.1081 - if (bo->getOrientation()==LinkableMapObj::RightOfCenter)
1.1082 - bo=par->getLastBranch();
1.1083 - if (bo)
1.1084 - {
1.1085 - bo=par->getLastBranch();
1.1086 - selection.select(bo);
1.1087 - selection.update();
1.1088 - ensureSelectionVisible();
1.1089 - sendSelection();
1.1090 - }
1.1091 - }
1.1092 + QModelIndex ix=getSelectedIndex();
1.1093 + selModel->select (index (rowCount(ix)-1,0,ix),QItemSelectionModel::ClearAndSelect );
1.1094 } else
1.1095 {
1.1096 par=(BranchObj*)(sel->getParObj());
1.1097 if (sel->getOrientation()==LinkableMapObj::RightOfCenter)
1.1098 {
1.1099 - if (selection.type() == Selection::Branch ||
1.1100 - selection.type() == Selection::FloatImage)
1.1101 + // right of center
1.1102 + if (selectionType() == TreeItem::Branch ||
1.1103 + selectionType() == TreeItem::Image)
1.1104 {
1.1105 - selection.select(par);
1.1106 - selection.update();
1.1107 - ensureSelectionVisible();
1.1108 - sendSelection();
1.1109 + QModelIndex ix=getSelectedIndex();
1.1110 + ix=parent(ix);
1.1111 + selModel->select (ix,QItemSelectionModel::ClearAndSelect );
1.1112 }
1.1113 } else
1.1114 {
1.1115 - if (selection.type() == Selection::Branch )
1.1116 + // left of center
1.1117 + if (selectionType() == TreeItem::Branch )
1.1118 {
1.1119 - bo=selection.getBranch()->getLastSelectedBranch();
1.1120 - if (bo)
1.1121 - {
1.1122 - selection.select(bo);
1.1123 - selection.update();
1.1124 - ensureSelectionVisible();
1.1125 - sendSelection();
1.1126 - }
1.1127 + selectLastSelectedBranch();
1.1128 + return;
1.1129 }
1.1130 }
1.1131 }
1.1132 + updateSelection (oldsel);
1.1133 }
1.1134 }
1.1135
1.1136 @@ -4708,14 +4726,16 @@
1.1137 {
1.1138 if (selection.isBlocked() ) return;
1.1139
1.1140 + QItemSelection oldsel=selModel->selection();
1.1141 +
1.1142 BranchObj* bo;
1.1143 BranchObj* par;
1.1144 - LinkableMapObj *sel=selection.single();
1.1145 + LinkableMapObj *sel=getSelectedBranch();
1.1146 if (sel)
1.1147 {
1.1148 - if (selection.type()==Selection::MapCenter)
1.1149 + if (selectionType()==TreeItem::MapCenter)
1.1150 {
1.1151 - par=selection.getBranch();
1.1152 + par=getSelectedBranch();
1.1153 bo=par->getLastSelectedBranch();
1.1154 if (bo)
1.1155 {
1.1156 @@ -4725,45 +4745,48 @@
1.1157 if (bo)
1.1158 {
1.1159 selection.select(bo);
1.1160 - selection.update();
1.1161 - ensureSelectionVisible();
1.1162 - sendSelection();
1.1163 + //selection.update();
1.1164 + //ensureSelectionVisible();
1.1165 + //sendSelection();
1.1166 }
1.1167 }
1.1168 } else
1.1169 {
1.1170 - par=(BranchObj*)(selection.single()->getParObj());
1.1171 - if (selection.single()->getOrientation()==LinkableMapObj::LeftOfCenter)
1.1172 + par=(BranchObj*)(getSelectedLMO()->getParObj());
1.1173 + if (getSelectedLMO()->getOrientation()==LinkableMapObj::LeftOfCenter)
1.1174 {
1.1175 - if (selection.type() == Selection::Branch ||
1.1176 - selection.type() == Selection::FloatImage)
1.1177 + if (selectionType() == TreeItem::Branch ||
1.1178 + selectionType() == TreeItem::Image)
1.1179 {
1.1180 - selection.select(par);
1.1181 - selection.update();
1.1182 - ensureSelectionVisible();
1.1183 - sendSelection();
1.1184 + QModelIndex ix=getSelectedIndex();
1.1185 + ix=parent(ix);
1.1186 + selModel->select (ix,QItemSelectionModel::ClearAndSelect );
1.1187 }
1.1188 } else
1.1189 {
1.1190 - if (selection.type() == Selection::Branch)
1.1191 + if (selectionType() == TreeItem::Branch)
1.1192 {
1.1193 - bo=selection.getBranch()->getLastSelectedBranch();
1.1194 + bo=getSelectedBranch()->getLastSelectedBranch();
1.1195 if (bo)
1.1196 {
1.1197 selection.select(bo);
1.1198 - selection.update();
1.1199 - ensureSelectionVisible();
1.1200 - sendSelection();
1.1201 + //selection.update();
1.1202 + //ensureSelectionVisible();
1.1203 + //sendSelection();
1.1204 }
1.1205 }
1.1206 }
1.1207 }
1.1208 + QItemSelection newsel=selModel->selection();
1.1209 + emit (selectionChanged(newsel,oldsel));
1.1210 + ensureSelectionVisible();
1.1211 + sendSelection();
1.1212 }
1.1213 }
1.1214
1.1215 void VymModel::selectFirstBranch()
1.1216 {
1.1217 - BranchObj *bo1=selection.getBranch();
1.1218 + BranchObj *bo1=getSelectedBranch();
1.1219 BranchObj *bo2;
1.1220 BranchObj* par;
1.1221 if (bo1)
1.1222 @@ -4782,7 +4805,7 @@
1.1223
1.1224 void VymModel::selectLastBranch()
1.1225 {
1.1226 - BranchObj *bo1=selection.getBranch();
1.1227 + BranchObj *bo1=getSelectedBranch();
1.1228 BranchObj *bo2;
1.1229 BranchObj* par;
1.1230 if (bo1)
1.1231 @@ -4800,33 +4823,94 @@
1.1232 }
1.1233 }
1.1234
1.1235 +void VymModel::selectLastSelectedBranch()
1.1236 +{
1.1237 + QItemSelection oldsel=selModel->selection();
1.1238 +
1.1239 + BranchObj *bo1=getSelectedBranch();
1.1240 + BranchObj *bo2;
1.1241 + if (bo1)
1.1242 + {
1.1243 + cout << "bo1="<<bo1->getHeading().toStdString()<<endl;
1.1244 + bo2=bo1->getLastSelectedBranch();
1.1245 + if (bo2)
1.1246 + {
1.1247 + cout << "bo2="<<bo2->getHeading().toStdString()<<endl;
1.1248 + select(bo2);
1.1249 + }
1.1250 + }
1.1251 +}
1.1252 +
1.1253 void VymModel::selectParent()
1.1254 {
1.1255 - LinkableMapObj *lmo=selection.first();
1.1256 + LinkableMapObj *lmo=getSelectedLMO();
1.1257 BranchObj* par;
1.1258 if (lmo)
1.1259 {
1.1260 par=(BranchObj*)(lmo->getParObj());
1.1261 if (!par) return;
1.1262 - selection.select(par);
1.1263 + select(par);
1.1264 selection.update();
1.1265 ensureSelectionVisible();
1.1266 sendSelection();
1.1267 }
1.1268 }
1.1269
1.1270 -Selection::Type VymModel::selectionType()
1.1271 +TreeItem::Type VymModel::selectionType()
1.1272 {
1.1273 - return selection.type();
1.1274 + QModelIndexList list=selModel->selectedIndexes();
1.1275 + if (list.isEmpty()) return TreeItem::Undefined;
1.1276 + TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
1.1277 + return ti->getType();
1.1278 +
1.1279 }
1.1280
1.1281 -LinkableMapObj* VymModel::getSelection()
1.1282 +LinkableMapObj* VymModel::getSelectedLMO()
1.1283 {
1.1284 - return selection.single();
1.1285 + QModelIndexList list=selModel->selectedIndexes();
1.1286 + if (!list.isEmpty() )
1.1287 + {
1.1288 + TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
1.1289 + TreeItem::Type type=ti->getType();
1.1290 + if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image)
1.1291 + {
1.1292 + return ti->getLMO();
1.1293 + }
1.1294 + }
1.1295 + return NULL;
1.1296 }
1.1297 +
1.1298 BranchObj* VymModel::getSelectedBranch()
1.1299 {
1.1300 - return selection.getBranch();
1.1301 + QModelIndexList list=selModel->selectedIndexes();
1.1302 + if (!list.isEmpty() )
1.1303 + {
1.1304 + TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
1.1305 + TreeItem::Type type=ti->getType();
1.1306 + if (type ==TreeItem::Branch || type==TreeItem::MapCenter)
1.1307 + {
1.1308 + return (BranchObj*)ti->getLMO();
1.1309 + }
1.1310 + }
1.1311 + return NULL;
1.1312 +
1.1313 +}
1.1314 +
1.1315 +TreeItem* VymModel::getSelectedTreeItem()
1.1316 +{
1.1317 + // FIXME this may not only be branch, but also float etc...
1.1318 + BranchObj* bo=getSelectedBranch();
1.1319 + if (bo) return bo->getTreeItem(); // FIXME VM get directly from treemodl
1.1320 + return NULL;
1.1321 +}
1.1322 +
1.1323 +QModelIndex VymModel::getSelectedIndex()
1.1324 +{
1.1325 + QModelIndexList list=selModel->selectedIndexes();
1.1326 + if (list.isEmpty() )
1.1327 + return QModelIndex();
1.1328 + else
1.1329 + return list.first();
1.1330 }
1.1331
1.1332 FloatImageObj* VymModel::getSelectedFloatImage()
1.1333 @@ -4854,7 +4938,7 @@
1.1334 s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
1.1335 else
1.1336 {
1.1337 - //cout << "VM::getSelectString lmo="<<lmo<<" d="<<lmo->getDepth()<<" s="<<s.toStdString()<<" h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
1.1338 + cout << "VM::getSelectString lmo="<<lmo<<" d="<<lmo->getDepth()<<" s="<<s.toStdString()<<" h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
1.1339 // Branch, call myself recursively
1.1340 s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
1.1341 }