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