insilmaril@822
|
1 |
#include "attributeitem.h"
|
insilmaril@747
|
2 |
#include "branchitem.h"
|
insilmaril@747
|
3 |
#include "branchobj.h"
|
insilmaril@753
|
4 |
#include "vymmodel.h"
|
insilmaril@790
|
5 |
#include "xlinkitem.h"
|
insilmaril@747
|
6 |
|
insilmaril@747
|
7 |
#include <iostream>
|
insilmaril@753
|
8 |
#include <QDir>
|
insilmaril@753
|
9 |
|
insilmaril@747
|
10 |
using namespace std;
|
insilmaril@747
|
11 |
|
insilmaril@779
|
12 |
BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):MapItem (data,parent)
|
insilmaril@747
|
13 |
{
|
insilmaril@749
|
14 |
//cout << "Constr. BranchItem\n";
|
insilmaril@749
|
15 |
|
insilmaril@791
|
16 |
// Set type if parent is known yet
|
insilmaril@791
|
17 |
// if not, type is set in insertBranch or TreeItem::appendChild
|
insilmaril@788
|
18 |
if (parent==rootItem)
|
insilmaril@788
|
19 |
setType (MapCenter);
|
insilmaril@788
|
20 |
else
|
insilmaril@788
|
21 |
setType (Branch);
|
insilmaril@788
|
22 |
|
insilmaril@749
|
23 |
scrolled=false;
|
insilmaril@749
|
24 |
tmpUnscrolled=false;
|
insilmaril@785
|
25 |
|
insilmaril@785
|
26 |
includeImagesVer=false;
|
insilmaril@785
|
27 |
includeImagesHor=false;
|
insilmaril@787
|
28 |
|
insilmaril@787
|
29 |
lastSelectedBranchNum=-1;
|
insilmaril@787
|
30 |
lastSelectedBranchNumAlt=-1;
|
insilmaril@747
|
31 |
}
|
insilmaril@747
|
32 |
|
insilmaril@747
|
33 |
BranchItem::~BranchItem()
|
insilmaril@747
|
34 |
{
|
insilmaril@788
|
35 |
//cout << "Destr. BranchItem "<<getHeadingStd()<<endl;
|
insilmaril@756
|
36 |
if (lmo)
|
insilmaril@756
|
37 |
{
|
insilmaril@756
|
38 |
delete lmo;
|
insilmaril@756
|
39 |
lmo=NULL;
|
insilmaril@756
|
40 |
}
|
insilmaril@747
|
41 |
}
|
insilmaril@747
|
42 |
|
insilmaril@749
|
43 |
void BranchItem::copy (BranchItem *other)
|
insilmaril@749
|
44 |
{
|
insilmaril@749
|
45 |
scrolled=other->scrolled;
|
insilmaril@749
|
46 |
tmpUnscrolled=other->tmpUnscrolled;
|
insilmaril@749
|
47 |
}
|
insilmaril@749
|
48 |
|
insilmaril@795
|
49 |
BranchItem* BranchItem::parentBranch ()
|
insilmaril@795
|
50 |
{
|
insilmaril@795
|
51 |
return (BranchItem*) parentItem;
|
insilmaril@795
|
52 |
}
|
insilmaril@795
|
53 |
|
insilmaril@756
|
54 |
void BranchItem::insertBranch (int pos, BranchItem *branch)
|
insilmaril@756
|
55 |
{
|
insilmaril@756
|
56 |
if (pos<0) pos=0;
|
insilmaril@756
|
57 |
if (pos>branchCounter) pos=branchCounter;
|
insilmaril@756
|
58 |
childItems.insert(pos+branchOffset,branch);
|
insilmaril@756
|
59 |
branch->parentItem=this;
|
insilmaril@791
|
60 |
branch->rootItem=rootItem;
|
insilmaril@756
|
61 |
branch->setModel (model);
|
insilmaril@791
|
62 |
if (parentItem==rootItem)
|
insilmaril@791
|
63 |
setType (MapCenter);
|
insilmaril@791
|
64 |
else
|
insilmaril@791
|
65 |
setType (Branch);
|
insilmaril@791
|
66 |
|
insilmaril@756
|
67 |
|
insilmaril@756
|
68 |
if (branchCounter==0)
|
insilmaril@756
|
69 |
branchOffset=childItems.count()-1;
|
insilmaril@756
|
70 |
branchCounter++;
|
insilmaril@756
|
71 |
}
|
insilmaril@756
|
72 |
|
insilmaril@771
|
73 |
QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-3 Check if everything is saved...
|
insilmaril@747
|
74 |
{
|
insilmaril@747
|
75 |
// Cloudy stuff can be hidden during exports
|
insilmaril@748
|
76 |
if (hidden) return QString();
|
insilmaril@747
|
77 |
|
insilmaril@747
|
78 |
QString s,a;
|
insilmaril@747
|
79 |
BranchObj *bo=(BranchObj*)lmo;
|
insilmaril@747
|
80 |
|
insilmaril@747
|
81 |
// Update of note is usually done while unselecting a branch
|
insilmaril@747
|
82 |
|
insilmaril@747
|
83 |
QString scrolledAttr;
|
insilmaril@747
|
84 |
if (scrolled)
|
insilmaril@747
|
85 |
scrolledAttr=attribut ("scrolled","yes");
|
insilmaril@747
|
86 |
else
|
insilmaril@747
|
87 |
scrolledAttr="";
|
insilmaril@747
|
88 |
|
insilmaril@775
|
89 |
// save area, if not scrolled // FIXME-5 not needed if HTML is rewritten...
|
insilmaril@768
|
90 |
// also we should check if _any_ of parents is scrolled
|
insilmaril@747
|
91 |
QString areaAttr;
|
insilmaril@775
|
92 |
if (lmo && parentItem->isBranchLikeType() && !((BranchItem*)parentItem)->isScrolled() )
|
insilmaril@747
|
93 |
{
|
insilmaril@775
|
94 |
qreal x=lmo->getAbsPos().x();
|
insilmaril@775
|
95 |
qreal y=lmo->getAbsPos().y();
|
insilmaril@747
|
96 |
areaAttr=
|
insilmaril@775
|
97 |
attribut("x1",QString().setNum(x-offset.x())) +
|
insilmaril@775
|
98 |
attribut("y1",QString().setNum(y-offset.y())) +
|
insilmaril@775
|
99 |
attribut("x2",QString().setNum(x+lmo->width()-offset.x())) +
|
insilmaril@775
|
100 |
attribut("y2",QString().setNum(y+lmo->height()-offset.y()));
|
insilmaril@747
|
101 |
|
insilmaril@747
|
102 |
} else
|
insilmaril@747
|
103 |
areaAttr="";
|
insilmaril@747
|
104 |
|
insilmaril@790
|
105 |
// Provide an ID for a branch makes export to XHTML easier
|
insilmaril@747
|
106 |
QString idAttr;
|
insilmaril@790
|
107 |
if (xlinkCount()>0)
|
insilmaril@790
|
108 |
idAttr=attribut ("id",model->getSelectString(this));
|
insilmaril@747
|
109 |
else
|
insilmaril@747
|
110 |
idAttr="";
|
insilmaril@747
|
111 |
|
insilmaril@773
|
112 |
QString elementName;
|
insilmaril@773
|
113 |
if (parentItem==rootItem)
|
insilmaril@773
|
114 |
elementName="mapcenter";
|
insilmaril@773
|
115 |
else
|
insilmaril@773
|
116 |
elementName="branch";
|
insilmaril@773
|
117 |
|
insilmaril@773
|
118 |
s=beginElement (elementName
|
insilmaril@779
|
119 |
+getMapAttr()
|
insilmaril@779
|
120 |
+getGeneralAttr()
|
insilmaril@768
|
121 |
+scrolledAttr
|
insilmaril@822
|
122 |
// +areaAttr // FIXME-4 not needed anymore. Wait until end of 2010 before removing...
|
insilmaril@790
|
123 |
+idAttr
|
insilmaril@785
|
124 |
+getIncludeImageAttr()
|
insilmaril@747
|
125 |
);
|
insilmaril@747
|
126 |
incIndent();
|
insilmaril@747
|
127 |
|
insilmaril@747
|
128 |
// save heading
|
insilmaril@747
|
129 |
s+=valueElement("heading", getHeading(),
|
insilmaril@747
|
130 |
attribut ("textColor",QColor( bo->getColor()).name()));
|
insilmaril@747
|
131 |
|
insilmaril@777
|
132 |
// Save frame //FIXME-4 not saved if there is no LMO
|
insilmaril@777
|
133 |
if (lmo && ((OrnamentedObj*)lmo)->getFrame()->getFrameType()!=FrameObj::NoFrame)
|
insilmaril@777
|
134 |
s+=((OrnamentedObj*)lmo)->getFrame()->saveToDir ();
|
insilmaril@747
|
135 |
|
insilmaril@747
|
136 |
// save names of flags set
|
insilmaril@768
|
137 |
s+=standardFlags.saveToDir(tmpdir,prefix,0);
|
insilmaril@747
|
138 |
|
insilmaril@776
|
139 |
// Save Images
|
insilmaril@776
|
140 |
for (int i=0; i<imageCount(); ++i)
|
insilmaril@776
|
141 |
s+=getImageNum(i)->saveToDir (tmpdir,prefix);
|
insilmaril@747
|
142 |
|
insilmaril@747
|
143 |
// save note
|
insilmaril@747
|
144 |
if (!note.isEmpty() )
|
insilmaril@747
|
145 |
s+=note.saveToDir();
|
insilmaril@747
|
146 |
|
insilmaril@747
|
147 |
// Save branches
|
insilmaril@760
|
148 |
int i=0;
|
insilmaril@760
|
149 |
TreeItem *ti=getBranchNum(i);
|
insilmaril@760
|
150 |
while (ti)
|
insilmaril@760
|
151 |
{
|
insilmaril@760
|
152 |
s+=getBranchNum(i)->saveToDir(tmpdir,prefix,offset);
|
insilmaril@760
|
153 |
i++;
|
insilmaril@760
|
154 |
ti=getBranchNum(i);
|
insilmaril@760
|
155 |
}
|
insilmaril@747
|
156 |
|
insilmaril@790
|
157 |
// Save XLinks
|
insilmaril@747
|
158 |
QString ol; // old link
|
insilmaril@747
|
159 |
QString cl; // current link
|
insilmaril@790
|
160 |
for (int i=0; i<xlinkCount(); ++i)
|
insilmaril@747
|
161 |
{
|
insilmaril@790
|
162 |
cl=getXLinkNum(i)->saveToDir();
|
insilmaril@747
|
163 |
if (cl!=ol)
|
insilmaril@747
|
164 |
{
|
insilmaril@747
|
165 |
s+=cl;
|
insilmaril@747
|
166 |
ol=cl;
|
insilmaril@747
|
167 |
} else
|
insilmaril@747
|
168 |
{
|
insilmaril@825
|
169 |
qWarning (QString("BranchItem::saveToDir Ignoring of duplicate xLink in %1").arg(getHeading()));
|
insilmaril@747
|
170 |
}
|
insilmaril@747
|
171 |
}
|
insilmaril@747
|
172 |
|
insilmaril@747
|
173 |
decIndent();
|
insilmaril@773
|
174 |
s+=endElement (elementName);
|
insilmaril@747
|
175 |
return s;
|
insilmaril@747
|
176 |
}
|
insilmaril@747
|
177 |
|
insilmaril@781
|
178 |
void BranchItem::updateVisibility()
|
insilmaril@753
|
179 |
{
|
insilmaril@781
|
180 |
// Needed to hide relinked branch, if parent is scrolled
|
insilmaril@781
|
181 |
if (lmo)
|
insilmaril@819
|
182 |
{
|
insilmaril@819
|
183 |
if (hasScrolledParent(this) || hidden)
|
insilmaril@819
|
184 |
lmo->setVisibility (false);
|
insilmaril@819
|
185 |
else
|
insilmaril@819
|
186 |
lmo->setVisibility (true);
|
insilmaril@819
|
187 |
}
|
insilmaril@753
|
188 |
}
|
insilmaril@753
|
189 |
|
insilmaril@758
|
190 |
void BranchItem::setHeadingColor (QColor color)
|
insilmaril@758
|
191 |
{
|
insilmaril@758
|
192 |
TreeItem::setHeadingColor (color);
|
insilmaril@758
|
193 |
if (lmo) ((BranchObj*)lmo)->setColor (color);
|
insilmaril@758
|
194 |
}
|
insilmaril@758
|
195 |
|
insilmaril@749
|
196 |
void BranchItem::unScroll()
|
insilmaril@749
|
197 |
{
|
insilmaril@749
|
198 |
if (tmpUnscrolled) resetTmpUnscroll();
|
insilmaril@749
|
199 |
if (scrolled) toggleScroll();
|
insilmaril@749
|
200 |
}
|
insilmaril@747
|
201 |
|
insilmaril@767
|
202 |
bool BranchItem::toggleScroll()
|
insilmaril@749
|
203 |
{
|
insilmaril@763
|
204 |
BranchObj *bo=NULL;
|
insilmaril@749
|
205 |
if (scrolled)
|
insilmaril@749
|
206 |
{
|
insilmaril@749
|
207 |
scrolled=false;
|
insilmaril@767
|
208 |
systemFlags.deactivate("system-scrolledright");
|
insilmaril@767
|
209 |
if (branchCounter>0)
|
insilmaril@763
|
210 |
{
|
insilmaril@767
|
211 |
for (int i=0;i<branchCounter;++i)
|
insilmaril@767
|
212 |
{
|
insilmaril@767
|
213 |
bo=(BranchObj*)(getBranchNum(i)->getLMO());
|
insilmaril@767
|
214 |
if (bo) bo->setVisibility(true);
|
insilmaril@767
|
215 |
}
|
insilmaril@763
|
216 |
}
|
insilmaril@749
|
217 |
} else
|
insilmaril@749
|
218 |
{
|
insilmaril@749
|
219 |
scrolled=true;
|
insilmaril@767
|
220 |
systemFlags.activate("system-scrolledright");
|
insilmaril@767
|
221 |
if (branchCounter>0)
|
insilmaril@763
|
222 |
{
|
insilmaril@767
|
223 |
for (int i=0;i<branchCounter;++i)
|
insilmaril@767
|
224 |
{
|
insilmaril@767
|
225 |
bo=(BranchObj*)(getBranchNum(i)->getLMO());
|
insilmaril@767
|
226 |
if (bo) bo->setVisibility(false);
|
insilmaril@767
|
227 |
}
|
insilmaril@763
|
228 |
}
|
insilmaril@749
|
229 |
}
|
insilmaril@795
|
230 |
//model->reposition(); // FIXME-3 we don't really want to update view from here...
|
insilmaril@767
|
231 |
return true;
|
insilmaril@749
|
232 |
}
|
insilmaril@749
|
233 |
|
insilmaril@749
|
234 |
bool BranchItem::isScrolled()
|
insilmaril@749
|
235 |
{
|
insilmaril@749
|
236 |
return scrolled;
|
insilmaril@749
|
237 |
}
|
insilmaril@749
|
238 |
|
insilmaril@749
|
239 |
bool BranchItem::hasScrolledParent(BranchItem *start)
|
insilmaril@749
|
240 |
{
|
insilmaril@749
|
241 |
// Calls parents recursivly to
|
insilmaril@749
|
242 |
// find out, if we are scrolled at all.
|
insilmaril@749
|
243 |
// But ignore myself, just look at parents.
|
insilmaril@749
|
244 |
|
insilmaril@749
|
245 |
if (this !=start && scrolled) return true;
|
insilmaril@749
|
246 |
|
insilmaril@749
|
247 |
BranchItem* bi=(BranchItem*)parentItem;
|
insilmaril@796
|
248 |
if (bi && bi!=rootItem )
|
insilmaril@749
|
249 |
return bi->hasScrolledParent(start);
|
insilmaril@749
|
250 |
else
|
insilmaril@749
|
251 |
return false;
|
insilmaril@749
|
252 |
}
|
insilmaril@749
|
253 |
|
insilmaril@796
|
254 |
bool BranchItem::tmpUnscroll()
|
insilmaril@749
|
255 |
{
|
insilmaril@796
|
256 |
bool result=false;
|
insilmaril@796
|
257 |
|
insilmaril@749
|
258 |
// Unscroll parent (recursivly)
|
insilmaril@775
|
259 |
BranchItem * pi=(BranchItem*)parentItem;
|
insilmaril@796
|
260 |
if (pi && pi->isBranchLikeType() ) result=pi->tmpUnscroll();
|
insilmaril@749
|
261 |
|
insilmaril@749
|
262 |
// Unscroll myself
|
insilmaril@749
|
263 |
if (scrolled)
|
insilmaril@749
|
264 |
{
|
insilmaril@749
|
265 |
tmpUnscrolled=true;
|
insilmaril@775
|
266 |
systemFlags.activate("system-tmpUnscrolledRight");
|
insilmaril@749
|
267 |
toggleScroll();
|
insilmaril@775
|
268 |
model->emitDataHasChanged (this);
|
insilmaril@796
|
269 |
result=true;
|
insilmaril@749
|
270 |
}
|
insilmaril@796
|
271 |
return result;
|
insilmaril@749
|
272 |
}
|
insilmaril@749
|
273 |
|
insilmaril@796
|
274 |
bool BranchItem::resetTmpUnscroll()
|
insilmaril@749
|
275 |
{
|
insilmaril@796
|
276 |
bool result=false;
|
insilmaril@796
|
277 |
|
insilmaril@749
|
278 |
// Unscroll parent (recursivly)
|
insilmaril@775
|
279 |
BranchItem * pi=(BranchItem*)parentItem;
|
insilmaril@796
|
280 |
if (pi && pi->isBranchLikeType() ) result=pi->resetTmpUnscroll();
|
insilmaril@749
|
281 |
|
insilmaril@749
|
282 |
// Unscroll myself
|
insilmaril@749
|
283 |
if (tmpUnscrolled)
|
insilmaril@749
|
284 |
{
|
insilmaril@749
|
285 |
tmpUnscrolled=false;
|
insilmaril@775
|
286 |
systemFlags.deactivate("system-tmpUnscrolledRight");
|
insilmaril@749
|
287 |
toggleScroll();
|
insilmaril@775
|
288 |
model->emitDataHasChanged (this);
|
insilmaril@796
|
289 |
result=true;
|
insilmaril@749
|
290 |
}
|
insilmaril@796
|
291 |
return result;
|
insilmaril@749
|
292 |
}
|
insilmaril@749
|
293 |
|
insilmaril@822
|
294 |
void BranchItem::sortChildren(bool inverse)
|
insilmaril@795
|
295 |
{
|
insilmaril@795
|
296 |
int childCount=branchCounter;
|
insilmaril@795
|
297 |
int curChildIndex;
|
insilmaril@795
|
298 |
bool madeChanges=false;
|
insilmaril@795
|
299 |
do
|
insilmaril@795
|
300 |
{
|
insilmaril@795
|
301 |
madeChanges=false;
|
insilmaril@823
|
302 |
for(curChildIndex=1;curChildIndex<childCount;curChildIndex++)
|
insilmaril@823
|
303 |
{
|
insilmaril@823
|
304 |
BranchItem* curChild =getBranchNum(curChildIndex);
|
insilmaril@823
|
305 |
BranchItem* prevChild=getBranchNum(curChildIndex-1);
|
insilmaril@823
|
306 |
if (inverse)
|
insilmaril@795
|
307 |
{
|
insilmaril@822
|
308 |
if (prevChild->getHeading().compare(curChild->getHeading())<0)
|
insilmaril@822
|
309 |
{
|
insilmaril@822
|
310 |
model->moveUp (curChild);
|
insilmaril@822
|
311 |
madeChanges=true;
|
insilmaril@822
|
312 |
}
|
insilmaril@823
|
313 |
} else
|
insilmaril@823
|
314 |
if (prevChild->getHeading().compare(curChild->getHeading())>0)
|
insilmaril@822
|
315 |
{
|
insilmaril@823
|
316 |
model->moveUp (curChild);
|
insilmaril@822
|
317 |
madeChanges=true;
|
insilmaril@822
|
318 |
}
|
insilmaril@823
|
319 |
}
|
insilmaril@795
|
320 |
}while(madeChanges);
|
insilmaril@795
|
321 |
}
|
insilmaril@795
|
322 |
|
insilmaril@785
|
323 |
void BranchItem::setIncludeImagesVer(bool b)
|
insilmaril@785
|
324 |
{
|
insilmaril@785
|
325 |
includeImagesVer=b;
|
insilmaril@795
|
326 |
/* calcBBoxSize(); FIXME-3
|
insilmaril@785
|
327 |
positionBBox();
|
insilmaril@785
|
328 |
requestReposition();
|
insilmaril@785
|
329 |
*/
|
insilmaril@785
|
330 |
}
|
insilmaril@785
|
331 |
|
insilmaril@785
|
332 |
bool BranchItem::getIncludeImagesVer()
|
insilmaril@785
|
333 |
{
|
insilmaril@785
|
334 |
return includeImagesVer;
|
insilmaril@785
|
335 |
}
|
insilmaril@785
|
336 |
|
insilmaril@785
|
337 |
void BranchItem::setIncludeImagesHor(bool b)
|
insilmaril@785
|
338 |
{
|
insilmaril@785
|
339 |
includeImagesHor=b;
|
insilmaril@795
|
340 |
/* calcBBoxSize(); FIXME-3
|
insilmaril@785
|
341 |
positionBBox();
|
insilmaril@785
|
342 |
requestReposition();
|
insilmaril@785
|
343 |
*/
|
insilmaril@785
|
344 |
}
|
insilmaril@785
|
345 |
|
insilmaril@785
|
346 |
bool BranchItem::getIncludeImagesHor()
|
insilmaril@785
|
347 |
{
|
insilmaril@785
|
348 |
return includeImagesHor;
|
insilmaril@785
|
349 |
}
|
insilmaril@785
|
350 |
|
insilmaril@785
|
351 |
QString BranchItem::getIncludeImageAttr()
|
insilmaril@785
|
352 |
{
|
insilmaril@785
|
353 |
QString a;
|
insilmaril@785
|
354 |
if (includeImagesVer)
|
insilmaril@785
|
355 |
a=attribut ("incImgV","true");
|
insilmaril@785
|
356 |
if (includeImagesHor)
|
insilmaril@785
|
357 |
a+=attribut ("incImgH","true");
|
insilmaril@785
|
358 |
return a;
|
insilmaril@785
|
359 |
}
|
insilmaril@785
|
360 |
|
insilmaril@787
|
361 |
void BranchItem::setLastSelectedBranch()
|
insilmaril@787
|
362 |
{
|
insilmaril@787
|
363 |
int d=depth();
|
insilmaril@787
|
364 |
if (d>=0)
|
insilmaril@787
|
365 |
{
|
insilmaril@787
|
366 |
if (d==1)
|
insilmaril@787
|
367 |
// Hack to save an additional lastSelected for mapcenters in MapEditor
|
insilmaril@787
|
368 |
// depending on orientation
|
insilmaril@787
|
369 |
// this allows to go both left and right from there
|
insilmaril@787
|
370 |
if (lmo && lmo->getOrientation()==LinkableMapObj::LeftOfCenter)
|
insilmaril@787
|
371 |
{
|
insilmaril@787
|
372 |
((BranchItem*)parentItem)->lastSelectedBranchNumAlt=parentItem->num(this);
|
insilmaril@787
|
373 |
return;
|
insilmaril@787
|
374 |
}
|
insilmaril@787
|
375 |
((BranchItem*)parentItem)->lastSelectedBranchNum=parentItem->num(this);
|
insilmaril@787
|
376 |
}
|
insilmaril@787
|
377 |
}
|
insilmaril@787
|
378 |
|
insilmaril@787
|
379 |
void BranchItem::setLastSelectedBranch(int i)
|
insilmaril@787
|
380 |
{
|
insilmaril@787
|
381 |
lastSelectedBranchNum=i;
|
insilmaril@787
|
382 |
}
|
insilmaril@787
|
383 |
|
insilmaril@787
|
384 |
BranchItem* BranchItem::getLastSelectedBranch()
|
insilmaril@787
|
385 |
{
|
insilmaril@804
|
386 |
if (lastSelectedBranchNum>=branchCounter)
|
insilmaril@804
|
387 |
return getBranchNum (branchCounter-1);
|
insilmaril@804
|
388 |
else
|
insilmaril@804
|
389 |
return getBranchNum (lastSelectedBranchNum);
|
insilmaril@787
|
390 |
}
|
insilmaril@787
|
391 |
|
insilmaril@787
|
392 |
BranchItem* BranchItem::getLastSelectedBranchAlt()
|
insilmaril@787
|
393 |
{
|
insilmaril@787
|
394 |
return getBranchNum (lastSelectedBranchNumAlt);
|
insilmaril@787
|
395 |
}
|
insilmaril@787
|
396 |
|
insilmaril@787
|
397 |
|
insilmaril@787
|
398 |
|
insilmaril@785
|
399 |
|
insilmaril@758
|
400 |
TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeTI)
|
insilmaril@754
|
401 |
{
|
insilmaril@754
|
402 |
// Search branches
|
insilmaril@754
|
403 |
TreeItem *ti;
|
insilmaril@754
|
404 |
for (int i=0; i<branchCount(); ++i)
|
insilmaril@754
|
405 |
{
|
insilmaril@758
|
406 |
ti=getBranchNum(i)->findMapItem(p, excludeTI);
|
insilmaril@754
|
407 |
if (ti != NULL) return ti;
|
insilmaril@754
|
408 |
}
|
insilmaril@754
|
409 |
|
insilmaril@754
|
410 |
|
insilmaril@754
|
411 |
// Search myself
|
insilmaril@758
|
412 |
if (getBranchObj()->isInClickBox (p) && (this != excludeTI) && getBranchObj()->isVisibleObj() )
|
insilmaril@754
|
413 |
return this;
|
insilmaril@754
|
414 |
|
insilmaril@776
|
415 |
// Search images
|
insilmaril@776
|
416 |
ImageItem *ii;
|
insilmaril@776
|
417 |
for (int i=0; i<imageCount(); ++i )
|
insilmaril@776
|
418 |
{
|
insilmaril@776
|
419 |
ii=getImageNum (i);
|
insilmaril@776
|
420 |
LinkableMapObj *mo=ii->getLMO();
|
insilmaril@776
|
421 |
if (mo && mo->isInClickBox(p) &&
|
insilmaril@776
|
422 |
(ii != excludeTI) &&
|
insilmaril@776
|
423 |
this!= excludeTI &&
|
insilmaril@776
|
424 |
mo->isVisibleObj()
|
insilmaril@776
|
425 |
) return ii;
|
insilmaril@776
|
426 |
}
|
insilmaril@822
|
427 |
|
insilmaril@822
|
428 |
// Search attributes
|
insilmaril@822
|
429 |
AttributeItem *ai;
|
insilmaril@822
|
430 |
for (int i=0; i<attributeCount(); ++i )
|
insilmaril@822
|
431 |
{
|
insilmaril@822
|
432 |
ai=getAttributeNum (i);
|
insilmaril@822
|
433 |
LinkableMapObj *mo=ai->getLMO();
|
insilmaril@822
|
434 |
if (mo && mo->isInClickBox(p) &&
|
insilmaril@822
|
435 |
(ii != excludeTI) &&
|
insilmaril@822
|
436 |
this!= excludeTI &&
|
insilmaril@822
|
437 |
mo->isVisibleObj()
|
insilmaril@822
|
438 |
) return ai;
|
insilmaril@822
|
439 |
}
|
insilmaril@822
|
440 |
|
insilmaril@776
|
441 |
return NULL;
|
insilmaril@754
|
442 |
}
|
insilmaril@754
|
443 |
|
insilmaril@822
|
444 |
void BranchItem::updateStyles(const bool &keepFrame)
|
insilmaril@773
|
445 |
{
|
insilmaril@773
|
446 |
// FIXME-5 compare also MapItem::initLMO...
|
insilmaril@773
|
447 |
|
insilmaril@798
|
448 |
if (lmo)
|
insilmaril@798
|
449 |
{
|
insilmaril@798
|
450 |
if ( parentItem != rootItem)
|
insilmaril@798
|
451 |
lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
|
insilmaril@798
|
452 |
else
|
insilmaril@798
|
453 |
lmo->setParObj (NULL);
|
insilmaril@822
|
454 |
((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch,keepFrame);
|
insilmaril@773
|
455 |
}
|
insilmaril@773
|
456 |
}
|
insilmaril@754
|
457 |
|
insilmaril@750
|
458 |
BranchObj* BranchItem::getBranchObj() // FIXME-3 only for transition BO->BI
|
insilmaril@750
|
459 |
{
|
insilmaril@750
|
460 |
return (BranchObj*)lmo;
|
insilmaril@750
|
461 |
}
|
insilmaril@749
|
462 |
|
insilmaril@786
|
463 |
BranchObj* BranchItem::createMapObj(QGraphicsScene *scene) // FIXME-4 maybe move this into MapEditor to get rid of scene in VymModel?
|
insilmaril@755
|
464 |
{
|
insilmaril@773
|
465 |
BranchObj *newbo;
|
insilmaril@790
|
466 |
newbo=new BranchObj(scene,this);
|
insilmaril@775
|
467 |
lmo=newbo;
|
insilmaril@775
|
468 |
|
insilmaril@773
|
469 |
if (parentItem==rootItem)
|
insilmaril@773
|
470 |
{
|
insilmaril@773
|
471 |
newbo->setParObj(NULL);
|
insilmaril@798
|
472 |
//newbo->setFrameType (FrameObj::Rectangle); //FIXME-4 maybe call updateStyles?
|
insilmaril@773
|
473 |
} else
|
insilmaril@773
|
474 |
{
|
insilmaril@779
|
475 |
newbo->setParObj( ((MapItem*)parentItem)->getLMO() );
|
insilmaril@775
|
476 |
// Set visibility depending on parents
|
insilmaril@791
|
477 |
if (parentItem!=rootItem &&
|
insilmaril@791
|
478 |
( ((BranchItem*)parentItem)->scrolled || !((MapItem*)parentItem)->getLMO()->isVisibleObj() ) )
|
insilmaril@775
|
479 |
newbo->setVisibility (false);
|
insilmaril@773
|
480 |
}
|
insilmaril@775
|
481 |
newbo->setDefAttr(BranchObj::NewBranch);
|
insilmaril@760
|
482 |
initLMO();
|
insilmaril@758
|
483 |
|
insilmaril@758
|
484 |
if (!getHeading().isEmpty() )
|
insilmaril@758
|
485 |
{
|
insilmaril@775
|
486 |
newbo->updateData(); //FIXME-3 maybe better model->emitDataHasChanged()?
|
insilmaril@775
|
487 |
newbo->setColor (headingColor);
|
insilmaril@758
|
488 |
}
|
insilmaril@758
|
489 |
|
insilmaril@779
|
490 |
//newbo->updateLinkGeometry(); //FIXME-3
|
insilmaril@755
|
491 |
|
insilmaril@755
|
492 |
return newbo;
|
insilmaril@755
|
493 |
}
|
insilmaril@755
|
494 |
|