historywindow moved to mainwindow. Started to get rid of Q3PtrList finally
3 #include "mapcenterobj.h"
4 #include "floatimageobj.h"
6 /////////////////////////////////////////////////////////////////
8 /////////////////////////////////////////////////////////////////
9 MapCenterObj::MapCenterObj() : BranchObj ()
11 // cout << "Const MapCenterObj\n";
15 MapCenterObj::MapCenterObj(Q3Canvas* c) : BranchObj (c)
17 // cout << "Const MapCenterObj canvas="<<c<<"\n";
21 MapCenterObj::~MapCenterObj()
23 // cout << "Destr MapCenterObj\n";
26 void MapCenterObj::clear()
31 void MapCenterObj::init ()
34 orientation=OrientUndef;
36 // FIXME this should be done in TextObj later...
37 //QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
38 //heading->setFont(font);
40 setDefAttr(MovedBranch);
42 frame->setFrameType (Rectangle);
45 void MapCenterObj::move (double x, double y)
50 void MapCenterObj::moveBy (double x, double y)
52 BranchObj::moveBy(x,y);
55 void MapCenterObj::moveAll (double x, double y)
58 double dx=x-absPos.x();
59 double dy=y-absPos.y();
61 // Move myself and branches
65 void MapCenterObj::moveAllBy (double dx, double dy)
67 // Move myself and childs
68 BranchObj::moveBy(dx,dy);
71 void MapCenterObj::updateLink()
73 // set childPos to middle of MapCenterObj
74 childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
75 childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
78 for (b=branch.first(); b; b=branch.next() )
82 void MapCenterObj::updateRelPositions()
84 if (repositionRequest) unsetAllRepositionRequests();
86 // update relative Positions of branches and floats
88 for (b=branch.first(); b; b=branch.next() )
94 for (int i=0; i<floatimage.size(); ++i)
95 floatimage.at(i)->setRelPos();
97 if (repositionRequest) reposition();
100 LinkableMapObj* MapCenterObj::findMapObj(QPoint p, LinkableMapObj *excludeLMO)
105 // Search through child branches
106 for (bo=branch.first(); bo; bo=branch.next() )
108 lmo = bo->findMapObj(p, excludeLMO);
109 if (lmo!= NULL) return lmo;
111 // is p in MapCenter?
112 if (inBox (p) && (this != excludeLMO) ) return this;
114 // Search float images
115 for (int i=0; i<floatimage.size(); ++i)
116 if (floatimage.at(i)->inBox(p) && (floatimage.at(i) != excludeLMO) && floatimage.at(i)->getParObj()!= excludeLMO) return floatimage.at(i);
122 QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPoint &offset)
126 // save area, if not scrolled
128 attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
129 attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
130 attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
131 attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
133 // Providing an ID for a branch makes export to XHTML easier
136 idAttr=attribut ("id",getSelectString());
140 QString linkAttr=getLinkAttr();
142 s=beginElement ("mapcenter"
144 +attribut("frameType",frame->getFrameTypeName())
147 +getIncludeImageAttr() );
149 if (heading->getColor()!=QColor("black"))
150 a=attribut ("textColor",QColor(heading->getColor()).name() );
154 // Save flags. If verbose is set (export to xml dir), also write
155 // the flags as picture
156 s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
157 s=s+valueElement("heading", getHeading(),a);
159 // add link to file in s
160 if (!note.isEmpty() )
165 for (bo=branch.first(); bo; bo=branch.next() )
166 s+=bo->saveToDir(tmpdir,prefix, offset);
169 for (int i=0; i<floatimage.size(); ++i)
170 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
174 for (xlo=xlink.first(); xlo; xlo=xlink.next() )
178 s+=endElement ("mapcenter");
182 void MapCenterObj::setVersion (const QString &s)
187 void MapCenterObj::setAuthor (const QString &s)
192 QString MapCenterObj::getAuthor()
197 void MapCenterObj::setComment (const QString &s)
202 QString MapCenterObj::getComment ()
207 QString MapCenterObj::getDate ()
209 return QDate::currentDate().toString ("yyyy-MM-dd");