10 TreeItem::TreeItem(const QList<QVariant> &data, TreeItem *parent)
20 lastSelectedBranchNum=-1;
23 // note.setFontHint (textEditor->getFontHintDefault() ); //FIXME-2
24 // isNoteInEditor=false;
31 qDeleteAll(childItems);
34 QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
36 qWarning ("TreeItem::saveToDir called directly");
42 void TreeItem::copy (OrnamentedObj* other) //FIXME-2
45 note.copy (other->note);
50 void TreeItem::setModel (VymModel *m)
55 VymModel* TreeItem::getModel ()
60 void TreeItem::appendChild(TreeItem *item)
62 childItems.append(item);
63 item->setModel (model);
65 if (item->type == Branch || item->type ==MapCenter)
68 branchOffset=childItems.count()-1;
73 void TreeItem::removeChild(int row)
75 if (row<0 || row > childItems.size()-1)
76 qWarning ("TreeItem::removeChild tried to remove non existing item?!\n");
79 cout << "TI::removeChild this="<<this<<" row="<<row<<endl;
80 delete childItems.takeAt (row);
84 TreeItem *TreeItem::child(int row)
86 return childItems.value(row);
89 int TreeItem::childCount() const
91 return childItems.count();
94 int TreeItem::childNumber() const
97 return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
102 int TreeItem::columnCount() const
104 return itemData.count();
107 int TreeItem::branchCount() const
109 return branchCounter;
111 int TreeItem::row() const
114 return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
119 int TreeItem::column() const
124 int TreeItem::depth()
136 TreeItem *TreeItem::parent()
145 case Undefined: return -1;
146 case MapCenter: return parentItem->childItems.indexOf (this) - branchOffset;
147 case Branch: return parentItem->childItems.indexOf (this) - branchOffset;
148 case Image: return -1; // FIXME-2
154 QVariant TreeItem::data(int column) const
156 return itemData.value(column);
159 void TreeItem::setHeading (const QString s)
164 QString TreeItem::getHeading ()
166 return itemData[0].toString();
169 void TreeItem::setNote(const QString s)
172 // updateNoteFlag(); FIXME-2 needed?
174 model->emitContentHasChanged (this);
177 void TreeItem::setNoteObj(const NoteObj &n, bool updateNoteEditor)
180 // updateNoteFlag(); FIXME-2 needed?
181 if (model && updateNoteEditor)
182 model->emitContentHasChanged (this);
185 QString TreeItem::getNote()
187 return note.getNote();
190 NoteObj TreeItem::getNoteObj()
195 QString TreeItem::getNoteASCII(const QString &indent, const int &width)
197 return note.getNoteASCII(indent,width);
200 QString TreeItem::getNoteASCII()
202 return note.getNoteASCII();
205 QString TreeItem::getNoteOpenDoc()
207 return note.getNoteOpenDoc();
210 void TreeItem::setType(const Type t)
213 itemData[1]=getTypeName();
216 TreeItem::Type TreeItem::getType()
221 QString TreeItem::getTypeName()
225 case Undefined: return QString ("Undefined");
226 case MapCenter: return QString ("MapCenter");
227 case Branch: return QString ("Branch");
228 case Image: return QString ("Image");
229 default: return QString ("TreeItem::getTypeName no typename defined?!");
233 TreeItem* TreeItem::getChildNum(const int &n)
235 if (n>=0 && n<childItems.count() )
236 return childItems.at(n);
241 TreeItem* TreeItem::getFirstBranch()
244 return getBranchNum (branchOffset);
249 TreeItem* TreeItem::getLastBranch()
252 return getBranchNum (branchOffset + branchCounter-1);
258 TreeItem* TreeItem::getBranchNum(const int &n)
261 return getChildNum (branchOffset + n);
266 void TreeItem::setLastSelectedBranch()
269 parentItem->lastSelectedBranchNum=parentItem->childItems.indexOf(this);
272 TreeItem* TreeItem::getLastSelectedBranch()
274 return getBranchNum (lastSelectedBranchNum);
277 LinkableMapObj* TreeItem::getLMO() // FIXME-3 VM should be unnecessary in the end
282 void TreeItem::setLMO(LinkableMapObj *l)