1.1 --- a/branchitem.cpp Mon Jun 29 10:28:28 2009 +0000
1.2 +++ b/branchitem.cpp Tue Jul 07 09:34:24 2009 +0000
1.3 @@ -7,7 +7,7 @@
1.4
1.5 using namespace std;
1.6
1.7 -BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
1.8 +BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
1.9 {
1.10 //cout << "Constr. BranchItem\n";
1.11
1.12 @@ -93,7 +93,8 @@
1.13 elementName="branch";
1.14
1.15 s=beginElement (elementName
1.16 - +getAttr()
1.17 + +getMapAttr()
1.18 + +getGeneralAttr()
1.19 +scrolledAttr
1.20 // +areaAttr
1.21 // +idAttr
1.22 @@ -249,10 +250,11 @@
1.23 // find out, if we are scrolled at all.
1.24 // But ignore myself, just look at parents.
1.25
1.26 + //cout << "BI::hasScrolledParent this="<<this<<" "<<getHeadingStd()<<endl;
1.27 if (this !=start && scrolled) return true;
1.28
1.29 BranchItem* bi=(BranchItem*)parentItem;
1.30 - if (bi && bi->isBranchLikeType() )
1.31 + if (bi && bi!=rootItem && bi->isBranchLikeType() )
1.32 return bi->hasScrolledParent(start);
1.33 else
1.34 return false;
1.35 @@ -350,9 +352,9 @@
1.36 {
1.37 // FIXME-5 compare also MapItem::initLMO...
1.38
1.39 - if (lmo)
1.40 + if (lmo && parentItem != rootItem)
1.41 {
1.42 - lmo->setParObj ( parentItem->getLMO() );
1.43 + lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
1.44 }
1.45 }
1.46
1.47 @@ -374,9 +376,9 @@
1.48 newbo->setFrameType (FrameObj::Rectangle);
1.49 } else
1.50 {
1.51 - newbo->setParObj( parentItem->getLMO() );
1.52 + newbo->setParObj( ((MapItem*)parentItem)->getLMO() );
1.53 // Set visibility depending on parents
1.54 - if (((BranchItem*)parentItem)->scrolled || !parentItem->getLMO()->isVisibleObj() )
1.55 + if (((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
1.56 newbo->setVisibility (false);
1.57 }
1.58 newbo->setDefAttr(BranchObj::NewBranch);
1.59 @@ -388,7 +390,7 @@
1.60 newbo->setColor (headingColor);
1.61 }
1.62
1.63 - //newbo->updateLink(); //FIXME-3
1.64 + //newbo->updateLinkGeometry(); //FIXME-3
1.65
1.66 return newbo;
1.67 }
2.1 --- a/branchitem.h Mon Jun 29 10:28:28 2009 +0000
2.2 +++ b/branchitem.h Tue Jul 07 09:34:24 2009 +0000
2.3 @@ -1,23 +1,24 @@
2.4 #ifndef BRANCHITEM_H
2.5 #define BRANCHITEM_H
2.6
2.7 -#include "treeitem.h"
2.8 +//#include "treeitem.h"
2.9 +#include "mapitem.h"
2.10
2.11
2.12 class QString;
2.13 class BranchObj;
2.14 class QGraphicsScene;
2.15
2.16 -class BranchItem:public TreeItem
2.17 +class BranchItem:public MapItem
2.18 {
2.19 public:
2.20 BranchItem(const QList<QVariant> &data, TreeItem *parent = 0);
2.21 virtual ~BranchItem();
2.22 - void copy (BranchItem *item);
2.23 + virtual void copy (BranchItem *item);
2.24
2.25 - void insertBranch (int pos,BranchItem *branch);
2.26 + virtual void insertBranch (int pos,BranchItem *branch);
2.27
2.28 - QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
2.29 + virtual QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset);
2.30
2.31 virtual void updateVisibility();
2.32
3.1 --- a/branchobj.cpp Mon Jun 29 10:28:28 2009 +0000
3.2 +++ b/branchobj.cpp Tue Jul 07 09:34:24 2009 +0000
3.3 @@ -146,7 +146,7 @@
3.4
3.5 // FIXME-2 depth=parObj->getDepth()+1;
3.6
3.7 - // setLinkStyle calls updateLink, only set it once
3.8 + // setLinkStyle calls updateLinkGeometry, only set it once
3.9 if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
3.10
3.11 // Move temporary to new position at destination
3.12 @@ -190,7 +190,7 @@
3.13 move (o->getChildPos().x() + linkwidth, y );
3.14 }
3.15
3.16 - // updateLink is called implicitly in move
3.17 + // updateLinkGeometry is called implicitly in move
3.18 requestReposition();
3.19 }
3.20
3.21 @@ -203,7 +203,7 @@
3.22 parObjTmpBuf=NULL;
3.23 //FIXME-2 depth=parObj->getDepth()+1;
3.24 setLinkStyle (getDefLinkStyle() );
3.25 - updateLink();
3.26 + updateLinkGeometry();
3.27 }
3.28 }
3.29
3.30 @@ -397,7 +397,7 @@
3.31 childPos.setY( clickBox.topLeft().y() + clickBox.height()/2 );
3.32 parPos=childPos;
3.33 for (int i=0; i<treeItem->branchCount(); ++i)
3.34 - treeItem->getBranchObjNum(i)->updateLink();
3.35 + treeItem->getBranchObjNum(i)->updateLinkGeometry();
3.36
3.37 } else
3.38 {
3.39 @@ -702,7 +702,7 @@
3.40 */
3.41
3.42 setOrientation();
3.43 - //updateLink();
3.44 + //updateLinkGeometry();
3.45
3.46 if (depth==1 && parObj)
3.47 {
3.48 @@ -788,7 +788,7 @@
3.49 // changes its height,
3.50 // all upper LMOs have to change, too.
3.51 calcBBoxSizeWithChildren();
3.52 - updateLink(); // This update is needed if the scene is resized
3.53 + updateLinkGeometry(); // This update is needed if the scene is resized
3.54 // due to excessive moving of a FIO
3.55
3.56 alignRelativeTo ( QPointF (absPos.x(),
4.1 --- a/branchpropwindow.cpp Mon Jun 29 10:28:28 2009 +0000
4.2 +++ b/branchpropwindow.cpp Tue Jul 07 09:34:24 2009 +0000
4.3 @@ -2,6 +2,7 @@
4.4
4.5 #include <QColorDialog>
4.6
4.7 +#include "branchitem.h"
4.8 #include "frameobj.h"
4.9 #include "settings.h"
4.10
4.11 @@ -63,7 +64,7 @@
4.12 branch=bo;
4.13 if (bo)
4.14 {
4.15 - qWarning ("BPW::setBranch");
4.16 + BranchItem *bi=(BranchItem*)(bo->getTreeItem());
4.17 ui.tabWidget->setEnabled (true);
4.18
4.19 // Frame
4.20 @@ -109,7 +110,7 @@
4.21 }
4.22
4.23 // Link
4.24 - if (branch->getHideLinkUnselected())
4.25 + if (bi->getHideLinkUnselected())
4.26 ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
4.27 else
4.28 ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
5.1 --- a/floatobj.cpp Mon Jun 29 10:28:28 2009 +0000
5.2 +++ b/floatobj.cpp Tue Jul 07 09:34:24 2009 +0000
5.3 @@ -30,13 +30,15 @@
5.4 // cout << "Destr FloatObj\n";
5.5 }
5.6
5.7 +#include <iostream>
5.8 +using namespace std;
5.9 void FloatObj::init ()
5.10 {
5.11 floatExport=true;
5.12 zPlane=Z_ICON;
5.13 setLinkStyle (LinkableMapObj::Parabel);
5.14 - setHideLinkUnselected(false);
5.15 //FIXME-2 setHideLinkUnselected(true);
5.16 + cout << "FO::init tI="<<treeItem<<endl;
5.17 }
5.18
5.19 void FloatObj::copy (FloatObj* other)
5.20 @@ -84,7 +86,7 @@
5.21 void FloatObj::reposition()
5.22 {
5.23 move2RelPos (relPos);
5.24 - updateLink();
5.25 + updateLinkGeometry();
5.26 }
5.27
5.28 QRectF FloatObj::getTotalBBox()
6.1 --- a/imageitem.cpp Mon Jun 29 10:28:28 2009 +0000
6.2 +++ b/imageitem.cpp Tue Jul 07 09:34:24 2009 +0000
6.3 @@ -14,7 +14,7 @@
6.4 init();
6.5 }
6.6
6.7 -ImageItem::ImageItem (const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
6.8 +ImageItem::ImageItem (const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
6.9 {
6.10 init();
6.11 }
6.12 @@ -29,6 +29,7 @@
6.13 {
6.14 type=Image;
6.15 imageType=Undefined;
6.16 + hideLinkUnselected=true;
6.17 originalFilename="no original name available";
6.18 zValue=Z_FLOATIMG;
6.19 posMode=Relative;
6.20 @@ -56,8 +57,8 @@
6.21 FloatImageObj *fio=new FloatImageObj (scene);
6.22 fio->setTreeItem (this);
6.23 lmo=fio;
6.24 - fio->setParObj ( parentItem->getLMO());
6.25 - if (((BranchItem*)parentItem)->isScrolled() || !parentItem->getLMO()->isVisibleObj() )
6.26 + fio->setParObj ( ((MapItem*)parentItem)->getLMO());
6.27 + if (((BranchItem*)parentItem)->isScrolled() || !((MapItem*)parentItem)->getLMO()->isVisibleObj() )
6.28 fio->setVisibility (false);
6.29 initLMO();
6.30 fio->setZValue(zValue);
6.31 @@ -136,7 +137,8 @@
6.32 QString nameAttr=attribut ("originalName",originalFilename);
6.33
6.34 return singleElement ("floatimage",
6.35 - getAttr()
6.36 + getMapAttr()
6.37 + +getGeneralAttr()
6.38 // +useOrientAttr
6.39 // +saveInMapAttr
6.40 // +exportAttr
7.1 --- a/imageitem.h Mon Jun 29 10:28:28 2009 +0000
7.2 +++ b/imageitem.h Tue Jul 07 09:34:24 2009 +0000
7.3 @@ -6,10 +6,11 @@
7.4 #include <QVariant>
7.5
7.6 #include "floatimageobj.h"
7.7 -#include "treeitem.h"
7.8 +//#include "treeitem.h"
7.9 +#include "mapitem.h"
7.10
7.11
7.12 -class ImageItem: public TreeItem
7.13 +class ImageItem: public MapItem
7.14 {
7.15 public:
7.16 enum ImageType {Undefined,Pixmap,SVG};
8.1 --- a/linkablemapobj.cpp Mon Jun 29 10:28:28 2009 +0000
8.2 +++ b/linkablemapobj.cpp Tue Jul 07 09:34:24 2009 +0000
8.3 @@ -79,11 +79,6 @@
8.4 bottomline->setZValue(Z_LINK);
8.5 bottomline->show();
8.6
8.7 - // Prepare showing the selection of a MapObj
8.8 - selected=false;
8.9 -
8.10 - hideLinkUnselected=false;
8.11 -
8.12 topPad=botPad=leftPad=rightPad=0;
8.13
8.14 repositionRequest=false;
8.15 @@ -287,16 +282,10 @@
8.16 return style;
8.17 }
8.18
8.19 -void LinkableMapObj::setHideLinkUnselected(bool b)
8.20 +void LinkableMapObj::setHideLinkUnselected()
8.21 {
8.22 - hideLinkUnselected=b;
8.23 setVisibility (visible);
8.24 - updateLink();
8.25 -}
8.26 -
8.27 -bool LinkableMapObj::getHideLinkUnselected()
8.28 -{
8.29 - return hideLinkUnselected;
8.30 + updateLinkGeometry();
8.31 }
8.32
8.33 void LinkableMapObj::setLinkPos(Position lp)
8.34 @@ -353,10 +342,40 @@
8.35 void LinkableMapObj::setVisibility (bool v)
8.36 {
8.37 MapObj::setVisibility (v);
8.38 + updateVisibility();
8.39 +}
8.40 +
8.41 +void LinkableMapObj::setOrientation()
8.42 +{
8.43 + Orientation orientOld=orientation;
8.44 +
8.45 + if (!parObj)
8.46 + {
8.47 + orientation=UndefinedOrientation;
8.48 + return;
8.49 + }
8.50 +
8.51 + // Set orientation, first look for orientation of parent
8.52 + if (parObj->getOrientation() != UndefinedOrientation )
8.53 + // use the orientation of the parent:
8.54 + orientation=parObj->getOrientation();
8.55 + else
8.56 + {
8.57 + // calc orientation depending on position rel to parent
8.58 + if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
8.59 + orientation=LeftOfCenter;
8.60 + else
8.61 + orientation=RightOfCenter;
8.62 + }
8.63 + if (orientOld!=orientation) requestReposition();
8.64 +}
8.65 +
8.66 +void LinkableMapObj::updateVisibility()
8.67 +{
8.68 bool visnow=visible;
8.69
8.70 - // We can hide the link, while object is not selected
8.71 - if (hideLinkUnselected && !selected)
8.72 + if (((MapItem*)treeItem)->getHideLinkUnselected()
8.73 + && treeItem->getModel()->getSelectedLMO() !=this)
8.74 visnow=false;
8.75
8.76 if (visnow)
8.77 @@ -372,11 +391,11 @@
8.78 segment.at(i)->show();
8.79 break;
8.80 case PolyLine:
8.81 - if (!p) cout << "LMO::setVis p==0 (PolyLine)\n"; //FIXME-3
8.82 + if (!p) cout << "LMO::updateVis p==0 (PolyLine)\n"; //FIXME-3
8.83 if (p) p->show();
8.84 break;
8.85 case PolyParabel:
8.86 - if (!p) cout << "LMO::setVis p==0 (PolyParabel) "<<treeItem->getHeading().toStdString()<<endl; //FIXME-3
8.87 + if (!p) cout << "LMO::updateVis p==0 (PolyParabel) "<<treeItem->getHeading().toStdString()<<endl; //FIXME-3
8.88 if (p) p->show();
8.89 break;
8.90 default:
8.91 @@ -406,32 +425,7 @@
8.92 }
8.93 }
8.94
8.95 -void LinkableMapObj::setOrientation()
8.96 -{
8.97 - Orientation orientOld=orientation;
8.98 -
8.99 - if (!parObj)
8.100 - {
8.101 - orientation=UndefinedOrientation;
8.102 - return;
8.103 - }
8.104 -
8.105 - // Set orientation, first look for orientation of parent
8.106 - if (parObj->getOrientation() != UndefinedOrientation )
8.107 - // use the orientation of the parent:
8.108 - orientation=parObj->getOrientation();
8.109 - else
8.110 - {
8.111 - // calc orientation depending on position rel to parent
8.112 - if (absPos.x() < QPointF(parObj->getChildPos() ).x() )
8.113 - orientation=LeftOfCenter;
8.114 - else
8.115 - orientation=RightOfCenter;
8.116 - }
8.117 - if (orientOld!=orientation) requestReposition();
8.118 -}
8.119 -
8.120 -void LinkableMapObj::updateLink()
8.121 +void LinkableMapObj::updateLinkGeometry()
8.122 {
8.123 // needs:
8.124 // childPos of parent
8.125 @@ -445,7 +439,7 @@
8.126 // bottomlineY
8.127 // drawing of the link itself
8.128
8.129 - // updateLink is called from move, but called from constructor we don't
8.130 + // updateLinkGeometry is called from move, but called from constructor we don't
8.131 // have parents yet...
8.132
8.133 if (!parObj)
8.134 @@ -456,7 +450,7 @@
8.135 parPos=childPos;
8.136 // Redraw links to children
8.137 for (int i=0; i<treeItem->branchCount(); ++i)
8.138 - treeItem->getBranchObjNum(i)->updateLink();
8.139 + treeItem->getBranchObjNum(i)->updateLinkGeometry();
8.140 return;
8.141 }
8.142
8.143 @@ -511,7 +505,6 @@
8.144 switch (style)
8.145 {
8.146 case Line:
8.147 - //l->prepareGeometryChange();
8.148 l->setLine( QLine(qRound (parPos.x()),
8.149 qRound(parPos.y()),
8.150 qRound(p2x),
8.151 @@ -520,17 +513,13 @@
8.152 case Parabel:
8.153 parabel (pa0, p1x,p1y,p2x,p2y);
8.154 for (int i=0; i<segment.size(); ++i)
8.155 - {
8.156 - //segment.at(i)->prepareGeometryChange();
8.157 segment.at(i)->setLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y()));
8.158 - }
8.159 break;
8.160 case PolyLine:
8.161 pa0.clear();
8.162 pa0<<QPointF (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
8.163 pa0<<QPointF (qRound(p2x-tp.x()), qRound(p2y-tp.y()));
8.164 pa0<<QPointF (qRound (parPos.x()), qRound(parPos.y()) );
8.165 - //p->prepareGeometryChange();
8.166 p->setPolygon(QPolygonF (pa0));
8.167 break;
8.168 case PolyParabel:
8.169 @@ -541,12 +530,11 @@
8.170 pa0 << QPointF (pa1.at(i));
8.171 for (int i=0;i<=arcsegs;i++)
8.172 pa0 << QPointF (pa2.at(arcsegs-i));
8.173 - //p->prepareGeometryChange();
8.174 p->setPolygon(QPolygonF (pa0));
8.175 break;
8.176 default:
8.177 break;
8.178 - } // switch (style)
8.179 + }
8.180 }
8.181
8.182 LinkableMapObj* LinkableMapObj::getParObj()
8.183 @@ -626,23 +614,6 @@
8.184 return repositionRequest;
8.185 }
8.186
8.187 -
8.188 -void LinkableMapObj::select()
8.189 -{
8.190 - // select and unselect are still needed to
8.191 - // handle hiding of links
8.192 - selected=true;
8.193 - setVisibility (visible);
8.194 -}
8.195 -
8.196 -
8.197 -void LinkableMapObj::unselect()
8.198 -{
8.199 - selected=false;
8.200 - // Maybe we have to hide the link:
8.201 - setVisibility (visible);
8.202 -}
8.203 -
8.204 void LinkableMapObj::parabel (QPolygonF &ya, double p1x, double p1y, double p2x, double p2y)
8.205
8.206 {
8.207 @@ -672,12 +643,3 @@
8.208 }
8.209 }
8.210
8.211 -QString LinkableMapObj::getLinkAttr ()
8.212 -{
8.213 - if (hideLinkUnselected)
8.214 - return attribut ("hideLink","true");
8.215 - else
8.216 - return attribut ("hideLink","false");
8.217 -
8.218 -}
8.219 -
9.1 --- a/linkablemapobj.h Mon Jun 29 10:28:28 2009 +0000
9.2 +++ b/linkablemapobj.h Tue Jul 07 09:34:24 2009 +0000
9.3 @@ -79,19 +79,23 @@
9.4 Style getDefLinkStyle();
9.5 void setLinkStyle(Style);
9.6 Style getLinkStyle();
9.7 - void setHideLinkUnselected(bool);
9.8 - bool getHideLinkUnselected();
9.9 +
9.10 + void setHideLinkUnselected();
9.11 void setLinkPos (Position);
9.12 Position getLinkPos ();
9.13
9.14 - virtual void setLinkColor(); // sets color according to colorhint, overloaded
9.15 + virtual void setLinkColor(); // sets color according to colorhint, overloaded
9.16 virtual void setLinkColor(QColor);
9.17 QColor getLinkColor();
9.18 virtual void setVisibility (bool);
9.19 virtual void setOrientation();
9.20 - virtual void updateLink(); // update parPos and childPos
9.21 - // depending on pos
9.22 - // redraw link with given style
9.23 + virtual void updateVisibility(); //! hides/unhides link depending on selection
9.24 +
9.25 + /*! update parPos, childPos
9.26 + depending on pos
9.27 + redraw link with given style */
9.28 + virtual void updateLinkGeometry();
9.29 +
9.30 LinkableMapObj* getChildObj(); // returns pointer to fromObj
9.31 LinkableMapObj* getParObj(); // returns pointer to toObj
9.32 virtual void setDockPos()=0; // sets childPos and parPos
9.33 @@ -108,12 +112,8 @@
9.34
9.35 virtual void calcBBoxSizeWithChildren()=0;// calc size of BBox including children recursivly
9.36
9.37 - virtual void select(); // FIXME-3 show/hide links...
9.38 - virtual void unselect();
9.39 -
9.40 protected:
9.41 void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points
9.42 - QString getLinkAttr();
9.43
9.44 QPointF childPos;
9.45 QPointF parPos;
9.46 @@ -142,8 +142,6 @@
9.47 QGraphicsLineItem* bottomline; // on bottom of BBox
9.48 bool repositionRequest; //
9.49
9.50 - bool selected; // Used for marking the selection
9.51 - bool hideLinkUnselected; // to hide links if unselected
9.52 qreal topPad, botPad,
9.53 leftPad, rightPad; // padding within bbox
9.54
10.1 --- a/mapeditor.cpp Mon Jun 29 10:28:28 2009 +0000
10.2 +++ b/mapeditor.cpp Tue Jul 07 09:34:24 2009 +0000
10.3 @@ -189,7 +189,7 @@
10.4 LinkableMapObj* lmo=NULL;
10.5 TreeItem *ti= static_cast<TreeItem*>(index.internalPointer());
10.6 if (ti->getType()==TreeItem::Image ||ti->isBranchLikeType() )
10.7 - lmo=ti->getLMO();
10.8 + lmo=((MapItem*)ti)->getLMO();
10.9 if (lmo) setScrollBarPosTarget (lmo->getBBox() );
10.10 }
10.11 }
10.12 @@ -599,7 +599,7 @@
10.13 QPointF p = mapToScene(e->pos());
10.14 TreeItem *ti=findMapItem (p, NULL);
10.15 LinkableMapObj* lmo=NULL;
10.16 - if (ti) lmo=ti->getLMO();
10.17 + if (ti) lmo=((MapItem*)ti)->getLMO();
10.18
10.19 if (lmo)
10.20 { // MapObj was found
10.21 @@ -683,7 +683,7 @@
10.22 QPointF p = mapToScene(e->pos());
10.23 TreeItem *ti=findMapItem (p, NULL);
10.24 LinkableMapObj* lmo=NULL;
10.25 - if (ti) lmo=ti->getLMO();
10.26 + if (ti) lmo=((MapItem*)ti)->getLMO();
10.27
10.28 e->accept();
10.29
10.30 @@ -818,7 +818,7 @@
10.31 TreeItem *seli=model->getSelectedItem();
10.32 LinkableMapObj* lmosel=NULL;
10.33 if (seli && (seli->isBranchLikeType() ||seli->getType()==TreeItem::Image))
10.34 - lmosel=seli->getLMO();
10.35 + lmosel=((MapItem*)seli)->getLMO();
10.36
10.37 // Move the selected MapObj
10.38 if ( lmosel && movingObj)
10.39 @@ -854,7 +854,7 @@
10.40 FloatObj *fio=(FloatImageObj*)lmosel;
10.41 fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
10.42 fio->setRelPos();
10.43 - fio->updateLink(); //no need for reposition, if we update link here
10.44 + fio->updateLinkGeometry(); //no need for reposition, if we update link here
10.45 model->emitSelectionChanged(); // position has changed
10.46
10.47 // Relink float to new mapcenter or branch, if shift is pressed
10.48 @@ -968,7 +968,7 @@
10.49 if (seli) dsti=findMapItem(p, seli);
10.50 LinkableMapObj* dst=NULL;
10.51 if (dsti && dsti->isBranchLikeType ())
10.52 - dst=dsti->getLMO();
10.53 + dst=((MapItem*)dsti)->getLMO();
10.54 else
10.55 dsti=NULL;
10.56
10.57 @@ -1013,7 +1013,7 @@
10.58 {
10.59 if (seli->getType()==TreeItem::Image)
10.60 {
10.61 - FloatImageObj *fio=(FloatImageObj*)(seli->getLMO());
10.62 + FloatImageObj *fio=(FloatImageObj*)( ((MapItem*)seli)->getLMO());
10.63 if(fio)
10.64 {
10.65 // Moved FloatObj. Maybe we need to reposition
10.66 @@ -1051,7 +1051,7 @@
10.67 if (seli->isBranchLikeType() ) //(seli->getType() == TreeItem::Branch )
10.68 { // A branch was moved
10.69 LinkableMapObj* lmosel=NULL;
10.70 - lmosel=seli->getLMO();
10.71 + lmosel=((MapItem*)seli)->getLMO();
10.72
10.73 // save the position in case we link to mapcenter
10.74 QPointF savePos=QPointF (lmosel->getAbsPos() );
10.75 @@ -1272,6 +1272,9 @@
10.76
10.77 void MapEditor::updateSelection(QItemSelection newsel,QItemSelection oldsel)
10.78 {
10.79 + // Note: Here we are prepared for multiple selections, though this
10.80 + // is not yet implemented elsewhere
10.81 +
10.82 // Here in MapEditor we can only select Branches and Images
10.83 QModelIndex ix;
10.84 foreach (ix,newsel.indexes() )
10.85 @@ -1281,6 +1284,7 @@
10.86 newsel.indexes().removeOne (ix);
10.87 }
10.88
10.89 + // Trim list of selection rectangles
10.90 while (newsel.indexes().count() < selboxList.count() )
10.91 delete selboxList.takeFirst();
10.92
10.93 @@ -1291,10 +1295,17 @@
10.94 if (ix.isValid() )
10.95 {
10.96 TreeItem *ti= static_cast<TreeItem*>(ix.internalPointer());
10.97 - if (ti && ti->isBranchLikeType() )
10.98 + if (ti)
10.99 {
10.100 - BranchItem *bi=(BranchItem*)ti;
10.101 - bi->resetTmpUnscroll();
10.102 + if (ti->isBranchLikeType() )
10.103 + {
10.104 + // reset tmp scrolled branches
10.105 + BranchItem *bi=(BranchItem*)ti;
10.106 + bi->resetTmpUnscroll();
10.107 + }
10.108 + if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
10.109 + // Hide link if not needed
10.110 + ((MapItem*)ti)->getLMO()->updateVisibility();
10.111 }
10.112 }
10.113 }
10.114 @@ -1313,6 +1324,9 @@
10.115 bi->tmpUnscroll();
10.116 }
10.117 scrollTo (ix);
10.118 + if (ti->isBranchLikeType() || ti->getType()==TreeItem::Image)
10.119 + // Show link if needed
10.120 + ((MapItem*)ti)->getLMO()->updateVisibility();
10.121 }
10.122 }
10.123
10.124 @@ -1344,7 +1358,7 @@
10.125 {
10.126 index=newsel.indexes().at(i);
10.127 ti= static_cast<TreeItem*>(index.internalPointer());
10.128 - lmo=ti->getLMO();
10.129 + lmo=((MapItem*)ti)->getLMO();
10.130 bbox=lmo->getBBox();
10.131 sb->setRect (
10.132 bbox.x(),bbox.y(),
10.133 @@ -1370,7 +1384,7 @@
10.134
10.135 if (ti->isBranchLikeType())
10.136 {
10.137 - BranchObj *bo=(BranchObj*) (ti->getLMO());
10.138 + BranchObj *bo=(BranchObj*) ( ((MapItem*)ti)->getLMO());
10.139 bo->updateData();
10.140 }
10.141
11.1 --- a/mapitem.cpp Mon Jun 29 10:28:28 2009 +0000
11.2 +++ b/mapitem.cpp Tue Jul 07 09:34:24 2009 +0000
11.3 @@ -8,10 +8,32 @@
11.4 init();
11.5 }
11.6
11.7 +MapItem::MapItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
11.8 +{
11.9 + init();
11.10 +}
11.11 +
11.12 void MapItem::init()
11.13 {
11.14 lmo=NULL;
11.15 posMode=Unused;
11.16 + hideLinkUnselected=false;
11.17 +}
11.18 +
11.19 +void MapItem::appendChild (TreeItem *item)
11.20 +{
11.21 + TreeItem::appendChild (item);
11.22 +
11.23 + // FIXME-4 maybe access parent in MapObjs directly via treeItem
11.24 + // and remove this here...
11.25 +
11.26 + // If lmo exists, also set parObj there
11.27 + if (lmo && (item->isBranchLikeType() || item->getType()==TreeItem::Image) )
11.28 + {
11.29 + LinkableMapObj *itemLMO=((MapItem*)item)->lmo;
11.30 + if (itemLMO)
11.31 + itemLMO->setParObj (lmo);
11.32 + }
11.33 }
11.34
11.35 void MapItem::setRelPos (const QPointF &p)
11.36 @@ -37,6 +59,51 @@
11.37 posMode=mode;
11.38 }
11.39
11.40 +void MapItem::setHideLinkUnselected (bool b)
11.41 +{
11.42 + hideLinkUnselected=b;
11.43 + if (lmo) lmo->setHideLinkUnselected();
11.44 +}
11.45 +
11.46 +bool MapItem::getHideLinkUnselected()
11.47 +{
11.48 + return hideLinkUnselected;
11.49 +}
11.50 +
11.51 +QString MapItem::getMapAttr ()
11.52 +{
11.53 + QString s;
11.54 +
11.55 + if (parentItem==rootItem)
11.56 + posMode=Absolute;
11.57 + else
11.58 + {
11.59 + if (type==TreeItem::Image ||depth()==1)
11.60 + posMode=Relative;
11.61 + else
11.62 + posMode=Unused;
11.63 + }
11.64 + switch (posMode)
11.65 + {
11.66 + case Relative:
11.67 + if (lmo) pos=lmo->getRelPos();
11.68 + s= attribut("relPosX",QString().setNum(pos.x())) +
11.69 + attribut("relPosY",QString().setNum(pos.y()));
11.70 + break;
11.71 + case Absolute:
11.72 + if (lmo) pos=lmo->getAbsPos();
11.73 + s=attribut("absPosX",QString().setNum(pos.x())) +
11.74 + attribut("absPosY",QString().setNum(pos.y()));
11.75 + break;
11.76 + default: break;
11.77 + }
11.78 + if (hideLinkUnselected)
11.79 + s+=attribut ("hideLink","true");
11.80 + else
11.81 + s+=attribut ("hideLink","false");
11.82 + return s;
11.83 +}
11.84 +
11.85 LinkableMapObj* MapItem::getLMO()
11.86 {
11.87 return lmo;
12.1 --- a/mapitem.h Mon Jun 29 10:28:28 2009 +0000
12.2 +++ b/mapitem.h Tue Jul 07 09:34:24 2009 +0000
12.3 @@ -3,7 +3,8 @@
12.4
12.5 #include <QPointF>
12.6
12.7 -#include "xmlobj.h"
12.8 +//#include "xmlobj.h"
12.9 +#include "treeitem.h"
12.10
12.11 class LinkableMapObj;
12.12
12.13 @@ -15,7 +16,7 @@
12.14 but just a treeview instead.
12.15 */
12.16
12.17 -class MapItem:public XMLObj
12.18 +class MapItem:public TreeItem
12.19 {
12.20 public:
12.21 enum PositionMode {Unused,Absolute,Relative};
12.22 @@ -25,8 +26,13 @@
12.23
12.24 public:
12.25 MapItem();
12.26 + MapItem(const QList<QVariant> &data, TreeItem *parent = 0);
12.27 +
12.28 void init();
12.29
12.30 + /*! Overloaded from TreeItem. Used to set parObj in LinkableMapObj */
12.31 + virtual void appendChild (TreeItem *item);
12.32 +
12.33 /*! Used to save relative position while map is not in QGraphicsView */
12.34 virtual void setRelPos(const QPointF&);
12.35
12.36 @@ -37,6 +43,20 @@
12.37 Defaulst is MapItem::Unused */
12.38 void setPositionMode (PositionMode mode);
12.39
12.40 +
12.41 +protected:
12.42 + bool hideLinkUnselected;
12.43 +public:
12.44 + /*! Hide link if item is not selected */
12.45 + virtual void setHideLinkUnselected(bool);
12.46 +
12.47 + /*! Check if link is hidden for unselected items */
12.48 + virtual bool getHideLinkUnselected();
12.49 +
12.50 + virtual QString getMapAttr(); //! Get attributes for saving as XML
12.51 +
12.52 +
12.53 +
12.54 protected:
12.55 LinkableMapObj *lmo;
12.56 public:
13.1 --- a/ornamentedobj.cpp Mon Jun 29 10:28:28 2009 +0000
13.2 +++ b/ornamentedobj.cpp Tue Jul 07 09:34:24 2009 +0000
13.3 @@ -190,7 +190,7 @@
13.4 {
13.5 MapObj::move (x,y);
13.6 positionContents();
13.7 - updateLink();
13.8 + updateLinkGeometry();
13.9 requestReposition();
13.10 }
13.11
13.12 @@ -207,7 +207,7 @@
13.13 systemFlags->moveBy (x,y);
13.14 standardFlags->moveBy (x,y);
13.15 heading->moveBy (x,y);
13.16 - updateLink();
13.17 + updateLinkGeometry();
13.18 requestReposition();
13.19 }
13.20
14.1 --- a/treeitem.cpp Mon Jun 29 10:28:28 2009 +0000
14.2 +++ b/treeitem.cpp Tue Jul 07 09:34:24 2009 +0000
14.3 @@ -124,10 +124,6 @@
14.4 item->rootItem=rootItem;
14.5 item->setModel (model);
14.6
14.7 - // If lmo exists, also set parObj there
14.8 - if (lmo && item->lmo)
14.9 - item->lmo->setParObj (lmo);
14.10 -
14.11 if (item->type == Image)
14.12 {
14.13 childItems.insert (imageCounter,item);
14.14 @@ -609,6 +605,7 @@
14.15 return NULL;
14.16 }
14.17
14.18 +
14.19 void TreeItem::setHideTmp (HideTmpMode mode)
14.20 {
14.21 if (isBranchLikeType() )
14.22 @@ -690,37 +687,12 @@
14.23 return hidden;
14.24 }
14.25
14.26 -QString TreeItem::getAttr()
14.27 +QString TreeItem::getGeneralAttr()
14.28 {
14.29 - QString s;
14.30 - if (parentItem==rootItem)
14.31 - posMode=Absolute;
14.32 + if (hideExport)
14.33 + return attribut("hideInExport","true");
14.34 else
14.35 - {
14.36 - if (type==TreeItem::Image ||depth()==1)
14.37 - posMode=Relative;
14.38 - else
14.39 - posMode=Unused;
14.40 - }
14.41 - switch (posMode)
14.42 - {
14.43 - case Relative:
14.44 - if (lmo) pos=lmo->getRelPos();
14.45 - s= attribut("relPosX",QString().setNum(pos.x())) +
14.46 - attribut("relPosY",QString().setNum(pos.y()));
14.47 - break;
14.48 - case Absolute:
14.49 - if (lmo) pos=lmo->getAbsPos();
14.50 - s=attribut("absPosX",QString().setNum(pos.x())) +
14.51 - attribut("absPosY",QString().setNum(pos.y()));
14.52 - break;
14.53 - default: break;
14.54 - }
14.55 - if (hideExport)
14.56 - return s+attribut("hideInExport","true");
14.57 - else
14.58 - return s;
14.59 + return QString();
14.60 }
14.61
14.62
14.63 -
15.1 --- a/treeitem.h Mon Jun 29 10:28:28 2009 +0000
15.2 +++ b/treeitem.h Tue Jul 07 09:34:24 2009 +0000
15.3 @@ -6,7 +6,7 @@
15.4 #include <QVariant>
15.5
15.6 #include "flagrow.h"
15.7 -#include "mapitem.h"
15.8 +//#include "mapitem.h"
15.9 #include "noteobj.h"
15.10 #include "xmlobj.h"
15.11
15.12 @@ -17,7 +17,7 @@
15.13 class ImageItem;
15.14 class VymModel;
15.15
15.16 -class TreeItem:public MapItem
15.17 +class TreeItem:public XMLObj
15.18 {
15.19 public:
15.20 enum Type {Undefined,MapCenter,Branch,Image}; //FIXME-3 MapCenter still needed?
15.21 @@ -157,6 +157,7 @@
15.22
15.23 virtual ImageItem* getImageNum(const int &n);
15.24 virtual FloatImageObj* getImageObjNum(const int &n);
15.25 +
15.26 protected:
15.27 bool hideExport; //! Hide this item in export
15.28 public:
15.29 @@ -165,8 +166,8 @@
15.30 virtual void setHideInExport(bool); // set export of object (and children)
15.31 virtual bool hideInExport();
15.32 virtual bool isHidden ();
15.33 - virtual QString getAttr(); //! Get attributes for saving as XML
15.34
15.35 + virtual QString getGeneralAttr();
15.36
15.37 protected:
15.38 VymModel *model;
16.1 --- a/version.h Mon Jun 29 10:28:28 2009 +0000
16.2 +++ b/version.h Tue Jul 07 09:34:24 2009 +0000
16.3 @@ -7,7 +7,7 @@
16.4 #define __VYM_VERSION "1.13.0"
16.5 //#define __VYM_CODENAME "Codename: RC-1"
16.6 #define __VYM_CODENAME "Codename: development version, not for production!"
16.7 -#define __VYM_BUILD_DATE "2009-06-29"
16.8 +#define __VYM_BUILD_DATE "2009-07-07"
16.9
16.10
16.11 bool checkVersion(const QString &);
17.1 --- a/vymmodel.cpp Mon Jun 29 10:28:28 2009 +0000
17.2 +++ b/vymmodel.cpp Tue Jul 07 09:34:24 2009 +0000
17.3 @@ -1623,7 +1623,7 @@
17.4 saveState (bi, QString("setFrameType (\"%1\")").arg(s),
17.5 bi, QString ("setFrameType (\"%1\")").arg(bo->getFrameTypeName()),QString ("set type of frame to %1").arg(s));
17.6 reposition();
17.7 - bo->updateLink();
17.8 + bo->updateLinkGeometry();
17.9 }
17.10 }
17.11 }
17.12 @@ -1640,7 +1640,7 @@
17.13 bi, QString ("setFrameType (\"%1\")").arg(s),QString ("set type of frame to %1").arg(s));
17.14 bo->setFrameType (s);
17.15 reposition();
17.16 - bo->updateLink();
17.17 + bo->updateLinkGeometry();
17.18 }
17.19 }
17.20 }
17.21 @@ -1688,7 +1688,7 @@
17.22 bi, QString ("setFramePadding (\"%1\")").arg(i),QString ("set brush color of frame to %1").arg(i));
17.23 bo->setFramePadding (i);
17.24 reposition();
17.25 - bo->updateLink();
17.26 + bo->updateLinkGeometry();
17.27 }
17.28 }
17.29 }
17.30 @@ -1705,7 +1705,7 @@
17.31 bi, QString ("setFrameBorderWidth (\"%1\")").arg(i),QString ("set border width of frame to %1").arg(i));
17.32 bo->setFrameBorderWidth (i);
17.33 reposition();
17.34 - bo->updateLink();
17.35 + bo->updateLinkGeometry();
17.36 }
17.37 }
17.38 }
17.39 @@ -1763,26 +1763,21 @@
17.40
17.41 void VymModel::setHideLinkUnselected (bool b)//FIXME-2
17.42 {
17.43 -/*
17.44 - LinkableMapObj *sel=getSelectedLMO();
17.45 - if (sel &&
17.46 - (selectionType() == TreeItem::Branch ||
17.47 - selectionType() == TreeItem::MapCenter ||
17.48 - selectionType() == TreeItem::Image ))
17.49 + TreeItem *ti=getSelectedItem();
17.50 + if (ti && (ti->getType()==TreeItem::Image ||ti->isBranchLikeType()))
17.51 {
17.52 QString u= b ? "false" : "true";
17.53 QString r=!b ? "false" : "true";
17.54
17.55 saveState(
17.56 - sel,
17.57 + ti,
17.58 QString("setHideLinkUnselected (%1)").arg(u),
17.59 - sel,
17.60 + ti,
17.61 QString("setHideLinkUnselected (%1)").arg(r),
17.62 - QString("Hide link of %1 if unselected").arg(getObjectName(sel))
17.63 + QString("Hide link of %1 if unselected").arg(getObjectName(ti))
17.64 );
17.65 - sel->setHideLinkUnselected(b);
17.66 + ((MapItem*)ti)->setHideLinkUnselected(b);
17.67 }
17.68 -*/
17.69 }
17.70
17.71 void VymModel::setHideExport(bool b)
17.72 @@ -4283,7 +4278,7 @@
17.73 QString("Move %1 to relative position %2").arg(getObjectName(bo)).arg(ps));
17.74 ((OrnamentedObj*)bo)->move2RelPos (x,y);
17.75 reposition();
17.76 - bo->updateLink();
17.77 + bo->updateLinkGeometry();
17.78 emitSelectionChanged();
17.79 }
17.80 }
17.81 @@ -4953,9 +4948,7 @@
17.82 TreeItem *ti = getItem (list.first() );
17.83 TreeItem::Type type=ti->getType();
17.84 if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image)
17.85 - {
17.86 - return ti->getLMO();
17.87 - }
17.88 + return ((MapItem*)ti)->getLMO();
17.89 }
17.90 return NULL;
17.91 }
17.92 @@ -4964,7 +4957,7 @@
17.93 {
17.94 TreeItem *ti = getSelectedBranchItem();
17.95 if (ti)
17.96 - return (BranchObj*)(ti->getLMO());
17.97 + return (BranchObj*)( ((MapItem*)ti)->getLMO());
17.98 else
17.99 return NULL;
17.100 }
18.1 --- a/xml-vym.cpp Mon Jun 29 10:28:28 2009 +0000
18.2 +++ b/xml-vym.cpp Tue Jul 07 09:34:24 2009 +0000
18.3 @@ -359,7 +359,8 @@
18.4 if (!readOOAttr(a)) return false;
18.5
18.6 if (!a.value( "scrolled").isEmpty() )
18.7 - lastBranch->toggleScroll();
18.8 + lastBranch->toggleScroll(); //FIXME-3 in endElement unscroll again, if branch is still empty
18.9 + // (interesting for import of KDE bookmarks)
18.10 /*
18.11 if (!a.value( "frameType").isEmpty() )
18.12 lastOO->setFrameType (a.value("frameType")); //Compatibility 1.8.1
18.13 @@ -456,15 +457,13 @@
18.14 if (a.value("hideInExport")=="true")
18.15 lastBranch->setHideInExport(true);
18.16
18.17 - /* FIXME-2
18.18 if (!a.value( "hideLink").isEmpty())
18.19 {
18.20 if (a.value ("hideLink") =="true")
18.21 - lastOO->setHideLinkUnselected(true);
18.22 + lastMI->setHideLinkUnselected(true);
18.23 else
18.24 - lastOO->setHideLinkUnselected(false);
18.25 + lastMI->setHideLinkUnselected(false);
18.26 }
18.27 - */
18.28 }
18.29 return true;
18.30 }