insilmaril@0
|
1 |
#include "branchobj.h"
|
insilmaril@0
|
2 |
#include "texteditor.h"
|
insilmaril@0
|
3 |
#include "mapeditor.h"
|
insilmaril@0
|
4 |
#include "mainwindow.h"
|
insilmaril@0
|
5 |
|
insilmaril@0
|
6 |
extern TextEditor *textEditor;
|
insilmaril@0
|
7 |
extern Main *mainWindow;
|
insilmaril@0
|
8 |
extern FlagRowObj *standardFlagsDefault;
|
insilmaril@0
|
9 |
extern QAction *actionEditOpenURL;
|
insilmaril@0
|
10 |
|
insilmaril@0
|
11 |
|
insilmaril@0
|
12 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
13 |
// BranchObj
|
insilmaril@0
|
14 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
15 |
|
insilmaril@0
|
16 |
BranchObj* BranchObj::itLast=NULL;
|
insilmaril@0
|
17 |
|
insilmaril@0
|
18 |
|
insilmaril@0
|
19 |
BranchObj::BranchObj () :OrnamentedObj()
|
insilmaril@0
|
20 |
{
|
insilmaril@0
|
21 |
// cout << "Const BranchObj ()\n";
|
insilmaril@0
|
22 |
setParObj (this);
|
insilmaril@0
|
23 |
init();
|
insilmaril@0
|
24 |
depth=-1;
|
insilmaril@0
|
25 |
}
|
insilmaril@0
|
26 |
|
insilmaril@0
|
27 |
BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c)
|
insilmaril@0
|
28 |
{
|
insilmaril@0
|
29 |
// cout << "Const BranchObj (c) called from MapCenterObj (c)\n";
|
insilmaril@83
|
30 |
parObj=NULL;
|
insilmaril@0
|
31 |
canvas=c;
|
insilmaril@0
|
32 |
}
|
insilmaril@0
|
33 |
|
insilmaril@0
|
34 |
BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c)
|
insilmaril@0
|
35 |
{
|
insilmaril@0
|
36 |
// cout << "Const BranchObj (c,p)\n";
|
insilmaril@0
|
37 |
canvas=c;
|
insilmaril@0
|
38 |
setParObj (p);
|
insilmaril@0
|
39 |
depth=p->getDepth()+1;
|
insilmaril@0
|
40 |
if (depth==1)
|
insilmaril@0
|
41 |
// Calc angle to mapCenter if I am a mainbranch
|
insilmaril@0
|
42 |
// needed for reordering the mainbranches clockwise
|
insilmaril@0
|
43 |
// around mapcenter
|
insilmaril@0
|
44 |
angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
|
insilmaril@0
|
45 |
(int)(y() - parObj->getChildPos().y() ) ) );
|
insilmaril@0
|
46 |
init();
|
insilmaril@0
|
47 |
}
|
insilmaril@0
|
48 |
|
insilmaril@0
|
49 |
BranchObj::~BranchObj ()
|
insilmaril@0
|
50 |
{
|
insilmaril@83
|
51 |
// cout << "Destr BranchObj of "<<this<<endl;
|
insilmaril@0
|
52 |
// Check, if this branch was the last child to be deleted
|
insilmaril@0
|
53 |
// If so, unset the scrolled flags
|
insilmaril@0
|
54 |
|
insilmaril@0
|
55 |
BranchObj *po=(BranchObj*)(parObj);
|
insilmaril@83
|
56 |
BranchObj *bo;
|
insilmaril@0
|
57 |
if (po)
|
insilmaril@0
|
58 |
{
|
insilmaril@83
|
59 |
bo=((BranchObj*)(parObj))->getLastBranch();
|
insilmaril@0
|
60 |
if (!bo) po->unScroll();
|
insilmaril@0
|
61 |
}
|
insilmaril@83
|
62 |
clear();
|
insilmaril@0
|
63 |
}
|
insilmaril@0
|
64 |
|
insilmaril@0
|
65 |
bool BranchObj::operator< ( const BranchObj & other )
|
insilmaril@0
|
66 |
{
|
insilmaril@0
|
67 |
return angle < other.angle;
|
insilmaril@0
|
68 |
}
|
insilmaril@0
|
69 |
|
insilmaril@0
|
70 |
bool BranchObj::operator== ( const BranchObj & other )
|
insilmaril@0
|
71 |
{
|
insilmaril@0
|
72 |
return angle == other.angle;
|
insilmaril@0
|
73 |
}
|
insilmaril@0
|
74 |
|
insilmaril@0
|
75 |
int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j)
|
insilmaril@0
|
76 |
{
|
insilmaril@0
|
77 |
// Make sure PtrList::find works
|
insilmaril@0
|
78 |
if (i==j) return 0;
|
insilmaril@0
|
79 |
|
insilmaril@0
|
80 |
if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle )
|
insilmaril@0
|
81 |
return 1;
|
insilmaril@0
|
82 |
else
|
insilmaril@0
|
83 |
return -1;
|
insilmaril@0
|
84 |
}
|
insilmaril@0
|
85 |
|
insilmaril@0
|
86 |
void BranchObj::init ()
|
insilmaril@0
|
87 |
{
|
insilmaril@83
|
88 |
branch.setAutoDelete (false);
|
insilmaril@0
|
89 |
floatimage.setAutoDelete (true);
|
insilmaril@95
|
90 |
xlink.setAutoDelete (false);
|
insilmaril@0
|
91 |
|
insilmaril@83
|
92 |
if (parObj)
|
insilmaril@83
|
93 |
{
|
insilmaril@83
|
94 |
absPos=getRandPos();
|
insilmaril@83
|
95 |
absPos+=parObj->getChildPos();
|
insilmaril@83
|
96 |
}
|
insilmaril@0
|
97 |
|
insilmaril@0
|
98 |
lastSelectedBranch=-1;
|
insilmaril@0
|
99 |
|
insilmaril@0
|
100 |
setChildObj(this);
|
insilmaril@0
|
101 |
|
insilmaril@0
|
102 |
scrolled=false;
|
insilmaril@0
|
103 |
tmpUnscrolled=false;
|
insilmaril@0
|
104 |
|
insilmaril@169
|
105 |
includeImagesVer=false;
|
insilmaril@169
|
106 |
includeImagesHor=false;
|
insilmaril@169
|
107 |
|
insilmaril@0
|
108 |
url="";
|
insilmaril@0
|
109 |
vymLink="";
|
insilmaril@0
|
110 |
}
|
insilmaril@0
|
111 |
|
insilmaril@0
|
112 |
void BranchObj::copy (BranchObj* other)
|
insilmaril@0
|
113 |
{
|
insilmaril@0
|
114 |
OrnamentedObj::copy(other);
|
insilmaril@0
|
115 |
|
insilmaril@0
|
116 |
branch.clear();
|
insilmaril@0
|
117 |
BranchObj* b;
|
insilmaril@0
|
118 |
for (b=other->branch.first(); b;b=other->branch.next() )
|
insilmaril@0
|
119 |
// Make deep copy of b
|
insilmaril@0
|
120 |
// Because addBranch again calls copy for the childs,
|
insilmaril@0
|
121 |
// Those will get a deep copy, too
|
insilmaril@0
|
122 |
addBranch(b);
|
insilmaril@0
|
123 |
|
insilmaril@0
|
124 |
FloatImageObj *fi;
|
insilmaril@0
|
125 |
for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() )
|
insilmaril@0
|
126 |
addFloatImage (fi);
|
insilmaril@0
|
127 |
|
insilmaril@0
|
128 |
scrolled=other->scrolled;
|
insilmaril@0
|
129 |
tmpUnscrolled=other->tmpUnscrolled;
|
insilmaril@0
|
130 |
setVisibility (other->visible);
|
insilmaril@0
|
131 |
|
insilmaril@0
|
132 |
url=other->url;
|
insilmaril@0
|
133 |
vymLink=other->vymLink;
|
insilmaril@0
|
134 |
|
insilmaril@0
|
135 |
angle=other->angle;
|
insilmaril@0
|
136 |
|
insilmaril@0
|
137 |
positionBBox();
|
insilmaril@0
|
138 |
}
|
insilmaril@0
|
139 |
|
insilmaril@0
|
140 |
void BranchObj::clear()
|
insilmaril@0
|
141 |
{
|
insilmaril@0
|
142 |
floatimage.clear();
|
insilmaril@95
|
143 |
while (!xlink.isEmpty())
|
insilmaril@95
|
144 |
deleteXLink (xlink.first() );
|
insilmaril@83
|
145 |
|
insilmaril@83
|
146 |
BranchObj *bo;
|
insilmaril@83
|
147 |
while (!branch.isEmpty())
|
insilmaril@83
|
148 |
{
|
insilmaril@83
|
149 |
bo=branch.first();
|
insilmaril@83
|
150 |
branch.removeFirst();
|
insilmaril@83
|
151 |
delete (bo);
|
insilmaril@83
|
152 |
}
|
insilmaril@0
|
153 |
}
|
insilmaril@0
|
154 |
|
insilmaril@0
|
155 |
int BranchObj::getNum()
|
insilmaril@0
|
156 |
{
|
insilmaril@0
|
157 |
if (parObj)
|
insilmaril@0
|
158 |
return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this));
|
insilmaril@0
|
159 |
else
|
insilmaril@0
|
160 |
return 0;
|
insilmaril@0
|
161 |
}
|
insilmaril@0
|
162 |
|
insilmaril@0
|
163 |
int BranchObj::getNum(BranchObj *bo)
|
insilmaril@0
|
164 |
{
|
insilmaril@95
|
165 |
// keep current pointer in branch,
|
insilmaril@95
|
166 |
// otherwise save might fail
|
insilmaril@95
|
167 |
int cur=branch.at();
|
insilmaril@95
|
168 |
int ind=branch.findRef (bo);
|
insilmaril@95
|
169 |
branch.at(cur);
|
insilmaril@95
|
170 |
return ind;
|
insilmaril@0
|
171 |
}
|
insilmaril@0
|
172 |
|
insilmaril@0
|
173 |
int BranchObj::getFloatImageNum(FloatImageObj *fio)
|
insilmaril@0
|
174 |
{
|
insilmaril@0
|
175 |
return floatimage.findRef (fio);
|
insilmaril@0
|
176 |
}
|
insilmaril@0
|
177 |
|
insilmaril@0
|
178 |
int BranchObj::countBranches()
|
insilmaril@0
|
179 |
{
|
insilmaril@0
|
180 |
return branch.count();
|
insilmaril@0
|
181 |
}
|
insilmaril@0
|
182 |
|
insilmaril@0
|
183 |
int BranchObj::countFloatImages()
|
insilmaril@0
|
184 |
{
|
insilmaril@0
|
185 |
return floatimage.count();
|
insilmaril@0
|
186 |
}
|
insilmaril@0
|
187 |
|
insilmaril@95
|
188 |
int BranchObj::countXLinks()
|
insilmaril@89
|
189 |
{
|
insilmaril@95
|
190 |
return xlink.count();
|
insilmaril@89
|
191 |
}
|
insilmaril@89
|
192 |
|
insilmaril@0
|
193 |
void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
|
insilmaril@0
|
194 |
{
|
insilmaril@0
|
195 |
// Temporary link to lmo
|
insilmaril@0
|
196 |
// m is position of mouse pointer
|
insilmaril@0
|
197 |
// offset 0: default 1: below lmo -1 above lmo (if possible)
|
insilmaril@0
|
198 |
|
insilmaril@0
|
199 |
|
insilmaril@0
|
200 |
BranchObj* o=(BranchObj*)(lmo);
|
insilmaril@0
|
201 |
if (!parObjTmpBuf)
|
insilmaril@0
|
202 |
parObjTmpBuf=parObj;
|
insilmaril@0
|
203 |
|
insilmaril@0
|
204 |
// ignore mapcenter and mainbranch
|
insilmaril@0
|
205 |
if (lmo->getDepth()<2) off=0;
|
insilmaril@0
|
206 |
if (off==0)
|
insilmaril@0
|
207 |
link2ParPos=false;
|
insilmaril@0
|
208 |
else
|
insilmaril@0
|
209 |
link2ParPos=true;
|
insilmaril@93
|
210 |
parObj=o;
|
insilmaril@0
|
211 |
|
insilmaril@0
|
212 |
depth=parObj->getDepth()+1;
|
insilmaril@0
|
213 |
|
insilmaril@0
|
214 |
// setLinkStyle calls updateLink, only set it once
|
insilmaril@0
|
215 |
if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle());
|
insilmaril@0
|
216 |
|
insilmaril@0
|
217 |
// Move temporary to new position at destination
|
insilmaril@0
|
218 |
// Usually the positioning would be done by reposition(),
|
insilmaril@0
|
219 |
// but then also the destination branch would "Jump" around...
|
insilmaril@0
|
220 |
// Better just do it approximately
|
insilmaril@0
|
221 |
if (depth==1)
|
insilmaril@0
|
222 |
{ // new parent is the mapcenter itself
|
insilmaril@0
|
223 |
|
insilmaril@0
|
224 |
QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(),
|
insilmaril@0
|
225 |
m.y() - o->getChildPos().y() ));
|
insilmaril@0
|
226 |
if (p.x()<0) p.setX( p.x()-bbox.width() );
|
insilmaril@0
|
227 |
move2RelPos (p);
|
insilmaril@0
|
228 |
} else
|
insilmaril@0
|
229 |
{
|
insilmaril@0
|
230 |
int y;
|
insilmaril@0
|
231 |
if (off==0)
|
insilmaril@0
|
232 |
{
|
insilmaril@0
|
233 |
// new parent is just a branch, link to it
|
insilmaril@0
|
234 |
QRect t=o->getBBoxSizeWithChilds();
|
insilmaril@0
|
235 |
if (o->getLastBranch())
|
insilmaril@0
|
236 |
y=t.y() + t.height() ;
|
insilmaril@0
|
237 |
else
|
insilmaril@0
|
238 |
y=t.y();
|
insilmaril@0
|
239 |
|
insilmaril@0
|
240 |
} else
|
insilmaril@0
|
241 |
{
|
insilmaril@0
|
242 |
if (off<0)
|
insilmaril@0
|
243 |
// we want to link above lmo
|
insilmaril@0
|
244 |
y=o->y() - height() + 5;
|
insilmaril@0
|
245 |
else
|
insilmaril@0
|
246 |
// we want to link below lmo
|
insilmaril@0
|
247 |
// Bottom of sel should be 5 pixels above
|
insilmaril@0
|
248 |
// the bottom of the branch _below_ the target:
|
insilmaril@0
|
249 |
// Don't try to find that branch, guess 12 pixels
|
insilmaril@0
|
250 |
y=o->getChildPos().y() -height() + 12;
|
insilmaril@0
|
251 |
}
|
insilmaril@0
|
252 |
if (o->getOrientation()==OrientLeftOfCenter)
|
insilmaril@0
|
253 |
move ( o->getChildPos().x() - linkwidth, y );
|
insilmaril@0
|
254 |
else
|
insilmaril@0
|
255 |
move (o->getChildPos().x() + linkwidth, y );
|
insilmaril@0
|
256 |
}
|
insilmaril@0
|
257 |
|
insilmaril@0
|
258 |
// updateLink is called implicitly in move
|
insilmaril@0
|
259 |
reposition(); // FIXME shouldn't be this a request?
|
insilmaril@0
|
260 |
}
|
insilmaril@0
|
261 |
|
insilmaril@0
|
262 |
void BranchObj::unsetParObjTmp()
|
insilmaril@0
|
263 |
{
|
insilmaril@0
|
264 |
if (parObjTmpBuf)
|
insilmaril@0
|
265 |
{
|
insilmaril@0
|
266 |
link2ParPos=false;
|
insilmaril@0
|
267 |
parObj=parObjTmpBuf;
|
insilmaril@0
|
268 |
parObjTmpBuf=NULL;
|
insilmaril@0
|
269 |
depth=parObj->getDepth()+1;
|
insilmaril@0
|
270 |
setLinkStyle (getDefLinkStyle() );
|
insilmaril@93
|
271 |
updateLink();
|
insilmaril@0
|
272 |
}
|
insilmaril@0
|
273 |
}
|
insilmaril@0
|
274 |
|
insilmaril@0
|
275 |
void BranchObj::unScroll()
|
insilmaril@0
|
276 |
{
|
insilmaril@0
|
277 |
if (tmpUnscrolled) resetTmpUnscroll();
|
insilmaril@0
|
278 |
if (scrolled) toggleScroll();
|
insilmaril@0
|
279 |
}
|
insilmaril@0
|
280 |
|
insilmaril@0
|
281 |
void BranchObj::toggleScroll()
|
insilmaril@0
|
282 |
{
|
insilmaril@0
|
283 |
BranchObj *bo;
|
insilmaril@0
|
284 |
if (scrolled)
|
insilmaril@0
|
285 |
{
|
insilmaril@0
|
286 |
scrolled=false;
|
insilmaril@0
|
287 |
systemFlags->deactivate("scrolledright");
|
insilmaril@0
|
288 |
for (bo=branch.first(); bo; bo=branch.next() )
|
insilmaril@0
|
289 |
{
|
insilmaril@0
|
290 |
bo->setVisibility(true);
|
insilmaril@0
|
291 |
}
|
insilmaril@0
|
292 |
} else
|
insilmaril@0
|
293 |
{
|
insilmaril@0
|
294 |
scrolled=true;
|
insilmaril@0
|
295 |
systemFlags->activate("scrolledright");
|
insilmaril@0
|
296 |
for (bo=branch.first(); bo; bo=branch.next() )
|
insilmaril@0
|
297 |
{
|
insilmaril@0
|
298 |
bo->setVisibility(false);
|
insilmaril@0
|
299 |
}
|
insilmaril@0
|
300 |
}
|
insilmaril@0
|
301 |
calcBBoxSize();
|
insilmaril@0
|
302 |
positionBBox();
|
insilmaril@0
|
303 |
move (absPos.x(), absPos.y() );
|
insilmaril@0
|
304 |
forceReposition();
|
insilmaril@0
|
305 |
}
|
insilmaril@0
|
306 |
|
insilmaril@0
|
307 |
bool BranchObj::isScrolled()
|
insilmaril@0
|
308 |
{
|
insilmaril@0
|
309 |
return scrolled;
|
insilmaril@0
|
310 |
}
|
insilmaril@0
|
311 |
|
insilmaril@0
|
312 |
bool BranchObj::hasScrolledParent(BranchObj *start)
|
insilmaril@0
|
313 |
{
|
insilmaril@0
|
314 |
// Calls parents recursivly to
|
insilmaril@0
|
315 |
// find out, if we are scrolled at all.
|
insilmaril@0
|
316 |
// But ignore myself, just look at parents.
|
insilmaril@0
|
317 |
|
insilmaril@0
|
318 |
if (this !=start && scrolled) return true;
|
insilmaril@0
|
319 |
|
insilmaril@0
|
320 |
BranchObj* bo=(BranchObj*)(parObj);
|
insilmaril@0
|
321 |
if (bo)
|
insilmaril@0
|
322 |
return bo->hasScrolledParent(start);
|
insilmaril@0
|
323 |
else
|
insilmaril@0
|
324 |
return false;
|
insilmaril@0
|
325 |
}
|
insilmaril@0
|
326 |
|
insilmaril@0
|
327 |
void BranchObj::tmpUnscroll()
|
insilmaril@0
|
328 |
{
|
insilmaril@0
|
329 |
// Unscroll parent (recursivly)
|
insilmaril@0
|
330 |
BranchObj* bo=(BranchObj*)(parObj);
|
insilmaril@0
|
331 |
if (bo) bo->tmpUnscroll();
|
insilmaril@0
|
332 |
|
insilmaril@0
|
333 |
// Unscroll myself
|
insilmaril@0
|
334 |
if (scrolled)
|
insilmaril@0
|
335 |
{
|
insilmaril@0
|
336 |
tmpUnscrolled=true;
|
insilmaril@0
|
337 |
systemFlags->activate("tmpUnscrolledright");
|
insilmaril@0
|
338 |
toggleScroll();
|
insilmaril@0
|
339 |
}
|
insilmaril@0
|
340 |
}
|
insilmaril@0
|
341 |
|
insilmaril@0
|
342 |
void BranchObj::resetTmpUnscroll()
|
insilmaril@0
|
343 |
{
|
insilmaril@0
|
344 |
// Unscroll parent (recursivly)
|
insilmaril@0
|
345 |
BranchObj* bo=(BranchObj*)(parObj);
|
insilmaril@0
|
346 |
if (bo)
|
insilmaril@0
|
347 |
bo->resetTmpUnscroll();
|
insilmaril@0
|
348 |
|
insilmaril@0
|
349 |
// Unscroll myself
|
insilmaril@0
|
350 |
if (tmpUnscrolled)
|
insilmaril@0
|
351 |
{
|
insilmaril@0
|
352 |
tmpUnscrolled=false;
|
insilmaril@0
|
353 |
systemFlags->deactivate("tmpUnscrolledright");
|
insilmaril@0
|
354 |
toggleScroll();
|
insilmaril@0
|
355 |
}
|
insilmaril@0
|
356 |
}
|
insilmaril@0
|
357 |
|
insilmaril@0
|
358 |
void BranchObj::setVisibility(bool v, int toDepth)
|
insilmaril@0
|
359 |
{
|
insilmaril@0
|
360 |
if (depth <= toDepth)
|
insilmaril@0
|
361 |
{
|
insilmaril@0
|
362 |
frame->setVisibility(v);
|
insilmaril@0
|
363 |
heading->setVisibility(v);
|
insilmaril@0
|
364 |
systemFlags->setVisibility(v);
|
insilmaril@0
|
365 |
standardFlags->setVisibility(v);
|
insilmaril@0
|
366 |
LinkableMapObj::setVisibility (v);
|
insilmaril@0
|
367 |
|
insilmaril@0
|
368 |
if (!scrolled && (depth < toDepth))
|
insilmaril@0
|
369 |
{
|
insilmaril@0
|
370 |
// Now go recursivly through all childs
|
insilmaril@0
|
371 |
BranchObj* b;
|
insilmaril@0
|
372 |
for (b=branch.first(); b;b=branch.next() )
|
insilmaril@0
|
373 |
b->setVisibility (v,toDepth);
|
insilmaril@0
|
374 |
FloatImageObj *fio;
|
insilmaril@0
|
375 |
for (fio=floatimage.first(); fio; fio=floatimage.next())
|
insilmaril@0
|
376 |
fio->setVisibility (v);
|
insilmaril@95
|
377 |
XLinkObj* xlo;
|
insilmaril@95
|
378 |
for (xlo=xlink.first(); xlo;xlo=xlink.next() )
|
insilmaril@95
|
379 |
xlo->setVisibility ();
|
insilmaril@0
|
380 |
}
|
insilmaril@0
|
381 |
} // depth <= toDepth
|
insilmaril@0
|
382 |
requestReposition();
|
insilmaril@0
|
383 |
}
|
insilmaril@0
|
384 |
|
insilmaril@0
|
385 |
void BranchObj::setVisibility(bool v)
|
insilmaril@0
|
386 |
{
|
insilmaril@0
|
387 |
setVisibility (v,MAX_DEPTH);
|
insilmaril@0
|
388 |
}
|
insilmaril@0
|
389 |
|
insilmaril@0
|
390 |
|
insilmaril@0
|
391 |
void BranchObj::setLinkColor ()
|
insilmaril@0
|
392 |
{
|
insilmaril@0
|
393 |
// Overloaded from LinkableMapObj
|
insilmaril@0
|
394 |
// BranchObj can use color of heading
|
insilmaril@0
|
395 |
|
insilmaril@164
|
396 |
if (mapEditor)
|
insilmaril@164
|
397 |
if (mapEditor->getLinkColorHint()==HeadingColor)
|
insilmaril@164
|
398 |
LinkableMapObj::setLinkColor (heading->getColor() );
|
insilmaril@164
|
399 |
else
|
insilmaril@164
|
400 |
LinkableMapObj::setLinkColor ();
|
insilmaril@0
|
401 |
}
|
insilmaril@0
|
402 |
|
insilmaril@0
|
403 |
void BranchObj::setColor (QColor col, bool colorChilds)
|
insilmaril@0
|
404 |
{
|
insilmaril@0
|
405 |
heading->setColor(col);
|
insilmaril@0
|
406 |
setLinkColor();
|
insilmaril@0
|
407 |
if (colorChilds)
|
insilmaril@0
|
408 |
{
|
insilmaril@0
|
409 |
BranchObj *bo;
|
insilmaril@0
|
410 |
for (bo=branch.first(); bo; bo=branch.next() )
|
insilmaril@0
|
411 |
bo->setColor(col,colorChilds);
|
insilmaril@0
|
412 |
}
|
insilmaril@0
|
413 |
}
|
insilmaril@0
|
414 |
|
insilmaril@100
|
415 |
QColor BranchObj::getColor()
|
insilmaril@100
|
416 |
{
|
insilmaril@100
|
417 |
return heading->getColor();
|
insilmaril@100
|
418 |
}
|
insilmaril@0
|
419 |
|
insilmaril@0
|
420 |
BranchObj* BranchObj::first()
|
insilmaril@0
|
421 |
{
|
insilmaril@0
|
422 |
itLast=NULL;
|
insilmaril@0
|
423 |
return this;
|
insilmaril@0
|
424 |
}
|
insilmaril@0
|
425 |
|
insilmaril@0
|
426 |
BranchObj* BranchObj::next()
|
insilmaril@0
|
427 |
{
|
insilmaril@0
|
428 |
BranchObj *lmo;
|
insilmaril@0
|
429 |
BranchObj *bo=branch.first();
|
insilmaril@0
|
430 |
BranchObj *po=(BranchObj*)(parObj);
|
insilmaril@0
|
431 |
|
insilmaril@0
|
432 |
if (!itLast)
|
insilmaril@0
|
433 |
{ // We are just beginning at the mapCenter
|
insilmaril@0
|
434 |
if (bo)
|
insilmaril@0
|
435 |
{
|
insilmaril@0
|
436 |
itLast=this;
|
insilmaril@0
|
437 |
return bo;
|
insilmaril@0
|
438 |
}
|
insilmaril@0
|
439 |
else
|
insilmaril@0
|
440 |
{
|
insilmaril@0
|
441 |
itLast=NULL;
|
insilmaril@0
|
442 |
return NULL;
|
insilmaril@0
|
443 |
}
|
insilmaril@0
|
444 |
}
|
insilmaril@0
|
445 |
|
insilmaril@0
|
446 |
if (itLast==parObj)
|
insilmaril@0
|
447 |
{ // We come from above
|
insilmaril@0
|
448 |
if (bo)
|
insilmaril@0
|
449 |
{
|
insilmaril@0
|
450 |
// there are childs, go there
|
insilmaril@0
|
451 |
itLast=this;
|
insilmaril@0
|
452 |
return bo;
|
insilmaril@0
|
453 |
}
|
insilmaril@0
|
454 |
else
|
insilmaril@0
|
455 |
{ // no childs, try to go up again
|
insilmaril@0
|
456 |
if (po)
|
insilmaril@0
|
457 |
{
|
insilmaril@0
|
458 |
// go up
|
insilmaril@0
|
459 |
itLast=this;
|
insilmaril@0
|
460 |
lmo=po->next();
|
insilmaril@0
|
461 |
itLast=this;
|
insilmaril@0
|
462 |
return lmo;
|
insilmaril@0
|
463 |
|
insilmaril@0
|
464 |
}
|
insilmaril@0
|
465 |
else
|
insilmaril@0
|
466 |
{
|
insilmaril@0
|
467 |
// can't go up, I am mapCenter
|
insilmaril@0
|
468 |
itLast=NULL;
|
insilmaril@0
|
469 |
return NULL;
|
insilmaril@0
|
470 |
}
|
insilmaril@0
|
471 |
}
|
insilmaril@0
|
472 |
}
|
insilmaril@0
|
473 |
|
insilmaril@0
|
474 |
// Try to find last child, we came from, in my own childs
|
insilmaril@0
|
475 |
bool searching=true;
|
insilmaril@0
|
476 |
while (bo && searching)
|
insilmaril@0
|
477 |
{
|
insilmaril@0
|
478 |
if (itLast==bo) searching=false;
|
insilmaril@0
|
479 |
bo=branch.next();
|
insilmaril@0
|
480 |
}
|
insilmaril@0
|
481 |
if (!searching)
|
insilmaril@0
|
482 |
{ // found lastLMO in my childs
|
insilmaril@0
|
483 |
if (bo)
|
insilmaril@0
|
484 |
{
|
insilmaril@0
|
485 |
// found a brother of lastLMO
|
insilmaril@0
|
486 |
itLast=this;
|
insilmaril@0
|
487 |
return bo;
|
insilmaril@0
|
488 |
}
|
insilmaril@0
|
489 |
else
|
insilmaril@0
|
490 |
{
|
insilmaril@0
|
491 |
if (po)
|
insilmaril@0
|
492 |
{
|
insilmaril@0
|
493 |
// go up
|
insilmaril@0
|
494 |
itLast=this;
|
insilmaril@0
|
495 |
lmo=po->next();
|
insilmaril@0
|
496 |
itLast=this;
|
insilmaril@0
|
497 |
return lmo;
|
insilmaril@0
|
498 |
}
|
insilmaril@0
|
499 |
else
|
insilmaril@0
|
500 |
{
|
insilmaril@0
|
501 |
// can't go up, I am mapCenter
|
insilmaril@0
|
502 |
itLast=NULL;
|
insilmaril@0
|
503 |
return NULL;
|
insilmaril@0
|
504 |
}
|
insilmaril@0
|
505 |
}
|
insilmaril@0
|
506 |
}
|
insilmaril@0
|
507 |
|
insilmaril@0
|
508 |
// couldn't find last child, it must be a nephew of mine
|
insilmaril@0
|
509 |
bo=branch.first();
|
insilmaril@0
|
510 |
if (bo)
|
insilmaril@0
|
511 |
{
|
insilmaril@0
|
512 |
// proceed with my first child
|
insilmaril@0
|
513 |
itLast=this;
|
insilmaril@0
|
514 |
return bo;
|
insilmaril@0
|
515 |
}
|
insilmaril@0
|
516 |
else
|
insilmaril@0
|
517 |
{
|
insilmaril@0
|
518 |
// or go back to my parents
|
insilmaril@0
|
519 |
if (po)
|
insilmaril@0
|
520 |
{
|
insilmaril@0
|
521 |
// go up
|
insilmaril@0
|
522 |
itLast=this;
|
insilmaril@0
|
523 |
lmo=po->next();
|
insilmaril@0
|
524 |
itLast=this;
|
insilmaril@0
|
525 |
return lmo;
|
insilmaril@0
|
526 |
}
|
insilmaril@0
|
527 |
else
|
insilmaril@0
|
528 |
{
|
insilmaril@0
|
529 |
// can't go up, I am mapCenter
|
insilmaril@0
|
530 |
itLast=NULL;
|
insilmaril@0
|
531 |
return NULL;
|
insilmaril@0
|
532 |
}
|
insilmaril@0
|
533 |
}
|
insilmaril@0
|
534 |
}
|
insilmaril@0
|
535 |
|
insilmaril@0
|
536 |
BranchObj* BranchObj::getLastIterator()
|
insilmaril@0
|
537 |
{
|
insilmaril@0
|
538 |
return itLast;
|
insilmaril@0
|
539 |
}
|
insilmaril@0
|
540 |
|
insilmaril@0
|
541 |
void BranchObj::setLastIterator(BranchObj* it)
|
insilmaril@0
|
542 |
{
|
insilmaril@0
|
543 |
itLast=it;
|
insilmaril@0
|
544 |
}
|
insilmaril@0
|
545 |
|
insilmaril@0
|
546 |
|
insilmaril@0
|
547 |
void BranchObj::move (double x, double y)
|
insilmaril@0
|
548 |
{
|
insilmaril@0
|
549 |
OrnamentedObj::move (x,y);
|
insilmaril@169
|
550 |
FloatImageObj *fio;
|
insilmaril@169
|
551 |
for (fio=floatimage.first(); fio; fio=floatimage.next() )
|
insilmaril@169
|
552 |
fio->reposition();
|
insilmaril@0
|
553 |
positionBBox();
|
insilmaril@0
|
554 |
}
|
insilmaril@0
|
555 |
|
insilmaril@0
|
556 |
void BranchObj::move (QPoint p)
|
insilmaril@0
|
557 |
{
|
insilmaril@0
|
558 |
move (p.x(), p.y());
|
insilmaril@0
|
559 |
}
|
insilmaril@0
|
560 |
|
insilmaril@0
|
561 |
void BranchObj::moveBy (double x, double y)
|
insilmaril@0
|
562 |
{
|
insilmaril@0
|
563 |
OrnamentedObj::moveBy (x,y);
|
insilmaril@0
|
564 |
positionBBox();
|
insilmaril@0
|
565 |
BranchObj* b;
|
insilmaril@0
|
566 |
for (b=branch.first(); b;b=branch.next() )
|
insilmaril@0
|
567 |
b->moveBy (x,y);
|
insilmaril@0
|
568 |
}
|
insilmaril@83
|
569 |
|
insilmaril@0
|
570 |
void BranchObj::moveBy (QPoint p)
|
insilmaril@0
|
571 |
{
|
insilmaril@0
|
572 |
moveBy (p.x(), p.y());
|
insilmaril@0
|
573 |
}
|
insilmaril@0
|
574 |
|
insilmaril@0
|
575 |
|
insilmaril@0
|
576 |
void BranchObj::positionBBox()
|
insilmaril@0
|
577 |
{
|
insilmaril@166
|
578 |
/*// TODO testing (optimization)
|
insilmaril@83
|
579 |
QString h=getHeading();
|
insilmaril@83
|
580 |
if (!h.isEmpty())
|
insilmaril@83
|
581 |
cout << "BO::positionBBox("<<h<<")\n";
|
insilmaril@83
|
582 |
else
|
insilmaril@83
|
583 |
cout << "BO::positionBBox (noHeading)\n";
|
insilmaril@166
|
584 |
*/
|
insilmaril@0
|
585 |
|
insilmaril@169
|
586 |
positionContents();
|
insilmaril@169
|
587 |
|
insilmaril@169
|
588 |
int d=frame->getBorder()/2;
|
insilmaril@83
|
589 |
|
insilmaril@169
|
590 |
bbox.moveTopLeft (QPoint (absPos.x(), absPos.y() - topPad));
|
insilmaril@169
|
591 |
clickBox.moveTopLeft(QPoint (absPos.x()+d, absPos.y()+d ));
|
insilmaril@169
|
592 |
|
insilmaril@0
|
593 |
setSelBox();
|
insilmaril@0
|
594 |
|
insilmaril@0
|
595 |
// set the frame
|
insilmaril@0
|
596 |
frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
|
insilmaril@83
|
597 |
|
insilmaril@83
|
598 |
// Update links to other branches
|
insilmaril@95
|
599 |
XLinkObj *xlo;
|
insilmaril@95
|
600 |
for (xlo=xlink.first(); xlo; xlo=xlink.next() )
|
insilmaril@95
|
601 |
xlo->updateXLink();
|
insilmaril@0
|
602 |
}
|
insilmaril@0
|
603 |
|
insilmaril@0
|
604 |
void BranchObj::calcBBoxSize()
|
insilmaril@0
|
605 |
{
|
insilmaril@0
|
606 |
QSize heading_r=heading->getSize();
|
insilmaril@0
|
607 |
int heading_w=static_cast <int> (heading_r.width() );
|
insilmaril@0
|
608 |
int heading_h=static_cast <int> (heading_r.height() );
|
insilmaril@0
|
609 |
QSize sysflags_r=systemFlags->getSize();
|
insilmaril@0
|
610 |
int sysflags_h=sysflags_r.height();
|
insilmaril@0
|
611 |
int sysflags_w=sysflags_r.width();
|
insilmaril@0
|
612 |
QSize stanflags_r=standardFlags->getSize();
|
insilmaril@0
|
613 |
int stanflags_h=stanflags_r.height();
|
insilmaril@0
|
614 |
int stanflags_w=stanflags_r.width();
|
insilmaril@0
|
615 |
int w;
|
insilmaril@0
|
616 |
int h;
|
insilmaril@0
|
617 |
|
insilmaril@0
|
618 |
// set width to sum of all widths
|
insilmaril@0
|
619 |
w=heading_w + sysflags_w + stanflags_w;
|
insilmaril@0
|
620 |
// set height to maximum needed height
|
insilmaril@0
|
621 |
h=max (sysflags_h,stanflags_h);
|
insilmaril@0
|
622 |
h=max (h,heading_h);
|
insilmaril@0
|
623 |
|
insilmaril@169
|
624 |
clickBox.setSize (QSize (w,h));
|
insilmaril@169
|
625 |
|
insilmaril@169
|
626 |
// Floatimages
|
insilmaril@169
|
627 |
QPoint rp;
|
insilmaril@169
|
628 |
FloatImageObj *foi;
|
insilmaril@169
|
629 |
|
insilmaril@169
|
630 |
topPad=botPad=leftPad=rightPad=0;
|
insilmaril@169
|
631 |
if (includeImagesVer || includeImagesHor)
|
insilmaril@169
|
632 |
{
|
insilmaril@169
|
633 |
if (countFloatImages()>0)
|
insilmaril@169
|
634 |
{
|
insilmaril@169
|
635 |
for (foi=floatimage.first(); foi; foi=floatimage.next() )
|
insilmaril@169
|
636 |
{
|
insilmaril@169
|
637 |
rp=foi->getRelPos();
|
insilmaril@169
|
638 |
if (includeImagesVer)
|
insilmaril@169
|
639 |
{
|
insilmaril@169
|
640 |
if (rp.y() < 0)
|
insilmaril@169
|
641 |
topPad=max (topPad,-rp.y());
|
insilmaril@169
|
642 |
if (rp.y()+foi->height() > h)
|
insilmaril@169
|
643 |
botPad=max (botPad,rp.y()+foi->height()-h);
|
insilmaril@169
|
644 |
}
|
insilmaril@213
|
645 |
if (includeImagesHor)
|
insilmaril@213
|
646 |
{
|
insilmaril@213
|
647 |
if (rp.x() < 0)
|
insilmaril@213
|
648 |
leftPad=max (leftPad,-rp.x());
|
insilmaril@213
|
649 |
if (rp.x()+foi->width() > w)
|
insilmaril@213
|
650 |
rightPad=max (rightPad,rp.x()+foi->width()-w);
|
insilmaril@213
|
651 |
}
|
insilmaril@169
|
652 |
}
|
insilmaril@169
|
653 |
}
|
insilmaril@169
|
654 |
h+=topPad+botPad;
|
insilmaril@213
|
655 |
w+=leftPad+rightPad;
|
insilmaril@169
|
656 |
}
|
insilmaril@169
|
657 |
|
insilmaril@169
|
658 |
// Frame thickness
|
insilmaril@0
|
659 |
w+=frame->getBorder();
|
insilmaril@0
|
660 |
h+=frame->getBorder();
|
insilmaril@169
|
661 |
|
insilmaril@169
|
662 |
// Finally set size
|
insilmaril@0
|
663 |
bbox.setSize (QSize (w,h));
|
insilmaril@0
|
664 |
}
|
insilmaril@0
|
665 |
|
insilmaril@0
|
666 |
LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
|
insilmaril@0
|
667 |
{
|
insilmaril@0
|
668 |
// Search branches
|
insilmaril@0
|
669 |
BranchObj *b;
|
insilmaril@0
|
670 |
LinkableMapObj *lmo;
|
insilmaril@0
|
671 |
for (b=branch.first(); b; b=branch.next() )
|
insilmaril@0
|
672 |
{
|
insilmaril@0
|
673 |
lmo=b->findMapObj(p, excludeLMO);
|
insilmaril@0
|
674 |
if (lmo != NULL) return lmo;
|
insilmaril@0
|
675 |
}
|
insilmaril@0
|
676 |
|
insilmaril@0
|
677 |
// Search myself
|
insilmaril@169
|
678 |
if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
|
insilmaril@0
|
679 |
return this;
|
insilmaril@0
|
680 |
|
insilmaril@0
|
681 |
// Search float images
|
insilmaril@0
|
682 |
FloatImageObj *foi;
|
insilmaril@0
|
683 |
for (foi=floatimage.first(); foi; foi=floatimage.next() )
|
insilmaril@169
|
684 |
if (foi->inBox(p) &&
|
insilmaril@158
|
685 |
(foi != excludeLMO) &&
|
insilmaril@158
|
686 |
foi->getParObj()!= excludeLMO &&
|
insilmaril@158
|
687 |
foi->isVisibleObj()
|
insilmaril@158
|
688 |
) return foi;
|
insilmaril@0
|
689 |
|
insilmaril@0
|
690 |
return NULL;
|
insilmaril@0
|
691 |
}
|
insilmaril@0
|
692 |
|
insilmaril@0
|
693 |
void BranchObj::setHeading(QString s)
|
insilmaril@0
|
694 |
{
|
insilmaril@0
|
695 |
heading->setText(s); // set new heading
|
insilmaril@0
|
696 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@0
|
697 |
positionBBox(); // rearrange contents
|
insilmaril@0
|
698 |
requestReposition();
|
insilmaril@0
|
699 |
}
|
insilmaril@0
|
700 |
|
insilmaril@0
|
701 |
void BranchObj::setURL(QString s)
|
insilmaril@0
|
702 |
{
|
insilmaril@0
|
703 |
url=s;
|
insilmaril@0
|
704 |
if (!url.isEmpty())
|
insilmaril@0
|
705 |
systemFlags->activate("url");
|
insilmaril@0
|
706 |
else
|
insilmaril@0
|
707 |
systemFlags->deactivate("url");
|
insilmaril@0
|
708 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@0
|
709 |
positionBBox(); // rearrange contents
|
insilmaril@0
|
710 |
forceReposition();
|
insilmaril@0
|
711 |
}
|
insilmaril@0
|
712 |
|
insilmaril@0
|
713 |
QString BranchObj::getURL()
|
insilmaril@0
|
714 |
{
|
insilmaril@0
|
715 |
return url;
|
insilmaril@0
|
716 |
}
|
insilmaril@0
|
717 |
|
insilmaril@0
|
718 |
void BranchObj::setVymLink(QString s)
|
insilmaril@0
|
719 |
{
|
insilmaril@0
|
720 |
if (!s.isEmpty())
|
insilmaril@0
|
721 |
{
|
insilmaril@0
|
722 |
// We need the relative (from loading)
|
insilmaril@0
|
723 |
// or absolute path (from User event)
|
insilmaril@0
|
724 |
// and build the absolute path.
|
insilmaril@0
|
725 |
// Note: If we have relative, use path of
|
insilmaril@0
|
726 |
// current map to build absolute path
|
insilmaril@0
|
727 |
QDir d(s);
|
insilmaril@0
|
728 |
if (!d.path().startsWith ("/"))
|
insilmaril@0
|
729 |
{
|
insilmaril@0
|
730 |
QString p=mapEditor->getDestPath();
|
insilmaril@0
|
731 |
int i=p.findRev("/",-1);
|
insilmaril@0
|
732 |
d.setPath(p.left(i)+"/"+s);
|
insilmaril@0
|
733 |
d.convertToAbs();
|
insilmaril@0
|
734 |
}
|
insilmaril@0
|
735 |
vymLink=d.path();
|
insilmaril@0
|
736 |
systemFlags->activate("vymLink");
|
insilmaril@0
|
737 |
}
|
insilmaril@0
|
738 |
else
|
insilmaril@0
|
739 |
{
|
insilmaril@0
|
740 |
systemFlags->deactivate("vymLink");
|
insilmaril@0
|
741 |
vymLink="";
|
insilmaril@0
|
742 |
}
|
insilmaril@0
|
743 |
calcBBoxSize(); // recalculate bbox
|
insilmaril@0
|
744 |
positionBBox(); // rearrange contents
|
insilmaril@0
|
745 |
forceReposition();
|
insilmaril@0
|
746 |
}
|
insilmaril@0
|
747 |
|
insilmaril@0
|
748 |
QString BranchObj::getVymLink()
|
insilmaril@0
|
749 |
{
|
insilmaril@0
|
750 |
return vymLink;
|
insilmaril@0
|
751 |
}
|
insilmaril@0
|
752 |
|
insilmaril@0
|
753 |
QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
|
insilmaril@0
|
754 |
{
|
insilmaril@0
|
755 |
QString s,a;
|
insilmaril@0
|
756 |
QString scrolledAttr;
|
insilmaril@0
|
757 |
if (scrolled)
|
insilmaril@0
|
758 |
scrolledAttr=attribut ("scrolled","yes");
|
insilmaril@0
|
759 |
else
|
insilmaril@0
|
760 |
scrolledAttr="";
|
insilmaril@0
|
761 |
|
insilmaril@0
|
762 |
QString posAttr;
|
insilmaril@0
|
763 |
if (depth<2) posAttr=
|
insilmaril@0
|
764 |
attribut("absPosX",QString().setNum(absPos.x(),10)) +
|
insilmaril@0
|
765 |
attribut("absPosY",QString().setNum(absPos.y(),10));
|
insilmaril@0
|
766 |
else
|
insilmaril@0
|
767 |
posAttr="";
|
insilmaril@0
|
768 |
|
insilmaril@169
|
769 |
QString linkAttr=getLinkAttr()+" "+getIncludeImageAttr();
|
insilmaril@169
|
770 |
|
insilmaril@160
|
771 |
|
insilmaril@0
|
772 |
QString urlAttr;
|
insilmaril@0
|
773 |
if (!url.isEmpty())
|
insilmaril@0
|
774 |
urlAttr=attribut ("url",url);
|
insilmaril@0
|
775 |
|
insilmaril@0
|
776 |
QString vymLinkAttr;
|
insilmaril@0
|
777 |
if (!vymLink.isEmpty())
|
insilmaril@0
|
778 |
vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
|
insilmaril@0
|
779 |
|
insilmaril@0
|
780 |
QString frameAttr;
|
insilmaril@0
|
781 |
if (frame->getFrameType()!=NoFrame)
|
insilmaril@0
|
782 |
frameAttr=attribut ("frameType",frame->getFrameTypeName());
|
insilmaril@0
|
783 |
else
|
insilmaril@0
|
784 |
frameAttr="";
|
insilmaril@0
|
785 |
|
insilmaril@0
|
786 |
// save area, if not scrolled
|
insilmaril@0
|
787 |
QString areaAttr;
|
insilmaril@0
|
788 |
if (!((BranchObj*)(parObj))->isScrolled() )
|
insilmaril@0
|
789 |
{
|
insilmaril@0
|
790 |
areaAttr=
|
insilmaril@0
|
791 |
attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) +
|
insilmaril@0
|
792 |
attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) +
|
insilmaril@0
|
793 |
attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
|
insilmaril@0
|
794 |
attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
|
insilmaril@0
|
795 |
|
insilmaril@0
|
796 |
} else
|
insilmaril@0
|
797 |
areaAttr="";
|
insilmaril@0
|
798 |
|
insilmaril@169
|
799 |
// Providing an ID for a branch makes export to XHTML easier
|
insilmaril@169
|
800 |
QString idAttr;
|
insilmaril@169
|
801 |
if (countXLinks()>0)
|
insilmaril@169
|
802 |
idAttr=attribut ("id",getSelectString());
|
insilmaril@169
|
803 |
else
|
insilmaril@169
|
804 |
idAttr="";
|
insilmaril@169
|
805 |
|
insilmaril@169
|
806 |
s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr +idAttr);
|
insilmaril@0
|
807 |
incIndent();
|
insilmaril@0
|
808 |
|
insilmaril@0
|
809 |
// save heading
|
insilmaril@160
|
810 |
s+=valueElement("heading", getHeading(),
|
insilmaril@0
|
811 |
attribut ("textColor",QColor(heading->getColor()).name()));
|
insilmaril@0
|
812 |
|
insilmaril@0
|
813 |
// save names of flags set
|
insilmaril@0
|
814 |
s+=standardFlags->saveToDir(tmpdir,prefix,0);
|
insilmaril@0
|
815 |
|
insilmaril@0
|
816 |
// save note
|
insilmaril@0
|
817 |
if (!note.isEmpty() )
|
insilmaril@0
|
818 |
s+=note.saveToDir();
|
insilmaril@0
|
819 |
|
insilmaril@0
|
820 |
// Save branches
|
insilmaril@0
|
821 |
BranchObj *bo;
|
insilmaril@0
|
822 |
for (bo=branch.first(); bo; bo=branch.next() )
|
insilmaril@0
|
823 |
s+=bo->saveToDir(tmpdir,prefix,offset);
|
insilmaril@0
|
824 |
|
insilmaril@0
|
825 |
// Save FloatImages
|
insilmaril@0
|
826 |
FloatImageObj *fio;
|
insilmaril@0
|
827 |
for (fio=floatimage.first(); fio; fio=floatimage.next() )
|
insilmaril@166
|
828 |
s+=fio->saveToDir (tmpdir,prefix,offset);
|
insilmaril@0
|
829 |
|
insilmaril@95
|
830 |
// Save XLinks
|
insilmaril@95
|
831 |
XLinkObj *xlo;
|
insilmaril@95
|
832 |
for (xlo=xlink.first(); xlo; xlo=xlink.next() )
|
insilmaril@95
|
833 |
s+=xlo->saveToDir();
|
insilmaril@95
|
834 |
|
insilmaril@95
|
835 |
decIndent();
|
insilmaril@0
|
836 |
s+=endElement ("branch");
|
insilmaril@0
|
837 |
return s;
|
insilmaril@0
|
838 |
}
|
insilmaril@0
|
839 |
|
insilmaril@95
|
840 |
void BranchObj::addXLink (XLinkObj *xlo)
|
insilmaril@83
|
841 |
{
|
insilmaril@95
|
842 |
xlink.append (xlo);
|
insilmaril@83
|
843 |
|
insilmaril@83
|
844 |
}
|
insilmaril@83
|
845 |
|
insilmaril@95
|
846 |
void BranchObj::removeXLinkRef (XLinkObj *xlo)
|
insilmaril@83
|
847 |
{
|
insilmaril@95
|
848 |
xlink.remove (xlo);
|
insilmaril@83
|
849 |
}
|
insilmaril@83
|
850 |
|
insilmaril@95
|
851 |
void BranchObj::deleteXLink(XLinkObj *xlo)
|
insilmaril@83
|
852 |
{
|
insilmaril@95
|
853 |
xlo->deactivate();
|
insilmaril@95
|
854 |
if (!xlo->isUsed()) delete (xlo);
|
insilmaril@83
|
855 |
}
|
insilmaril@83
|
856 |
|
insilmaril@95
|
857 |
void BranchObj::deleteXLinkAt (int i)
|
insilmaril@94
|
858 |
{
|
insilmaril@95
|
859 |
XLinkObj *xlo=xlink.at(i);
|
insilmaril@95
|
860 |
xlo->deactivate();
|
insilmaril@95
|
861 |
if (!xlo->isUsed()) delete(xlo);
|
insilmaril@94
|
862 |
}
|
insilmaril@94
|
863 |
|
insilmaril@97
|
864 |
XLinkObj* BranchObj::XLinkAt (int i)
|
insilmaril@97
|
865 |
{
|
insilmaril@97
|
866 |
return xlink.at(i);
|
insilmaril@97
|
867 |
}
|
insilmaril@97
|
868 |
|
insilmaril@95
|
869 |
int BranchObj::countXLink()
|
insilmaril@83
|
870 |
{
|
insilmaril@95
|
871 |
return xlink.count();
|
insilmaril@83
|
872 |
}
|
insilmaril@83
|
873 |
|
insilmaril@95
|
874 |
BranchObj* BranchObj::XLinkTargetAt (int i)
|
insilmaril@89
|
875 |
{
|
insilmaril@95
|
876 |
if (xlink.at(i))
|
insilmaril@95
|
877 |
return xlink.at(i)->otherBranch (this);
|
insilmaril@89
|
878 |
else
|
insilmaril@89
|
879 |
return NULL;
|
insilmaril@89
|
880 |
}
|
insilmaril@89
|
881 |
|
insilmaril@169
|
882 |
void BranchObj::setIncludeImagesVer(bool b)
|
insilmaril@169
|
883 |
{
|
insilmaril@169
|
884 |
includeImagesVer=b;
|
insilmaril@169
|
885 |
calcBBoxSize();
|
insilmaril@169
|
886 |
positionBBox();
|
insilmaril@169
|
887 |
requestReposition();
|
insilmaril@213
|
888 |
//FIXME undo needed
|
insilmaril@169
|
889 |
}
|
insilmaril@169
|
890 |
|
insilmaril@169
|
891 |
bool BranchObj::getIncludeImagesVer()
|
insilmaril@169
|
892 |
{
|
insilmaril@169
|
893 |
return includeImagesVer;
|
insilmaril@169
|
894 |
}
|
insilmaril@169
|
895 |
|
insilmaril@169
|
896 |
void BranchObj::setIncludeImagesHor(bool b)
|
insilmaril@169
|
897 |
{
|
insilmaril@169
|
898 |
includeImagesHor=b;
|
insilmaril@169
|
899 |
calcBBoxSize();
|
insilmaril@169
|
900 |
positionBBox();
|
insilmaril@169
|
901 |
requestReposition();
|
insilmaril@213
|
902 |
//FIXME undo needed
|
insilmaril@169
|
903 |
}
|
insilmaril@169
|
904 |
|
insilmaril@169
|
905 |
bool BranchObj::getIncludeImagesHor()
|
insilmaril@169
|
906 |
{
|
insilmaril@169
|
907 |
return includeImagesHor;
|
insilmaril@169
|
908 |
}
|
insilmaril@169
|
909 |
|
insilmaril@169
|
910 |
QString BranchObj::getIncludeImageAttr()
|
insilmaril@169
|
911 |
{
|
insilmaril@169
|
912 |
QString a;
|
insilmaril@169
|
913 |
if (includeImagesVer)
|
insilmaril@169
|
914 |
a=attribut ("incImgV","true");
|
insilmaril@169
|
915 |
else
|
insilmaril@169
|
916 |
a=attribut ("incImgV","false");
|
insilmaril@169
|
917 |
if (includeImagesHor)
|
insilmaril@213
|
918 |
a+=attribut ("incImgH","true");
|
insilmaril@169
|
919 |
else
|
insilmaril@213
|
920 |
a+=attribut ("incImgH","false");
|
insilmaril@169
|
921 |
return a;
|
insilmaril@169
|
922 |
}
|
insilmaril@169
|
923 |
|
insilmaril@0
|
924 |
LinkableMapObj* BranchObj::addFloatImage ()
|
insilmaril@0
|
925 |
{
|
insilmaril@0
|
926 |
FloatImageObj *newfi=new FloatImageObj (canvas,this);
|
insilmaril@0
|
927 |
floatimage.append (newfi);
|
insilmaril@0
|
928 |
if (hasScrolledParent(this) )
|
insilmaril@0
|
929 |
newfi->setVisibility (false);
|
insilmaril@0
|
930 |
else
|
insilmaril@0
|
931 |
newfi->setVisibility(visible);
|
insilmaril@169
|
932 |
calcBBoxSize();
|
insilmaril@169
|
933 |
positionBBox();
|
insilmaril@0
|
934 |
requestReposition();
|
insilmaril@0
|
935 |
return newfi;
|
insilmaril@220
|
936 |
//FIXME undo needed
|
insilmaril@0
|
937 |
}
|
insilmaril@0
|
938 |
|
insilmaril@0
|
939 |
LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
|
insilmaril@0
|
940 |
{
|
insilmaril@0
|
941 |
FloatImageObj *newfi=new FloatImageObj (canvas,this);
|
insilmaril@0
|
942 |
floatimage.append (newfi);
|
insilmaril@0
|
943 |
newfi->copy (fio);
|
insilmaril@0
|
944 |
if (hasScrolledParent(this) )
|
insilmaril@0
|
945 |
newfi->setVisibility (false);
|
insilmaril@0
|
946 |
else
|
insilmaril@0
|
947 |
newfi->setVisibility(visible);
|
insilmaril@169
|
948 |
calcBBoxSize();
|
insilmaril@169
|
949 |
positionBBox();
|
insilmaril@0
|
950 |
requestReposition();
|
insilmaril@0
|
951 |
return newfi;
|
insilmaril@169
|
952 |
// FIMXE undo needed
|
insilmaril@0
|
953 |
}
|
insilmaril@0
|
954 |
|
insilmaril@0
|
955 |
FloatImageObj* BranchObj::getFirstFloatImage ()
|
insilmaril@0
|
956 |
{
|
insilmaril@0
|
957 |
return floatimage.first();
|
insilmaril@0
|
958 |
}
|
insilmaril@0
|
959 |
|
insilmaril@0
|
960 |
FloatImageObj* BranchObj::getLastFloatImage ()
|
insilmaril@0
|
961 |
{
|
insilmaril@0
|
962 |
return floatimage.last();
|
insilmaril@0
|
963 |
}
|
insilmaril@0
|
964 |
|
insilmaril@0
|
965 |
FloatImageObj* BranchObj::getFloatImageNum (const uint &i)
|
insilmaril@0
|
966 |
{
|
insilmaril@0
|
967 |
return floatimage.at(i);
|
insilmaril@0
|
968 |
}
|
insilmaril@0
|
969 |
|
insilmaril@0
|
970 |
void BranchObj::removeFloatImage (FloatImageObj *fio)
|
insilmaril@0
|
971 |
{
|
insilmaril@0
|
972 |
floatimage.remove (fio);
|
insilmaril@169
|
973 |
calcBBoxSize();
|
insilmaril@169
|
974 |
positionBBox();
|
insilmaril@0
|
975 |
requestReposition();
|
insilmaril@169
|
976 |
// FIMXE undo needed
|
insilmaril@0
|
977 |
}
|
insilmaril@0
|
978 |
|
insilmaril@0
|
979 |
void BranchObj::savePosInAngle ()
|
insilmaril@0
|
980 |
{
|
insilmaril@0
|
981 |
// Save position in angle
|
insilmaril@0
|
982 |
BranchObj *b;
|
insilmaril@0
|
983 |
int i=0;
|
insilmaril@0
|
984 |
for (b=branch.first(); b; b=branch.next() )
|
insilmaril@0
|
985 |
{
|
insilmaril@0
|
986 |
b->angle=i;
|
insilmaril@0
|
987 |
i++;
|
insilmaril@0
|
988 |
}
|
insilmaril@0
|
989 |
}
|
insilmaril@0
|
990 |
|
insilmaril@146
|
991 |
void BranchObj::setDefAttr (BranchModification mod)
|
insilmaril@146
|
992 |
{
|
insilmaril@146
|
993 |
int fontsize;
|
insilmaril@146
|
994 |
switch (depth)
|
insilmaril@146
|
995 |
{
|
insilmaril@146
|
996 |
case 0: fontsize=16; break;
|
insilmaril@146
|
997 |
case 1: fontsize=12; break;
|
insilmaril@146
|
998 |
default: fontsize=10; break;
|
insilmaril@146
|
999 |
}
|
insilmaril@146
|
1000 |
|
insilmaril@146
|
1001 |
setLinkColor ();
|
insilmaril@146
|
1002 |
setLinkStyle(getDefLinkStyle());
|
insilmaril@146
|
1003 |
QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
|
insilmaril@146
|
1004 |
font.setPointSize(fontsize);
|
insilmaril@146
|
1005 |
heading->setFont(font );
|
insilmaril@146
|
1006 |
|
insilmaril@146
|
1007 |
if (mod==NewBranch)
|
insilmaril@146
|
1008 |
setColor (((BranchObj*)(parObj))->getColor(),false);
|
insilmaril@146
|
1009 |
|
insilmaril@146
|
1010 |
calcBBoxSize();
|
insilmaril@146
|
1011 |
}
|
insilmaril@146
|
1012 |
|
insilmaril@0
|
1013 |
BranchObj* BranchObj::addBranch()
|
insilmaril@0
|
1014 |
{
|
insilmaril@0
|
1015 |
BranchObj* newbo=new BranchObj(canvas,this);
|
insilmaril@0
|
1016 |
branch.append (newbo);
|
insilmaril@0
|
1017 |
newbo->setParObj(this);
|
insilmaril@146
|
1018 |
newbo->setDefAttr(NewBranch);
|
insilmaril@0
|
1019 |
newbo->setHeading ("new");
|
insilmaril@0
|
1020 |
if (scrolled)
|
insilmaril@0
|
1021 |
newbo->setVisibility (false);
|
insilmaril@0
|
1022 |
else
|
insilmaril@0
|
1023 |
newbo->setVisibility(visible);
|
insilmaril@93
|
1024 |
newbo->updateLink();
|
insilmaril@0
|
1025 |
requestReposition();
|
insilmaril@0
|
1026 |
return newbo;
|
insilmaril@0
|
1027 |
}
|
insilmaril@0
|
1028 |
|
insilmaril@0
|
1029 |
BranchObj* BranchObj::addBranch(BranchObj* bo)
|
insilmaril@0
|
1030 |
{
|
insilmaril@0
|
1031 |
BranchObj* newbo=new BranchObj(canvas,this);
|
insilmaril@0
|
1032 |
branch.append (newbo);
|
insilmaril@0
|
1033 |
newbo->copy(bo);
|
insilmaril@0
|
1034 |
newbo->setParObj(this);
|
insilmaril@162
|
1035 |
newbo->setDefAttr(MovedBranch);
|
insilmaril@0
|
1036 |
if (scrolled)
|
insilmaril@0
|
1037 |
newbo->setVisibility (false);
|
insilmaril@0
|
1038 |
else
|
insilmaril@0
|
1039 |
newbo->setVisibility(bo->visible);
|
insilmaril@93
|
1040 |
newbo->updateLink();
|
insilmaril@0
|
1041 |
requestReposition();
|
insilmaril@0
|
1042 |
return newbo;
|
insilmaril@0
|
1043 |
}
|
insilmaril@0
|
1044 |
|
insilmaril@83
|
1045 |
BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
|
insilmaril@83
|
1046 |
{
|
insilmaril@83
|
1047 |
branch.append (bo);
|
insilmaril@83
|
1048 |
bo->setParObj (this);
|
insilmaril@83
|
1049 |
bo->depth=depth+1;
|
insilmaril@146
|
1050 |
bo->setDefAttr(MovedBranch);
|
insilmaril@83
|
1051 |
if (scrolled) tmpUnscroll();
|
insilmaril@83
|
1052 |
setLastSelectedBranch (bo);
|
insilmaril@83
|
1053 |
return bo;
|
insilmaril@83
|
1054 |
}
|
insilmaril@83
|
1055 |
|
insilmaril@0
|
1056 |
BranchObj* BranchObj::insertBranch(int pos)
|
insilmaril@0
|
1057 |
{
|
insilmaril@0
|
1058 |
savePosInAngle();
|
insilmaril@0
|
1059 |
// Add new bo and resort branches
|
insilmaril@0
|
1060 |
BranchObj *newbo=addBranch ();
|
insilmaril@0
|
1061 |
newbo->angle=pos-0.5;
|
insilmaril@0
|
1062 |
branch.sort();
|
insilmaril@0
|
1063 |
return newbo;
|
insilmaril@0
|
1064 |
}
|
insilmaril@0
|
1065 |
|
insilmaril@0
|
1066 |
BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos)
|
insilmaril@0
|
1067 |
{
|
insilmaril@0
|
1068 |
savePosInAngle();
|
insilmaril@0
|
1069 |
// Add new bo and resort branches
|
insilmaril@0
|
1070 |
bo->angle=pos-0.5;
|
insilmaril@0
|
1071 |
BranchObj *newbo=addBranch (bo);
|
insilmaril@0
|
1072 |
branch.sort();
|
insilmaril@0
|
1073 |
return newbo;
|
insilmaril@0
|
1074 |
}
|
insilmaril@0
|
1075 |
|
insilmaril@83
|
1076 |
BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
|
insilmaril@83
|
1077 |
{
|
insilmaril@83
|
1078 |
savePosInAngle();
|
insilmaril@83
|
1079 |
// Add new bo and resort branches
|
insilmaril@83
|
1080 |
bo->angle=pos-0.5;
|
insilmaril@83
|
1081 |
branch.append (bo);
|
insilmaril@83
|
1082 |
bo->setParObj (this);
|
insilmaril@83
|
1083 |
bo->depth=depth+1;
|
insilmaril@146
|
1084 |
bo->setDefAttr (MovedBranch);
|
insilmaril@83
|
1085 |
if (scrolled) tmpUnscroll();
|
insilmaril@83
|
1086 |
setLastSelectedBranch (bo);
|
insilmaril@83
|
1087 |
branch.sort();
|
insilmaril@83
|
1088 |
return bo;
|
insilmaril@83
|
1089 |
}
|
insilmaril@83
|
1090 |
|
insilmaril@98
|
1091 |
void BranchObj::removeBranchHere(BranchObj* borem)
|
insilmaril@98
|
1092 |
{
|
insilmaril@98
|
1093 |
// This removes the branch bo from list, but
|
insilmaril@98
|
1094 |
// inserts its childs at the place of bo
|
insilmaril@98
|
1095 |
BranchObj *bo;
|
insilmaril@98
|
1096 |
bo=borem->getLastBranch();
|
insilmaril@139
|
1097 |
int pos=borem->getNum();
|
insilmaril@98
|
1098 |
while (bo)
|
insilmaril@98
|
1099 |
{
|
insilmaril@139
|
1100 |
bo->moveBranchTo (this,pos+1);
|
insilmaril@98
|
1101 |
bo=borem->getLastBranch();
|
insilmaril@98
|
1102 |
}
|
insilmaril@98
|
1103 |
removeBranch (borem);
|
insilmaril@98
|
1104 |
}
|
insilmaril@98
|
1105 |
|
insilmaril@98
|
1106 |
void BranchObj::removeChilds()
|
insilmaril@98
|
1107 |
{
|
insilmaril@98
|
1108 |
clear();
|
insilmaril@98
|
1109 |
}
|
insilmaril@98
|
1110 |
|
insilmaril@0
|
1111 |
void BranchObj::removeBranch(BranchObj* bo)
|
insilmaril@0
|
1112 |
{
|
insilmaril@0
|
1113 |
// if bo is not in branch remove returns false, we
|
insilmaril@0
|
1114 |
// don't care...
|
insilmaril@83
|
1115 |
|
insilmaril@83
|
1116 |
if (branch.remove (bo))
|
insilmaril@83
|
1117 |
delete (bo);
|
insilmaril@83
|
1118 |
else
|
insilmaril@83
|
1119 |
qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
|
insilmaril@83
|
1120 |
requestReposition();
|
insilmaril@83
|
1121 |
}
|
insilmaril@83
|
1122 |
|
insilmaril@83
|
1123 |
void BranchObj::removeBranchPtr(BranchObj* bo)
|
insilmaril@83
|
1124 |
{
|
insilmaril@83
|
1125 |
branch.remove (bo);
|
insilmaril@0
|
1126 |
requestReposition();
|
insilmaril@0
|
1127 |
}
|
insilmaril@0
|
1128 |
|
insilmaril@0
|
1129 |
void BranchObj::setLastSelectedBranch (BranchObj* bo)
|
insilmaril@0
|
1130 |
{
|
insilmaril@0
|
1131 |
lastSelectedBranch=branch.find(bo);
|
insilmaril@0
|
1132 |
}
|
insilmaril@0
|
1133 |
|
insilmaril@0
|
1134 |
BranchObj* BranchObj::getLastSelectedBranch ()
|
insilmaril@0
|
1135 |
{
|
insilmaril@0
|
1136 |
if (lastSelectedBranch>=0)
|
insilmaril@0
|
1137 |
{
|
insilmaril@0
|
1138 |
BranchObj* bo=branch.at(lastSelectedBranch);
|
insilmaril@0
|
1139 |
if (bo) return bo;
|
insilmaril@0
|
1140 |
}
|
insilmaril@0
|
1141 |
return branch.first();
|
insilmaril@0
|
1142 |
}
|
insilmaril@0
|
1143 |
|
insilmaril@0
|
1144 |
BranchObj* BranchObj::getFirstBranch ()
|
insilmaril@0
|
1145 |
{
|
insilmaril@0
|
1146 |
return branch.first();
|
insilmaril@0
|
1147 |
}
|
insilmaril@0
|
1148 |
|
insilmaril@0
|
1149 |
BranchObj* BranchObj::getLastBranch ()
|
insilmaril@0
|
1150 |
{
|
insilmaril@0
|
1151 |
return branch.last();
|
insilmaril@0
|
1152 |
}
|
insilmaril@0
|
1153 |
|
insilmaril@0
|
1154 |
BranchObj* BranchObj::getBranchNum (const uint &i)
|
insilmaril@0
|
1155 |
{
|
insilmaril@0
|
1156 |
return branch.at(i);
|
insilmaril@0
|
1157 |
}
|
insilmaril@0
|
1158 |
|
insilmaril@0
|
1159 |
|
insilmaril@0
|
1160 |
BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
|
insilmaril@0
|
1161 |
{
|
insilmaril@0
|
1162 |
savePosInAngle();
|
insilmaril@0
|
1163 |
int i=branch.find(bo1);
|
insilmaril@0
|
1164 |
if (i>0)
|
insilmaril@0
|
1165 |
{ // -1 if bo1 not found
|
insilmaril@0
|
1166 |
branch.at(i)->angle--;
|
insilmaril@0
|
1167 |
branch.at(i-1)->angle++;
|
insilmaril@0
|
1168 |
branch.sort();
|
insilmaril@0
|
1169 |
return branch.at(i-1);
|
insilmaril@0
|
1170 |
} else
|
insilmaril@0
|
1171 |
return branch.at(i);
|
insilmaril@0
|
1172 |
}
|
insilmaril@0
|
1173 |
|
insilmaril@0
|
1174 |
BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
|
insilmaril@0
|
1175 |
{
|
insilmaril@0
|
1176 |
savePosInAngle();
|
insilmaril@0
|
1177 |
int i=branch.find(bo1);
|
insilmaril@0
|
1178 |
int j;
|
insilmaril@0
|
1179 |
if (branch.next())
|
insilmaril@0
|
1180 |
{
|
insilmaril@0
|
1181 |
j = branch.at();
|
insilmaril@0
|
1182 |
branch.at(i)->angle++;
|
insilmaril@0
|
1183 |
branch.at(j)->angle--;
|
insilmaril@0
|
1184 |
branch.sort();
|
insilmaril@0
|
1185 |
return branch.at(j);
|
insilmaril@0
|
1186 |
} else
|
insilmaril@0
|
1187 |
return branch.at(i);
|
insilmaril@0
|
1188 |
}
|
insilmaril@0
|
1189 |
|
insilmaril@83
|
1190 |
BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
|
insilmaril@83
|
1191 |
{
|
insilmaril@83
|
1192 |
// Find current parent and
|
insilmaril@83
|
1193 |
// remove pointer to myself there
|
insilmaril@94
|
1194 |
if (!dst) return NULL;
|
insilmaril@83
|
1195 |
BranchObj *par=(BranchObj*)(parObj);
|
insilmaril@83
|
1196 |
if (par)
|
insilmaril@83
|
1197 |
par->removeBranchPtr (this);
|
insilmaril@83
|
1198 |
else
|
insilmaril@83
|
1199 |
return NULL;
|
insilmaril@83
|
1200 |
|
insilmaril@129
|
1201 |
// Create new pointer to myself at dst
|
insilmaril@98
|
1202 |
if (pos<0||dst->getDepth()==0)
|
insilmaril@83
|
1203 |
{
|
insilmaril@98
|
1204 |
// links myself as last branch at dst
|
insilmaril@83
|
1205 |
dst->addBranchPtr (this);
|
insilmaril@151
|
1206 |
updateLink();
|
insilmaril@83
|
1207 |
return this;
|
insilmaril@83
|
1208 |
} else
|
insilmaril@83
|
1209 |
{
|
insilmaril@83
|
1210 |
// inserts me at pos in parent of dst
|
insilmaril@83
|
1211 |
if (par)
|
insilmaril@139
|
1212 |
{
|
insilmaril@139
|
1213 |
BranchObj *bo=dst->insertBranchPtr (this,pos);
|
insilmaril@146
|
1214 |
bo->setDefAttr(MovedBranch);
|
insilmaril@151
|
1215 |
updateLink();
|
insilmaril@139
|
1216 |
return bo;
|
insilmaril@139
|
1217 |
|
insilmaril@139
|
1218 |
} else
|
insilmaril@83
|
1219 |
return NULL;
|
insilmaril@83
|
1220 |
}
|
insilmaril@83
|
1221 |
}
|
insilmaril@83
|
1222 |
|
insilmaril@0
|
1223 |
void BranchObj::alignRelativeTo (QPoint ref)
|
insilmaril@0
|
1224 |
{
|
insilmaril@169
|
1225 |
int th = bboxTotal.height();
|
insilmaril@164
|
1226 |
/* TODO testing
|
insilmaril@0
|
1227 |
if (!getHeading().isEmpty())
|
insilmaril@0
|
1228 |
cout << "BO::alignRelTo "<<getHeading()<<endl;
|
insilmaril@0
|
1229 |
else
|
insilmaril@0
|
1230 |
cout << "BO::alignRelTo ???"<<endl;
|
insilmaril@169
|
1231 |
cout << " d="<<depth<<
|
insilmaril@169
|
1232 |
// " ref="<<ref<<
|
insilmaril@169
|
1233 |
// " bbTot="<<bboxTotal.topLeft()<<
|
insilmaril@169
|
1234 |
// " absPos="<<absPos<<
|
insilmaril@169
|
1235 |
" pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
|
insilmaril@169
|
1236 |
" th="<<th<<endl;
|
insilmaril@0
|
1237 |
*/
|
insilmaril@0
|
1238 |
|
insilmaril@0
|
1239 |
// If I am the mapcenter or a mainbranch, reposition heading
|
insilmaril@0
|
1240 |
if (depth<2)
|
insilmaril@166
|
1241 |
{ //FIXME optimize this move for MCO needed to initially position text in box...
|
insilmaril@0
|
1242 |
if (depth==1)
|
insilmaril@0
|
1243 |
{
|
insilmaril@166
|
1244 |
move (absPos.x(),absPos.y());
|
insilmaril@0
|
1245 |
// Calc angle to mapCenter if I am a mainbranch
|
insilmaril@0
|
1246 |
// needed for reordering the mainbranches clockwise
|
insilmaril@0
|
1247 |
// around mapcenter
|
insilmaril@0
|
1248 |
angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
|
insilmaril@0
|
1249 |
(int)(y() - parObj->getChildPos().y() ) ) );
|
insilmaril@169
|
1250 |
}
|
insilmaril@0
|
1251 |
}
|
insilmaril@0
|
1252 |
else
|
insilmaril@0
|
1253 |
{
|
insilmaril@0
|
1254 |
// Align myself depending on orientation and parent, but
|
insilmaril@0
|
1255 |
// only if I am not the mainbranch or mapcenter itself
|
insilmaril@0
|
1256 |
switch (orientation)
|
insilmaril@0
|
1257 |
{
|
insilmaril@0
|
1258 |
case OrientLeftOfCenter:
|
insilmaril@213
|
1259 |
move (ref.x() + rightPad - bbox.width(), ref.y() + (th-bbox.height())/2 +topPad);
|
insilmaril@0
|
1260 |
break;
|
insilmaril@0
|
1261 |
case OrientRightOfCenter:
|
insilmaril@213
|
1262 |
move (ref.x() + rightPad, ref.y() + (th-bbox.height())/2 + topPad);
|
insilmaril@0
|
1263 |
break;
|
insilmaril@0
|
1264 |
default:
|
insilmaril@0
|
1265 |
cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
|
insilmaril@0
|
1266 |
break;
|
insilmaril@0
|
1267 |
}
|
insilmaril@0
|
1268 |
}
|
insilmaril@0
|
1269 |
|
insilmaril@0
|
1270 |
if (scrolled) return;
|
insilmaril@0
|
1271 |
|
insilmaril@0
|
1272 |
// Set reference point for alignment of childs
|
insilmaril@0
|
1273 |
QPoint ref2;
|
insilmaril@0
|
1274 |
if (orientation==OrientLeftOfCenter)
|
insilmaril@0
|
1275 |
ref2.setX(childPos.x() - linkwidth);
|
insilmaril@0
|
1276 |
else
|
insilmaril@0
|
1277 |
ref2.setX(childPos.x() + linkwidth);
|
insilmaril@0
|
1278 |
|
insilmaril@0
|
1279 |
if (depth==1)
|
insilmaril@0
|
1280 |
ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
|
insilmaril@0
|
1281 |
else
|
insilmaril@0
|
1282 |
ref2.setY(ref.y() );
|
insilmaril@0
|
1283 |
|
insilmaril@0
|
1284 |
// Align the childs depending on reference point
|
insilmaril@0
|
1285 |
BranchObj *b;
|
insilmaril@0
|
1286 |
for (b=branch.first(); b; b=branch.next() )
|
insilmaril@0
|
1287 |
{
|
insilmaril@0
|
1288 |
b->alignRelativeTo (ref2);
|
insilmaril@0
|
1289 |
ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
|
insilmaril@0
|
1290 |
}
|
insilmaril@0
|
1291 |
}
|
insilmaril@0
|
1292 |
|
insilmaril@0
|
1293 |
|
insilmaril@0
|
1294 |
void BranchObj::reposition()
|
insilmaril@0
|
1295 |
{
|
insilmaril@164
|
1296 |
/* TODO testing only
|
insilmaril@0
|
1297 |
if (!getHeading().isEmpty())
|
insilmaril@0
|
1298 |
cout << "BO::reposition "<<getHeading()<<endl;
|
insilmaril@0
|
1299 |
else
|
insilmaril@0
|
1300 |
cout << "BO::reposition ???"<<endl;
|
insilmaril@0
|
1301 |
*/
|
insilmaril@0
|
1302 |
if (depth==0)
|
insilmaril@0
|
1303 |
{
|
insilmaril@0
|
1304 |
// only calculate the sizes once. If the deepest LMO
|
insilmaril@0
|
1305 |
// changes its height,
|
insilmaril@0
|
1306 |
// all upper LMOs have to change, too.
|
insilmaril@0
|
1307 |
calcBBoxSizeWithChilds();
|
insilmaril@0
|
1308 |
alignRelativeTo ( QPoint (absPos.x(),
|
insilmaril@0
|
1309 |
absPos.y()-(bboxTotal.height()-bbox.height())/2) );
|
insilmaril@0
|
1310 |
branch.sort();
|
insilmaril@169
|
1311 |
|
insilmaril@169
|
1312 |
// After load, the floats might be at wrong position, force
|
insilmaril@169
|
1313 |
// them to move, too
|
insilmaril@169
|
1314 |
move (absPos);
|
insilmaril@0
|
1315 |
} else
|
insilmaril@0
|
1316 |
{
|
insilmaril@0
|
1317 |
// This is only important for moving branches:
|
insilmaril@0
|
1318 |
// For editing a branch it isn't called...
|
insilmaril@0
|
1319 |
alignRelativeTo ( QPoint (absPos.x(),
|
insilmaril@0
|
1320 |
absPos.y()-(bboxTotal.height()-bbox.height())/2) );
|
insilmaril@0
|
1321 |
}
|
insilmaril@0
|
1322 |
}
|
insilmaril@0
|
1323 |
|
insilmaril@0
|
1324 |
|
insilmaril@0
|
1325 |
QRect BranchObj::getTotalBBox()
|
insilmaril@0
|
1326 |
{
|
insilmaril@0
|
1327 |
QRect r=bbox;
|
insilmaril@0
|
1328 |
|
insilmaril@0
|
1329 |
if (scrolled) return r;
|
insilmaril@0
|
1330 |
|
insilmaril@0
|
1331 |
BranchObj* b;
|
insilmaril@0
|
1332 |
for (b=branch.first();b ;b=branch.next() )
|
insilmaril@0
|
1333 |
r=addBBox(b->getTotalBBox(),r);
|
insilmaril@0
|
1334 |
|
insilmaril@0
|
1335 |
FloatImageObj* fio;
|
insilmaril@0
|
1336 |
for (fio=floatimage.first();fio ;fio=floatimage.next() )
|
insilmaril@0
|
1337 |
r=addBBox(fio->getTotalBBox(),r);
|
insilmaril@0
|
1338 |
|
insilmaril@0
|
1339 |
return r;
|
insilmaril@0
|
1340 |
}
|
insilmaril@0
|
1341 |
|
insilmaril@0
|
1342 |
QRect BranchObj::getBBoxSizeWithChilds()
|
insilmaril@0
|
1343 |
{
|
insilmaril@0
|
1344 |
return bboxTotal;
|
insilmaril@0
|
1345 |
}
|
insilmaril@0
|
1346 |
|
insilmaril@0
|
1347 |
void BranchObj::calcBBoxSizeWithChilds()
|
insilmaril@169
|
1348 |
{
|
insilmaril@169
|
1349 |
// This is initially called only from reposition and
|
insilmaril@0
|
1350 |
// and only for mapcenter. So it won't be
|
insilmaril@0
|
1351 |
// called more than once for a single user
|
insilmaril@0
|
1352 |
// action
|
insilmaril@0
|
1353 |
|
insilmaril@169
|
1354 |
|
insilmaril@0
|
1355 |
// Calculate size of LMO including all childs (to align them later)
|
insilmaril@0
|
1356 |
bboxTotal.setX(bbox.x() );
|
insilmaril@0
|
1357 |
bboxTotal.setY(bbox.y() );
|
insilmaril@0
|
1358 |
|
insilmaril@0
|
1359 |
// if branch is scrolled, ignore childs, but still consider floatimages
|
insilmaril@0
|
1360 |
if (scrolled)
|
insilmaril@0
|
1361 |
{
|
insilmaril@0
|
1362 |
bboxTotal.setWidth (bbox.width());
|
insilmaril@0
|
1363 |
bboxTotal.setHeight(bbox.height());
|
insilmaril@0
|
1364 |
return;
|
insilmaril@0
|
1365 |
}
|
insilmaril@0
|
1366 |
|
insilmaril@0
|
1367 |
QRect r(0,0,0,0);
|
insilmaril@0
|
1368 |
QRect br;
|
insilmaril@0
|
1369 |
// Now calculate recursivly
|
insilmaril@0
|
1370 |
// sum of heights
|
insilmaril@0
|
1371 |
// maximum of widths
|
insilmaril@0
|
1372 |
// minimum of y
|
insilmaril@0
|
1373 |
BranchObj* b;
|
insilmaril@0
|
1374 |
for (b=branch.first();b ;b=branch.next() )
|
insilmaril@0
|
1375 |
{
|
insilmaril@0
|
1376 |
b->calcBBoxSizeWithChilds();
|
insilmaril@0
|
1377 |
br=b->getBBoxSizeWithChilds();
|
insilmaril@0
|
1378 |
r.setWidth( max (br.width(), r.width() ));
|
insilmaril@0
|
1379 |
r.setHeight(br.height() + r.height() );
|
insilmaril@0
|
1380 |
if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
|
insilmaril@0
|
1381 |
}
|
insilmaril@0
|
1382 |
// Add myself and also
|
insilmaril@0
|
1383 |
// add width of link to sum if necessary
|
insilmaril@0
|
1384 |
if (branch.isEmpty())
|
insilmaril@0
|
1385 |
bboxTotal.setWidth (bbox.width() + r.width() );
|
insilmaril@0
|
1386 |
else
|
insilmaril@0
|
1387 |
bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
|
insilmaril@169
|
1388 |
|
insilmaril@169
|
1389 |
bboxTotal.setHeight(max (r.height(), bbox.height()));
|
insilmaril@0
|
1390 |
// frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
|
insilmaril@169
|
1391 |
|
insilmaril@0
|
1392 |
}
|
insilmaril@0
|
1393 |
|
insilmaril@0
|
1394 |
void BranchObj::select()
|
insilmaril@0
|
1395 |
{
|
insilmaril@160
|
1396 |
// set Text in Editor
|
insilmaril@160
|
1397 |
textEditor->setText(note.getNote() );
|
insilmaril@160
|
1398 |
QString fnh=note.getFilenameHint();
|
insilmaril@160
|
1399 |
if (fnh!="")
|
insilmaril@160
|
1400 |
textEditor->setFilenameHint(note.getFilenameHint() );
|
insilmaril@160
|
1401 |
else
|
insilmaril@160
|
1402 |
textEditor->setFilenameHint(getHeading() );
|
insilmaril@160
|
1403 |
textEditor->setFontHint (note.getFontHint() );
|
insilmaril@160
|
1404 |
|
insilmaril@0
|
1405 |
LinkableMapObj::select();
|
insilmaril@0
|
1406 |
// Tell parent that I am selected now:
|
insilmaril@0
|
1407 |
BranchObj* po=(BranchObj*)(parObj);
|
insilmaril@0
|
1408 |
if (po) // TODO Try to get rid of this cast...
|
insilmaril@0
|
1409 |
po->setLastSelectedBranch(this);
|
insilmaril@0
|
1410 |
|
insilmaril@0
|
1411 |
// temporary unscroll, if we have scrolled parents somewhere
|
insilmaril@0
|
1412 |
if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
|
insilmaril@0
|
1413 |
|
insilmaril@0
|
1414 |
// Show URL and link in statusbar
|
insilmaril@0
|
1415 |
QString status;
|
insilmaril@0
|
1416 |
if (!url.isEmpty()) status+="URL: "+url+" ";
|
insilmaril@0
|
1417 |
if (!vymLink.isEmpty()) status+="Link: "+vymLink;
|
insilmaril@0
|
1418 |
if (!status.isEmpty()) mainWindow->statusMessage (status);
|
insilmaril@0
|
1419 |
|
insilmaril@0
|
1420 |
// Update Toolbar
|
insilmaril@103
|
1421 |
standardFlags->updateToolbar();
|
insilmaril@0
|
1422 |
|
insilmaril@0
|
1423 |
// Update Browserbutton
|
insilmaril@0
|
1424 |
if (!url.isEmpty())
|
insilmaril@0
|
1425 |
actionEditOpenURL->setEnabled (true);
|
insilmaril@0
|
1426 |
else
|
insilmaril@0
|
1427 |
actionEditOpenURL->setEnabled (false);
|
insilmaril@0
|
1428 |
|
insilmaril@0
|
1429 |
// Update actions in mapeditor
|
insilmaril@0
|
1430 |
mapEditor->updateActions();
|
insilmaril@0
|
1431 |
}
|
insilmaril@0
|
1432 |
|
insilmaril@0
|
1433 |
void BranchObj::unselect()
|
insilmaril@0
|
1434 |
{
|
insilmaril@0
|
1435 |
LinkableMapObj::unselect();
|
insilmaril@0
|
1436 |
// Delete any messages like vymLink in StatusBar
|
insilmaril@0
|
1437 |
mainWindow->statusMessage ("");
|
insilmaril@0
|
1438 |
|
insilmaril@0
|
1439 |
// save note from editor and set flag
|
insilmaril@0
|
1440 |
// text is done by updateNoteFlag(), just save
|
insilmaril@0
|
1441 |
// filename here
|
insilmaril@0
|
1442 |
note.setFilenameHint (textEditor->getFilename());
|
insilmaril@0
|
1443 |
|
insilmaril@0
|
1444 |
// reset temporary unscroll, if we have scrolled parents somewhere
|
insilmaril@0
|
1445 |
if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
|
insilmaril@0
|
1446 |
|
insilmaril@0
|
1447 |
// Erase content of editor
|
insilmaril@0
|
1448 |
textEditor->setInactive();
|
insilmaril@0
|
1449 |
|
insilmaril@0
|
1450 |
// unselect all buttons in toolbar
|
insilmaril@103
|
1451 |
standardFlagsDefault->updateToolbar();
|
insilmaril@0
|
1452 |
}
|
insilmaril@0
|
1453 |
|
insilmaril@0
|
1454 |
QString BranchObj::getSelectString()
|
insilmaril@0
|
1455 |
{
|
insilmaril@0
|
1456 |
QString s;
|
insilmaril@0
|
1457 |
if (parObj)
|
insilmaril@0
|
1458 |
{
|
insilmaril@95
|
1459 |
if (depth==1)
|
insilmaril@0
|
1460 |
s= "bo:" + QString("%1").arg(getNum());
|
insilmaril@0
|
1461 |
else
|
insilmaril@0
|
1462 |
s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());
|
insilmaril@0
|
1463 |
} else
|
insilmaril@0
|
1464 |
s="mc:";
|
insilmaril@0
|
1465 |
return s;
|
insilmaril@0
|
1466 |
}
|
insilmaril@0
|
1467 |
|