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";
28 void MapCenterObj::clear()
33 void MapCenterObj::init ()
36 orientation=LinkableMapObj::UndefinedOrientation;
38 // TODO this should be done in TextObj later...
39 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
40 //heading->setFont(font);
42 setDefAttr(MovedBranch);
44 frame->setFrameType (FrameObj::Rectangle);
47 void MapCenterObj::move (double x, double y)
52 void MapCenterObj::moveBy (double x, double y)
54 BranchObj::moveBy(x,y);
57 void MapCenterObj::moveAll (double x, double y)
60 double dx=x-absPos.x();
61 double dy=y-absPos.y();
63 // Move myself and branches
67 void MapCenterObj::moveAllBy (double dx, double dy)
69 // Move myself and childs
70 BranchObj::moveBy(dx,dy);
73 void MapCenterObj::updateLink()
75 // set childPos to middle of MapCenterObj
76 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
77 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
79 for (int i=0; i<branch.size(); ++i)
80 branch.at(i)->updateLink();
83 void MapCenterObj::updateRelPositions()
85 if (repositionRequest) unsetAllRepositionRequests();
87 // update relative Positions of branches and floats
88 for (int i=0; i<branch.size(); ++i)
90 branch.at(i)->setRelPos();
91 branch.at(i)->setOrientation();
94 for (int i=0; i<floatimage.size(); ++i)
95 floatimage.at(i)->setRelPos();
97 if (repositionRequest) reposition();
100 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
104 // Search through child branches
105 for (int i=0; i<branch.size(); ++i)
107 lmo = branch.at(i)->findMapObj(p, excludeLMO);
108 if (lmo!= NULL) return lmo;
110 // is p in MapCenter?
111 if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
113 // Search float images
114 for (int i=0; i<floatimage.size(); ++i)
115 if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
121 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
125 // save area, if not scrolled
127 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
128 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
129 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
130 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
132 // Providing an ID for a branch makes export to XHTML easier
135 idAttr=attribut ("id",getSelectString());
139 QString linkAttr=getLinkAttr();
141 s=beginElement ("mapcenter"
145 +getIncludeImageAttr() );
147 if (heading->getColor()!=QColor("black"))
148 a=attribut ("textColor",QColor(heading->getColor()).name() );
152 // Save flags. If verbose is set (export to xml dir), also write
153 // the flags as picture
154 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
157 s+=valueElement("heading", getHeading(),a);
160 s+=frame->saveToDir ();
162 // add link to file in s
163 if (!note.isEmpty() )
167 for (int i=0; i<branch.size(); ++i)
168 s+=branch.at(i)->saveToDir(tmpdir,prefix, offset);
171 for (int i=0; i<floatimage.size(); ++i)
172 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
175 for (int i=0;i<xlink.size(); ++i)
176 s+=xlink.at(i)->saveToDir();
179 s+=endElement ("mapcenter");
183 void MapCenterObj::setVersion (const QString &s)
188 void MapCenterObj::setAuthor (const QString &s)
193 QString MapCenterObj::getAuthor()
198 void MapCenterObj::setComment (const QString &s)
203 QString MapCenterObj::getComment ()
208 QString MapCenterObj::getDate ()
210 return QDate::currentDate().toString ("yyyy-MM-dd");