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);
49 setDefAttr(MovedBranch);
51 frame->setFrameType (FrameObj::Rectangle);
54 void MapCenterObj::move (double x, double y)
59 void MapCenterObj::move (QPointF absPos)
61 BranchObj::move(absPos);
64 void MapCenterObj::moveBy (double x, double y)
66 BranchObj::moveBy(x,y);
69 void MapCenterObj::moveAll (double x, double y)
72 double dx=x-absPos.x();
73 double dy=y-absPos.y();
75 // Move myself and branches
79 void MapCenterObj::moveAllBy (double dx, double dy)
81 // Move myself and children
82 BranchObj::moveBy(dx,dy);
85 void MapCenterObj::updateLink()
87 // set childPos to middle of MapCenterObj
88 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
89 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
91 for (int i=0; i<treeItem->branchCount(); ++i)
92 treeItem->getBranchObjNum(i)->updateLink();
95 void MapCenterObj::updateRelPositions()
97 if (repositionRequest) unsetAllRepositionRequests();
99 // update relative Positions of branches and floats
100 for (int i=0; i<treeItem->branchCount(); ++i)
102 treeItem->getBranchObjNum(i)->setRelPos();
103 treeItem->getBranchObjNum(i)->setOrientation();
106 for (int i=0; i<floatimage.size(); ++i)
107 floatimage.at(i)->setRelPos();
109 if (repositionRequest) reposition();
112 LinkableMapObj* MapCenterObj::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
114 /* FIXME-1 should not be necessary
117 // Search through child branches
118 for (int i=0; i<treeItem->branchCount(); ++i)
120 lmo = treeItem->getBranchObjNum(i)->findMapObj(p, excludeLMO);
121 if (lmo!= NULL) return lmo;
123 // is p in MapCenter?
124 if (inBox (p,clickBox) && (this != excludeLMO) ) return this;
126 // Search float images
127 for (int i=0; i<floatimage.size(); ++i)
128 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 if (treeItem->xlinkCount()>0)
150 idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
156 QString linkAttr=getLinkAttr();
158 s=beginElement ("mapcenter"
162 +getIncludeImageAttr() );
164 if (heading->getColor()!=QColor("black"))
165 a=attribut ("textColor",QColor(heading->getColor()).name() );
169 // Save flags. If verbose is set (export to xml dir), also write
170 // the flags as picture
171 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
174 s+=valueElement("heading", treeItem->getHeading(),a);
177 s+=frame->saveToDir ();
179 // Update of note is usually done while unselecting a branch
180 //if (isNoteInEditor) getNoteFromTextEditor(); FIXME-3
183 if (!treeItem->getNoteObj().isEmpty() )
184 s+=treeItem->getNoteObj().saveToDir();
187 for (int i=0; i<treeItem->branchCount(); ++i)
188 s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix, offset);
191 for (int i=0; i<floatimage.size(); ++i)
192 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
195 for (int i=0;i<xlink.size(); ++i)
196 s+=xlink.at(i)->saveToDir();
199 s+=endElement ("mapcenter");
203 void MapCenterObj::setVersion (const QString &s)
208 void MapCenterObj::setAuthor (const QString &s)
213 QString MapCenterObj::getAuthor()
218 void MapCenterObj::setComment (const QString &s)
223 QString MapCenterObj::getComment ()
228 QString MapCenterObj::getDate ()
230 return QDate::currentDate().toString ("yyyy-MM-dd");