insilmaril@746
|
1 |
#include <iostream>
|
insilmaril@725
|
2 |
#include <QStringList>
|
insilmaril@725
|
3 |
|
insilmaril@750
|
4 |
#include "treeitem.h"
|
insilmaril@750
|
5 |
|
insilmaril@741
|
6 |
#include "branchobj.h"
|
insilmaril@750
|
7 |
#include "branchitem.h"
|
insilmaril@760
|
8 |
#include "mapcenteritem.h"
|
insilmaril@746
|
9 |
#include "vymmodel.h"
|
insilmaril@725
|
10 |
|
insilmaril@758
|
11 |
using namespace std;
|
insilmaril@758
|
12 |
|
insilmaril@758
|
13 |
|
insilmaril@760
|
14 |
TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent):MapItem()
|
insilmaril@725
|
15 |
{
|
insilmaril@756
|
16 |
init();
|
insilmaril@756
|
17 |
parentItem = parent;
|
insilmaril@756
|
18 |
itemData = data;
|
insilmaril@756
|
19 |
}
|
insilmaril@756
|
20 |
|
insilmaril@756
|
21 |
TreeItem::~TreeItem()
|
insilmaril@756
|
22 |
{
|
insilmaril@756
|
23 |
//cout << "Destructor TreeItem "<<getHeadingStd()<<endl;
|
insilmaril@756
|
24 |
TreeItem *ti;
|
insilmaril@756
|
25 |
while (!childItems.isEmpty())
|
insilmaril@756
|
26 |
{
|
insilmaril@756
|
27 |
ti=childItems.takeFirst();
|
insilmaril@756
|
28 |
switch (ti->getType() )
|
insilmaril@756
|
29 |
{
|
insilmaril@756
|
30 |
case TreeItem::MapCenter:
|
insilmaril@756
|
31 |
delete (MapCenterItem*)ti;
|
insilmaril@756
|
32 |
break;
|
insilmaril@756
|
33 |
case TreeItem::Branch:
|
insilmaril@756
|
34 |
delete (BranchItem*)ti;
|
insilmaril@756
|
35 |
break;
|
insilmaril@756
|
36 |
default:
|
insilmaril@756
|
37 |
delete ti;
|
insilmaril@756
|
38 |
break;
|
insilmaril@756
|
39 |
}
|
insilmaril@756
|
40 |
}
|
insilmaril@756
|
41 |
}
|
insilmaril@756
|
42 |
|
insilmaril@756
|
43 |
|
insilmaril@756
|
44 |
void TreeItem::init()
|
insilmaril@756
|
45 |
{
|
insilmaril@746
|
46 |
model=NULL;
|
insilmaril@746
|
47 |
|
insilmaril@756
|
48 |
parentItem = NULL;
|
insilmaril@756
|
49 |
itemData.clear();
|
insilmaril@738
|
50 |
|
insilmaril@738
|
51 |
branchOffset=0;
|
insilmaril@741
|
52 |
branchCounter=0;
|
insilmaril@738
|
53 |
lastSelectedBranchNum=-1;
|
insilmaril@746
|
54 |
|
insilmaril@763
|
55 |
imageOffset=0;
|
insilmaril@763
|
56 |
imageCounter=0;
|
insilmaril@763
|
57 |
|
insilmaril@746
|
58 |
note.setNote("");
|
insilmaril@746
|
59 |
// note.setFontHint (textEditor->getFontHintDefault() ); //FIXME-2
|
insilmaril@746
|
60 |
// isNoteInEditor=false;
|
insilmaril@753
|
61 |
|
insilmaril@753
|
62 |
hidden=false;
|
insilmaril@754
|
63 |
|
insilmaril@754
|
64 |
// Reset ID
|
insilmaril@754
|
65 |
objID="";
|
insilmaril@725
|
66 |
}
|
insilmaril@725
|
67 |
|
insilmaril@746
|
68 |
QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
|
insilmaril@746
|
69 |
{
|
insilmaril@755
|
70 |
cout << "TreeItem::saveToDir called directly for ("<<getHeadingStd()<<"), instead of inherited type...\n"; //FIXME-1 triggered on save
|
insilmaril@746
|
71 |
return QString();
|
insilmaril@746
|
72 |
}
|
insilmaril@746
|
73 |
|
insilmaril@746
|
74 |
|
insilmaril@746
|
75 |
/*
|
insilmaril@753
|
76 |
void TreeItem::copy (OrnamentedObj* other) //FIXME-2 probably need deep copy of branches and data!
|
insilmaril@746
|
77 |
|
insilmaril@746
|
78 |
{
|
insilmaril@746
|
79 |
note.copy (other->note);
|
insilmaril@746
|
80 |
model=other->model;
|
insilmaril@754
|
81 |
hideExport=officially
|
insilmaril@754
|
82 |
other->hideExport;
|
insilmaril@746
|
83 |
}
|
insilmaril@746
|
84 |
*/
|
insilmaril@746
|
85 |
|
insilmaril@746
|
86 |
void TreeItem::setModel (VymModel *m)
|
insilmaril@746
|
87 |
{
|
insilmaril@746
|
88 |
model=m;
|
insilmaril@746
|
89 |
}
|
insilmaril@746
|
90 |
|
insilmaril@746
|
91 |
VymModel* TreeItem::getModel ()
|
insilmaril@746
|
92 |
{
|
insilmaril@746
|
93 |
return model;
|
insilmaril@746
|
94 |
}
|
insilmaril@741
|
95 |
|
insilmaril@725
|
96 |
void TreeItem::appendChild(TreeItem *item)
|
insilmaril@725
|
97 |
{
|
insilmaril@725
|
98 |
childItems.append(item);
|
insilmaril@756
|
99 |
item->parentItem=this;
|
insilmaril@746
|
100 |
item->setModel (model);
|
insilmaril@741
|
101 |
|
insilmaril@741
|
102 |
if (item->type == Branch || item->type ==MapCenter)
|
insilmaril@738
|
103 |
{
|
insilmaril@741
|
104 |
if (branchCounter==0)
|
insilmaril@738
|
105 |
branchOffset=childItems.count()-1;
|
insilmaril@741
|
106 |
branchCounter++;
|
insilmaril@738
|
107 |
}
|
insilmaril@725
|
108 |
}
|
insilmaril@725
|
109 |
|
insilmaril@727
|
110 |
void TreeItem::removeChild(int row)
|
insilmaril@727
|
111 |
{
|
insilmaril@745
|
112 |
if (row<0 || row > childItems.size()-1)
|
insilmaril@745
|
113 |
qWarning ("TreeItem::removeChild tried to remove non existing item?!\n");
|
insilmaril@745
|
114 |
else
|
insilmaril@727
|
115 |
{
|
insilmaril@755
|
116 |
if (childItems.at(row)->isBranchLikeType())
|
insilmaril@755
|
117 |
branchCounter--;
|
insilmaril@755
|
118 |
childItems.removeAt (row);
|
insilmaril@745
|
119 |
}
|
insilmaril@727
|
120 |
}
|
insilmaril@727
|
121 |
|
insilmaril@725
|
122 |
TreeItem *TreeItem::child(int row)
|
insilmaril@725
|
123 |
{
|
insilmaril@725
|
124 |
return childItems.value(row);
|
insilmaril@725
|
125 |
}
|
insilmaril@725
|
126 |
|
insilmaril@725
|
127 |
int TreeItem::childCount() const
|
insilmaril@725
|
128 |
{
|
insilmaril@725
|
129 |
return childItems.count();
|
insilmaril@725
|
130 |
}
|
insilmaril@725
|
131 |
|
insilmaril@745
|
132 |
int TreeItem::childNumber() const
|
insilmaril@745
|
133 |
{
|
insilmaril@745
|
134 |
if (parentItem)
|
insilmaril@745
|
135 |
return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
|
insilmaril@745
|
136 |
|
insilmaril@745
|
137 |
return 0;
|
insilmaril@745
|
138 |
}
|
insilmaril@745
|
139 |
|
insilmaril@725
|
140 |
int TreeItem::columnCount() const
|
insilmaril@725
|
141 |
{
|
insilmaril@725
|
142 |
return itemData.count();
|
insilmaril@725
|
143 |
}
|
insilmaril@741
|
144 |
|
insilmaril@741
|
145 |
int TreeItem::branchCount() const
|
insilmaril@741
|
146 |
{
|
insilmaril@741
|
147 |
return branchCounter;
|
insilmaril@741
|
148 |
}
|
insilmaril@749
|
149 |
|
insilmaril@749
|
150 |
int TreeItem::imageCount() const
|
insilmaril@749
|
151 |
{
|
insilmaril@749
|
152 |
int imageCounter=0;
|
insilmaril@749
|
153 |
return imageCounter; // FIXME-1 imageCounter needs to be calculated...
|
insilmaril@749
|
154 |
}
|
insilmaril@749
|
155 |
|
insilmaril@749
|
156 |
int TreeItem::xlinkCount() const // FIXME-2 check if xlinks are stored in a different way (global to model?)
|
insilmaril@749
|
157 |
{
|
insilmaril@749
|
158 |
int xlinkCounter=0;
|
insilmaril@749
|
159 |
return xlinkCounter; // FIXME-1 xlinkCounter needs to be calculated...
|
insilmaril@749
|
160 |
}
|
insilmaril@749
|
161 |
|
insilmaril@727
|
162 |
int TreeItem::row() const
|
insilmaril@727
|
163 |
{
|
insilmaril@727
|
164 |
if (parentItem)
|
insilmaril@727
|
165 |
return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
|
insilmaril@727
|
166 |
|
insilmaril@727
|
167 |
return 0;
|
insilmaril@727
|
168 |
}
|
insilmaril@727
|
169 |
|
insilmaril@727
|
170 |
int TreeItem::column() const
|
insilmaril@727
|
171 |
{
|
insilmaril@727
|
172 |
return 0;
|
insilmaril@727
|
173 |
}
|
insilmaril@727
|
174 |
|
insilmaril@740
|
175 |
int TreeItem::depth()
|
insilmaril@740
|
176 |
{
|
insilmaril@755
|
177 |
int d=-2;
|
insilmaril@740
|
178 |
TreeItem *ti=this;
|
insilmaril@740
|
179 |
while (ti!=NULL)
|
insilmaril@740
|
180 |
{
|
insilmaril@740
|
181 |
ti=ti->parent();
|
insilmaril@740
|
182 |
d++;
|
insilmaril@740
|
183 |
}
|
insilmaril@740
|
184 |
return d;
|
insilmaril@740
|
185 |
}
|
insilmaril@740
|
186 |
|
insilmaril@727
|
187 |
TreeItem *TreeItem::parent()
|
insilmaril@727
|
188 |
{
|
insilmaril@727
|
189 |
return parentItem;
|
insilmaril@727
|
190 |
}
|
insilmaril@727
|
191 |
|
insilmaril@755
|
192 |
int TreeItem::childNum()
|
insilmaril@755
|
193 |
{
|
insilmaril@755
|
194 |
return parentItem->childItems.indexOf (this);
|
insilmaril@755
|
195 |
}
|
insilmaril@755
|
196 |
|
insilmaril@741
|
197 |
int TreeItem::num()
|
insilmaril@741
|
198 |
{
|
insilmaril@741
|
199 |
switch (type)
|
insilmaril@741
|
200 |
{
|
insilmaril@741
|
201 |
case Undefined: return -1;
|
insilmaril@741
|
202 |
case MapCenter: return parentItem->childItems.indexOf (this) - branchOffset;
|
insilmaril@741
|
203 |
case Branch: return parentItem->childItems.indexOf (this) - branchOffset;
|
insilmaril@763
|
204 |
case Image: return parentItem->childItems.indexOf (this) - imageOffset;
|
insilmaril@741
|
205 |
default: return -1;
|
insilmaril@741
|
206 |
}
|
insilmaril@749
|
207 |
}
|
insilmaril@749
|
208 |
|
insilmaril@749
|
209 |
int TreeItem::num (TreeItem *item)
|
insilmaril@749
|
210 |
{
|
insilmaril@749
|
211 |
if (!item) return -1;
|
insilmaril@749
|
212 |
switch (item->getType())
|
insilmaril@749
|
213 |
{
|
insilmaril@749
|
214 |
case Undefined: return -1;
|
insilmaril@763
|
215 |
case MapCenter: return childItems.indexOf (item) - branchOffset;
|
insilmaril@763
|
216 |
case Branch: return childItems.indexOf (item) - branchOffset;
|
insilmaril@763
|
217 |
case Image: return parentItem->childItems.indexOf (item) - imageOffset;
|
insilmaril@749
|
218 |
default: return -1;
|
insilmaril@749
|
219 |
}
|
insilmaril@741
|
220 |
}
|
insilmaril@766
|
221 |
void TreeItem::setType(const Type t)
|
insilmaril@766
|
222 |
{
|
insilmaril@766
|
223 |
type=t;
|
insilmaril@766
|
224 |
itemData[1]=getTypeName();
|
insilmaril@766
|
225 |
}
|
insilmaril@766
|
226 |
|
insilmaril@766
|
227 |
TreeItem::Type TreeItem::getType()
|
insilmaril@766
|
228 |
{
|
insilmaril@766
|
229 |
return type;
|
insilmaril@766
|
230 |
}
|
insilmaril@766
|
231 |
|
insilmaril@766
|
232 |
bool TreeItem::isBranchLikeType() const
|
insilmaril@766
|
233 |
{
|
insilmaril@766
|
234 |
if (type==Branch ||type==MapCenter) return true;
|
insilmaril@766
|
235 |
return false;
|
insilmaril@766
|
236 |
}
|
insilmaril@766
|
237 |
|
insilmaril@766
|
238 |
QString TreeItem::getTypeName()
|
insilmaril@766
|
239 |
{
|
insilmaril@766
|
240 |
switch (type)
|
insilmaril@766
|
241 |
{
|
insilmaril@766
|
242 |
case Undefined: return QString ("Undefined");
|
insilmaril@766
|
243 |
case MapCenter: return QString ("MapCenter");
|
insilmaril@766
|
244 |
case Branch: return QString ("Branch");
|
insilmaril@766
|
245 |
case Image: return QString ("Image");
|
insilmaril@766
|
246 |
default: return QString ("TreeItem::getTypeName no typename defined?!");
|
insilmaril@766
|
247 |
}
|
insilmaril@766
|
248 |
}
|
insilmaril@766
|
249 |
|
insilmaril@725
|
250 |
|
insilmaril@725
|
251 |
QVariant TreeItem::data(int column) const
|
insilmaril@725
|
252 |
{
|
insilmaril@725
|
253 |
return itemData.value(column);
|
insilmaril@725
|
254 |
}
|
insilmaril@725
|
255 |
|
insilmaril@726
|
256 |
void TreeItem::setHeading (const QString s)
|
insilmaril@725
|
257 |
{
|
insilmaril@726
|
258 |
itemData[0]=s;
|
insilmaril@726
|
259 |
}
|
insilmaril@726
|
260 |
|
insilmaril@753
|
261 |
QString TreeItem::getHeading () const
|
insilmaril@726
|
262 |
{
|
insilmaril@726
|
263 |
return itemData[0].toString();
|
insilmaril@726
|
264 |
}
|
insilmaril@726
|
265 |
|
insilmaril@755
|
266 |
std::string TreeItem::getHeadingStd () const
|
insilmaril@753
|
267 |
{
|
insilmaril@753
|
268 |
return itemData[0].toString().toStdString();
|
insilmaril@753
|
269 |
}
|
insilmaril@753
|
270 |
|
insilmaril@758
|
271 |
void TreeItem::setHeadingColor (QColor color)
|
insilmaril@758
|
272 |
{
|
insilmaril@758
|
273 |
headingColor=color;
|
insilmaril@758
|
274 |
}
|
insilmaril@758
|
275 |
|
insilmaril@758
|
276 |
QColor TreeItem::getHeadingColor ()
|
insilmaril@758
|
277 |
{
|
insilmaril@758
|
278 |
return headingColor;
|
insilmaril@758
|
279 |
}
|
insilmaril@758
|
280 |
|
insilmaril@767
|
281 |
void TreeItem::setURL (const QString &u)
|
insilmaril@741
|
282 |
{
|
insilmaril@767
|
283 |
url=u;
|
insilmaril@767
|
284 |
if (!url.isEmpty())
|
insilmaril@767
|
285 |
systemFlags.activate ("system-url");
|
insilmaril@767
|
286 |
else
|
insilmaril@767
|
287 |
systemFlags.deactivate ("system-url");
|
insilmaril@767
|
288 |
}
|
insilmaril@767
|
289 |
|
insilmaril@767
|
290 |
QString TreeItem::getURL ()
|
insilmaril@767
|
291 |
{
|
insilmaril@767
|
292 |
return url;
|
insilmaril@767
|
293 |
}
|
insilmaril@767
|
294 |
|
insilmaril@767
|
295 |
void TreeItem::setVymLink (const QString &vl)
|
insilmaril@767
|
296 |
{
|
insilmaril@767
|
297 |
if (!vl.isEmpty())
|
insilmaril@767
|
298 |
{
|
insilmaril@767
|
299 |
// We need the relative (from loading)
|
insilmaril@767
|
300 |
// or absolute path (from User event)
|
insilmaril@767
|
301 |
// and build the absolute path.
|
insilmaril@767
|
302 |
// Note: If we have relative, use path of
|
insilmaril@767
|
303 |
// current map to build absolute path
|
insilmaril@767
|
304 |
QDir d(vl);
|
insilmaril@767
|
305 |
if (!d.path().startsWith ("/"))
|
insilmaril@767
|
306 |
{
|
insilmaril@767
|
307 |
QString p=model->getDestPath();
|
insilmaril@767
|
308 |
int i=p.findRev("/",-1);
|
insilmaril@767
|
309 |
d.setPath(p.left(i)+"/"+vl);
|
insilmaril@767
|
310 |
d.convertToAbs();
|
insilmaril@767
|
311 |
}
|
insilmaril@767
|
312 |
vymLink=d.path();
|
insilmaril@767
|
313 |
systemFlags.activate("system-vymLink");
|
insilmaril@767
|
314 |
}
|
insilmaril@767
|
315 |
else
|
insilmaril@767
|
316 |
{
|
insilmaril@767
|
317 |
systemFlags.deactivate("system-vymLink");
|
insilmaril@767
|
318 |
vymLink.clear();
|
insilmaril@767
|
319 |
}
|
insilmaril@767
|
320 |
}
|
insilmaril@767
|
321 |
|
insilmaril@767
|
322 |
QString TreeItem::getVymLink ()
|
insilmaril@767
|
323 |
{
|
insilmaril@767
|
324 |
return vymLink;
|
insilmaril@767
|
325 |
}
|
insilmaril@767
|
326 |
|
insilmaril@767
|
327 |
void TreeItem::setNote(const QString &s)
|
insilmaril@767
|
328 |
{
|
insilmaril@767
|
329 |
NoteObj n;
|
insilmaril@767
|
330 |
n.setNote(s);
|
insilmaril@767
|
331 |
setNoteObj (n,false);
|
insilmaril@767
|
332 |
}
|
insilmaril@767
|
333 |
|
insilmaril@767
|
334 |
void TreeItem::clearNote()
|
insilmaril@767
|
335 |
{
|
insilmaril@767
|
336 |
note.clear();
|
insilmaril@767
|
337 |
systemFlags.deactivate ("system-note");
|
insilmaril@746
|
338 |
}
|
insilmaril@746
|
339 |
|
insilmaril@746
|
340 |
void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor)
|
insilmaril@746
|
341 |
{
|
insilmaril@746
|
342 |
note=n;
|
insilmaril@767
|
343 |
if (!note.isEmpty() && !systemFlags.isActive ("system-note"))
|
insilmaril@767
|
344 |
systemFlags.activate ("system-note");
|
insilmaril@767
|
345 |
if (note.isEmpty() && systemFlags.isActive ("system-note"))
|
insilmaril@767
|
346 |
systemFlags.deactivate ("system-note");
|
insilmaril@741
|
347 |
}
|
insilmaril@741
|
348 |
|
insilmaril@741
|
349 |
QString TreeItem::getNote()
|
insilmaril@741
|
350 |
{
|
insilmaril@746
|
351 |
return note.getNote();
|
insilmaril@746
|
352 |
}
|
insilmaril@746
|
353 |
|
insilmaril@746
|
354 |
NoteObj TreeItem::getNoteObj()
|
insilmaril@746
|
355 |
{
|
insilmaril@746
|
356 |
return note;
|
insilmaril@746
|
357 |
}
|
insilmaril@746
|
358 |
|
insilmaril@746
|
359 |
QString TreeItem::getNoteASCII(const QString &indent, const int &width)
|
insilmaril@746
|
360 |
{
|
insilmaril@746
|
361 |
return note.getNoteASCII(indent,width);
|
insilmaril@746
|
362 |
}
|
insilmaril@746
|
363 |
|
insilmaril@746
|
364 |
QString TreeItem::getNoteASCII()
|
insilmaril@746
|
365 |
{
|
insilmaril@746
|
366 |
return note.getNoteASCII();
|
insilmaril@746
|
367 |
}
|
insilmaril@746
|
368 |
|
insilmaril@746
|
369 |
QString TreeItem::getNoteOpenDoc()
|
insilmaril@746
|
370 |
{
|
insilmaril@746
|
371 |
return note.getNoteOpenDoc();
|
insilmaril@741
|
372 |
}
|
insilmaril@741
|
373 |
|
insilmaril@766
|
374 |
void TreeItem::activateStandardFlag (const QString &name)
|
insilmaril@726
|
375 |
{
|
insilmaril@766
|
376 |
standardFlags.activate (name);
|
insilmaril@767
|
377 |
model->emitDataHasChanged(this);
|
insilmaril@726
|
378 |
}
|
insilmaril@726
|
379 |
|
insilmaril@766
|
380 |
void TreeItem::deactivateStandardFlag (const QString &name)
|
insilmaril@726
|
381 |
{
|
insilmaril@766
|
382 |
standardFlags.deactivate (name);
|
insilmaril@767
|
383 |
model->emitDataHasChanged(this);
|
insilmaril@726
|
384 |
}
|
insilmaril@726
|
385 |
|
insilmaril@767
|
386 |
void TreeItem::deactivateAllStandardFlags ()
|
insilmaril@753
|
387 |
{
|
insilmaril@767
|
388 |
standardFlags.deactivateAll ();
|
insilmaril@767
|
389 |
model->emitDataHasChanged(this);
|
insilmaril@767
|
390 |
}
|
insilmaril@767
|
391 |
|
insilmaril@767
|
392 |
void TreeItem::toggleStandardFlag(const QString &name, FlagRow *master)
|
insilmaril@767
|
393 |
{
|
insilmaril@767
|
394 |
standardFlags.toggle (name,master);
|
insilmaril@767
|
395 |
model->emitDataHasChanged(this);
|
insilmaril@753
|
396 |
}
|
insilmaril@753
|
397 |
|
insilmaril@766
|
398 |
bool TreeItem::isActiveStandardFlag (const QString &name)
|
insilmaril@726
|
399 |
{
|
insilmaril@766
|
400 |
return standardFlags.isActive (name);
|
insilmaril@725
|
401 |
}
|
insilmaril@725
|
402 |
|
insilmaril@767
|
403 |
QStringList TreeItem::activeStandardFlagNames ()
|
insilmaril@767
|
404 |
{
|
insilmaril@767
|
405 |
return standardFlags.activeFlagNames();
|
insilmaril@767
|
406 |
}
|
insilmaril@767
|
407 |
|
insilmaril@767
|
408 |
QStringList TreeItem::activeSystemFlagNames () //FIXME-1 missing: scrolled-tmp,hideInExport
|
insilmaril@767
|
409 |
{
|
insilmaril@767
|
410 |
return systemFlags.activeFlagNames();
|
insilmaril@767
|
411 |
}
|
insilmaril@767
|
412 |
|
insilmaril@767
|
413 |
bool TreeItem::canMoveDown()
|
insilmaril@767
|
414 |
{
|
insilmaril@767
|
415 |
switch (type)
|
insilmaril@767
|
416 |
{
|
insilmaril@767
|
417 |
case Undefined: return false;
|
insilmaril@767
|
418 |
case MapCenter:
|
insilmaril@767
|
419 |
case Branch:
|
insilmaril@767
|
420 |
if (!parentItem) return false;
|
insilmaril@767
|
421 |
if (parentItem->num (this) < parentItem->branchCount()-1)
|
insilmaril@767
|
422 |
return true;
|
insilmaril@767
|
423 |
else
|
insilmaril@767
|
424 |
return false;
|
insilmaril@767
|
425 |
break;
|
insilmaril@767
|
426 |
case Image: return false;
|
insilmaril@767
|
427 |
default: return false;
|
insilmaril@767
|
428 |
}
|
insilmaril@767
|
429 |
}
|
insilmaril@767
|
430 |
|
insilmaril@767
|
431 |
bool TreeItem::canMoveUp()
|
insilmaril@767
|
432 |
{
|
insilmaril@767
|
433 |
switch (type)
|
insilmaril@767
|
434 |
{
|
insilmaril@767
|
435 |
case Undefined: return false;
|
insilmaril@767
|
436 |
case MapCenter:
|
insilmaril@767
|
437 |
case Branch:
|
insilmaril@767
|
438 |
if (!parentItem) return false;
|
insilmaril@767
|
439 |
if (parentItem->num (this) > 0)
|
insilmaril@767
|
440 |
return true;
|
insilmaril@767
|
441 |
else
|
insilmaril@767
|
442 |
return false;
|
insilmaril@767
|
443 |
break;
|
insilmaril@767
|
444 |
case Image: return false;
|
insilmaril@767
|
445 |
default: return false;
|
insilmaril@767
|
446 |
}
|
insilmaril@767
|
447 |
}
|
insilmaril@767
|
448 |
|
insilmaril@754
|
449 |
void TreeItem::setID (const QString &s)
|
insilmaril@754
|
450 |
{
|
insilmaril@754
|
451 |
objID=s;
|
insilmaril@754
|
452 |
}
|
insilmaril@754
|
453 |
|
insilmaril@754
|
454 |
QString TreeItem::getID()
|
insilmaril@754
|
455 |
{
|
insilmaril@754
|
456 |
return objID;
|
insilmaril@754
|
457 |
}
|
insilmaril@754
|
458 |
|
insilmaril@754
|
459 |
|
insilmaril@738
|
460 |
TreeItem* TreeItem::getChildNum(const int &n)
|
insilmaril@738
|
461 |
{
|
insilmaril@738
|
462 |
if (n>=0 && n<childItems.count() )
|
insilmaril@738
|
463 |
return childItems.at(n);
|
insilmaril@738
|
464 |
else
|
insilmaril@738
|
465 |
return NULL;
|
insilmaril@738
|
466 |
}
|
insilmaril@738
|
467 |
|
insilmaril@750
|
468 |
BranchItem* TreeItem::getFirstBranch()
|
insilmaril@738
|
469 |
{
|
insilmaril@741
|
470 |
if (branchCounter>0)
|
insilmaril@738
|
471 |
return getBranchNum (branchOffset);
|
insilmaril@738
|
472 |
else
|
insilmaril@738
|
473 |
return NULL;
|
insilmaril@738
|
474 |
}
|
insilmaril@738
|
475 |
|
insilmaril@750
|
476 |
BranchItem* TreeItem::getLastBranch()
|
insilmaril@738
|
477 |
{
|
insilmaril@741
|
478 |
if (branchCounter>0)
|
insilmaril@741
|
479 |
return getBranchNum (branchOffset + branchCounter-1);
|
insilmaril@738
|
480 |
else
|
insilmaril@738
|
481 |
return NULL;
|
insilmaril@738
|
482 |
}
|
insilmaril@738
|
483 |
|
insilmaril@763
|
484 |
BranchItem* TreeItem::getNextBranch(BranchItem *currentBranch)
|
insilmaril@763
|
485 |
{
|
insilmaril@763
|
486 |
if (!currentBranch) return NULL;
|
insilmaril@763
|
487 |
int n=num (currentBranch)+1;
|
insilmaril@763
|
488 |
if (n<branchCounter)
|
insilmaril@763
|
489 |
return getBranchNum (branchOffset + n);
|
insilmaril@763
|
490 |
else
|
insilmaril@763
|
491 |
return NULL;
|
insilmaril@763
|
492 |
}
|
insilmaril@763
|
493 |
|
insilmaril@738
|
494 |
|
insilmaril@750
|
495 |
BranchItem* TreeItem::getBranchNum(const int &n)
|
insilmaril@738
|
496 |
{
|
insilmaril@741
|
497 |
if (branchCounter>0)
|
insilmaril@750
|
498 |
return (BranchItem*)getChildNum (branchOffset + n);
|
insilmaril@738
|
499 |
else
|
insilmaril@738
|
500 |
return NULL;
|
insilmaril@738
|
501 |
}
|
insilmaril@738
|
502 |
|
insilmaril@750
|
503 |
BranchObj* TreeItem::getBranchObjNum(const int &n)
|
insilmaril@750
|
504 |
{
|
insilmaril@750
|
505 |
if (branchCounter>0)
|
insilmaril@750
|
506 |
{
|
insilmaril@750
|
507 |
return (BranchObj*)(getChildNum (branchOffset+n)->lmo);
|
insilmaril@750
|
508 |
} else
|
insilmaril@750
|
509 |
return NULL;
|
insilmaril@750
|
510 |
}
|
insilmaril@750
|
511 |
|
insilmaril@738
|
512 |
void TreeItem::setLastSelectedBranch()
|
insilmaril@738
|
513 |
{
|
insilmaril@738
|
514 |
if (parentItem)
|
insilmaril@738
|
515 |
parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
|
insilmaril@738
|
516 |
}
|
insilmaril@738
|
517 |
|
insilmaril@754
|
518 |
void TreeItem::setLastSelectedBranch(int i)
|
insilmaril@754
|
519 |
{
|
insilmaril@754
|
520 |
lastSelectedBranchNum=i;
|
insilmaril@754
|
521 |
}
|
insilmaril@754
|
522 |
|
insilmaril@738
|
523 |
TreeItem* TreeItem::getLastSelectedBranch()
|
insilmaril@738
|
524 |
{
|
insilmaril@738
|
525 |
return getBranchNum (lastSelectedBranchNum);
|
insilmaril@738
|
526 |
}
|
insilmaril@738
|
527 |
|
insilmaril@753
|
528 |
|
insilmaril@753
|
529 |
void TreeItem::setHideTmp (HideTmpMode mode)
|
insilmaril@753
|
530 |
{
|
insilmaril@753
|
531 |
if (isBranchLikeType() )
|
insilmaril@753
|
532 |
((BranchItem*)this)->updateVisibility();
|
insilmaril@753
|
533 |
/*
|
insilmaril@753
|
534 |
if (type==Image)
|
insilmaril@753
|
535 |
//updateVisibility();
|
insilmaril@753
|
536 |
*/
|
insilmaril@753
|
537 |
|
insilmaril@753
|
538 |
/*
|
insilmaril@753
|
539 |
|
insilmaril@753
|
540 |
if (mode==HideExport && (hideExport || hasHiddenExportParent() ) )
|
insilmaril@753
|
541 |
{
|
insilmaril@753
|
542 |
// Hide stuff according to hideExport flag and parents
|
insilmaril@753
|
543 |
//setVisibility (false);
|
insilmaril@753
|
544 |
updateVisibility();
|
insilmaril@753
|
545 |
//FIXME-2 hidden=true;
|
insilmaril@753
|
546 |
}else
|
insilmaril@753
|
547 |
{
|
insilmaril@753
|
548 |
// Do not hide, but still take care of scrolled status
|
insilmaril@753
|
549 |
|
insilmaril@753
|
550 |
|
insilmaril@753
|
551 |
XXXXXXXX treeItem should be THIS
|
insilmaril@753
|
552 |
|
insilmaril@753
|
553 |
move visible to TreeItem???
|
insilmaril@753
|
554 |
|
insilmaril@753
|
555 |
BranchObj now has updateContents
|
insilmaril@753
|
556 |
|
insilmaril@753
|
557 |
maybe also start "bool TreeItem::branchlikeType"
|
insilmaril@753
|
558 |
|
insilmaril@753
|
559 |
|
insilmaril@753
|
560 |
|
insilmaril@753
|
561 |
if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem))
|
insilmaril@753
|
562 |
setVisibility (false);
|
insilmaril@753
|
563 |
else
|
insilmaril@753
|
564 |
setVisibility (true);
|
insilmaril@753
|
565 |
//FIXME-2 hidden=false;
|
insilmaril@753
|
566 |
}
|
insilmaril@753
|
567 |
|
insilmaril@753
|
568 |
*/
|
insilmaril@753
|
569 |
// And take care of my children
|
insilmaril@753
|
570 |
for (int i=0; i<branchCount(); ++i)
|
insilmaril@753
|
571 |
getBranchNum(i)->setHideTmp (mode);
|
insilmaril@753
|
572 |
}
|
insilmaril@753
|
573 |
|
insilmaril@753
|
574 |
bool TreeItem::hasHiddenExportParent()
|
insilmaril@753
|
575 |
{
|
insilmaril@753
|
576 |
// Calls parents recursivly to
|
insilmaril@753
|
577 |
// find out, if we or parents are temp. hidden
|
insilmaril@753
|
578 |
|
insilmaril@753
|
579 |
if (hidden || hideExport) return true;
|
insilmaril@753
|
580 |
|
insilmaril@753
|
581 |
if (parentItem)
|
insilmaril@753
|
582 |
return parentItem->hasHiddenExportParent();
|
insilmaril@753
|
583 |
else
|
insilmaril@753
|
584 |
return false;
|
insilmaril@753
|
585 |
}
|
insilmaril@753
|
586 |
|
insilmaril@753
|
587 |
|
insilmaril@753
|
588 |
void TreeItem::setHideInExport(bool b)
|
insilmaril@753
|
589 |
{
|
insilmaril@753
|
590 |
if (isBranchLikeType() )
|
insilmaril@753
|
591 |
{
|
insilmaril@753
|
592 |
hideExport=b;
|
insilmaril@753
|
593 |
/* FIXME-1 call setVis and updateContentsSize...
|
insilmaril@753
|
594 |
if (b)
|
insilmaril@753
|
595 |
systemFlags->activate("hideInExport");
|
insilmaril@753
|
596 |
else
|
insilmaril@753
|
597 |
systemFlags->deactivate("hideInExport");
|
insilmaril@753
|
598 |
calcBBoxSize();
|
insilmaril@753
|
599 |
positionBBox();
|
insilmaril@753
|
600 |
requestReposition();
|
insilmaril@753
|
601 |
*/
|
insilmaril@753
|
602 |
}
|
insilmaril@753
|
603 |
}
|
insilmaril@753
|
604 |
|
insilmaril@753
|
605 |
bool TreeItem::hideInExport()
|
insilmaril@753
|
606 |
{
|
insilmaril@753
|
607 |
return hideExport;
|
insilmaril@753
|
608 |
}
|
insilmaril@753
|
609 |
|
insilmaril@753
|
610 |
bool TreeItem::isHidden()
|
insilmaril@753
|
611 |
{
|
insilmaril@753
|
612 |
return hidden;
|
insilmaril@753
|
613 |
}
|
insilmaril@753
|
614 |
|
insilmaril@753
|
615 |
|
insilmaril@726
|
616 |
|