3 #include "mapcenterobj.h"
4 #include "floatimageobj.h"
6 /////////////////////////////////////////////////////////////////
8 /////////////////////////////////////////////////////////////////
9 MapCenterObj::MapCenterObj() : BranchObj ()
11 // cout << "Const MapCenterObj\n";
15 MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s)
17 // cout << "Const MapCenterObj canvas="<<s<<"\n";
21 MapCenterObj::~MapCenterObj()
23 // cout << "Destr MapCenterObj\n";
26 void MapCenterObj::clear()
31 void MapCenterObj::init ()
34 orientation=LinkableMapObj::UndefinedOrientation;
36 // TODO this should be done in TextObj later...
37 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
38 //heading->setFont(font);
40 setDefAttr(MovedBranch);
42 frame->setFrameType (FrameObj::Rectangle);
45 void MapCenterObj::move (double x, double y)
50 void MapCenterObj::moveBy (double x, double y)
52 BranchObj::moveBy(x,y);
55 void MapCenterObj::moveAll (double x, double y)
58 double dx=x-absPos.x();
59 double dy=y-absPos.y();
61 // Move myself and branches
65 void MapCenterObj::moveAllBy (double dx, double dy)
67 // Move myself and childs
68 BranchObj::moveBy(dx,dy);
71 void MapCenterObj::updateLink()
73 // set childPos to middle of MapCenterObj
74 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
75 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
77 for (int i=0; i<branch.size(); ++i)
78 branch.at(i)->updateLink();
81 void MapCenterObj::updateRelPositions()
83 if (repositionRequest) unsetAllRepositionRequests();
85 // update relative Positions of branches and floats
86 for (int i=0; i<branch.size(); ++i)
88 branch.at(i)->setRelPos();
89 branch.at(i)->setOrientation();
92 for (int i=0; i<floatimage.size(); ++i)
93 floatimage.at(i)->setRelPos();
95 if (repositionRequest) reposition();
98 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
102 // Search through child branches
103 for (int i=0; i<branch.size(); ++i)
105 lmo = branch.at(i)->findMapObj(p, excludeLMO);
106 if (lmo!= NULL) return lmo;
108 // is p in MapCenter?
109 if (inBox (p) && (this != excludeLMO) ) return this;
111 // Search float images
112 for (int i=0; i<floatimage.size(); ++i)
113 if (floatimage.at(i)->inBox(p) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
119 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
123 // save area, if not scrolled
125 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
126 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
127 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
128 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
130 // Providing an ID for a branch makes export to XHTML easier
133 idAttr=attribut ("id",getSelectString());
137 QString linkAttr=getLinkAttr();
139 s=beginElement ("mapcenter"
143 +getIncludeImageAttr() );
145 if (heading->getColor()!=QColor("black"))
146 a=attribut ("textColor",QColor(heading->getColor()).name() );
150 // Save flags. If verbose is set (export to xml dir), also write
151 // the flags as picture
152 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
155 s+=valueElement("heading", getHeading(),a);
158 s+=frame->saveToDir ();
160 // add link to file in s
161 if (!note.isEmpty() )
165 for (int i=0; i<branch.size(); ++i)
166 s+=branch.at(i)->saveToDir(tmpdir,prefix, offset);
169 for (int i=0; i<floatimage.size(); ++i)
170 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
173 for (int i=0;i<xlink.size(); ++i)
174 s+=xlink.at(i)->saveToDir();
177 s+=endElement ("mapcenter");
181 void MapCenterObj::setVersion (const QString &s)
186 void MapCenterObj::setAuthor (const QString &s)
191 QString MapCenterObj::getAuthor()
196 void MapCenterObj::setComment (const QString &s)
201 QString MapCenterObj::getComment ()
206 QString MapCenterObj::getDate ()
208 return QDate::currentDate().toString ("yyyy-MM-dd");