diff -r 53e51e8d47e7 -r 716a777c1c98 vymmodel.cpp --- a/vymmodel.cpp Thu Jan 22 15:40:08 2009 +0000 +++ b/vymmodel.cpp Fri Jan 30 09:14:12 2009 +0000 @@ -1500,7 +1500,7 @@ sel->setHeading(s ); /* FIXME testing only */ - TreeItem *ti=getSelectedTreeItem(); + TreeItem *ti=getSelectedItem(); if (ti) { ti->setHeading (s); @@ -3975,7 +3975,7 @@ } } -void VymModel::selectMapBackgroundImage () +void VymModel::selectMapBackgroundImage () // FIXME move to ME { Q3FileDialog *fd=new Q3FileDialog( NULL); fd->setMode (Q3FileDialog::ExistingFile); @@ -4012,7 +4012,7 @@ mapScene->setBackgroundBrush(brush); } -void VymModel::selectMapBackgroundColor() +void VymModel::selectMapBackgroundColor() // FIXME move to ME { QColor col = QColorDialog::getColor( mapScene->backgroundBrush().color(), NULL); if ( !col.isValid() ) return; @@ -4020,7 +4020,7 @@ } -void VymModel::setMapBackgroundColor(QColor col) +void VymModel::setMapBackgroundColor(QColor col) // FIXME move to ME { QColor oldcol=mapScene->backgroundBrush().color(); saveState( @@ -4030,38 +4030,38 @@ mapScene->setBackgroundBrush(col); } -QColor VymModel::getMapBackgroundColor() +QColor VymModel::getMapBackgroundColor() // FIXME move to ME { return mapScene->backgroundBrush().color(); } -LinkableMapObj::ColorHint VymModel::getMapLinkColorHint() +LinkableMapObj::ColorHint VymModel::getMapLinkColorHint() // FIXME move to ME { return linkcolorhint; } -QColor VymModel::getMapDefLinkColor() +QColor VymModel::getMapDefLinkColor() // FIXME move to ME { return defLinkColor; } -void VymModel::setMapDefXLinkColor(QColor col) +void VymModel::setMapDefXLinkColor(QColor col) // FIXME move to ME { defXLinkColor=col; } -QColor VymModel::getMapDefXLinkColor() +QColor VymModel::getMapDefXLinkColor() // FIXME move to ME { return defXLinkColor; } -void VymModel::setMapDefXLinkWidth (int w) +void VymModel::setMapDefXLinkWidth (int w) // FIXME move to ME { defXLinkWidth=w; } -int VymModel::getMapDefXLinkWidth() +int VymModel::getMapDefXLinkWidth() // FIXME move to ME { return defXLinkWidth; } @@ -4326,7 +4326,6 @@ void VymModel::updateSelection() { - cout << "VM::updateSelection ()\n"; QItemSelection newsel=selModel->selection(); updateSelection (newsel); } @@ -4334,6 +4333,7 @@ void VymModel::updateSelection(const QItemSelection &oldsel) { QItemSelection newsel=selModel->selection(); + /* cout << "VM::updateSelection new="; if (!newsel.indexes().isEmpty() ) cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column(); @@ -4341,7 +4341,8 @@ if (!oldsel.indexes().isEmpty() ) cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column(); cout <selection(); if (lmo) + return select (lmo->getTreeItem() ); + else + return false; +} + +bool VymModel::select (TreeItem *ti) +{ + if (ti) { - TreeItem *ti=lmo->getTreeItem(); QModelIndex ix=index(ti); selModel->select (ix,QItemSelectionModel::ClearAndSelect ); + ti->setLastSelectedBranch(); //updateSelection(oldsel); //FIXME needed? return true; } @@ -4556,10 +4565,9 @@ void VymModel::selectPrevBranchInt() { // Decrease number of branch - BranchObj *bo=getSelectedBranch(); - if (bo) + if (selectionType()==TreeItem::Branch) { - QString s=selection.getSelectString(); + QString s=getSelectString(); QString part; QString typ; QString num; @@ -4577,6 +4585,9 @@ num=QString ("%1").arg(n); s=s+num; + cout <<"SP:: s0="<=0 && select (s)) return; @@ -4612,6 +4623,7 @@ s=typ+num; } + cout <<"SP:: si="<getParObj()); + TreeItem *par=ti->parent(); if (!par) return; - bo2=par->getFirstBranch(); - if (bo2) { - selection.select(bo2); + TreeItem *ti2=par->getFirstBranch(); + if (ti2) { + select(ti2); selection.update(); ensureSelectionVisible(); sendSelection(); @@ -4772,17 +4782,14 @@ void VymModel::selectLastBranch() { - BranchObj *bo1=getSelectedBranch(); - BranchObj *bo2; - BranchObj* par; - if (bo1) + TreeItem *ti=getSelectedBranchItem(); + if (ti) { - par=(BranchObj*)(bo1->getParObj()); + TreeItem *par=ti->parent(); if (!par) return; - bo2=par->getLastBranch(); - if (bo2) - { - selection.select(bo2); + TreeItem *ti2=par->getLastBranch(); + if (ti2) { + select(ti2); selection.update(); ensureSelectionVisible(); sendSelection(); @@ -4792,29 +4799,23 @@ void VymModel::selectLastSelectedBranch() { - QItemSelection oldsel=selModel->selection(); - + TreeItem *ti=getSelectedBranchItem(); BranchObj *bo1=getSelectedBranch(); - BranchObj *bo2; - if (bo1) + if (ti) { - cout << "bo1="<getHeading().toStdString()<getLastSelectedBranch(); - if (bo2) - { - cout << "bo2="<getHeading().toStdString()<getLastSelectedBranch(); + if (ti) select (ti); } } void VymModel::selectParent() { + TreeItem *ti=getSelectedItem(); LinkableMapObj *lmo=getSelectedLMO(); - BranchObj* par; - if (lmo) + TreeItem *par; + if (ti) { - par=(BranchObj*)(lmo->getParObj()); + par=ti->parent(); if (!par) return; select(par); selection.update(); @@ -4849,21 +4850,27 @@ BranchObj* VymModel::getSelectedBranch() { + TreeItem *ti = getSelectedBranchItem(); + if (ti) + return (BranchObj*)ti->getLMO(); + else + return NULL; +} + +TreeItem* VymModel::getSelectedBranchItem() +{ QModelIndexList list=selModel->selectedIndexes(); if (!list.isEmpty() ) { TreeItem *ti = static_cast(list.first().internalPointer()); TreeItem::Type type=ti->getType(); if (type ==TreeItem::Branch || type==TreeItem::MapCenter) - { - return (BranchObj*)ti->getLMO(); - } + return ti; } return NULL; - } -TreeItem* VymModel::getSelectedTreeItem() +TreeItem* VymModel::getSelectedItem() { // FIXME this may not only be branch, but also float etc... BranchObj* bo=getSelectedBranch(); @@ -4887,7 +4894,11 @@ QString VymModel::getSelectString () { - return selection.getSelectString(); + LinkableMapObj *lmo=getSelectedLMO(); + if (lmo) + return getSelectString(lmo); + else + return QString(); } QString VymModel::getSelectString (LinkableMapObj *lmo) // FIXME VM needs to use TreeModel