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(QGraphicsScene* s,VymModel *m) : BranchObj (s)
24 // cout << "Const MapCenterObj canvas="<<s<<"\n";
29 MapCenterObj::~MapCenterObj()
31 // cout << "Destr MapCenterObj\n";
35 void MapCenterObj::clear()
40 void MapCenterObj::init ()
43 orientation=LinkableMapObj::UndefinedOrientation;
45 // TODO this should be done in TextObj later...
46 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
47 //heading->setFont(font);
48 setDefAttr(MovedBranch);
50 frame->setFrameType (FrameObj::Rectangle);
53 void MapCenterObj::move (double x, double y)
58 void MapCenterObj::move (QPointF absPos)
60 BranchObj::move(absPos);
63 void MapCenterObj::moveBy (double x, double y)
65 BranchObj::moveBy(x,y);
68 void MapCenterObj::moveAll (double x, double y)
71 double dx=x-absPos.x();
72 double dy=y-absPos.y();
74 // Move myself and branches
78 void MapCenterObj::moveAllBy (double dx, double dy)
80 // Move myself and children
81 BranchObj::moveBy(dx,dy);
84 void MapCenterObj::updateLink()
86 // set childPos to middle of MapCenterObj
87 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
88 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
90 for (int i=0; i<treeItem->branchCount(); ++i)
91 treeItem->getBranchObjNum(i)->updateLink();
94 void MapCenterObj::updateRelPositions()
96 if (repositionRequest) unsetAllRepositionRequests();
98 // update relative Positions of branches and floats
99 for (int i=0; i<treeItem->branchCount(); ++i)
101 treeItem->getBranchObjNum(i)->setRelPos();
102 treeItem->getBranchObjNum(i)->setOrientation();
105 for (int i=0; i<floatimage.size(); ++i)
106 floatimage.at(i)->setRelPos();
108 if (repositionRequest) reposition();
111 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
113 /* FIXME-1 should not be necessary
116 // Search through child branches
117 for (int i=0; i<treeItem->branchCount(); ++i)
119 lmo = treeItem->getBranchObjNum(i)->findMapObj(p, excludeLMO);
120 if (lmo!= NULL) return lmo;
122 // is p in MapCenter?
123 if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
125 // Search float images
126 for (int i=0; i<floatimage.size(); ++i)
127 if (inBox(p,floatimage.at(i)->getClickBox()) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
134 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
138 // save area, if not scrolled
140 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
141 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
142 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
143 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
145 // Providing an ID for a branch makes export to XHTML easier
148 if (treeItem->xlinkCount()>0)
149 idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
155 QString linkAttr=getLinkAttr();
157 s=beginElement ("mapcenter"
161 +getIncludeImageAttr() );
163 if (heading->getColor()!=QColor("black"))
164 a=attribut ("textColor",QColor(heading->getColor()).name() );
168 // Save flags. If verbose is set (export to xml dir), also write
169 // the flags as picture
170 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
173 s+=valueElement("heading", treeItem->getHeading(),a);
176 s+=frame->saveToDir ();
178 // Update of note is usually done while unselecting a branch
179 //if (isNoteInEditor) getNoteFromTextEditor(); FIXME-3
182 if (!treeItem->getNoteObj().isEmpty() )
183 s+=treeItem->getNoteObj().saveToDir();
186 for (int i=0; i<treeItem->branchCount(); ++i)
187 s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix, offset);
190 for (int i=0; i<floatimage.size(); ++i)
191 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
194 for (int i=0;i<xlink.size(); ++i)
195 s+=xlink.at(i)->saveToDir();
198 s+=endElement ("mapcenter");
202 void MapCenterObj::setVersion (const QString &s)
207 void MapCenterObj::setAuthor (const QString &s)
212 QString MapCenterObj::getAuthor()
217 void MapCenterObj::setComment (const QString &s)
222 QString MapCenterObj::getComment ()
227 QString MapCenterObj::getDate ()
229 return QDate::currentDate().toString ("yyyy-MM-dd");