1.1 --- a/vymmodel.cpp Thu Aug 06 10:42:17 2009 +0000
1.2 +++ b/vymmodel.cpp Sat Aug 08 21:58:26 2009 +0000
1.3 @@ -360,7 +360,7 @@
1.4 // (map state is set later at end of load...)
1.5 } else
1.6 {
1.7 - BranchItem *bi=getSelectedBranchItem();
1.8 + BranchItem *bi=getSelectedBranch();
1.9 if (!bi) return aborted;
1.10 if (lmode==ImportAdd)
1.11 saveStateChangingPart(
1.12 @@ -607,7 +607,7 @@
1.13 if (selectionType()==TreeItem::Image)
1.14 saveFloatImage();
1.15 else
1.16 - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranchItem());
1.17 + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranch());
1.18 // TODO take care of multiselections
1.19 }
1.20
1.21 @@ -725,7 +725,7 @@
1.22
1.23 void VymModel::loadFloatImage ()
1.24 {
1.25 - BranchItem *selbi=getSelectedBranchItem();
1.26 + BranchItem *selbi=getSelectedBranch();
1.27 if (selbi)
1.28 {
1.29
1.30 @@ -776,7 +776,7 @@
1.31
1.32 void VymModel::saveFloatImage ()
1.33 {
1.34 - ImageItem *ii=getSelectedImageItem();
1.35 + ImageItem *ii=getSelectedImage();
1.36 if (ii)
1.37 {
1.38 QFileDialog *fd=new QFileDialog( NULL);
1.39 @@ -1487,7 +1487,7 @@
1.40
1.41 void VymModel::setHeading(const QString &s)
1.42 {
1.43 - BranchItem *selbi=getSelectedBranchItem();
1.44 + BranchItem *selbi=getSelectedBranch();
1.45 if (selbi)
1.46 {
1.47 saveState(
1.48 @@ -1564,7 +1564,7 @@
1.49 //cout <<"still searching... "<<qPrintable( itFind->getHeading())<<endl;
1.50 }
1.51 if (!searching)
1.52 - return getSelectedBranchItem();
1.53 + return getSelectedBranch();
1.54 else
1.55 return NULL;
1.56 }
1.57 @@ -1615,7 +1615,7 @@
1.58 QStringList VymModel::getURLs()
1.59 {
1.60 QStringList urls;
1.61 - BranchItem *selbi=getSelectedBranchItem();
1.62 + BranchItem *selbi=getSelectedBranch();
1.63 BranchItem *cur=selbi;
1.64 BranchItem *prev=NULL;
1.65 while (cur)
1.66 @@ -1629,7 +1629,7 @@
1.67
1.68 void VymModel::setFrameType(const FrameObj::FrameType &t) //FIXME-4 not saved if there is no LMO
1.69 {
1.70 - BranchItem *bi=getSelectedBranchItem();
1.71 + BranchItem *bi=getSelectedBranch();
1.72 if (bi)
1.73 {
1.74 BranchObj *bo=(BranchObj*)(bi->getLMO());
1.75 @@ -1647,7 +1647,7 @@
1.76
1.77 void VymModel::setFrameType(const QString &s) //FIXME-4 not saved if there is no LMO
1.78 {
1.79 - BranchItem *bi=getSelectedBranchItem();
1.80 + BranchItem *bi=getSelectedBranch();
1.81 if (bi)
1.82 {
1.83 BranchObj *bo=(BranchObj*)(bi->getLMO());
1.84 @@ -1665,7 +1665,7 @@
1.85 void VymModel::setFramePenColor(const QColor &c) //FIXME-4 not saved if there is no LMO
1.86
1.87 {
1.88 - BranchItem *bi=getSelectedBranchItem();
1.89 + BranchItem *bi=getSelectedBranch();
1.90 if (bi)
1.91 {
1.92 BranchObj *bo=(BranchObj*)(bi->getLMO());
1.93 @@ -1680,7 +1680,7 @@
1.94
1.95 void VymModel::setFrameBrushColor(const QColor &c) //FIXME-4 not saved if there is no LMO
1.96 {
1.97 - BranchItem *bi=getSelectedBranchItem();
1.98 + BranchItem *bi=getSelectedBranch();
1.99 if (bi)
1.100 {
1.101 BranchObj *bo=(BranchObj*)(bi->getLMO());
1.102 @@ -1695,7 +1695,7 @@
1.103
1.104 void VymModel::setFramePadding (const int &i) //FIXME-4 not saved if there is no LMO
1.105 {
1.106 - BranchItem *bi=getSelectedBranchItem();
1.107 + BranchItem *bi=getSelectedBranch();
1.108 if (bi)
1.109 {
1.110 BranchObj *bo=(BranchObj*)(bi->getLMO());
1.111 @@ -1712,7 +1712,7 @@
1.112
1.113 void VymModel::setFrameBorderWidth(const int &i) //FIXME-4 not saved if there is no LMO
1.114 {
1.115 - BranchItem *bi=getSelectedBranchItem();
1.116 + BranchItem *bi=getSelectedBranch();
1.117 if (bi)
1.118 {
1.119 BranchObj *bo=(BranchObj*)(bi->getLMO());
1.120 @@ -1729,7 +1729,7 @@
1.121
1.122 void VymModel::setIncludeImagesVer(bool b)
1.123 {
1.124 - BranchItem *bi=getSelectedBranchItem();
1.125 + BranchItem *bi=getSelectedBranch();
1.126 if (bi)
1.127 {
1.128 QString u= b ? "false" : "true";
1.129 @@ -1750,7 +1750,7 @@
1.130
1.131 void VymModel::setIncludeImagesHor(bool b)
1.132 {
1.133 - BranchItem *bi=getSelectedBranchItem();
1.134 + BranchItem *bi=getSelectedBranch();
1.135 if (bi)
1.136 {
1.137 QString u= b ? "false" : "true";
1.138 @@ -1869,7 +1869,7 @@
1.139
1.140 void VymModel::paste()
1.141 {
1.142 - BranchItem *selbi=getSelectedBranchItem();
1.143 + BranchItem *selbi=getSelectedBranch();
1.144 if (selbi)
1.145 {
1.146 saveStateChangingPart(
1.147 @@ -1896,7 +1896,7 @@
1.148
1.149 void VymModel::moveUp()
1.150 {
1.151 - BranchItem *selbi=getSelectedBranchItem();
1.152 + BranchItem *selbi=getSelectedBranch();
1.153 if (selbi)
1.154 {
1.155 if (!selbi->canMoveUp()) return;
1.156 @@ -1909,7 +1909,7 @@
1.157
1.158 void VymModel::moveDown()
1.159 {
1.160 - BranchItem *selbi=getSelectedBranchItem();
1.161 + BranchItem *selbi=getSelectedBranch();
1.162 if (selbi)
1.163 {
1.164 if (!selbi->canMoveDown()) return;
1.165 @@ -1985,8 +1985,6 @@
1.166
1.167 AttributeItem* VymModel::addAttribute()
1.168 {
1.169 - cout << "VM::addAttribute\n";
1.170 -
1.171 TreeItem *selti=getSelectedItem();
1.172 if (selti)
1.173 {
1.174 @@ -2108,7 +2106,7 @@
1.175 // 0 add as child
1.176 // +1 add below
1.177 BranchItem *newbi=NULL;
1.178 - BranchItem *selbi=getSelectedBranchItem();
1.179 + BranchItem *selbi=getSelectedBranch();
1.180
1.181 if (selbi)
1.182 {
1.183 @@ -2145,7 +2143,7 @@
1.184 BranchItem* VymModel::addNewBranchBefore()
1.185 {
1.186 BranchItem *newbi=NULL;
1.187 - BranchItem *selbi=getSelectedBranchItem();
1.188 + BranchItem *selbi=getSelectedBranch();
1.189 if (selbi && selbi->getType()==TreeItem::Branch)
1.190 // We accept no MapCenter here, so we _have_ a parent
1.191 {
1.192 @@ -2255,7 +2253,7 @@
1.193
1.194 void VymModel::deleteSelection() // FIXME-2 include fix for deleted mapcenters from 1.12.4
1.195 {
1.196 - BranchItem *selbi=getSelectedBranchItem();
1.197 + BranchItem *selbi=getSelectedBranch();
1.198
1.199 if (selbi && selbi->isBranchLikeType() )
1.200 {
1.201 @@ -2270,18 +2268,19 @@
1.202 }
1.203 return;
1.204 }
1.205 - ImageItem *ii=getSelectedImageItem();
1.206 - if (ii)
1.207 + TreeItem *ti=getSelectedImage();
1.208 + if (ti->getType()==TreeItem::Image || ti->getType()==TreeItem::Attribute)
1.209 {
1.210 - BranchItem *pi=(BranchItem*)(ii->parent());
1.211 + TreeItem *pi=ti->parent();
1.212 saveStateChangingPart(
1.213 pi,
1.214 - ii,
1.215 + ti,
1.216 "delete ()",
1.217 - QString("Delete %1").arg(getObjectName(ii))
1.218 + QString("Delete %1").arg(getObjectName(ti))
1.219 );
1.220 unselect();
1.221 - deleteItem (ii);
1.222 + deleteItem (ti);
1.223 + emitDataHasChanged (pi);
1.224 select (pi);
1.225 reposition();
1.226 emitShowSelection();
1.227 @@ -2289,10 +2288,10 @@
1.228 }
1.229 }
1.230
1.231 -void VymModel::deleteKeepChildren() //FIXME-2 does not work yet for mapcenters
1.232 -
1.233 -{
1.234 - BranchItem *selbi=getSelectedBranchItem();
1.235 +void VymModel::deleteKeepChildren() //FIXME-3 does not work yet for mapcenters
1.236 +
1.237 +{
1.238 + BranchItem *selbi=getSelectedBranch();
1.239 BranchItem *pi;
1.240 if (selbi)
1.241 {
1.242 @@ -2341,7 +2340,7 @@
1.243 void VymModel::deleteChildren()
1.244
1.245 {
1.246 - BranchItem *selbi=getSelectedBranchItem();
1.247 + BranchItem *selbi=getSelectedBranch();
1.248 if (selbi)
1.249 {
1.250 saveStateChangingPart(
1.251 @@ -2442,7 +2441,7 @@
1.252
1.253 void VymModel::toggleScroll()
1.254 {
1.255 - BranchItem *bi=(BranchItem*)getSelectedBranchItem();
1.256 + BranchItem *bi=(BranchItem*)getSelectedBranch();
1.257 if (bi && bi->isBranchLikeType() )
1.258 {
1.259 if (bi->isScrolled())
1.260 @@ -2477,7 +2476,7 @@
1.261
1.262 void VymModel::toggleStandardFlag (const QString &name, FlagRow *master)
1.263 {
1.264 - BranchItem *bi=getSelectedBranchItem();
1.265 + BranchItem *bi=getSelectedBranch();
1.266 if (bi)
1.267 {
1.268 QString u,r;
1.269 @@ -2524,7 +2523,7 @@
1.270
1.271 void VymModel::colorBranch (QColor c)
1.272 {
1.273 - BranchItem *selbi=getSelectedBranchItem();
1.274 + BranchItem *selbi=getSelectedBranch();
1.275 if (selbi)
1.276 {
1.277 saveState(
1.278 @@ -2540,7 +2539,7 @@
1.279
1.280 void VymModel::colorSubtree (QColor c)
1.281 {
1.282 - BranchItem *selbi=getSelectedBranchItem();
1.283 + BranchItem *selbi=getSelectedBranch();
1.284 if (selbi)
1.285 {
1.286 saveStateChangingPart(
1.287 @@ -2562,7 +2561,7 @@
1.288
1.289 QColor VymModel::getCurrentHeadingColor()
1.290 {
1.291 - BranchItem *selbi=getSelectedBranchItem();
1.292 + BranchItem *selbi=getSelectedBranch();
1.293 if (selbi) return selbi->getHeadingColor();
1.294
1.295 QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected");
1.296 @@ -2651,7 +2650,7 @@
1.297
1.298 void VymModel::editVymLink()
1.299 {
1.300 - BranchItem *bi=getSelectedBranchItem();
1.301 + BranchItem *bi=getSelectedBranch();
1.302 if (bi)
1.303 {
1.304 QStringList filters;
1.305 @@ -2695,7 +2694,7 @@
1.306
1.307 void VymModel::deleteVymLink()
1.308 {
1.309 - BranchItem *bi=getSelectedBranchItem();
1.310 + BranchItem *bi=getSelectedBranch();
1.311 if (bi)
1.312 {
1.313 saveState(
1.314 @@ -2713,7 +2712,7 @@
1.315
1.316 QString VymModel::getVymLink()
1.317 {
1.318 - BranchItem *bi=getSelectedBranchItem();
1.319 + BranchItem *bi=getSelectedBranch();
1.320 if (bi)
1.321 return bi->getVymLink();
1.322 else
1.323 @@ -2724,7 +2723,7 @@
1.324 QStringList VymModel::getVymLinks()
1.325 {
1.326 QStringList links;
1.327 - BranchItem *selbi=getSelectedBranchItem();
1.328 + BranchItem *selbi=getSelectedBranch();
1.329 BranchItem *cur=selbi;
1.330 BranchItem *prev=NULL;
1.331 while (cur)
1.332 @@ -2792,7 +2791,7 @@
1.333 void VymModel::parseAtom(const QString &atom)
1.334 {
1.335 TreeItem* selti=getSelectedItem();
1.336 - BranchItem *selbi=getSelectedBranchItem();
1.337 + BranchItem *selbi=getSelectedBranch();
1.338 QString s,t;
1.339 double x,y;
1.340 int n;
1.341 @@ -3307,7 +3306,7 @@
1.342 /////////////////////////////////////////////////////////////////////
1.343 } else if (com=="saveImage")
1.344 {
1.345 - ImageItem *ii=getSelectedImageItem();
1.346 + ImageItem *ii=getSelectedImage();
1.347 if (!ii )
1.348 {
1.349 parser.setError (Aborted,"No image selected");
1.350 @@ -4612,12 +4611,7 @@
1.351 bool VymModel::select (const QString &s)
1.352 {
1.353 TreeItem *ti=findBySelectString(s);
1.354 - if (ti)
1.355 - {
1.356 - unselect();
1.357 - select (ti);
1.358 - return true;
1.359 - }
1.360 + if (ti) return select (index(ti));
1.361 return false;
1.362 }
1.363
1.364 @@ -4626,7 +4620,7 @@
1.365 QItemSelection oldsel=selModel->selection();
1.366
1.367 if (lmo)
1.368 - return select (lmo->getTreeItem() );
1.369 + return select (index (lmo->getTreeItem()) );
1.370 else
1.371 return false;
1.372 }
1.373 @@ -4642,7 +4636,8 @@
1.374 if (index.isValid() )
1.375 {
1.376 selModel->select (index,QItemSelectionModel::ClearAndSelect );
1.377 - getSelectedItem()->setLastSelectedBranch();
1.378 + BranchItem *bi=getSelectedBranch();
1.379 + if (bi) bi->setLastSelectedBranch();
1.380 return true;
1.381 }
1.382 return false;
1.383 @@ -4654,9 +4649,9 @@
1.384 selModel->clearSelection();
1.385 }
1.386
1.387 -void VymModel::reselect()
1.388 -{
1.389 - select (lastSelectString);
1.390 +bool VymModel::reselect()
1.391 +{
1.392 + return select (lastSelectString);
1.393 }
1.394
1.395 void VymModel::emitShowSelection()
1.396 @@ -4678,7 +4673,7 @@
1.397 }
1.398
1.399
1.400 -//void VymModel::selectInt (LinkableMapObj *lmo) // FIXME-3 still needed?
1.401 +//bool VymModel::selectInt (LinkableMapObj *lmo) // FIXME-3 still needed?
1.402 /*
1.403 {
1.404 if (selection.select(lmo))
1.405 @@ -4687,7 +4682,7 @@
1.406 }
1.407 }
1.408
1.409 -void VymModel::selectInt (TreeItem *ti)
1.410 +bool VymModel::selectInt (TreeItem *ti)
1.411 {
1.412 if (selection.select(lmo))
1.413 {
1.414 @@ -4696,264 +4691,58 @@
1.415 }
1.416 */
1.417
1.418 -void VymModel::selectNextBranchInt()
1.419 -{
1.420 - BranchItem *bi=getSelectedBranchItem();
1.421 - if (bi)
1.422 - {
1.423 - TreeItem *pi=bi->parent();
1.424 - if (bi!=rootItem)
1.425 - {
1.426 - int i=bi->num();
1.427 - if (i<pi->branchCount() )
1.428 - {
1.429 - // select previous branch with same parent
1.430 - i++;
1.431 - select (pi->getBranchNum(i));
1.432 - return;
1.433 - }
1.434 - }
1.435 -
1.436 - }
1.437 -}
1.438 -
1.439 -void VymModel::selectPrevBranchInt()
1.440 -{
1.441 -
1.442 - BranchItem *bi=getSelectedBranchItem();
1.443 - if (bi)
1.444 - {
1.445 - BranchItem *pi=(BranchItem*)bi->parent();
1.446 - if (bi!=rootItem)
1.447 - {
1.448 - int i=bi->num();
1.449 - if (i>0)
1.450 - {
1.451 - // select previous branch with same parent
1.452 - bi=pi->getBranchNum(i-1);
1.453 - select (bi);
1.454 - return;
1.455 - }
1.456 - bi=pi;
1.457 - while (bi->branchCount() >0)
1.458 - bi=bi->getLastBranch();
1.459 - select (bi);
1.460 -
1.461 - // Try to select last branch in parent pi2 previous to own parent pi
1.462 - /*
1.463 - TreeItem *pi2=pi->parent();
1.464 - if (pi2)
1.465 - {
1.466 - int j=pi->num();
1.467 - if (pi2->)
1.468 - }
1.469 - */
1.470 - }
1.471 - }
1.472 -}
1.473 -
1.474 -void VymModel::selectAboveBranchInt()
1.475 -{
1.476 - BranchItem *bi=getSelectedBranchItem();
1.477 - if (bi)
1.478 - {
1.479 - BranchItem *newbi=NULL;
1.480 - BranchItem *pi=(BranchItem*)bi->parent();
1.481 - int i=bi->num();
1.482 - if (i>0)
1.483 - {
1.484 - // goto previous branch with same parent
1.485 - newbi=pi->getBranchNum(i-1);
1.486 - while (newbi->branchCount() >0 )
1.487 - newbi=newbi->getLastBranch();
1.488 - }
1.489 - else
1.490 - newbi=pi;
1.491 - if (newbi==rootItem)
1.492 - // already at top branch (resp. mapcenter)
1.493 - return;
1.494 - select (newbi);
1.495 - }
1.496 -}
1.497 -
1.498 -void VymModel::selectBelowBranchInt()
1.499 -{
1.500 - BranchItem *bi=getSelectedBranchItem();
1.501 - if (bi)
1.502 - {
1.503 - BranchItem *newbi=NULL;
1.504 -
1.505 - if (bi->branchCount() >0)
1.506 - newbi=bi->getFirstBranch();
1.507 - else
1.508 - {
1.509 - BranchItem *pi;
1.510 - int i;
1.511 - while (!newbi)
1.512 - {
1.513 - pi=(BranchItem*)bi->parent();
1.514 - i=bi->num();
1.515 - if (pi->branchCount()-1 > i)
1.516 - {
1.517 - newbi=(BranchItem*)pi->getBranchNum(i+1);
1.518 - //done...
1.519 - break;
1.520 - }
1.521 - else
1.522 - // look for siblings of myself
1.523 - // or parent, or parent of parent...
1.524 - bi=pi;
1.525 - if (bi==rootItem)
1.526 - // already at end
1.527 - return;
1.528 - }
1.529 - }
1.530 - select (newbi);
1.531 - }
1.532 -}
1.533 -
1.534 -void VymModel::selectUpperBranch()
1.535 -{
1.536 - BranchItem *bi=getSelectedBranchItem();
1.537 - if (bi && bi->isBranchLikeType())
1.538 - selectAboveBranchInt();
1.539 -}
1.540 -
1.541 -void VymModel::selectLowerBranch()
1.542 -{
1.543 - BranchItem *bi=getSelectedBranchItem();
1.544 - if (bi && bi->isBranchLikeType())
1.545 - selectBelowBranchInt();
1.546 -}
1.547 -
1.548 -
1.549 -void VymModel::selectLeftBranch()
1.550 -{
1.551 - QItemSelection oldsel=selModel->selection();
1.552 -
1.553 - BranchItem* par;
1.554 - BranchItem *selbi=getSelectedBranchItem();
1.555 - TreeItem::Type type=selbi->getType();
1.556 - if (selbi)
1.557 - {
1.558 - if (type == TreeItem::MapCenter)
1.559 - {
1.560 - QModelIndex ix=index(selbi);
1.561 - selModel->select (index (rowCount(ix)-1,0,ix),QItemSelectionModel::ClearAndSelect );
1.562 - } else
1.563 - {
1.564 - par=(BranchItem*)selbi->parent();
1.565 - if (selbi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO...
1.566 - {
1.567 - // right of center
1.568 - if (type == TreeItem::Branch ||
1.569 - type == TreeItem::Image)
1.570 - {
1.571 - QModelIndex ix=index (selbi->parent());
1.572 - selModel->select (ix,QItemSelectionModel::ClearAndSelect );
1.573 - }
1.574 - } else
1.575 - {
1.576 - // left of center
1.577 - if (type == TreeItem::Branch )
1.578 - {
1.579 - selectLastSelectedBranch();
1.580 - return;
1.581 - }
1.582 - }
1.583 - }
1.584 - }
1.585 -}
1.586 -
1.587 -void VymModel::selectRightBranch()
1.588 -{
1.589 - QItemSelection oldsel=selModel->selection();
1.590 -
1.591 - BranchItem* par;
1.592 - BranchItem *selbi=getSelectedBranchItem();
1.593 - TreeItem::Type type=selbi->getType();
1.594 - if (selbi)
1.595 - {
1.596 - if (type==TreeItem::MapCenter)
1.597 - {
1.598 - QModelIndex ix=index(selbi);
1.599 - selModel->select (index (0,0,ix),QItemSelectionModel::ClearAndSelect );
1.600 - } else
1.601 - {
1.602 - par=(BranchItem*)selbi->parent();
1.603 - if (selbi->getBranchObj()->getOrientation()==LinkableMapObj::RightOfCenter) //FIXME-3 check getBO
1.604 - {
1.605 - // right of center
1.606 - if ( type== TreeItem::Branch )
1.607 - {
1.608 - selectLastSelectedBranch();
1.609 - return;
1.610 - }
1.611 - } else
1.612 - {
1.613 - // left of center
1.614 - if (type == TreeItem::Branch ||
1.615 - type == TreeItem::Image)
1.616 - {
1.617 - QModelIndex ix=index(selbi->parent());
1.618 - selModel->select (ix,QItemSelectionModel::ClearAndSelect );
1.619 - }
1.620 - }
1.621 - }
1.622 - }
1.623 -}
1.624 -
1.625 -void VymModel::selectFirstBranch()
1.626 -{
1.627 - TreeItem *ti=getSelectedBranchItem();
1.628 +bool VymModel::selectFirstBranch()
1.629 +{
1.630 + TreeItem *ti=getSelectedBranch();
1.631 if (ti)
1.632 {
1.633 TreeItem *par=ti->parent();
1.634 - if (!par) return;
1.635 - TreeItem *ti2=par->getFirstBranch();
1.636 - if (ti2) {
1.637 - select(ti2);
1.638 - emitSelectionChanged();
1.639 + if (par)
1.640 + {
1.641 + TreeItem *ti2=par->getFirstBranch();
1.642 + if (ti2) return select(ti2);
1.643 }
1.644 }
1.645 + return false;
1.646 }
1.647
1.648 -void VymModel::selectLastBranch()
1.649 -{
1.650 - TreeItem *ti=getSelectedBranchItem();
1.651 +bool VymModel::selectLastBranch()
1.652 +{
1.653 + TreeItem *ti=getSelectedBranch();
1.654 if (ti)
1.655 {
1.656 TreeItem *par=ti->parent();
1.657 - if (!par) return;
1.658 - TreeItem *ti2=par->getLastBranch();
1.659 - if (ti2) {
1.660 - select(ti2);
1.661 - emitSelectionChanged();
1.662 + if (par)
1.663 + {
1.664 + TreeItem *ti2=par->getLastBranch();
1.665 + if (ti2) return select(ti2);
1.666 }
1.667 }
1.668 + return false;
1.669 }
1.670
1.671 -void VymModel::selectLastSelectedBranch()
1.672 -{
1.673 - TreeItem *ti=getSelectedBranchItem();
1.674 - if (ti)
1.675 +bool VymModel::selectLastSelectedBranch()
1.676 +{
1.677 + BranchItem *bi=getSelectedBranch();
1.678 + if (bi)
1.679 {
1.680 - ti=ti->getLastSelectedBranch();
1.681 - if (ti) select (ti);
1.682 + bi=bi->getLastSelectedBranch();
1.683 + if (bi) return select (bi);
1.684 }
1.685 + return false;
1.686 }
1.687
1.688 -void VymModel::selectParent()
1.689 +bool VymModel::selectParent()
1.690 {
1.691 TreeItem *ti=getSelectedItem();
1.692 TreeItem *par;
1.693 if (ti)
1.694 {
1.695 par=ti->parent();
1.696 - if (!par) return;
1.697 - select(par);
1.698 - emitSelectionChanged();
1.699 + if (par)
1.700 + return select(par);
1.701 }
1.702 + return false;
1.703 }
1.704
1.705 TreeItem::Type VymModel::selectionType()
1.706 @@ -4980,14 +4769,14 @@
1.707
1.708 BranchObj* VymModel::getSelectedBranchObj() // FIXME-3 this should not be needed in the end!!!
1.709 {
1.710 - TreeItem *ti = getSelectedBranchItem();
1.711 + TreeItem *ti = getSelectedBranch();
1.712 if (ti)
1.713 return (BranchObj*)( ((MapItem*)ti)->getLMO());
1.714 else
1.715 return NULL;
1.716 }
1.717
1.718 -BranchItem* VymModel::getSelectedBranchItem()
1.719 +BranchItem* VymModel::getSelectedBranch()
1.720 {
1.721 QModelIndexList list=selModel->selectedIndexes();
1.722 if (!list.isEmpty() )
1.723 @@ -5000,25 +4789,7 @@
1.724 return NULL;
1.725 }
1.726
1.727 -TreeItem* VymModel::getSelectedItem()
1.728 -{
1.729 - QModelIndexList list=selModel->selectedIndexes();
1.730 - if (!list.isEmpty() )
1.731 - return getItem (list.first() );
1.732 - else
1.733 - return NULL;
1.734 -}
1.735 -
1.736 -QModelIndex VymModel::getSelectedIndex()
1.737 -{
1.738 - QModelIndexList list=selModel->selectedIndexes();
1.739 - if (list.isEmpty() )
1.740 - return QModelIndex();
1.741 - else
1.742 - return list.first();
1.743 -}
1.744 -
1.745 -ImageItem* VymModel::getSelectedImageItem()
1.746 +ImageItem* VymModel::getSelectedImage()
1.747 {
1.748 QModelIndexList list=selModel->selectedIndexes();
1.749 if (!list.isEmpty())
1.750 @@ -5030,6 +4801,37 @@
1.751 return NULL;
1.752 }
1.753
1.754 +AttributeItem* VymModel::getSelectedAttribute()
1.755 +{
1.756 + QModelIndexList list=selModel->selectedIndexes();
1.757 + if (!list.isEmpty() )
1.758 + {
1.759 + TreeItem *ti = getItem (list.first() );
1.760 + TreeItem::Type type=ti->getType();
1.761 + if (type ==TreeItem::Attribute)
1.762 + return (AttributeItem*)ti;
1.763 + }
1.764 + return NULL;
1.765 +}
1.766 +
1.767 +TreeItem* VymModel::getSelectedItem()
1.768 +{
1.769 + QModelIndexList list=selModel->selectedIndexes();
1.770 + if (!list.isEmpty() )
1.771 + return getItem (list.first() );
1.772 + else
1.773 + return NULL;
1.774 +}
1.775 +
1.776 +QModelIndex VymModel::getSelectedIndex()
1.777 +{
1.778 + QModelIndexList list=selModel->selectedIndexes();
1.779 + if (list.isEmpty() )
1.780 + return QModelIndex();
1.781 + else
1.782 + return list.first();
1.783 +}
1.784 +
1.785 QString VymModel::getSelectString ()
1.786 {
1.787 return getSelectString (getSelectedItem());
1.788 @@ -5050,6 +4852,7 @@
1.789 case TreeItem::MapCenter: s="mc:"; break;
1.790 case TreeItem::Branch: s="bo:";break;
1.791 case TreeItem::Image: s="fi:";break;
1.792 + case TreeItem::Attribute: s="ai:";break;
1.793 default:break;
1.794 }
1.795 s= s + QString("%1").arg(ti->num());