1.1 --- a/branchobj.cpp Thu Jan 21 11:56:57 2010 +0000
1.2 +++ b/branchobj.cpp Wed Feb 10 13:48:42 2010 +0000
1.3 @@ -1,5 +1,6 @@
1.4 #include "branchobj.h"
1.5
1.6 +#include "attributeitem.h"
1.7 #include "branchitem.h"
1.8 #include "geometry.h"
1.9 #include "mapeditor.h"
1.10 @@ -439,26 +440,22 @@
1.11 if (changed) updateContentSize();
1.12 }
1.13
1.14 -void BranchObj::setDefAttr (BranchModification mod)
1.15 +void BranchObj::setDefAttr (BranchModification mod, bool keepFrame)
1.16 {
1.17 int fontsize;
1.18 switch (treeItem->depth())
1.19 {
1.20 case 0:
1.21 fontsize=16;
1.22 - setFrameType (FrameObj::Rectangle);
1.23 break;
1.24 case 1:
1.25 fontsize=14;
1.26 - setFrameType (FrameObj::NoFrame);
1.27 break;
1.28 case 2:
1.29 fontsize=12;
1.30 - setFrameType (FrameObj::NoFrame);
1.31 break;
1.32 default:
1.33 fontsize=10;
1.34 - setFrameType (FrameObj::NoFrame);
1.35 break;
1.36 }
1.37 setLinkStyle(getDefLinkStyle(treeItem->parent() ));
1.38 @@ -467,12 +464,20 @@
1.39 font.setPointSize(fontsize);
1.40 heading->setFont(font );
1.41
1.42 + if (mod==NewBranch && !keepFrame)
1.43 + if (treeItem->depth()==0)
1.44 + setFrameType (FrameObj::Rectangle);
1.45 + else
1.46 + setFrameType (FrameObj::NoFrame);
1.47 +
1.48 if (mod==NewBranch)
1.49 setColor (treeItem->getHeadingColor() );
1.50 else
1.51 + {
1.52 // Also set styles for children
1.53 for (int i=0; i<treeItem->branchCount(); ++i)
1.54 treeItem->getBranchObjNum(i)->setDefAttr(MovedBranch);
1.55 + }
1.56 calcBBoxSize();
1.57 }
1.58
1.59 @@ -559,7 +564,21 @@
1.60 else
1.61 ref2.setY(ref.y() );
1.62
1.63 - // Align the children depending on reference point
1.64 + // Align the attribute children depending on reference point
1.65 + // on top like in TreeEditor
1.66 + for (int i=0; i<treeItem->attributeCount(); ++i)
1.67 + {
1.68 + if (!treeItem->getAttributeNum(i)->isHidden())
1.69 + {
1.70 + BranchObj *bo=(BranchObj*)(treeItem->getAttributeNum(i)->getBranchObj());
1.71 + if (!bo) break;
1.72 + bo->alignRelativeTo (ref2,true);
1.73 +
1.74 + // append next branch below current one
1.75 + ref2.setY(ref2.y() + bo->getBBoxSizeWithChildren().height() );
1.76 + }
1.77 + }
1.78 + // Align the branch children depending on reference point
1.79 for (int i=0; i<treeItem->branchCount(); ++i)
1.80 {
1.81 if (!treeItem->getBranchNum(i)->isHidden())
1.82 @@ -718,8 +737,22 @@
1.83 {
1.84 if (!bi->getBranchNum(i)->isHidden())
1.85 {
1.86 - bi->getBranchObjNum(i)->calcBBoxSizeWithChildren();
1.87 - br=bi->getBranchObjNum(i)->getBBoxSizeWithChildren();
1.88 + BranchObj *bo=bi->getBranchObjNum(i);
1.89 + bo->calcBBoxSizeWithChildren();
1.90 + br=bo->getBBoxSizeWithChildren();
1.91 + r.setWidth( max (br.width(), r.width() ));
1.92 + r.setHeight(br.height() + r.height() );
1.93 + if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
1.94 + if (br.x()<bboxTotal.x()) bboxTotal.setX(br.x());
1.95 + }
1.96 + }
1.97 + for (int i=0; i<treeItem->attributeCount(); i++)
1.98 + {
1.99 + if (!bi->getAttributeNum(i)->isHidden())
1.100 + {
1.101 + BranchObj *bo=bi->getAttributeNum(i)->getBranchObj();
1.102 + bo->calcBBoxSizeWithChildren();
1.103 + br=bo->getBBoxSizeWithChildren();
1.104 r.setWidth( max (br.width(), r.width() ));
1.105 r.setHeight(br.height() + r.height() );
1.106 if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());