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;
37 // FIXME this should be done in TextObj later...
38 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
39 //heading->setFont(font);
41 setDefAttr(MovedBranch);
43 frame->setFrameType (Rectangle);
46 void MapCenterObj::move (double x, double y)
51 void MapCenterObj::moveBy (double x, double y)
53 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)
75 void MapCenterObj::updateLink()
77 // set childPos to middle of MapCenterObj
78 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
79 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
82 for (b=branch.first(); b; b=branch.next() )
86 LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO)
91 // Search through child branches
92 for (bo=branch.first(); bo; bo=branch.next() )
94 lmo = bo->findMapObj(p, excludeLMO);
95 if (lmo!= NULL) return lmo;
98 if (inBox (p) && (this != excludeLMO) ) return this;
100 // Search float images
102 for (foi=floatimage.first(); foi; foi=floatimage.next() )
103 if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
109 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset)
113 // save area, if not scrolled
115 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
116 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
117 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
118 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
120 // Providing an ID for a branch makes export to XHTML easier
123 idAttr=attribut ("id",getSelectString());
127 QString linkAttr=getLinkAttr();
131 urlAttr=attribut ("url",url);
133 if (!vymLink.isEmpty())
134 vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
136 s=beginElement ("mapcenter"
137 +attribut("absPosX",QString().setNum(absPos.x(),10))
138 +attribut("absPosY",QString().setNum(absPos.y(),10))
143 +attribut("frameType",frame->getFrameTypeName())
148 if (heading->getColor()!=QColor("black"))
149 a=attribut ("textColor",QColor(heading->getColor()).name() );
153 // Save flags. If verbose is set (export to xml dir), also write
154 // the flags as picture
155 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
156 s=s+valueElement("heading", getHeading(),a);
158 // add link to file in s
159 if (!note.isEmpty() )
164 for (bo=branch.first(); bo; bo=branch.next() )
165 s+=bo->saveToDir(tmpdir,prefix, offset);
169 for (fio=floatimage.first(); fio; fio=floatimage.next() )
170 s+=fio->saveToDir (tmpdir,prefix,offset);
174 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
178 s+=endElement ("mapcenter");
182 void MapCenterObj::setVersion (const QString &s)
187 bool MapCenterObj::checkVersion ()
189 // returns true, if vym is able to read file regarding
190 // the version set with setVersion
191 QString s1=version.section (".",0,0);
192 QString s2=version.section (".",1,1);
193 QString s3=version.section (".",2,2);
195 int vv1 =QString(__VYM_VERSION__).section (".",0,0).toInt(&ok,10);
196 int vv2 =QString(__VYM_VERSION__).section (".",1,1).toInt(&ok,10);
197 int vv3 =QString(__VYM_VERSION__).section (".",2,2).toInt(&ok,10);
201 if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
202 if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
203 if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
220 void MapCenterObj::setAuthor (const QString &s)
225 QString MapCenterObj::getAuthor()
230 void MapCenterObj::setComment (const QString &s)
235 QString MapCenterObj::getComment ()
240 QString MapCenterObj::getDate ()
242 return QDate::currentDate().toString ("yyyy-MM-dd");