insilmaril@406
|
1 |
#include <QDateTime>
|
insilmaril@0
|
2 |
|
insilmaril@641
|
3 |
#include "floatimageobj.h"
|
insilmaril@641
|
4 |
#include "geometry.h"
|
insilmaril@0
|
5 |
#include "mapcenterobj.h"
|
insilmaril@0
|
6 |
|
insilmaril@0
|
7 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
8 |
// MapCenterObj
|
insilmaril@0
|
9 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
10 |
MapCenterObj::MapCenterObj() : BranchObj ()
|
insilmaril@0
|
11 |
{
|
insilmaril@0
|
12 |
// cout << "Const MapCenterObj\n";
|
insilmaril@0
|
13 |
init();
|
insilmaril@0
|
14 |
}
|
insilmaril@0
|
15 |
|
insilmaril@408
|
16 |
MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s)
|
insilmaril@0
|
17 |
{
|
insilmaril@408
|
18 |
// cout << "Const MapCenterObj canvas="<<s<<"\n";
|
insilmaril@0
|
19 |
init();
|
insilmaril@0
|
20 |
}
|
insilmaril@0
|
21 |
|
insilmaril@727
|
22 |
MapCenterObj::MapCenterObj(QGraphicsScene* s,VymModel *m) : BranchObj (s)
|
insilmaril@727
|
23 |
{
|
insilmaril@727
|
24 |
// cout << "Const MapCenterObj canvas="<<s<<"\n";
|
insilmaril@727
|
25 |
model=m;
|
insilmaril@727
|
26 |
init();
|
insilmaril@727
|
27 |
}
|
insilmaril@727
|
28 |
|
insilmaril@0
|
29 |
MapCenterObj::~MapCenterObj()
|
insilmaril@0
|
30 |
{
|
insilmaril@421
|
31 |
// cout << "Destr MapCenterObj\n";
|
insilmaril@661
|
32 |
clear();
|
insilmaril@0
|
33 |
}
|
insilmaril@0
|
34 |
|
insilmaril@0
|
35 |
void MapCenterObj::clear()
|
insilmaril@0
|
36 |
{
|
insilmaril@0
|
37 |
BranchObj::clear();
|
insilmaril@0
|
38 |
}
|
insilmaril@0
|
39 |
|
insilmaril@0
|
40 |
void MapCenterObj::init ()
|
insilmaril@0
|
41 |
{
|
insilmaril@83
|
42 |
BranchObj::init();
|
insilmaril@459
|
43 |
orientation=LinkableMapObj::UndefinedOrientation;
|
insilmaril@0
|
44 |
|
insilmaril@411
|
45 |
// TODO this should be done in TextObj later...
|
insilmaril@164
|
46 |
//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");
|
insilmaril@164
|
47 |
//heading->setFont(font);
|
insilmaril@760
|
48 |
//FIXME-2 no treeitem yet: setDefAttr(MovedBranch);
|
insilmaril@0
|
49 |
|
insilmaril@459
|
50 |
frame->setFrameType (FrameObj::Rectangle);
|
insilmaril@0
|
51 |
}
|
insilmaril@0
|
52 |
|
insilmaril@0
|
53 |
void MapCenterObj::move (double x, double y)
|
insilmaril@0
|
54 |
{
|
insilmaril@0
|
55 |
BranchObj::move(x,y);
|
insilmaril@0
|
56 |
}
|
insilmaril@0
|
57 |
|
insilmaril@681
|
58 |
void MapCenterObj::move (QPointF absPos)
|
insilmaril@681
|
59 |
{
|
insilmaril@681
|
60 |
BranchObj::move(absPos);
|
insilmaril@681
|
61 |
}
|
insilmaril@681
|
62 |
|
insilmaril@0
|
63 |
void MapCenterObj::moveBy (double x, double y)
|
insilmaril@0
|
64 |
{
|
insilmaril@169
|
65 |
BranchObj::moveBy(x,y);
|
insilmaril@0
|
66 |
}
|
insilmaril@0
|
67 |
|
insilmaril@0
|
68 |
void MapCenterObj::moveAll (double x, double y)
|
insilmaril@0
|
69 |
{
|
insilmaril@0
|
70 |
// Get rel. position
|
insilmaril@0
|
71 |
double dx=x-absPos.x();
|
insilmaril@0
|
72 |
double dy=y-absPos.y();
|
insilmaril@0
|
73 |
|
insilmaril@0
|
74 |
// Move myself and branches
|
insilmaril@0
|
75 |
moveAllBy (dx,dy);
|
insilmaril@0
|
76 |
}
|
insilmaril@0
|
77 |
|
insilmaril@0
|
78 |
void MapCenterObj::moveAllBy (double dx, double dy)
|
insilmaril@0
|
79 |
{
|
insilmaril@721
|
80 |
// Move myself and children
|
insilmaril@388
|
81 |
BranchObj::moveBy(dx,dy);
|
insilmaril@0
|
82 |
}
|
insilmaril@0
|
83 |
|
insilmaril@0
|
84 |
void MapCenterObj::updateLink()
|
insilmaril@0
|
85 |
{
|
insilmaril@0
|
86 |
// set childPos to middle of MapCenterObj
|
insilmaril@169
|
87 |
childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
|
insilmaril@169
|
88 |
childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
|
insilmaril@0
|
89 |
parPos=childPos;
|
insilmaril@753
|
90 |
for (int i=0; i<treeItem->branchCount(); ++i)
|
insilmaril@753
|
91 |
treeItem->getBranchObjNum(i)->updateLink();
|
insilmaril@0
|
92 |
}
|
insilmaril@0
|
93 |
|
insilmaril@388
|
94 |
void MapCenterObj::updateRelPositions()
|
insilmaril@388
|
95 |
{
|
insilmaril@388
|
96 |
if (repositionRequest) unsetAllRepositionRequests();
|
insilmaril@388
|
97 |
|
insilmaril@388
|
98 |
// update relative Positions of branches and floats
|
insilmaril@753
|
99 |
for (int i=0; i<treeItem->branchCount(); ++i)
|
insilmaril@388
|
100 |
{
|
insilmaril@753
|
101 |
treeItem->getBranchObjNum(i)->setRelPos();
|
insilmaril@753
|
102 |
treeItem->getBranchObjNum(i)->setOrientation();
|
insilmaril@388
|
103 |
}
|
insilmaril@388
|
104 |
|
insilmaril@404
|
105 |
for (int i=0; i<floatimage.size(); ++i)
|
insilmaril@404
|
106 |
floatimage.at(i)->setRelPos();
|
insilmaril@388
|
107 |
|
insilmaril@388
|
108 |
if (repositionRequest) reposition();
|
insilmaril@388
|
109 |
}
|
insilmaril@388
|
110 |
|
insilmaril@408
|
111 |
QString MapCenterObj::saveToDir (const QString &tmpdir,const QString &prefix, int verbose, const QPointF &offset)
|
insilmaril@0
|
112 |
{
|
insilmaril@0
|
113 |
QString s,a;
|
insilmaril@0
|
114 |
|
insilmaril@766
|
115 |
/*
|
insilmaril@0
|
116 |
// save area, if not scrolled
|
insilmaril@0
|
117 |
QString areaAttr=
|
insilmaril@408
|
118 |
attribut("x1",QString().setNum(absPos.x()-offset.x())) +
|
insilmaril@408
|
119 |
attribut("y1",QString().setNum(absPos.y()-offset.y())) +
|
insilmaril@408
|
120 |
attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
|
insilmaril@408
|
121 |
attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
|
insilmaril@0
|
122 |
|
insilmaril@169
|
123 |
// Providing an ID for a branch makes export to XHTML easier
|
insilmaril@766
|
124 |
// FIXME-3
|
insilmaril@169
|
125 |
QString idAttr;
|
insilmaril@749
|
126 |
if (treeItem->xlinkCount()>0)
|
insilmaril@681
|
127 |
idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
|
insilmaril@681
|
128 |
|
insilmaril@169
|
129 |
else
|
insilmaril@169
|
130 |
idAttr="";
|
insilmaril@766
|
131 |
|
insilmaril@169
|
132 |
|
insilmaril@169
|
133 |
QString linkAttr=getLinkAttr();
|
insilmaril@169
|
134 |
|
insilmaril@0
|
135 |
s=beginElement ("mapcenter"
|
insilmaril@628
|
136 |
+getOrnXMLAttr()
|
insilmaril@0
|
137 |
+areaAttr
|
insilmaril@754
|
138 |
// +idAttr
|
insilmaril@239
|
139 |
+getIncludeImageAttr() );
|
insilmaril@0
|
140 |
incIndent();
|
insilmaril@0
|
141 |
if (heading->getColor()!=QColor("black"))
|
insilmaril@0
|
142 |
a=attribut ("textColor",QColor(heading->getColor()).name() );
|
insilmaril@0
|
143 |
else
|
insilmaril@0
|
144 |
a="";
|
insilmaril@0
|
145 |
|
insilmaril@0
|
146 |
// Save flags. If verbose is set (export to xml dir), also write
|
insilmaril@0
|
147 |
// the flags as picture
|
insilmaril@0
|
148 |
s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
|
insilmaril@421
|
149 |
|
insilmaril@421
|
150 |
// Save heading
|
insilmaril@753
|
151 |
s+=valueElement("heading", treeItem->getHeading(),a);
|
insilmaril@421
|
152 |
|
insilmaril@421
|
153 |
// Save frame
|
insilmaril@421
|
154 |
s+=frame->saveToDir ();
|
insilmaril@0
|
155 |
|
insilmaril@729
|
156 |
// Update of note is usually done while unselecting a branch
|
insilmaril@746
|
157 |
//if (isNoteInEditor) getNoteFromTextEditor(); FIXME-3
|
insilmaril@729
|
158 |
|
insilmaril@729
|
159 |
// save note
|
insilmaril@746
|
160 |
if (!treeItem->getNoteObj().isEmpty() )
|
insilmaril@746
|
161 |
s+=treeItem->getNoteObj().saveToDir();
|
insilmaril@0
|
162 |
|
insilmaril@95
|
163 |
// Save branches
|
insilmaril@753
|
164 |
for (int i=0; i<treeItem->branchCount(); ++i)
|
insilmaril@753
|
165 |
s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix, offset);
|
insilmaril@95
|
166 |
|
insilmaril@0
|
167 |
// Save FloatImages
|
insilmaril@404
|
168 |
for (int i=0; i<floatimage.size(); ++i)
|
insilmaril@404
|
169 |
s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
|
insilmaril@0
|
170 |
|
insilmaril@95
|
171 |
// Save XLinks
|
insilmaril@406
|
172 |
for (int i=0;i<xlink.size(); ++i)
|
insilmaril@406
|
173 |
s+=xlink.at(i)->saveToDir();
|
insilmaril@0
|
174 |
|
insilmaril@0
|
175 |
decIndent();
|
insilmaril@0
|
176 |
s+=endElement ("mapcenter");
|
insilmaril@766
|
177 |
*/
|
insilmaril@0
|
178 |
return s;
|
insilmaril@0
|
179 |
}
|
insilmaril@0
|
180 |
|
insilmaril@0
|
181 |
void MapCenterObj::setVersion (const QString &s)
|
insilmaril@0
|
182 |
{
|
insilmaril@0
|
183 |
version=s;
|
insilmaril@0
|
184 |
}
|
insilmaril@0
|
185 |
|
insilmaril@0
|
186 |
void MapCenterObj::setAuthor (const QString &s)
|
insilmaril@0
|
187 |
{
|
insilmaril@0
|
188 |
author=s;
|
insilmaril@0
|
189 |
}
|
insilmaril@0
|
190 |
|
insilmaril@0
|
191 |
QString MapCenterObj::getAuthor()
|
insilmaril@0
|
192 |
{
|
insilmaril@0
|
193 |
return author;
|
insilmaril@0
|
194 |
}
|
insilmaril@0
|
195 |
|
insilmaril@0
|
196 |
void MapCenterObj::setComment (const QString &s)
|
insilmaril@0
|
197 |
{
|
insilmaril@0
|
198 |
comment=s;
|
insilmaril@0
|
199 |
}
|
insilmaril@0
|
200 |
|
insilmaril@0
|
201 |
QString MapCenterObj::getComment ()
|
insilmaril@0
|
202 |
{
|
insilmaril@0
|
203 |
return comment;
|
insilmaril@0
|
204 |
}
|
insilmaril@0
|
205 |
|
insilmaril@0
|
206 |
QString MapCenterObj::getDate ()
|
insilmaril@0
|
207 |
{
|
insilmaril@0
|
208 |
return QDate::currentDate().toString ("yyyy-MM-dd");
|
insilmaril@0
|
209 |
}
|
insilmaril@83
|
210 |
|