1.1 --- a/branchobj.cpp Tue Mar 31 15:36:10 2009 +0000
1.2 +++ b/branchobj.cpp Wed Apr 01 15:06:57 2009 +0000
1.3 @@ -1,6 +1,7 @@
1.4 #include "branchobj.h"
1.5
1.6 // #include "texteditor.h"
1.7 +#include "branchitem.h"
1.8 #include "geometry.h"
1.9 #include "mapeditor.h"
1.10 #include "mainwindow.h"
1.11 @@ -58,8 +59,9 @@
1.12
1.13 cout << "Destr BranchObj of "<<this<<" ("<<getHeading().toStdString()<<")"<<endl;
1.14 // Check, if this branch was the last child to be deleted
1.15 - // If so, unset the scrolled flags
1.16 + // If so, unset the scrolled flags in parent // FIXME-2 better do this in model?
1.17
1.18 + /*
1.19 BranchObj *po=(BranchObj*)parObj;
1.20 BranchObj *bo;
1.21 if (po)
1.22 @@ -67,6 +69,7 @@
1.23 bo=((BranchObj*)parObj)->getLastBranch();
1.24 if (bo) po->unScroll();
1.25 }
1.26 + */
1.27 clear();
1.28 }
1.29
1.30 @@ -90,9 +93,6 @@
1.31
1.32 setChildObj(this);
1.33
1.34 - scrolled=false;
1.35 - tmpUnscrolled=false;
1.36 -
1.37 includeImagesVer=false;
1.38 includeImagesHor=false;
1.39 }
1.40 @@ -110,8 +110,7 @@
1.41
1.42 for (int i=0; i<other->floatimage.size(); ++i)
1.43 addFloatImage (other->floatimage.at(i));
1.44 - scrolled=other->scrolled;
1.45 - tmpUnscrolled=other->tmpUnscrolled;
1.46 +
1.47 setVisibility (other->visible);
1.48
1.49 angle=other->angle;
1.50 @@ -141,39 +140,6 @@
1.51 return false;
1.52 }
1.53
1.54 -int BranchObj::getNum()
1.55 -{
1.56 - if (parObj)
1.57 - return ((BranchObj*)parObj)->getNum (this);
1.58 - else
1.59 - return 0;
1.60 -}
1.61 -
1.62 -int BranchObj::getNum(BranchObj *bo)
1.63 -{
1.64 - return branch.indexOf (bo);
1.65 -}
1.66 -
1.67 -int BranchObj::getFloatImageNum(FloatImageObj *fio)
1.68 -{
1.69 - return floatimage.indexOf(fio);
1.70 -}
1.71 -
1.72 -int BranchObj::countBranches()
1.73 -{
1.74 - return branch.count();
1.75 -}
1.76 -
1.77 -int BranchObj::countFloatImages()
1.78 -{
1.79 - return floatimage.count();
1.80 -}
1.81 -
1.82 -int BranchObj::countXLinks()
1.83 -{
1.84 - return xlink.count();
1.85 -}
1.86 -
1.87 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off)
1.88 {
1.89 // Temporary link to lmo
1.90 @@ -256,86 +222,9 @@
1.91 }
1.92 }
1.93
1.94 -void BranchObj::unScroll()
1.95 -{
1.96 - if (tmpUnscrolled) resetTmpUnscroll();
1.97 - if (scrolled) toggleScroll();
1.98 -}
1.99 -
1.100 -void BranchObj::toggleScroll()
1.101 -{
1.102 - if (scrolled)
1.103 - {
1.104 - scrolled=false;
1.105 - systemFlags->deactivate("scrolledright");
1.106 - for (int i=0; i<branch.size(); ++i)
1.107 - branch.at(i)->setVisibility(true);
1.108 - } else
1.109 - {
1.110 - scrolled=true;
1.111 - systemFlags->activate("scrolledright");
1.112 - for (int i=0; i<branch.size(); ++i)
1.113 - branch.at(i)->setVisibility(false);
1.114 - }
1.115 - calcBBoxSize();
1.116 - positionBBox();
1.117 - move (absPos.x(), absPos.y() );
1.118 - forceReposition();
1.119 -}
1.120 -
1.121 -bool BranchObj::isScrolled()
1.122 -{
1.123 - return scrolled;
1.124 -}
1.125 -
1.126 -bool BranchObj::hasScrolledParent(BranchObj *start)
1.127 -{
1.128 - // Calls parents recursivly to
1.129 - // find out, if we are scrolled at all.
1.130 - // But ignore myself, just look at parents.
1.131 -
1.132 - if (this !=start && scrolled) return true;
1.133 -
1.134 - BranchObj* bo=(BranchObj*)(parObj);
1.135 - if (bo)
1.136 - return bo->hasScrolledParent(start);
1.137 - else
1.138 - return false;
1.139 -}
1.140 -
1.141 -void BranchObj::tmpUnscroll()
1.142 -{
1.143 - // Unscroll parent (recursivly)
1.144 - BranchObj* bo=(BranchObj*)(parObj);
1.145 - if (bo) bo->tmpUnscroll();
1.146 -
1.147 - // Unscroll myself
1.148 - if (scrolled)
1.149 - {
1.150 - tmpUnscrolled=true;
1.151 - systemFlags->activate("tmpUnscrolledright");
1.152 - toggleScroll();
1.153 - }
1.154 -}
1.155 -
1.156 -void BranchObj::resetTmpUnscroll()
1.157 -{
1.158 - // Unscroll parent (recursivly)
1.159 - BranchObj* bo=(BranchObj*)(parObj);
1.160 - if (bo)
1.161 - bo->resetTmpUnscroll();
1.162 -
1.163 - // Unscroll myself
1.164 - if (tmpUnscrolled)
1.165 - {
1.166 - tmpUnscrolled=false;
1.167 - systemFlags->deactivate("tmpUnscrolledright");
1.168 - toggleScroll();
1.169 - }
1.170 -}
1.171 -
1.172 void BranchObj::setVisibility(bool v, int toDepth)
1.173 {
1.174 + BranchItem *bi=(BranchItem*)treeItem;
1.175 if (depth <= toDepth)
1.176 {
1.177 frame->setVisibility(v);
1.178 @@ -343,7 +232,6 @@
1.179 systemFlags->setVisibility(v);
1.180 standardFlags->setVisibility(v);
1.181 LinkableMapObj::setVisibility (v);
1.182 -
1.183 int i;
1.184 for (i=0; i<floatimage.size(); ++i)
1.185 floatimage.at(i)->setVisibility (v);
1.186 @@ -351,7 +239,7 @@
1.187 xlink.at(i)->setVisibility ();
1.188
1.189 // Only change children, if I am not scrolled
1.190 - if (!scrolled && (depth < toDepth))
1.191 + if (! bi->isScrolled() && (bi->depth() < toDepth))
1.192 {
1.193 // Now go recursivly through all children
1.194 for (i=0; i<branch.size(); ++i)
1.195 @@ -468,7 +356,7 @@
1.196 topPad=botPad=leftPad=rightPad=0;
1.197 if (includeImagesVer || includeImagesHor)
1.198 {
1.199 - if (countFloatImages()>0)
1.200 + if (treeItem->imageCount()>0)
1.201 {
1.202 for (int i=0; i<floatimage.size(); ++i )
1.203 {
1.204 @@ -602,7 +490,7 @@
1.205 }else
1.206 {
1.207 // Do not hide, but still take care of scrolled status
1.208 - if (hasScrolledParent(this))
1.209 + if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem))
1.210 setVisibility (false);
1.211 else
1.212 setVisibility (true);
1.213 @@ -638,14 +526,14 @@
1.214
1.215 QString s,a;
1.216 QString scrolledAttr;
1.217 - if (scrolled)
1.218 + if ( ((BranchItem*)treeItem)->isScrolled() )
1.219 scrolledAttr=attribut ("scrolled","yes");
1.220 else
1.221 scrolledAttr="";
1.222
1.223 // save area, if not scrolled
1.224 QString areaAttr;
1.225 - if (!((BranchObj*)(parObj))->isScrolled() )
1.226 + if (!((BranchItem*) (treeItem->parent()) )->isScrolled() )
1.227 {
1.228 areaAttr=
1.229 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
1.230 @@ -658,7 +546,7 @@
1.231
1.232 // Providing an ID for a branch makes export to XHTML easier
1.233 QString idAttr;
1.234 - if (countXLinks()>0)
1.235 + if (treeItem->xlinkCount()>0)
1.236 idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
1.237 else
1.238 idAttr="";
1.239 @@ -744,12 +632,6 @@
1.240 return xlink.at(i);
1.241 }
1.242
1.243 -int BranchObj::countXLink()
1.244 -{
1.245 - return xlink.count();
1.246 -}
1.247 -
1.248 -
1.249 BranchObj* BranchObj::XLinkTargetAt (int i)
1.250 {
1.251 if (i>=0 && i<xlink.size())
1.252 @@ -804,7 +686,7 @@
1.253 {
1.254 FloatImageObj *newfi=new FloatImageObj (scene,this);
1.255 floatimage.append (newfi);
1.256 - if (hasScrolledParent(this) )
1.257 + if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
1.258 newfi->setVisibility (false);
1.259 else
1.260 newfi->setVisibility(visible);
1.261 @@ -821,7 +703,7 @@
1.262 FloatImageObj *newfi=new FloatImageObj (scene,this);
1.263 floatimage.append (newfi);
1.264 newfi->copy (fio);
1.265 - if (hasScrolledParent(this) )
1.266 + if (((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem) )
1.267 newfi->setVisibility (false);
1.268 else
1.269 newfi->setVisibility(visible);
1.270 @@ -893,10 +775,12 @@
1.271 newbo->setParObj(this);
1.272 newbo->setDefAttr(NewBranch);
1.273 newbo->setHeading ("new");
1.274 - if (scrolled)
1.275 + /* FIXME-2 treeItem not set yet!!!
1.276 + if ( ((BranchItem*)treeItem)->isScrolled() )
1.277 newbo->setVisibility (false);
1.278 else
1.279 newbo->setVisibility(visible);
1.280 + */
1.281 newbo->updateLink();
1.282 requestReposition();
1.283 return newbo;
1.284 @@ -909,7 +793,7 @@
1.285 newbo->copy(bo);
1.286 newbo->setParObj(this);
1.287 newbo->setDefAttr(MovedBranch);
1.288 - if (scrolled)
1.289 + if ( ((BranchItem*)treeItem)->isScrolled() )
1.290 newbo->setVisibility (false);
1.291 else
1.292 newbo->setVisibility(bo->visible);
1.293 @@ -924,7 +808,8 @@
1.294 bo->setParObj (this);
1.295 bo->depth=depth+1;
1.296 bo->setDefAttr(MovedBranch);
1.297 - if (scrolled) tmpUnscroll();
1.298 + BranchItem *bi=(BranchItem*)treeItem;
1.299 + if ( bi->isScrolled() ) bi->tmpUnscroll();
1.300 //setLastSelectedBranch (bo); //FIXME-3 needed?
1.301 return bo;
1.302 }
1.303 @@ -958,14 +843,16 @@
1.304 bo->setParObj (this);
1.305 bo->depth=depth+1;
1.306 bo->setDefAttr (MovedBranch);
1.307 - if (scrolled) tmpUnscroll();
1.308 + BranchItem *bi=(BranchItem*)treeItem;
1.309 + if ( bi->isScrolled() ) bi->tmpUnscroll();
1.310 //setLastSelectedBranch (bo); //FIXME-3 needed?
1.311 qSort (branch.begin(),branch.end(), isAbove);
1.312 return bo;
1.313 }
1.314
1.315 -void BranchObj::removeBranchHere(BranchObj* borem)
1.316 +void BranchObj::removeBranchHere(BranchObj* borem) // FIXME-1 getNum no longer available
1.317 {
1.318 +/*
1.319 // This removes the branch bo from list, but
1.320 // inserts its children at the place of bo
1.321 BranchObj *bo;
1.322 @@ -977,6 +864,7 @@
1.323 bo=borem->getLastBranch();
1.324 }
1.325 removeBranch (borem);
1.326 + */
1.327 }
1.328
1.329 void BranchObj::removeChildren()
1.330 @@ -1084,9 +972,10 @@
1.331 return NULL;
1.332 }
1.333
1.334 -void BranchObj::sortChildren()
1.335 +void BranchObj::sortChildren() //FIXME-1
1.336 {
1.337 - int childCount=branch.count();
1.338 +/*
1.339 + int childCount=branch.count();
1.340 int curChildIndex;
1.341 bool madeChanges=false;
1.342 do
1.343 @@ -1102,6 +991,7 @@
1.344 }
1.345 }
1.346 }while(madeChanges);
1.347 +*/
1.348 }
1.349
1.350
1.351 @@ -1206,7 +1096,7 @@
1.352 }
1.353 }
1.354
1.355 - if (scrolled) return;
1.356 + if ( ((BranchItem*)treeItem)->isScrolled() ) return;
1.357
1.358 // Set reference point for alignment of children
1.359 QPointF ref2;
1.360 @@ -1301,7 +1191,7 @@
1.361 {
1.362 QRectF r=bbox;
1.363
1.364 - if (scrolled) return r;
1.365 + if ( ((BranchItem*)treeItem)->isScrolled() ) return r;
1.366
1.367 for (int i=0; i<branch.size(); ++i)
1.368 if (!branch.at(i)->isHidden())
1.369 @@ -1332,7 +1222,7 @@
1.370 bboxTotal.setY(bbox.y() );
1.371
1.372 // if branch is scrolled, ignore children, but still consider floatimages
1.373 - if (scrolled)
1.374 + if ( ((BranchItem*)treeItem)->isScrolled() )
1.375 {
1.376 bboxTotal.setWidth (bbox.width());
1.377 bboxTotal.setHeight(bbox.height());