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