diff -r 000000000000 -r 7a96bd401351 branchobj.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/branchobj.cpp Sun Jan 30 12:58:47 2005 +0000 @@ -0,0 +1,1184 @@ +#include "branchobj.h" +#include "texteditor.h" +#include "mapeditor.h" +#include "mainwindow.h" + +extern TextEditor *textEditor; +extern Main *mainWindow; +extern FlagRowObj *standardFlagsDefault; +extern QAction *actionEditOpenURL; + + +///////////////////////////////////////////////////////////////// +// BranchObj +///////////////////////////////////////////////////////////////// + +BranchObj* BranchObj::itLast=NULL; + + +BranchObj::BranchObj () :OrnamentedObj() +{ +// cout << "Const BranchObj ()\n"; + setParObj (this); + init(); + depth=-1; +} + +BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c) +{ +// cout << "Const BranchObj (c) called from MapCenterObj (c)\n"; + canvas=c; +} + +BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c) +{ +// cout << "Const BranchObj (c,p)\n"; + canvas=c; + setParObj (p); + depth=p->getDepth()+1; + if (depth==1) + // Calc angle to mapCenter if I am a mainbranch + // needed for reordering the mainbranches clockwise + // around mapcenter + angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ), + (int)(y() - parObj->getChildPos().y() ) ) ); + init(); +} + +BranchObj::~BranchObj () +{ + //cout << "Destr BranchObj\n"; + // Check, if this branch was the last child to be deleted + // If so, unset the scrolled flags + + BranchObj *po=(BranchObj*)(parObj); + if (po) + { + BranchObj *bo=((BranchObj*)(parObj))->getLastBranch(); + if (!bo) po->unScroll(); + } +} + +bool BranchObj::operator< ( const BranchObj & other ) +{ + return angle < other.angle; +} + +bool BranchObj::operator== ( const BranchObj & other ) +{ + return angle == other.angle; +} + +int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j) +{ + // Make sure PtrList::find works + if (i==j) return 0; + + if ( ((BranchObj*)(i))->angle > ((BranchObj*)(j))->angle ) + return 1; + else + return -1; +} + +void BranchObj::init () +{ + branch.setAutoDelete (true); + floatimage.setAutoDelete (true); + + absPos=getRandPos(); + absPos+=parObj->getChildPos(); + + // TODO This should be done in TextObj later + QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0"); +// font.setPointSize(12); + heading->setFont(font ); +// heading->setText(QObject::tr("new branch")); + + lastSelectedBranch=-1; + + setChildObj(this); + + scrolled=false; + tmpUnscrolled=false; + + url=""; + vymLink=""; +} + +void BranchObj::copy (BranchObj* other) +{ + OrnamentedObj::copy(other); + + branch.clear(); + BranchObj* b; + for (b=other->branch.first(); b;b=other->branch.next() ) + // Make deep copy of b + // Because addBranch again calls copy for the childs, + // Those will get a deep copy, too + addBranch(b); + + FloatImageObj *fi; + for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() ) + addFloatImage (fi); + + scrolled=other->scrolled; + tmpUnscrolled=other->tmpUnscrolled; + setVisibility (other->visible); + + url=other->url; + vymLink=other->vymLink; + + angle=other->angle; + + positionBBox(); +} + +void BranchObj::clear() +{ + branch.clear(); + floatimage.clear(); +} + +int BranchObj::getNum() +{ + if (parObj) + return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this)); + else + return 0; +} + +int BranchObj::getNum(BranchObj *bo) +{ + return branch.findRef (bo); +} + +int BranchObj::getFloatImageNum(FloatImageObj *fio) +{ + return floatimage.findRef (fio); +} + +int BranchObj::countBranches() +{ + return branch.count(); +} + +int BranchObj::countFloatImages() +{ + return floatimage.count(); +} + +void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off) +{ + // Temporary link to lmo + // m is position of mouse pointer + // offset 0: default 1: below lmo -1 above lmo (if possible) + + + BranchObj* o=(BranchObj*)(lmo); + if (!parObjTmpBuf) + parObjTmpBuf=parObj; + + // ignore mapcenter and mainbranch + if (lmo->getDepth()<2) off=0; + if (off==0) + { + link2ParPos=false; + parObj=o; + } + else + { + link2ParPos=true; + if (off>0) + parObj=o->getParObj(); + else + parObj=o->getParObj(); + parObj=o; + } + + depth=parObj->getDepth()+1; + + // setLinkStyle calls updateLink, only set it once + if (style!=getDefLinkStyle() ) setLinkStyle (getDefLinkStyle()); + + // Move temporary to new position at destination + // Usually the positioning would be done by reposition(), + // but then also the destination branch would "Jump" around... + // Better just do it approximately + if (depth==1) + { // new parent is the mapcenter itself + + QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(), + m.y() - o->getChildPos().y() )); + if (p.x()<0) p.setX( p.x()-bbox.width() ); + move2RelPos (p); + } else + { + int y; + if (off==0) + { + // new parent is just a branch, link to it + QRect t=o->getBBoxSizeWithChilds(); + if (o->getLastBranch()) + y=t.y() + t.height() ; + else + y=t.y(); + + } else + { + if (off<0) + // we want to link above lmo + y=o->y() - height() + 5; + else + // we want to link below lmo + // Bottom of sel should be 5 pixels above + // the bottom of the branch _below_ the target: + // Don't try to find that branch, guess 12 pixels + y=o->getChildPos().y() -height() + 12; + } + if (o->getOrientation()==OrientLeftOfCenter) + move ( o->getChildPos().x() - linkwidth, y ); + else + move (o->getChildPos().x() + linkwidth, y ); + } + + // updateLink is called implicitly in move + reposition(); // FIXME shouldn't be this a request? +} + +void BranchObj::unsetParObjTmp() +{ + if (parObjTmpBuf) + { + link2ParPos=false; + parObj=parObjTmpBuf; + parObjTmpBuf=NULL; + depth=parObj->getDepth()+1; + setLinkStyle (getDefLinkStyle() ); + } +} + +void BranchObj::unScroll() +{ + if (tmpUnscrolled) resetTmpUnscroll(); + if (scrolled) toggleScroll(); +} + +void BranchObj::toggleScroll() +{ + BranchObj *bo; + if (scrolled) + { + scrolled=false; + systemFlags->deactivate("scrolledright"); + for (bo=branch.first(); bo; bo=branch.next() ) + { + bo->setVisibility(true); + } + } else + { + scrolled=true; + systemFlags->activate("scrolledright"); + for (bo=branch.first(); bo; bo=branch.next() ) + { + bo->setVisibility(false); + } + } + calcBBoxSize(); + positionBBox(); + move (absPos.x(), absPos.y() ); + forceReposition(); +} + +bool BranchObj::isScrolled() +{ + return scrolled; +} + +bool BranchObj::hasScrolledParent(BranchObj *start) +{ + // Calls parents recursivly to + // find out, if we are scrolled at all. + // But ignore myself, just look at parents. + + if (this !=start && scrolled) return true; + + BranchObj* bo=(BranchObj*)(parObj); + if (bo) + return bo->hasScrolledParent(start); + else + return false; +} + +void BranchObj::tmpUnscroll() +{ + // Unscroll parent (recursivly) + BranchObj* bo=(BranchObj*)(parObj); + if (bo) bo->tmpUnscroll(); + + // Unscroll myself + if (scrolled) + { + tmpUnscrolled=true; + systemFlags->activate("tmpUnscrolledright"); + toggleScroll(); + } +} + +void BranchObj::resetTmpUnscroll() +{ + // Unscroll parent (recursivly) + BranchObj* bo=(BranchObj*)(parObj); + if (bo) + bo->resetTmpUnscroll(); + + // Unscroll myself + if (tmpUnscrolled) + { + tmpUnscrolled=false; + systemFlags->deactivate("tmpUnscrolledright"); + toggleScroll(); + } +} + +void BranchObj::setVisibility(bool v, int toDepth) +{ + if (depth <= toDepth) + { + frame->setVisibility(v); + heading->setVisibility(v); + systemFlags->setVisibility(v); + standardFlags->setVisibility(v); + LinkableMapObj::setVisibility (v); + + if (!scrolled && (depth < toDepth)) + { + // Now go recursivly through all childs + BranchObj* b; + for (b=branch.first(); b;b=branch.next() ) + b->setVisibility (v,toDepth); + FloatImageObj *fio; + for (fio=floatimage.first(); fio; fio=floatimage.next()) + fio->setVisibility (v); + } + } // depth <= toDepth + move (absPos.x(), absPos.y() ); + requestReposition(); +} + +void BranchObj::setVisibility(bool v) +{ + setVisibility (v,MAX_DEPTH); +} + + +void BranchObj::setLinkColor () +{ + // Overloaded from LinkableMapObj + // BranchObj can use color of heading + + if (mapEditor->getLinkColorHint()==HeadingColor) + LinkableMapObj::setLinkColor (heading->getColor() ); + else + LinkableMapObj::setLinkColor (); +} + +void BranchObj::setColor (QColor col, bool colorChilds) +{ + heading->setColor(col); + setLinkColor(); + if (colorChilds) + { + BranchObj *bo; + for (bo=branch.first(); bo; bo=branch.next() ) + bo->setColor(col,colorChilds); + } +} + + +BranchObj* BranchObj::first() +{ + itLast=NULL; + return this; +} + +BranchObj* BranchObj::next() +{ + BranchObj *lmo; + BranchObj *bo=branch.first(); + BranchObj *po=(BranchObj*)(parObj); + + if (!itLast) + { // We are just beginning at the mapCenter + if (bo) + { + itLast=this; + return bo; + } + else + { + itLast=NULL; + return NULL; + } + } + + if (itLast==parObj) + { // We come from above + if (bo) + { + // there are childs, go there + itLast=this; + return bo; + } + else + { // no childs, try to go up again + if (po) + { + // go up + itLast=this; + lmo=po->next(); + itLast=this; + return lmo; + + } + else + { + // can't go up, I am mapCenter + itLast=NULL; + return NULL; + } + } + } + + // Try to find last child, we came from, in my own childs + bool searching=true; + while (bo && searching) + { + if (itLast==bo) searching=false; + bo=branch.next(); + } + if (!searching) + { // found lastLMO in my childs + if (bo) + { + // found a brother of lastLMO + itLast=this; + return bo; + } + else + { + if (po) + { + // go up + itLast=this; + lmo=po->next(); + itLast=this; + return lmo; + } + else + { + // can't go up, I am mapCenter + itLast=NULL; + return NULL; + } + } + } + + // couldn't find last child, it must be a nephew of mine + bo=branch.first(); + if (bo) + { + // proceed with my first child + itLast=this; + return bo; + } + else + { + // or go back to my parents + if (po) + { + // go up + itLast=this; + lmo=po->next(); + itLast=this; + return lmo; + } + else + { + // can't go up, I am mapCenter + itLast=NULL; + return NULL; + } + } +} + +BranchObj* BranchObj::getLastIterator() +{ + return itLast; +} + +void BranchObj::setLastIterator(BranchObj* it) +{ + itLast=it; +} + + +void BranchObj::move (double x, double y) +{ + OrnamentedObj::move (x,y); + positionBBox(); +} + +void BranchObj::move (QPoint p) +{ + move (p.x(), p.y()); +} + +void BranchObj::moveBy (double x, double y) +{ + OrnamentedObj::moveBy (x,y); + positionBBox(); + BranchObj* b; + for (b=branch.first(); b;b=branch.next() ) + b->moveBy (x,y); +} + +void BranchObj::moveBy (QPoint p) +{ + moveBy (p.x(), p.y()); +} + + +void BranchObj::positionBBox() +{ + + heading->positionBBox(); + systemFlags->positionBBox(); + standardFlags->positionBBox(); + // It seems that setting x,y also affects width,height + int w_old=bbox.width(); + int h_old=bbox.height(); + bbox.setX (absPos.x() ); + bbox.setY (absPos.y() ); + bbox.setWidth(w_old); + bbox.setHeight(h_old); + + + setSelBox(); + + // set the frame + frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); +} + +void BranchObj::calcBBoxSize() +{ + QSize heading_r=heading->getSize(); + int heading_w=static_cast (heading_r.width() ); + int heading_h=static_cast (heading_r.height() ); + QSize sysflags_r=systemFlags->getSize(); + int sysflags_h=sysflags_r.height(); + int sysflags_w=sysflags_r.width(); + QSize stanflags_r=standardFlags->getSize(); + int stanflags_h=stanflags_r.height(); + int stanflags_w=stanflags_r.width(); + int w; + int h; + + // set width to sum of all widths + w=heading_w + sysflags_w + stanflags_w; + // set height to maximum needed height + h=max (sysflags_h,stanflags_h); + h=max (h,heading_h); + + w+=frame->getBorder(); + h+=frame->getBorder(); + bbox.setSize (QSize (w,h)); +} + +LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO) +{ + // Search branches + BranchObj *b; + LinkableMapObj *lmo; + for (b=branch.first(); b; b=branch.next() ) + { + lmo=b->findMapObj(p, excludeLMO); + if (lmo != NULL) return lmo; + } + + // Search myself + if (inBBox (p) && (this != excludeLMO) && isVisibleObj() ) + return this; + + // Search float images + FloatImageObj *foi; + for (foi=floatimage.first(); foi; foi=floatimage.next() ) + if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi; + + return NULL; +} + +void BranchObj::setHeading(QString s) +{ + // Adjusting font size + QFont font=heading->getFont(); + if (depth==0) + font.setPointSize(16); + else + if (depth>1) + font.setPointSize(10); + else + font.setPointSize(12); + heading->setFont(font); + heading->setText(s); // set new heading + calcBBoxSize(); // recalculate bbox + positionBBox(); // rearrange contents + requestReposition(); +} + +void BranchObj::setURL(QString s) +{ + url=s; + if (!url.isEmpty()) + systemFlags->activate("url"); + else + systemFlags->deactivate("url"); + calcBBoxSize(); // recalculate bbox + positionBBox(); // rearrange contents + forceReposition(); +} + +QString BranchObj::getURL() +{ + return url; +} + +void BranchObj::setVymLink(QString s) +{ + if (!s.isEmpty()) + { + // We need the relative (from loading) + // or absolute path (from User event) + // and build the absolute path. + // Note: If we have relative, use path of + // current map to build absolute path + QDir d(s); + if (!d.path().startsWith ("/")) + { + QString p=mapEditor->getDestPath(); + int i=p.findRev("/",-1); + d.setPath(p.left(i)+"/"+s); + d.convertToAbs(); + } + vymLink=d.path(); + systemFlags->activate("vymLink"); + } + else + { + systemFlags->deactivate("vymLink"); + vymLink=""; + } + calcBBoxSize(); // recalculate bbox + positionBBox(); // rearrange contents + forceReposition(); +} + +QString BranchObj::getVymLink() +{ + return vymLink; +} + +QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset) +{ + QString s,a; + QString scrolledAttr; + if (scrolled) + scrolledAttr=attribut ("scrolled","yes"); + else + scrolledAttr=""; + + QString posAttr; + if (depth<2) posAttr= + attribut("absPosX",QString().setNum(absPos.x(),10)) + + attribut("absPosY",QString().setNum(absPos.y(),10)); + else + posAttr=""; + + QString urlAttr; + if (!url.isEmpty()) + urlAttr=attribut ("url",url); + + QString vymLinkAttr; + if (!vymLink.isEmpty()) + vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) ); + + QString frameAttr; + if (frame->getFrameType()!=NoFrame) + frameAttr=attribut ("frameType",frame->getFrameTypeName()); + else + frameAttr=""; + + // save area, if not scrolled + QString areaAttr; + if (!((BranchObj*)(parObj))->isScrolled() ) + { + areaAttr= + attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) + + attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) + + attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) + + attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10)); + + } else + areaAttr=""; + + s=beginElement ("branch" +scrolledAttr +posAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr); + incIndent(); + + // save heading + s=s+valueElement("heading", getHeading(), + attribut ("textColor",QColor(heading->getColor()).name())); + + // save names of flags set + s+=standardFlags->saveToDir(tmpdir,prefix,0); + + // save note + if (!note.isEmpty() ) + s+=note.saveToDir(); + + // Save branches + BranchObj *bo; + for (bo=branch.first(); bo; bo=branch.next() ) + s+=bo->saveToDir(tmpdir,prefix,offset); + decIndent(); + + // Save FloatImages + FloatImageObj *fio; + for (fio=floatimage.first(); fio; fio=floatimage.next() ) + s+=fio->saveToDir (tmpdir,prefix); + + s+=endElement ("branch"); + return s; +} + +LinkableMapObj* BranchObj::addFloatImage () +{ + FloatImageObj *newfi=new FloatImageObj (canvas,this); + floatimage.append (newfi); + if (hasScrolledParent(this) ) + newfi->setVisibility (false); + else + newfi->setVisibility(visible); + requestReposition(); + return newfi; +} + +LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio) +{ + FloatImageObj *newfi=new FloatImageObj (canvas,this); + floatimage.append (newfi); + newfi->copy (fio); + if (hasScrolledParent(this) ) + newfi->setVisibility (false); + else + newfi->setVisibility(visible); + requestReposition(); + return newfi; +} + +FloatImageObj* BranchObj::getFirstFloatImage () +{ + return floatimage.first(); +} + +FloatImageObj* BranchObj::getLastFloatImage () +{ + return floatimage.last(); +} + +FloatImageObj* BranchObj::getFloatImageNum (const uint &i) +{ + return floatimage.at(i); +} + +void BranchObj::removeFloatImage (FloatImageObj *fio) +{ + floatimage.remove (fio); + requestReposition(); +} + +void BranchObj::savePosInAngle () +{ + // Save position in angle + BranchObj *b; + int i=0; + for (b=branch.first(); b; b=branch.next() ) + { + b->angle=i; + i++; + } +} + +BranchObj* BranchObj::addBranch() +{ + BranchObj* newbo=new BranchObj(canvas,this); + branch.append (newbo); + newbo->setParObj(this); + newbo->setColor(getColor(),false); + newbo->setLinkColor(); + newbo->setHeading ("new"); + newbo->setLinkStyle (newbo->getDefLinkStyle()); + if (scrolled) + newbo->setVisibility (false); + else + newbo->setVisibility(visible); + requestReposition(); + return newbo; +} + +BranchObj* BranchObj::addBranch(BranchObj* bo) +{ + BranchObj* newbo=new BranchObj(canvas,this); + branch.append (newbo); + newbo->copy(bo); + newbo->setParObj(this); + newbo->setHeading (newbo->getHeading()); // adjust fontsize to depth + newbo->setLinkStyle (newbo->getDefLinkStyle()); + if (scrolled) + newbo->setVisibility (false); + else + newbo->setVisibility(bo->visible); + requestReposition(); + return newbo; +} + +BranchObj* BranchObj::insertBranch(int pos) +{ + savePosInAngle(); + // Add new bo and resort branches + BranchObj *newbo=addBranch (); + newbo->angle=pos-0.5; + branch.sort(); + return newbo; +} + +BranchObj* BranchObj::insertBranch(BranchObj* bo, int pos) +{ + savePosInAngle(); + // Add new bo and resort branches + bo->angle=pos-0.5; + BranchObj *newbo=addBranch (bo); + branch.sort(); + return newbo; +} + +void BranchObj::removeBranch(BranchObj* bo) +{ + // if bo is not in branch remove returns false, we + // don't care... + branch.remove (bo); + requestReposition(); +} + +void BranchObj::setLastSelectedBranch (BranchObj* bo) +{ + lastSelectedBranch=branch.find(bo); +} + +BranchObj* BranchObj::getLastSelectedBranch () +{ + if (lastSelectedBranch>=0) + { + BranchObj* bo=branch.at(lastSelectedBranch); + if (bo) return bo; + } + return branch.first(); +} + +BranchObj* BranchObj::getFirstBranch () +{ + return branch.first(); +} + +BranchObj* BranchObj::getLastBranch () +{ + return branch.last(); +} + +BranchObj* BranchObj::getBranchNum (const uint &i) +{ + return branch.at(i); +} + + +BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself) +{ + savePosInAngle(); + int i=branch.find(bo1); + if (i>0) + { // -1 if bo1 not found + branch.at(i)->angle--; + branch.at(i-1)->angle++; + branch.sort(); + return branch.at(i-1); + } else + return branch.at(i); +} + +BranchObj* BranchObj::moveBranchDown(BranchObj* bo1) +{ + savePosInAngle(); + int i=branch.find(bo1); + int j; + if (branch.next()) + { + j = branch.at(); + branch.at(i)->angle++; + branch.at(j)->angle--; + branch.sort(); + return branch.at(j); + } else + return branch.at(i); +} + +void BranchObj::alignRelativeTo (QPoint ref) +{ +/* FIXME testing + if (!getHeading().isEmpty()) + cout << "BO::alignRelTo "<reposition(); + + if (scrolled) return; + + // Set reference point for alignment of childs + QPoint ref2; + if (orientation==OrientLeftOfCenter) + ref2.setX(childPos.x() - linkwidth); + else + ref2.setX(childPos.x() + linkwidth); + + if (depth==1) + ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2); + else + ref2.setY(ref.y() ); + + // Align the childs depending on reference point + BranchObj *b; + for (b=branch.first(); b; b=branch.next() ) + { + b->alignRelativeTo (ref2); + ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() ); + } +} + + +void BranchObj::reposition() +{ +/* FIXME testing + if (!getHeading().isEmpty()) + cout << "BO::reposition "<getTotalBBox(),r); + + FloatImageObj* fio; + for (fio=floatimage.first();fio ;fio=floatimage.next() ) + r=addBBox(fio->getTotalBBox(),r); + + return r; +} + +QRect BranchObj::getBBoxSizeWithChilds() +{ + return bboxTotal; +} + +void BranchObj::calcBBoxSizeWithChilds() +{ + // This is called only from reposition and + // and only for mapcenter. So it won't be + // called more than once for a single user + // action + + // Calculate size of LMO including all childs (to align them later) + + bboxTotal.setX(bbox.x() ); + bboxTotal.setY(bbox.y() ); + + // if branch is scrolled, ignore childs, but still consider floatimages + if (scrolled) + { + bboxTotal.setWidth (bbox.width()); + bboxTotal.setHeight(bbox.height()); + return; + } + + QRect r(0,0,0,0); + QRect br; + // Now calculate recursivly + // sum of heights + // maximum of widths + // minimum of y + BranchObj* b; + for (b=branch.first();b ;b=branch.next() ) + { + b->calcBBoxSizeWithChilds(); + br=b->getBBoxSizeWithChilds(); + r.setWidth( max (br.width(), r.width() )); + r.setHeight(br.height() + r.height() ); + if (br.y()setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); +} + +void BranchObj::select() +{ + LinkableMapObj::select(); + // Tell parent that I am selected now: + BranchObj* po=(BranchObj*)(parObj); + if (po) // TODO Try to get rid of this cast... + po->setLastSelectedBranch(this); + + // temporary unscroll, if we have scrolled parents somewhere + if (parObj) ((BranchObj*)(parObj))->tmpUnscroll(); + + // set Text in Editor + textEditor->setText(note.getNote() ); + textEditor->setFilename(note.getFilenameHint() ); + textEditor->setFontHint (note.getFontHint() ); + connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag() ) ); + connect (textEditor, SIGNAL (fontSizeHasChanged() ), this, SLOT (updateNoteFlag() ) ); + + // Show URL and link in statusbar + QString status; + if (!url.isEmpty()) status+="URL: "+url+" "; + if (!vymLink.isEmpty()) status+="Link: "+vymLink; + if (!status.isEmpty()) mainWindow->statusMessage (status); + + // Update Toolbar + standardFlags->updateToolBar(); + + // Update Browserbutton + if (!url.isEmpty()) + actionEditOpenURL->setEnabled (true); + else + actionEditOpenURL->setEnabled (false); + + // Update actions in mapeditor + mapEditor->updateActions(); +} + +void BranchObj::unselect() +{ + LinkableMapObj::unselect(); + // Delete any messages like vymLink in StatusBar + mainWindow->statusMessage (""); + + // save note from editor and set flag + // text is done by updateNoteFlag(), just save + // filename here + note.setFilenameHint (textEditor->getFilename()); + + // reset temporary unscroll, if we have scrolled parents somewhere + if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll(); + + // Disconnect textEditor from this LMO + disconnect( textEditor, SIGNAL(textHasChanged()), 0, 0 ); + disconnect( textEditor, SIGNAL (fontSizeHasChanged()),0,0 ); + + // Erase content of editor + textEditor->setInactive(); + + // unselect all buttons in toolbar + standardFlagsDefault->updateToolBar(); +} + +QString BranchObj::getSelectString() +{ + QString s; + if (parObj) + { + if (parObj->getDepth()==0) + s= "bo:" + QString("%1").arg(getNum()); + else + s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum()); + } else + { + s="mc:"; + } + + return s; +} +