3 #include "mapcenterobj.h"
4 #include "floatimageobj.h"
7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
10 MapCenterObj::MapCenterObj() : BranchObj ()
12 // cout << "Const MapCenterObj\n";
16 MapCenterObj::MapCenterObj(Q3Canvas* 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);
56 void MapCenterObj::moveAll (double x, double y)
59 double dx=x-absPos.x();
60 double dy=y-absPos.y();
62 // Move myself and branches
66 void MapCenterObj::moveAllBy (double dx, double dy)
68 // Move myself and childs
69 BranchObj::moveBy(dx,dy);
72 void MapCenterObj::updateLink()
74 // set childPos to middle of MapCenterObj
75 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
76 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
79 for (b=branch.first(); b; b=branch.next() )
83 void MapCenterObj::updateRelPositions()
85 if (repositionRequest) unsetAllRepositionRequests();
87 // update relative Positions of branches and floats
89 for (b=branch.first(); b; b=branch.next() )
96 for (fo=floatimage.first(); fo; fo=floatimage.next() ) fo->setRelPos();
98 if (repositionRequest) reposition();
101 LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO)
106 // Search through child branches
107 for (bo=branch.first(); bo; bo=branch.next() )
109 lmo = bo->findMapObj(p, excludeLMO);
110 if (lmo!= NULL) return lmo;
112 // is p in MapCenter?
113 if (inBox (p) && (this != excludeLMO) ) return this;
115 // Search float images
117 for (foi=floatimage.first(); foi; foi=floatimage.next() )
118 if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
124 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset)
128 // save area, if not scrolled
130 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
131 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
132 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
133 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
135 // Providing an ID for a branch makes export to XHTML easier
138 idAttr=attribut ("id",getSelectString());
142 QString linkAttr=getLinkAttr();
144 s=beginElement ("mapcenter"
146 +attribut("frameType",frame->getFrameTypeName())
149 +getIncludeImageAttr() );
151 if (heading->getColor()!=QColor("black"))
152 a=attribut ("textColor",QColor(heading->getColor()).name() );
156 // Save flags. If verbose is set (export to xml dir), also write
157 // the flags as picture
158 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
159 s=s+valueElement("heading", getHeading(),a);
161 // add link to file in s
162 if (!note.isEmpty() )
167 for (bo=branch.first(); bo; bo=branch.next() )
168 s+=bo->saveToDir(tmpdir,prefix, offset);
172 for (fio=floatimage.first(); fio; fio=floatimage.next() )
173 s+=fio->saveToDir (tmpdir,prefix);
177 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
181 s+=endElement ("mapcenter");
185 void MapCenterObj::setVersion (const QString &s)
190 bool MapCenterObj::checkVersion ()
192 // returns true, if vym is able to read file regarding
193 // the version set with setVersion
194 QString s1=version.section (".",0,0);
195 QString s2=version.section (".",1,1);
196 QString s3=version.section (".",2,2);
198 int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10);
199 int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10);
200 int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10);
204 if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
205 if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
206 if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
223 void MapCenterObj::setAuthor (const QString &s)
228 QString MapCenterObj::getAuthor()
233 void MapCenterObj::setComment (const QString &s)
238 QString MapCenterObj::getComment ()
243 QString MapCenterObj::getDate ()
245 return QDate::currentDate().toString ("yyyy-MM-dd");