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