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(QGraphicsScene* s,VymModel *m) : BranchObj (s)
26 // cout << "Const MapCenterObj canvas="<<s<<"\n";
31 MapCenterObj::~MapCenterObj()
33 // cout << "Destr MapCenterObj\n";
37 void MapCenterObj::clear()
42 void MapCenterObj::init ()
45 orientation=LinkableMapObj::UndefinedOrientation;
47 // TODO this should be done in TextObj later...
48 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
49 //heading->setFont(font);
51 setDefAttr(MovedBranch);
53 frame->setFrameType (FrameObj::Rectangle);
56 void MapCenterObj::move (double x, double y)
61 void MapCenterObj::move (QPointF absPos)
63 BranchObj::move(absPos);
66 void MapCenterObj::moveBy (double x, double y)
68 BranchObj::moveBy(x,y);
71 void MapCenterObj::moveAll (double x, double y)
74 double dx=x-absPos.x();
75 double dy=y-absPos.y();
77 // Move myself and branches
81 void MapCenterObj::moveAllBy (double dx, double dy)
83 // Move myself and children
84 BranchObj::moveBy(dx,dy);
87 void MapCenterObj::updateLink()
89 // set childPos to middle of MapCenterObj
90 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
91 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
93 for (int i=0; i<branch.size(); ++i)
94 branch.at(i)->updateLink();
97 void MapCenterObj::updateRelPositions()
99 if (repositionRequest) unsetAllRepositionRequests();
101 // update relative Positions of branches and floats
102 for (int i=0; i<branch.size(); ++i)
104 branch.at(i)->setRelPos();
105 branch.at(i)->setOrientation();
108 for (int i=0; i<floatimage.size(); ++i)
109 floatimage.at(i)->setRelPos();
111 if (repositionRequest) reposition();
114 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
118 // Search through child branches
119 for (int i=0; i<branch.size(); ++i)
121 lmo = branch.at(i)->findMapObj(p, excludeLMO);
122 if (lmo!= NULL) return lmo;
124 // is p in MapCenter?
125 if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
127 // Search float images
128 for (int i=0; i<floatimage.size(); ++i)
129 if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
135 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
139 // save area, if not scrolled
141 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
142 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
143 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
144 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
146 // Providing an ID for a branch makes export to XHTML easier
149 idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
154 QString linkAttr=getLinkAttr();
156 s=beginElement ("mapcenter"
160 +getIncludeImageAttr() );
162 if (heading->getColor()!=QColor("black"))
163 a=attribut ("textColor",QColor(heading->getColor()).name() );
167 // Save flags. If verbose is set (export to xml dir), also write
168 // the flags as picture
169 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
172 s+=valueElement("heading", getHeading(),a);
175 s+=frame->saveToDir ();
177 // add link to file in s
178 if (!note.isEmpty() )
182 for (int i=0; i<branch.size(); ++i)
183 s+=branch.at(i)->saveToDir(tmpdir,prefix, offset);
186 for (int i=0; i<floatimage.size(); ++i)
187 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
190 for (int i=0;i<xlink.size(); ++i)
191 s+=xlink.at(i)->saveToDir();
194 s+=endElement ("mapcenter");
198 void MapCenterObj::setVersion (const QString &s)
203 void MapCenterObj::setAuthor (const QString &s)
208 QString MapCenterObj::getAuthor()
213 void MapCenterObj::setComment (const QString &s)
218 QString MapCenterObj::getComment ()
223 QString MapCenterObj::getDate ()
225 return QDate::currentDate().toString ("yyyy-MM-dd");