3 #include "mapcenterobj.h"
4 #include "floatimageobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
10 MapCenterObj::MapCenterObj() : BranchObj ()
12 // cout << "Const MapCenterObj\n";
16 MapCenterObj::MapCenterObj(QCanvas* c) : BranchObj (c)
18 // cout << "Const MapCenterObj canvas="<<c<<"\n";
22 MapCenterObj::~MapCenterObj()
24 // cout << "Destr MapCenterObj\n";
27 void MapCenterObj::clear()
32 void MapCenterObj::init ()
35 orientation=OrientUndef;
36 absPos=QPoint (canvas->width()/2, canvas->height()/2);
38 // FIXME 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);
45 frame->setFrameType (Rectangle);
46 move (absPos.x(), absPos.y() );
49 void MapCenterObj::move (double x, double y)
55 void MapCenterObj::moveBy (double x, double y)
57 BranchObj::moveBy(x,y);
61 void MapCenterObj::moveAll (double x, double y)
64 double dx=x-absPos.x();
65 double dy=y-absPos.y();
67 // Move myself and branches
71 void MapCenterObj::moveAllBy (double dx, double dy)
79 void MapCenterObj::updateLink()
81 // set childPos to middle of MapCenterObj
83 absPos.x() + QSize(getSize() ).width()/2,
84 absPos.y() + QSize(getSize() ).height()/2);
87 for (b=branch.first(); b; b=branch.next() )
91 LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO)
96 // Search through child branches
97 for (bo=branch.first(); bo; bo=branch.next() )
99 lmo = bo->findMapObj(p, excludeLMO);
106 // is p in MapCenter?
107 if (inBBox (p) && (this != excludeLMO) ) return this;
109 // Search float images
111 for (foi=floatimage.first(); foi; foi=floatimage.next() )
112 if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
118 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset)
122 // save area, if not scrolled
124 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
125 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
126 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
127 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
129 s=beginElement ("mapcenter"
130 +attribut("absPosX",QString().setNum(absPos.x(),10))
131 +attribut("absPosY",QString().setNum(absPos.y(),10))
132 +attribut("frameType",frame->getFrameTypeName())
137 if (heading->getColor()!=QColor("black"))
138 a=attribut ("textColor",QColor(heading->getColor()).name() );
142 // Save flags. If verbose is set (export to xml dir), also write
143 // the flags as picture
144 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
145 s=s+valueElement("heading", getHeading(),a);
147 // Reset the counters before saving
148 FloatImageObj (canvas).resetSaveCounter();
150 // add link to file in s
151 if (!note.isEmpty() )
156 for (bo=branch.first(); bo; bo=branch.next() )
157 s+=bo->saveToDir(tmpdir,prefix, offset);
161 for (fio=floatimage.first(); fio; fio=floatimage.next() )
162 s+=fio->saveToDir (tmpdir,prefix);
166 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
170 s+=endElement ("mapcenter");
174 void MapCenterObj::setVersion (const QString &s)
179 bool MapCenterObj::checkVersion ()
181 // returns true, if vym is able to read file regarding
182 // the version set with setVersion
183 QString s1=version.section (".",0,0);
184 QString s2=version.section (".",1,1);
185 QString s3=version.section (".",2,2);
187 int vv1 =QString(__VYM_VERSION__).section (".",0,0).toInt(&ok,10);
188 int vv2 =QString(__VYM_VERSION__).section (".",1,1).toInt(&ok,10);
189 int vv3 =QString(__VYM_VERSION__).section (".",2,2).toInt(&ok,10);
193 if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
194 if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
195 if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
212 void MapCenterObj::setAuthor (const QString &s)
217 QString MapCenterObj::getAuthor()
222 void MapCenterObj::setComment (const QString &s)
227 QString MapCenterObj::getComment ()
232 QString MapCenterObj::getDate ()
234 return QDate::currentDate().toString ("yyyy-MM-dd");