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