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