3 #include "floatimageobj.h"
5 #include "mapcenterobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
10 MapCenterObj::MapCenterObj() : BranchObj ()
12 // cout << "Const MapCenterObj\n";
16 MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s)
18 // cout << "Const MapCenterObj canvas="<<s<<"\n";
22 MapCenterObj::~MapCenterObj()
24 // cout << "Destr MapCenterObj\n";
27 void MapCenterObj::clear()
32 void MapCenterObj::init ()
35 orientation=LinkableMapObj::UndefinedOrientation;
37 // TODO this should be done in TextObj later...
38 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
39 //heading->setFont(font);
41 setDefAttr(MovedBranch);
43 frame->setFrameType (FrameObj::Rectangle);
46 void MapCenterObj::move (double x, double y)
51 void MapCenterObj::moveBy (double x, double y)
53 BranchObj::moveBy(x,y);
56 void MapCenterObj::moveAll (double x, double y)
59 double dx=x-absPos.x();
60 double dy=y-absPos.y();
62 // Move myself and branches
66 void MapCenterObj::moveAllBy (double dx, double dy)
68 // Move myself and childs
69 BranchObj::moveBy(dx,dy);
72 void MapCenterObj::updateLink()
74 // set childPos to middle of MapCenterObj
75 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
76 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
78 for (int i=0; i<branch.size(); ++i)
79 branch.at(i)->updateLink();
82 void MapCenterObj::updateRelPositions()
84 if (repositionRequest) unsetAllRepositionRequests();
86 // update relative Positions of branches and floats
87 for (int i=0; i<branch.size(); ++i)
89 branch.at(i)->setRelPos();
90 branch.at(i)->setOrientation();
93 for (int i=0; i<floatimage.size(); ++i)
94 floatimage.at(i)->setRelPos();
96 if (repositionRequest) reposition();
99 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
103 // Search through child branches
104 for (int i=0; i<branch.size(); ++i)
106 lmo = branch.at(i)->findMapObj(p, excludeLMO);
107 if (lmo!= NULL) return lmo;
109 // is p in MapCenter?
110 if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
112 // Search float images
113 for (int i=0; i<floatimage.size(); ++i)
114 if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
120 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
124 // save area, if not scrolled
126 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
127 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
128 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
129 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
131 // Providing an ID for a branch makes export to XHTML easier
134 idAttr=attribut ("id",getSelectString());
138 QString linkAttr=getLinkAttr();
140 s=beginElement ("mapcenter"
144 +getIncludeImageAttr() );
146 if (heading->getColor()!=QColor("black"))
147 a=attribut ("textColor",QColor(heading->getColor()).name() );
151 // Save flags. If verbose is set (export to xml dir), also write
152 // the flags as picture
153 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
156 s+=valueElement("heading", getHeading(),a);
159 s+=frame->saveToDir ();
161 // add link to file in s
162 if (!note.isEmpty() )
166 for (int i=0; i<branch.size(); ++i)
167 s+=branch.at(i)->saveToDir(tmpdir,prefix, offset);
170 for (int i=0; i<floatimage.size(); ++i)
171 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
174 for (int i=0;i<xlink.size(); ++i)
175 s+=xlink.at(i)->saveToDir();
178 s+=endElement ("mapcenter");
182 void MapCenterObj::setVersion (const QString &s)
187 void MapCenterObj::setAuthor (const QString &s)
192 QString MapCenterObj::getAuthor()
197 void MapCenterObj::setComment (const QString &s)
202 QString MapCenterObj::getComment ()
207 QString MapCenterObj::getDate ()
209 return QDate::currentDate().toString ("yyyy-MM-dd");