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