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@768
|
340 |
void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor) //FIXME-1 setNoteObj is called for every select or so???
|
insilmaril@746
|
341 |
{
|
insilmaril@746
|
342 |
note=n;
|
insilmaril@768
|
343 |
cout << "TI::setNoteObj of "<<getHeadingStd()<<endl;
|
insilmaril@767
|
344 |
if (!note.isEmpty() && !systemFlags.isActive ("system-note"))
|
insilmaril@767
|
345 |
systemFlags.activate ("system-note");
|
insilmaril@767
|
346 |
if (note.isEmpty() && systemFlags.isActive ("system-note"))
|
insilmaril@767
|
347 |
systemFlags.deactivate ("system-note");
|
insilmaril@741
|
348 |
}
|
insilmaril@741
|
349 |
|
insilmaril@741
|
350 |
QString TreeItem::getNote()
|
insilmaril@741
|
351 |
{
|
insilmaril@746
|
352 |
return note.getNote();
|
insilmaril@746
|
353 |
}
|
insilmaril@746
|
354 |
|
insilmaril@768
|
355 |
bool TreeItem::hasEmptyNote()
|
insilmaril@768
|
356 |
{
|
insilmaril@768
|
357 |
return note.isEmpty();
|
insilmaril@768
|
358 |
}
|
insilmaril@768
|
359 |
|
insilmaril@746
|
360 |
NoteObj TreeItem::getNoteObj()
|
insilmaril@746
|
361 |
{
|
insilmaril@746
|
362 |
return note;
|
insilmaril@746
|
363 |
}
|
insilmaril@746
|
364 |
|
insilmaril@746
|
365 |
QString TreeItem::getNoteASCII(const QString &indent, const int &width)
|
insilmaril@746
|
366 |
{
|
insilmaril@746
|
367 |
return note.getNoteASCII(indent,width);
|
insilmaril@746
|
368 |
}
|
insilmaril@746
|
369 |
|
insilmaril@746
|
370 |
QString TreeItem::getNoteASCII()
|
insilmaril@746
|
371 |
{
|
insilmaril@746
|
372 |
return note.getNoteASCII();
|
insilmaril@746
|
373 |
}
|
insilmaril@746
|
374 |
|
insilmaril@746
|
375 |
QString TreeItem::getNoteOpenDoc()
|
insilmaril@746
|
376 |
{
|
insilmaril@746
|
377 |
return note.getNoteOpenDoc();
|
insilmaril@741
|
378 |
}
|
insilmaril@741
|
379 |
|
insilmaril@766
|
380 |
void TreeItem::activateStandardFlag (const QString &name)
|
insilmaril@726
|
381 |
{
|
insilmaril@766
|
382 |
standardFlags.activate (name);
|
insilmaril@767
|
383 |
model->emitDataHasChanged(this);
|
insilmaril@726
|
384 |
}
|
insilmaril@726
|
385 |
|
insilmaril@766
|
386 |
void TreeItem::deactivateStandardFlag (const QString &name)
|
insilmaril@726
|
387 |
{
|
insilmaril@766
|
388 |
standardFlags.deactivate (name);
|
insilmaril@767
|
389 |
model->emitDataHasChanged(this);
|
insilmaril@726
|
390 |
}
|
insilmaril@726
|
391 |
|
insilmaril@767
|
392 |
void TreeItem::deactivateAllStandardFlags ()
|
insilmaril@753
|
393 |
{
|
insilmaril@767
|
394 |
standardFlags.deactivateAll ();
|
insilmaril@767
|
395 |
model->emitDataHasChanged(this);
|
insilmaril@767
|
396 |
}
|
insilmaril@767
|
397 |
|
insilmaril@767
|
398 |
void TreeItem::toggleStandardFlag(const QString &name, FlagRow *master)
|
insilmaril@767
|
399 |
{
|
insilmaril@767
|
400 |
standardFlags.toggle (name,master);
|
insilmaril@767
|
401 |
model->emitDataHasChanged(this);
|
insilmaril@753
|
402 |
}
|
insilmaril@753
|
403 |
|
insilmaril@766
|
404 |
bool TreeItem::isActiveStandardFlag (const QString &name)
|
insilmaril@726
|
405 |
{
|
insilmaril@766
|
406 |
return standardFlags.isActive (name);
|
insilmaril@725
|
407 |
}
|
insilmaril@725
|
408 |
|
insilmaril@767
|
409 |
QStringList TreeItem::activeStandardFlagNames ()
|
insilmaril@767
|
410 |
{
|
insilmaril@767
|
411 |
return standardFlags.activeFlagNames();
|
insilmaril@767
|
412 |
}
|
insilmaril@767
|
413 |
|
insilmaril@767
|
414 |
QStringList TreeItem::activeSystemFlagNames () //FIXME-1 missing: scrolled-tmp,hideInExport
|
insilmaril@767
|
415 |
{
|
insilmaril@767
|
416 |
return systemFlags.activeFlagNames();
|
insilmaril@767
|
417 |
}
|
insilmaril@767
|
418 |
|
insilmaril@767
|
419 |
bool TreeItem::canMoveDown()
|
insilmaril@767
|
420 |
{
|
insilmaril@767
|
421 |
switch (type)
|
insilmaril@767
|
422 |
{
|
insilmaril@767
|
423 |
case Undefined: return false;
|
insilmaril@767
|
424 |
case MapCenter:
|
insilmaril@767
|
425 |
case Branch:
|
insilmaril@767
|
426 |
if (!parentItem) return false;
|
insilmaril@767
|
427 |
if (parentItem->num (this) < parentItem->branchCount()-1)
|
insilmaril@767
|
428 |
return true;
|
insilmaril@767
|
429 |
else
|
insilmaril@767
|
430 |
return false;
|
insilmaril@767
|
431 |
break;
|
insilmaril@767
|
432 |
case Image: return false;
|
insilmaril@767
|
433 |
default: return false;
|
insilmaril@767
|
434 |
}
|
insilmaril@767
|
435 |
}
|
insilmaril@767
|
436 |
|
insilmaril@767
|
437 |
bool TreeItem::canMoveUp()
|
insilmaril@767
|
438 |
{
|
insilmaril@767
|
439 |
switch (type)
|
insilmaril@767
|
440 |
{
|
insilmaril@767
|
441 |
case Undefined: return false;
|
insilmaril@767
|
442 |
case MapCenter:
|
insilmaril@767
|
443 |
case Branch:
|
insilmaril@767
|
444 |
if (!parentItem) return false;
|
insilmaril@767
|
445 |
if (parentItem->num (this) > 0)
|
insilmaril@767
|
446 |
return true;
|
insilmaril@767
|
447 |
else
|
insilmaril@767
|
448 |
return false;
|
insilmaril@767
|
449 |
break;
|
insilmaril@767
|
450 |
case Image: return false;
|
insilmaril@767
|
451 |
default: return false;
|
insilmaril@767
|
452 |
}
|
insilmaril@767
|
453 |
}
|
insilmaril@767
|
454 |
|
insilmaril@754
|
455 |
void TreeItem::setID (const QString &s)
|
insilmaril@754
|
456 |
{
|
insilmaril@754
|
457 |
objID=s;
|
insilmaril@754
|
458 |
}
|
insilmaril@754
|
459 |
|
insilmaril@754
|
460 |
QString TreeItem::getID()
|
insilmaril@754
|
461 |
{
|
insilmaril@754
|
462 |
return objID;
|
insilmaril@754
|
463 |
}
|
insilmaril@754
|
464 |
|
insilmaril@754
|
465 |
|
insilmaril@738
|
466 |
TreeItem* TreeItem::getChildNum(const int &n)
|
insilmaril@738
|
467 |
{
|
insilmaril@738
|
468 |
if (n>=0 && n<childItems.count() )
|
insilmaril@738
|
469 |
return childItems.at(n);
|
insilmaril@738
|
470 |
else
|
insilmaril@738
|
471 |
return NULL;
|
insilmaril@738
|
472 |
}
|
insilmaril@738
|
473 |
|
insilmaril@750
|
474 |
BranchItem* TreeItem::getFirstBranch()
|
insilmaril@738
|
475 |
{
|
insilmaril@741
|
476 |
if (branchCounter>0)
|
insilmaril@738
|
477 |
return getBranchNum (branchOffset);
|
insilmaril@738
|
478 |
else
|
insilmaril@738
|
479 |
return NULL;
|
insilmaril@738
|
480 |
}
|
insilmaril@738
|
481 |
|
insilmaril@750
|
482 |
BranchItem* TreeItem::getLastBranch()
|
insilmaril@738
|
483 |
{
|
insilmaril@741
|
484 |
if (branchCounter>0)
|
insilmaril@741
|
485 |
return getBranchNum (branchOffset + branchCounter-1);
|
insilmaril@738
|
486 |
else
|
insilmaril@738
|
487 |
return NULL;
|
insilmaril@738
|
488 |
}
|
insilmaril@738
|
489 |
|
insilmaril@763
|
490 |
BranchItem* TreeItem::getNextBranch(BranchItem *currentBranch)
|
insilmaril@763
|
491 |
{
|
insilmaril@763
|
492 |
if (!currentBranch) return NULL;
|
insilmaril@763
|
493 |
int n=num (currentBranch)+1;
|
insilmaril@763
|
494 |
if (n<branchCounter)
|
insilmaril@763
|
495 |
return getBranchNum (branchOffset + n);
|
insilmaril@763
|
496 |
else
|
insilmaril@763
|
497 |
return NULL;
|
insilmaril@763
|
498 |
}
|
insilmaril@763
|
499 |
|
insilmaril@738
|
500 |
|
insilmaril@750
|
501 |
BranchItem* TreeItem::getBranchNum(const int &n)
|
insilmaril@738
|
502 |
{
|
insilmaril@741
|
503 |
if (branchCounter>0)
|
insilmaril@750
|
504 |
return (BranchItem*)getChildNum (branchOffset + n);
|
insilmaril@738
|
505 |
else
|
insilmaril@738
|
506 |
return NULL;
|
insilmaril@738
|
507 |
}
|
insilmaril@738
|
508 |
|
insilmaril@750
|
509 |
BranchObj* TreeItem::getBranchObjNum(const int &n)
|
insilmaril@750
|
510 |
{
|
insilmaril@750
|
511 |
if (branchCounter>0)
|
insilmaril@750
|
512 |
{
|
insilmaril@750
|
513 |
return (BranchObj*)(getChildNum (branchOffset+n)->lmo);
|
insilmaril@750
|
514 |
} else
|
insilmaril@750
|
515 |
return NULL;
|
insilmaril@750
|
516 |
}
|
insilmaril@750
|
517 |
|
insilmaril@738
|
518 |
void TreeItem::setLastSelectedBranch()
|
insilmaril@738
|
519 |
{
|
insilmaril@738
|
520 |
if (parentItem)
|
insilmaril@738
|
521 |
parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
|
insilmaril@738
|
522 |
}
|
insilmaril@738
|
523 |
|
insilmaril@754
|
524 |
void TreeItem::setLastSelectedBranch(int i)
|
insilmaril@754
|
525 |
{
|
insilmaril@754
|
526 |
lastSelectedBranchNum=i;
|
insilmaril@754
|
527 |
}
|
insilmaril@754
|
528 |
|
insilmaril@738
|
529 |
TreeItem* TreeItem::getLastSelectedBranch()
|
insilmaril@738
|
530 |
{
|
insilmaril@738
|
531 |
return getBranchNum (lastSelectedBranchNum);
|
insilmaril@738
|
532 |
}
|
insilmaril@738
|
533 |
|
insilmaril@753
|
534 |
|
insilmaril@753
|
535 |
void TreeItem::setHideTmp (HideTmpMode mode)
|
insilmaril@753
|
536 |
{
|
insilmaril@753
|
537 |
if (isBranchLikeType() )
|
insilmaril@753
|
538 |
((BranchItem*)this)->updateVisibility();
|
insilmaril@753
|
539 |
/*
|
insilmaril@753
|
540 |
if (type==Image)
|
insilmaril@753
|
541 |
//updateVisibility();
|
insilmaril@753
|
542 |
*/
|
insilmaril@753
|
543 |
|
insilmaril@753
|
544 |
/*
|
insilmaril@753
|
545 |
|
insilmaril@753
|
546 |
if (mode==HideExport && (hideExport || hasHiddenExportParent() ) )
|
insilmaril@753
|
547 |
{
|
insilmaril@753
|
548 |
// Hide stuff according to hideExport flag and parents
|
insilmaril@753
|
549 |
//setVisibility (false);
|
insilmaril@753
|
550 |
updateVisibility();
|
insilmaril@753
|
551 |
//FIXME-2 hidden=true;
|
insilmaril@753
|
552 |
}else
|
insilmaril@753
|
553 |
{
|
insilmaril@753
|
554 |
// Do not hide, but still take care of scrolled status
|
insilmaril@753
|
555 |
|
insilmaril@753
|
556 |
|
insilmaril@753
|
557 |
XXXXXXXX treeItem should be THIS
|
insilmaril@753
|
558 |
|
insilmaril@753
|
559 |
move visible to TreeItem???
|
insilmaril@753
|
560 |
|
insilmaril@753
|
561 |
BranchObj now has updateContents
|
insilmaril@753
|
562 |
|
insilmaril@753
|
563 |
maybe also start "bool TreeItem::branchlikeType"
|
insilmaril@753
|
564 |
|
insilmaril@753
|
565 |
|
insilmaril@753
|
566 |
|
insilmaril@753
|
567 |
if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem))
|
insilmaril@753
|
568 |
setVisibility (false);
|
insilmaril@753
|
569 |
else
|
insilmaril@753
|
570 |
setVisibility (true);
|
insilmaril@753
|
571 |
//FIXME-2 hidden=false;
|
insilmaril@753
|
572 |
}
|
insilmaril@753
|
573 |
|
insilmaril@753
|
574 |
*/
|
insilmaril@753
|
575 |
// And take care of my children
|
insilmaril@753
|
576 |
for (int i=0; i<branchCount(); ++i)
|
insilmaril@753
|
577 |
getBranchNum(i)->setHideTmp (mode);
|
insilmaril@753
|
578 |
}
|
insilmaril@753
|
579 |
|
insilmaril@753
|
580 |
bool TreeItem::hasHiddenExportParent()
|
insilmaril@753
|
581 |
{
|
insilmaril@753
|
582 |
// Calls parents recursivly to
|
insilmaril@753
|
583 |
// find out, if we or parents are temp. hidden
|
insilmaril@753
|
584 |
|
insilmaril@753
|
585 |
if (hidden || hideExport) return true;
|
insilmaril@753
|
586 |
|
insilmaril@753
|
587 |
if (parentItem)
|
insilmaril@753
|
588 |
return parentItem->hasHiddenExportParent();
|
insilmaril@753
|
589 |
else
|
insilmaril@753
|
590 |
return false;
|
insilmaril@753
|
591 |
}
|
insilmaril@753
|
592 |
|
insilmaril@753
|
593 |
|
insilmaril@753
|
594 |
void TreeItem::setHideInExport(bool b)
|
insilmaril@753
|
595 |
{
|
insilmaril@753
|
596 |
if (isBranchLikeType() )
|
insilmaril@753
|
597 |
{
|
insilmaril@753
|
598 |
hideExport=b;
|
insilmaril@753
|
599 |
/* FIXME-1 call setVis and updateContentsSize...
|
insilmaril@753
|
600 |
if (b)
|
insilmaril@753
|
601 |
systemFlags->activate("hideInExport");
|
insilmaril@753
|
602 |
else
|
insilmaril@753
|
603 |
systemFlags->deactivate("hideInExport");
|
insilmaril@753
|
604 |
calcBBoxSize();
|
insilmaril@753
|
605 |
positionBBox();
|
insilmaril@753
|
606 |
requestReposition();
|
insilmaril@753
|
607 |
*/
|
insilmaril@753
|
608 |
}
|
insilmaril@753
|
609 |
}
|
insilmaril@753
|
610 |
|
insilmaril@753
|
611 |
bool TreeItem::hideInExport()
|
insilmaril@753
|
612 |
{
|
insilmaril@753
|
613 |
return hideExport;
|
insilmaril@753
|
614 |
}
|
insilmaril@753
|
615 |
|
insilmaril@753
|
616 |
bool TreeItem::isHidden()
|
insilmaril@753
|
617 |
{
|
insilmaril@753
|
618 |
return hidden;
|
insilmaril@753
|
619 |
}
|
insilmaril@753
|
620 |
|
insilmaril@753
|
621 |
|
insilmaril@726
|
622 |
|