1.1 --- a/mapeditor.cpp Mon Jun 29 10:28:28 2009 +0000
1.2 +++ b/mapeditor.cpp Tue Jul 07 09:34:24 2009 +0000
1.3 @@ -189,7 +189,7 @@
1.4 LinkableMapObj* lmo=NULL;
1.5 TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
1.6 if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
1.7 - lmo=ti->getLMO();
1.8 + lmo=((MapItem*)ti)->getLMO();
1.9 if (lmo) setScrollBarPosTarget (lmo->getBBox() );
1.10 }
1.11 }
1.12 @@ -599,7 +599,7 @@
1.13 QPointF p = mapToScene(e->pos());
1.14 TreeItem *ti=findMapItem (p, NULL);
1.15 LinkableMapObj* lmo=NULL;
1.16 - if (ti) lmo=ti->getLMO();
1.17 + if (ti) lmo=((MapItem*)ti)->getLMO();
1.18
1.19 if (lmo)
1.20 { // MapObj was found
1.21 @@ -683,7 +683,7 @@
1.22 QPointF p = mapToScene(e->pos());
1.23 TreeItem *ti=findMapItem (p, NULL);
1.24 LinkableMapObj* lmo=NULL;
1.25 - if (ti) lmo=ti->getLMO();
1.26 + if (ti) lmo=((MapItem*)ti)->getLMO();
1.27
1.28 e->accept();
1.29
1.30 @@ -818,7 +818,7 @@
1.31 TreeItem *seli=model->getSelectedItem();
1.32 LinkableMapObj* lmosel=NULL;
1.33 if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image))
1.34 - lmosel=seli->getLMO();
1.35 + lmosel=((MapItem*)seli)->getLMO();
1.36
1.37 // Move the selected MapObj
1.38 if ( lmosel && movingObj)
1.39 @@ -854,7 +854,7 @@
1.40 FloatObj *fio=(FloatImageObj*)lmosel;
1.41 fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
1.42 fio->setRelPos();
1.43 - fio->updateLink(); //no need for reposition, if we update link here
1.44 + fio->updateLinkGeometry(); //no need for reposition, if we update link here
1.45 model->emitSelectionChanged(); // position has changed
1.46
1.47 // Relink float to new mapcenter or branch, if shift is pressed
1.48 @@ -968,7 +968,7 @@
1.49 if (seli) dsti=findMapItem(p, seli);
1.50 LinkableMapObj* dst=NULL;
1.51 if (dsti && dsti->isBranchLikeType ())
1.52 - dst=dsti->getLMO();
1.53 + dst=((MapItem*)dsti)->getLMO();
1.54 else
1.55 dsti=NULL;
1.56
1.57 @@ -1013,7 +1013,7 @@
1.58 {
1.59 if (seli->getType()==TreeItem::Image)
1.60 {
1.61 - FloatImageObj *fio=(FloatImageObj*)(seli->getLMO());
1.62 + FloatImageObj *fio=(FloatImageObj*)( ((MapItem*)seli)->getLMO());
1.63 if(fio)
1.64 {
1.65 // Moved FloatObj. Maybe we need to reposition
1.66 @@ -1051,7 +1051,7 @@
1.67 if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
1.68 { // A branch was moved
1.69 LinkableMapObj* lmosel=NULL;
1.70 - lmosel=seli->getLMO();
1.71 + lmosel=((MapItem*)seli)->getLMO();
1.72
1.73 // save the position in case we link to mapcenter
1.74 QPointF savePos=QPointF (lmosel->getAbsPos() );
1.75 @@ -1272,6 +1272,9 @@
1.76
1.77 void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel)
1.78 {
1.79 + // Note: Here we are prepared for multiple selections, though this
1.80 + // is not yet implemented elsewhere
1.81 +
1.82 // Here in MapEditor we can only select Branches and Images
1.83 QModelIndex ix;
1.84 foreach (ix,newsel.indexes() )
1.85 @@ -1281,6 +1284,7 @@
1.86 newsel.indexes().removeOne (ix);
1.87 }
1.88
1.89 + // Trim list of selection rectangles
1.90 while (newsel.indexes().count() < selboxList.count() )
1.91 delete selboxList.takeFirst();
1.92
1.93 @@ -1291,10 +1295,17 @@
1.94 if (ix.isValid() )
1.95 {
1.96 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
1.97 - if (ti && ti->isBranchLikeType() )
1.98 + if (ti)
1.99 {
1.100 - BranchItem *bi=(BranchItem*)ti;
1.101 - bi->resetTmpUnscroll();
1.102 + if (ti->isBranchLikeType() )
1.103 + {
1.104 + // reset tmp scrolled branches
1.105 + BranchItem *bi=(BranchItem*)ti;
1.106 + bi->resetTmpUnscroll();
1.107 + }
1.108 + if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
1.109 + // Hide link if not needed
1.110 + ((MapItem*)ti)->getLMO()->updateVisibility();
1.111 }
1.112 }
1.113 }
1.114 @@ -1313,6 +1324,9 @@
1.115 bi->tmpUnscroll();
1.116 }
1.117 scrollTo (ix);
1.118 + if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
1.119 + // Show link if needed
1.120 + ((MapItem*)ti)->getLMO()->updateVisibility();
1.121 }
1.122 }
1.123
1.124 @@ -1344,7 +1358,7 @@
1.125 {
1.126 index=newsel.indexes().at(i);
1.127 ti= static_cast<TreeItem*>(index.internalPointer());
1.128 - lmo=ti->getLMO();
1.129 + lmo=((MapItem*)ti)->getLMO();
1.130 bbox=lmo->getBBox();
1.131 sb->setRect (
1.132 bbox.x(),bbox.y(),
1.133 @@ -1370,7 +1384,7 @@
1.134
1.135 if (ti->isBranchLikeType())
1.136 {
1.137 - BranchObj *bo=(BranchObj*) (ti->getLMO());
1.138 + BranchObj *bo=(BranchObj*) ( ((MapItem*)ti)->getLMO());
1.139 bo->updateData();
1.140 }
1.141