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