3 #include "floatimageobj.h"
5 #include "mapcenterobj.h"
9 /////////////////////////////////////////////////////////////////
11 /////////////////////////////////////////////////////////////////
12 MapCenterObj::MapCenterObj() : BranchObj ()
14 // cout << "Const MapCenterObj\n";
18 MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s)
20 // cout << "Const MapCenterObj canvas="<<s<<"\n";
24 MapCenterObj::~MapCenterObj()
26 // cout << "Destr MapCenterObj\n";
30 void MapCenterObj::clear()
35 void MapCenterObj::init ()
38 orientation=LinkableMapObj::UndefinedOrientation;
40 // TODO this should be done in TextObj later...
41 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
42 //heading->setFont(font);
44 setDefAttr(MovedBranch);
46 frame->setFrameType (FrameObj::Rectangle);
49 void MapCenterObj::move (double x, double y)
54 void MapCenterObj::move (QPointF absPos)
56 BranchObj::move(absPos);
59 void MapCenterObj::moveBy (double x, double y)
61 BranchObj::moveBy(x,y);
64 void MapCenterObj::moveAll (double x, double y)
67 double dx=x-absPos.x();
68 double dy=y-absPos.y();
70 // Move myself and branches
74 void MapCenterObj::moveAllBy (double dx, double dy)
76 // Move myself and childs
77 BranchObj::moveBy(dx,dy);
80 void MapCenterObj::updateLink()
82 // set childPos to middle of MapCenterObj
83 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
84 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
86 for (int i=0; i<branch.size(); ++i)
87 branch.at(i)->updateLink();
90 void MapCenterObj::updateRelPositions()
92 if (repositionRequest) unsetAllRepositionRequests();
94 // update relative Positions of branches and floats
95 for (int i=0; i<branch.size(); ++i)
97 branch.at(i)->setRelPos();
98 branch.at(i)->setOrientation();
101 for (int i=0; i<floatimage.size(); ++i)
102 floatimage.at(i)->setRelPos();
104 if (repositionRequest) reposition();
107 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
111 // Search through child branches
112 for (int i=0; i<branch.size(); ++i)
114 lmo = branch.at(i)->findMapObj(p, excludeLMO);
115 if (lmo!= NULL) return lmo;
117 // is p in MapCenter?
118 if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
120 // Search float images
121 for (int i=0; i<floatimage.size(); ++i)
122 if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
128 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
132 // save area, if not scrolled
134 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
135 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
136 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
137 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
139 // Providing an ID for a branch makes export to XHTML easier
142 idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
147 QString linkAttr=getLinkAttr();
149 s=beginElement ("mapcenter"
153 +getIncludeImageAttr() );
155 if (heading->getColor()!=QColor("black"))
156 a=attribut ("textColor",QColor(heading->getColor()).name() );
160 // Save flags. If verbose is set (export to xml dir), also write
161 // the flags as picture
162 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
165 s+=valueElement("heading", getHeading(),a);
168 s+=frame->saveToDir ();
170 // add link to file in s
171 if (!note.isEmpty() )
175 for (int i=0; i<branch.size(); ++i)
176 s+=branch.at(i)->saveToDir(tmpdir,prefix, offset);
179 for (int i=0; i<floatimage.size(); ++i)
180 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
183 for (int i=0;i<xlink.size(); ++i)
184 s+=xlink.at(i)->saveToDir();
187 s+=endElement ("mapcenter");
191 void MapCenterObj::setVersion (const QString &s)
196 void MapCenterObj::setAuthor (const QString &s)
201 QString MapCenterObj::getAuthor()
206 void MapCenterObj::setComment (const QString &s)
211 QString MapCenterObj::getComment ()
216 QString MapCenterObj::getDate ()
218 return QDate::currentDate().toString ("yyyy-MM-dd");