1 #include "branchitem.h"
10 BranchItem::BranchItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
12 //cout << "Constr. BranchItem\n";
18 BranchItem::~BranchItem()
20 cout << "Destr. BranchItem\n";
21 qDeleteAll(childItems);
24 void BranchItem::copy (BranchItem *other)
26 scrolled=other->scrolled;
27 tmpUnscrolled=other->tmpUnscrolled;
30 QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
32 // Cloudy stuff can be hidden during exports
33 if (hidden) return QString();
36 BranchObj *bo=(BranchObj*)lmo;
39 // Update of note is usually done while unselecting a branch
40 if (isNoteInEditor) getNoteFromTextEditor();
44 scrolledAttr=attribut ("scrolled","yes");
48 // save area, if not scrolled
50 if (!((BranchObj*)(parObj))->isScrolled() )
53 attribut("x1",QString().setNum(absPos.x()-offset.x())) +
54 attribut("y1",QString().setNum(absPos.y()-offset.y())) +
55 attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
56 attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
61 // Providing an ID for a branch makes export to XHTML easier
64 idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
69 s=beginElement ("branch"
74 // +getIncludeImageAttr()
79 s+=valueElement("heading", getHeading(),
80 attribut ("textColor",QColor( bo->getColor()).name()));
84 if (frame->getFrameType()!=FrameObj::NoFrame)
85 s+=frame->saveToDir ();
87 // save names of flags set
88 s+=standardFlags->saveToDir(tmpdir,prefix,0);
91 for (int i=0; i<floatimage.size(); ++i)
92 s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
100 TreeItem *ti=getFirstBranch();
101 TreeItem *last=getLastBranch();
102 while (ti && ti!=last)
103 s+=ti->saveToDir(tmpdir,prefix,offset);
107 QString ol; // old link
108 QString cl; // current link
109 for (int i=0; i<xlink.size(); ++i)
111 cl=xlink.at(i)->saveToDir();
118 qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
124 s+=endElement ("branch");
128 void BranchItem::updateVisibility() // FIXME-1
132 void BranchItem::setVymLink(QString s)
136 // We need the relative (from loading)
137 // or absolute path (from User event)
138 // and build the absolute path.
139 // Note: If we have relative, use path of
140 // current map to build absolute path
142 if (!d.path().startsWith ("/"))
144 QString p=model->getDestPath();
145 int i=p.findRev("/",-1);
146 d.setPath(p.left(i)+"/"+s);
150 //FIXME-2 systemFlags->activate("vymLink");
154 //FIXME-2 systemFlags->deactivate("vymLink");
158 calcBBoxSize(); // recalculate bbox
159 positionBBox(); // rearrange contents
164 QString BranchItem::getVymLink()
169 void BranchItem::unScroll()
171 if (tmpUnscrolled) resetTmpUnscroll();
172 if (scrolled) toggleScroll();
175 void BranchItem::toggleScroll()
180 //FIXME-1 systemFlags->deactivate("scrolledright");
182 for (int i=0; i<branch.size(); ++i)
183 branch.at(i)->setVisibility(true);
189 //FIXME-1 systemFlags->activate("scrolledright");
190 for (int i=0; i<branch.size(); ++i)
191 branch.at(i)->setVisibility(false);
197 move (absPos.x(), absPos.y() );
202 bool BranchItem::isScrolled()
207 bool BranchItem::hasScrolledParent(BranchItem *start)
209 // Calls parents recursivly to
210 // find out, if we are scrolled at all.
211 // But ignore myself, just look at parents.
213 if (this !=start && scrolled) return true;
215 BranchItem* bi=(BranchItem*)parentItem;
217 return bi->hasScrolledParent(start);
222 void BranchItem::tmpUnscroll()
224 // Unscroll parent (recursivly)
225 BranchItem * bi=(BranchItem*)parentItem;
226 if (bi) bi->tmpUnscroll();
232 // FIXME-1 systemFlags->activate("tmpUnscrolledright");
237 void BranchItem::resetTmpUnscroll()
239 // Unscroll parent (recursivly)
240 BranchItem * bi=(BranchItem*)parentItem;
241 if (bi) bi->resetTmpUnscroll();
247 // FIXME-1 systemFlags->deactivate("tmpUnscrolledright");
252 BranchObj* BranchItem::getBranchObj() // FIXME-3 only for transition BO->BI
254 return (BranchObj*)lmo;