1.1 --- a/branchobj.cpp Thu Jan 22 15:40:08 2009 +0000
1.2 +++ b/branchobj.cpp Fri Jan 30 09:14:12 2009 +0000
1.3 @@ -92,8 +92,6 @@
1.4 absPos+=parObj->getChildPos();
1.5 }
1.6
1.7 - lastSelectedBranch=0;
1.8 -
1.9 setChildObj(this);
1.10
1.11 scrolled=false;
1.12 @@ -1165,24 +1163,6 @@
1.13 requestReposition();
1.14 }
1.15
1.16 -void BranchObj::setLastSelectedBranch (BranchObj* bo)
1.17 -{
1.18 - cout << "BO::setLastSelectedBranch for "<<getHeading().toStdString()<<endl;
1.19 - lastSelectedBranch=branch.indexOf(bo);
1.20 -}
1.21 -
1.22 -BranchObj* BranchObj::getLastSelectedBranch ()
1.23 -{
1.24 - if (lastSelectedBranch>=0)
1.25 - {
1.26 - if ( branch.size()>lastSelectedBranch)
1.27 - return branch.at(lastSelectedBranch);
1.28 - if (branch.size()>0)
1.29 - return branch.last();
1.30 - }
1.31 - return NULL;
1.32 -}
1.33 -
1.34 BranchObj* BranchObj::getFirstBranch ()
1.35 {
1.36 if (branch.size()>0)
2.1 --- a/branchobj.h Thu Jan 22 15:40:08 2009 +0000
2.2 +++ b/branchobj.h Fri Jan 30 09:14:12 2009 +0000
2.3 @@ -105,8 +105,6 @@
2.4 virtual void removeChildren();
2.5 virtual void removeBranch(BranchObj*);
2.6 virtual void removeBranchPtr (BranchObj*);
2.7 - virtual void setLastSelectedBranch(BranchObj*);
2.8 - virtual BranchObj* getLastSelectedBranch();
2.9 virtual BranchObj* getFirstBranch();
2.10 virtual BranchObj* getLastBranch();
2.11 virtual BranchObj* getBranchNum(int);
2.12 @@ -143,7 +141,6 @@
2.13 public:
2.14 float angle; // used in mainbranch to reorder mainbranches
2.15 protected:
2.16 - int lastSelectedBranch; // for going deeper into tree
2.17 bool scrolled; // true if all children are scrolled and thus invisible
2.18 bool tmpUnscrolled; // can only be true (temporary) for a scrolled subtree
2.19 bool includeImagesVer; // include floatimages in bbox vertically
3.1 --- a/mapeditor.cpp Thu Jan 22 15:40:08 2009 +0000
3.2 +++ b/mapeditor.cpp Fri Jan 30 09:14:12 2009 +0000
3.3 @@ -537,19 +537,22 @@
3.4
3.5 if (lmo)
3.6 {
3.7 + /*
3.8 cout << "ME::mouse pressed\n";
3.9 cout << " lmo="<<lmo<<endl;
3.10 cout << " h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
3.11 + */
3.12 // Select the clicked object
3.13
3.14 // FIXME VM better let "find" return an index instead of lmo...
3.15 // Get index of clicked LMO
3.16 TreeItem *ti=lmo->getTreeItem();
3.17 + /*
3.18 cout << " lmo="<<lmo<<" lmo(ti)="<<ti->getLMO()<<endl;
3.19 cout << " ti ("<<ti->row()<<","<<ti->column()<<") = "<<ti<<endl;
3.20 + */
3.21 //QModelIndex ix=model->index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) );
3.22 - QModelIndex ix=model->index(ti);
3.23 - model->getSelectionModel()->select (ix,QItemSelectionModel::ClearAndSelect );
3.24 + model->select (ti);
3.25
3.26 // Left Button Move Branches
3.27 if (e->button() == Qt::LeftButton )
4.1 --- a/treeitem.cpp Thu Jan 22 15:40:08 2009 +0000
4.2 +++ b/treeitem.cpp Fri Jan 30 09:14:12 2009 +0000
4.3 @@ -7,6 +7,10 @@
4.4 parentItem = parent;
4.5 itemData = data;
4.6 lmo=NULL;
4.7 +
4.8 + branchOffset=0;
4.9 + branchCount=0;
4.10 + lastSelectedBranchNum=-1;
4.11 }
4.12
4.13 TreeItem::~TreeItem()
4.14 @@ -17,6 +21,12 @@
4.15 void TreeItem::appendChild(TreeItem *item)
4.16 {
4.17 childItems.append(item);
4.18 + if (item->type == Branch)
4.19 + {
4.20 + if (branchCount==0)
4.21 + branchOffset=childItems.count()-1;
4.22 + branchCount++;
4.23 + }
4.24 }
4.25
4.26 void TreeItem::removeChild(int row)
4.27 @@ -99,6 +109,50 @@
4.28 }
4.29 }
4.30
4.31 +TreeItem* TreeItem::getChildNum(const int &n)
4.32 +{
4.33 + if (n>=0 && n<childItems.count() )
4.34 + return childItems.at(n);
4.35 + else
4.36 + return NULL;
4.37 +}
4.38 +
4.39 +TreeItem* TreeItem::getFirstBranch()
4.40 +{
4.41 + if (branchCount>0)
4.42 + return getBranchNum (branchOffset);
4.43 + else
4.44 + return NULL;
4.45 +}
4.46 +
4.47 +TreeItem* TreeItem::getLastBranch()
4.48 +{
4.49 + if (branchCount>0)
4.50 + return getBranchNum (branchOffset + branchCount-1);
4.51 + else
4.52 + return NULL;
4.53 +}
4.54 +
4.55 +
4.56 +TreeItem* TreeItem::getBranchNum(const int &n)
4.57 +{
4.58 + if (branchCount>0)
4.59 + return getChildNum (branchOffset + n);
4.60 + else
4.61 + return NULL;
4.62 +}
4.63 +
4.64 +void TreeItem::setLastSelectedBranch()
4.65 +{
4.66 + if (parentItem)
4.67 + parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
4.68 +}
4.69 +
4.70 +TreeItem* TreeItem::getLastSelectedBranch()
4.71 +{
4.72 + return getBranchNum (lastSelectedBranchNum);
4.73 +}
4.74 +
4.75 LinkableMapObj* TreeItem::getLMO() // FIXME VM should be unnecessary in the end
4.76 {
4.77 return lmo;
5.1 --- a/treeitem.h Thu Jan 22 15:40:08 2009 +0000
5.2 +++ b/treeitem.h Fri Jan 30 09:14:12 2009 +0000
5.3 @@ -32,6 +32,15 @@
5.4 void setType (const Type t);
5.5 Type getType ();
5.6 QString getTypeName ();
5.7 +
5.8 + // Navigation and selection
5.9 + TreeItem* getChildNum(const int &n);
5.10 + TreeItem* getFirstBranch();
5.11 + TreeItem* getLastBranch();
5.12 + TreeItem* getBranchNum(const int &n);
5.13 + void setLastSelectedBranch();
5.14 + TreeItem* getLastSelectedBranch();
5.15 +
5.16
5.17 // Relation to map objects in graphicsscene
5.18 LinkableMapObj* getLMO();
5.19 @@ -44,6 +53,10 @@
5.20
5.21 Type type;
5.22 LinkableMapObj *lmo;
5.23 +
5.24 + int branchOffset;
5.25 + int branchCount;
5.26 + int lastSelectedBranchNum;
5.27 };
5.28
5.29 #endif
6.1 --- a/version.h Thu Jan 22 15:40:08 2009 +0000
6.2 +++ b/version.h Fri Jan 30 09:14:12 2009 +0000
6.3 @@ -7,7 +7,7 @@
6.4 #define __VYM_VERSION "1.13.0"
6.5 //#define __VYM_CODENAME "Codename: RC-1"
6.6 #define __VYM_CODENAME "Codename: development version"
6.7 -#define __VYM_BUILD_DATE "2009-01-22"
6.8 +#define __VYM_BUILD_DATE "2009-01-28"
6.9
6.10
6.11 bool checkVersion(const QString &);
7.1 --- a/vymmodel.cpp Thu Jan 22 15:40:08 2009 +0000
7.2 +++ b/vymmodel.cpp Fri Jan 30 09:14:12 2009 +0000
7.3 @@ -1500,7 +1500,7 @@
7.4 sel->setHeading(s );
7.5 /* FIXME testing only
7.6 */
7.7 - TreeItem *ti=getSelectedTreeItem();
7.8 + TreeItem *ti=getSelectedItem();
7.9 if (ti)
7.10 {
7.11 ti->setHeading (s);
7.12 @@ -3975,7 +3975,7 @@
7.13 }
7.14 }
7.15
7.16 -void VymModel::selectMapBackgroundImage ()
7.17 +void VymModel::selectMapBackgroundImage () // FIXME move to ME
7.18 {
7.19 Q3FileDialog *fd=new Q3FileDialog( NULL);
7.20 fd->setMode (Q3FileDialog::ExistingFile);
7.21 @@ -4012,7 +4012,7 @@
7.22 mapScene->setBackgroundBrush(brush);
7.23 }
7.24
7.25 -void VymModel::selectMapBackgroundColor()
7.26 +void VymModel::selectMapBackgroundColor() // FIXME move to ME
7.27 {
7.28 QColor col = QColorDialog::getColor( mapScene->backgroundBrush().color(), NULL);
7.29 if ( !col.isValid() ) return;
7.30 @@ -4020,7 +4020,7 @@
7.31 }
7.32
7.33
7.34 -void VymModel::setMapBackgroundColor(QColor col)
7.35 +void VymModel::setMapBackgroundColor(QColor col) // FIXME move to ME
7.36 {
7.37 QColor oldcol=mapScene->backgroundBrush().color();
7.38 saveState(
7.39 @@ -4030,38 +4030,38 @@
7.40 mapScene->setBackgroundBrush(col);
7.41 }
7.42
7.43 -QColor VymModel::getMapBackgroundColor()
7.44 +QColor VymModel::getMapBackgroundColor() // FIXME move to ME
7.45 {
7.46 return mapScene->backgroundBrush().color();
7.47 }
7.48
7.49
7.50 -LinkableMapObj::ColorHint VymModel::getMapLinkColorHint()
7.51 +LinkableMapObj::ColorHint VymModel::getMapLinkColorHint() // FIXME move to ME
7.52 {
7.53 return linkcolorhint;
7.54 }
7.55
7.56 -QColor VymModel::getMapDefLinkColor()
7.57 +QColor VymModel::getMapDefLinkColor() // FIXME move to ME
7.58 {
7.59 return defLinkColor;
7.60 }
7.61
7.62 -void VymModel::setMapDefXLinkColor(QColor col)
7.63 +void VymModel::setMapDefXLinkColor(QColor col) // FIXME move to ME
7.64 {
7.65 defXLinkColor=col;
7.66 }
7.67
7.68 -QColor VymModel::getMapDefXLinkColor()
7.69 +QColor VymModel::getMapDefXLinkColor() // FIXME move to ME
7.70 {
7.71 return defXLinkColor;
7.72 }
7.73
7.74 -void VymModel::setMapDefXLinkWidth (int w)
7.75 +void VymModel::setMapDefXLinkWidth (int w) // FIXME move to ME
7.76 {
7.77 defXLinkWidth=w;
7.78 }
7.79
7.80 -int VymModel::getMapDefXLinkWidth()
7.81 +int VymModel::getMapDefXLinkWidth() // FIXME move to ME
7.82 {
7.83 return defXLinkWidth;
7.84 }
7.85 @@ -4326,7 +4326,6 @@
7.86
7.87 void VymModel::updateSelection()
7.88 {
7.89 - cout << "VM::updateSelection ()\n";
7.90 QItemSelection newsel=selModel->selection();
7.91 updateSelection (newsel);
7.92 }
7.93 @@ -4334,6 +4333,7 @@
7.94 void VymModel::updateSelection(const QItemSelection &oldsel)
7.95 {
7.96 QItemSelection newsel=selModel->selection();
7.97 + /*
7.98 cout << "VM::updateSelection new=";
7.99 if (!newsel.indexes().isEmpty() )
7.100 cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column();
7.101 @@ -4341,7 +4341,8 @@
7.102 if (!oldsel.indexes().isEmpty() )
7.103 cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column();
7.104 cout <<endl;
7.105 - //emit (selectionChanged(newsel,oldsel));
7.106 + */
7.107 + //emit (selectionChanged(newsel,oldsel)); // FIXME needed?
7.108 ensureSelectionVisible();
7.109 sendSelection();
7.110 }
7.111 @@ -4435,10 +4436,18 @@
7.112 QItemSelection oldsel=selModel->selection();
7.113
7.114 if (lmo)
7.115 + return select (lmo->getTreeItem() );
7.116 + else
7.117 + return false;
7.118 +}
7.119 +
7.120 +bool VymModel::select (TreeItem *ti)
7.121 +{
7.122 + if (ti)
7.123 {
7.124 - TreeItem *ti=lmo->getTreeItem();
7.125 QModelIndex ix=index(ti);
7.126 selModel->select (ix,QItemSelectionModel::ClearAndSelect );
7.127 + ti->setLastSelectedBranch();
7.128 //updateSelection(oldsel); //FIXME needed?
7.129 return true;
7.130 }
7.131 @@ -4556,10 +4565,9 @@
7.132 void VymModel::selectPrevBranchInt()
7.133 {
7.134 // Decrease number of branch
7.135 - BranchObj *bo=getSelectedBranch();
7.136 - if (bo)
7.137 + if (selectionType()==TreeItem::Branch)
7.138 {
7.139 - QString s=selection.getSelectString();
7.140 + QString s=getSelectString();
7.141 QString part;
7.142 QString typ;
7.143 QString num;
7.144 @@ -4577,6 +4585,9 @@
7.145 num=QString ("%1").arg(n);
7.146 s=s+num;
7.147
7.148 + cout <<"SP:: s0="<<s.toStdString()<<endl;
7.149 +
7.150 +
7.151 // Try to select this one
7.152 if (n>=0 && select (s)) return;
7.153
7.154 @@ -4612,6 +4623,7 @@
7.155 s=typ+num;
7.156 }
7.157
7.158 + cout <<"SP:: si="<<s.toStdString()<<endl;
7.159 if (select(s))
7.160 // pad to oldDepth, select the last branch for each depth
7.161 for (i=d;i<oldDepth;i++)
7.162 @@ -4753,16 +4765,14 @@
7.163
7.164 void VymModel::selectFirstBranch()
7.165 {
7.166 - BranchObj *bo1=getSelectedBranch();
7.167 - BranchObj *bo2;
7.168 - BranchObj* par;
7.169 - if (bo1)
7.170 + TreeItem *ti=getSelectedBranchItem();
7.171 + if (ti)
7.172 {
7.173 - par=(BranchObj*)(bo1->getParObj());
7.174 + TreeItem *par=ti->parent();
7.175 if (!par) return;
7.176 - bo2=par->getFirstBranch();
7.177 - if (bo2) {
7.178 - selection.select(bo2);
7.179 + TreeItem *ti2=par->getFirstBranch();
7.180 + if (ti2) {
7.181 + select(ti2);
7.182 selection.update();
7.183 ensureSelectionVisible();
7.184 sendSelection();
7.185 @@ -4772,17 +4782,14 @@
7.186
7.187 void VymModel::selectLastBranch()
7.188 {
7.189 - BranchObj *bo1=getSelectedBranch();
7.190 - BranchObj *bo2;
7.191 - BranchObj* par;
7.192 - if (bo1)
7.193 + TreeItem *ti=getSelectedBranchItem();
7.194 + if (ti)
7.195 {
7.196 - par=(BranchObj*)(bo1->getParObj());
7.197 + TreeItem *par=ti->parent();
7.198 if (!par) return;
7.199 - bo2=par->getLastBranch();
7.200 - if (bo2)
7.201 - {
7.202 - selection.select(bo2);
7.203 + TreeItem *ti2=par->getLastBranch();
7.204 + if (ti2) {
7.205 + select(ti2);
7.206 selection.update();
7.207 ensureSelectionVisible();
7.208 sendSelection();
7.209 @@ -4792,29 +4799,23 @@
7.210
7.211 void VymModel::selectLastSelectedBranch()
7.212 {
7.213 - QItemSelection oldsel=selModel->selection();
7.214 -
7.215 + TreeItem *ti=getSelectedBranchItem();
7.216 BranchObj *bo1=getSelectedBranch();
7.217 - BranchObj *bo2;
7.218 - if (bo1)
7.219 + if (ti)
7.220 {
7.221 - cout << "bo1="<<bo1->getHeading().toStdString()<<endl;
7.222 - bo2=bo1->getLastSelectedBranch();
7.223 - if (bo2)
7.224 - {
7.225 - cout << "bo2="<<bo2->getHeading().toStdString()<<endl;
7.226 - select(bo2);
7.227 - }
7.228 + ti=ti->getLastSelectedBranch();
7.229 + if (ti) select (ti);
7.230 }
7.231 }
7.232
7.233 void VymModel::selectParent()
7.234 {
7.235 + TreeItem *ti=getSelectedItem();
7.236 LinkableMapObj *lmo=getSelectedLMO();
7.237 - BranchObj* par;
7.238 - if (lmo)
7.239 + TreeItem *par;
7.240 + if (ti)
7.241 {
7.242 - par=(BranchObj*)(lmo->getParObj());
7.243 + par=ti->parent();
7.244 if (!par) return;
7.245 select(par);
7.246 selection.update();
7.247 @@ -4849,21 +4850,27 @@
7.248
7.249 BranchObj* VymModel::getSelectedBranch()
7.250 {
7.251 + TreeItem *ti = getSelectedBranchItem();
7.252 + if (ti)
7.253 + return (BranchObj*)ti->getLMO();
7.254 + else
7.255 + return NULL;
7.256 +}
7.257 +
7.258 +TreeItem* VymModel::getSelectedBranchItem()
7.259 +{
7.260 QModelIndexList list=selModel->selectedIndexes();
7.261 if (!list.isEmpty() )
7.262 {
7.263 TreeItem *ti = static_cast<TreeItem*>(list.first().internalPointer());
7.264 TreeItem::Type type=ti->getType();
7.265 if (type ==TreeItem::Branch || type==TreeItem::MapCenter)
7.266 - {
7.267 - return (BranchObj*)ti->getLMO();
7.268 - }
7.269 + return ti;
7.270 }
7.271 return NULL;
7.272 -
7.273 }
7.274
7.275 -TreeItem* VymModel::getSelectedTreeItem()
7.276 +TreeItem* VymModel::getSelectedItem()
7.277 {
7.278 // FIXME this may not only be branch, but also float etc...
7.279 BranchObj* bo=getSelectedBranch();
7.280 @@ -4887,7 +4894,11 @@
7.281
7.282 QString VymModel::getSelectString ()
7.283 {
7.284 - return selection.getSelectString();
7.285 + LinkableMapObj *lmo=getSelectedLMO();
7.286 + if (lmo)
7.287 + return getSelectString(lmo);
7.288 + else
7.289 + return QString();
7.290 }
7.291
7.292 QString VymModel::getSelectString (LinkableMapObj *lmo) // FIXME VM needs to use TreeModel
8.1 --- a/vymmodel.h Thu Jan 22 15:40:08 2009 +0000
8.2 +++ b/vymmodel.h Fri Jan 30 09:14:12 2009 +0000
8.3 @@ -534,7 +534,8 @@
8.4
8.5 bool select (); // select by using common QItemSlectionModel
8.6 bool select (const QString &); // Select by string
8.7 - bool select (LinkableMapObj *lmo); // Select by pointer
8.8 + bool select (LinkableMapObj *lmo); // Select by pointer to LMO
8.9 + bool select (TreeItem *ti ); // Select by point to TreeItem
8.10 void unselect();
8.11 void reselect();
8.12
8.13 @@ -559,7 +560,8 @@
8.14 TreeItem::Type selectionType();
8.15 LinkableMapObj* getSelectedLMO();
8.16 BranchObj* getSelectedBranch();
8.17 - TreeItem* getSelectedTreeItem();
8.18 + TreeItem* getSelectedBranchItem();
8.19 + TreeItem* getSelectedItem();
8.20 QModelIndex getSelectedIndex();
8.21 FloatImageObj* getSelectedFloatImage();
8.22 QString getSelectString ();