# HG changeset patch # User insilmaril # Date 1216293115 0 # Node ID 394b2f297e1d6f8c141ebba597750914f0c6fb55 # Parent e37153bea487db698000c8f5a0f880401681131d Deleting an animated part no longer segfaults diff -r e37153bea487 -r 394b2f297e1d INSTALL.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/INSTALL.txt Thu Jul 17 11:11:55 2008 +0000 @@ -0,0 +1,59 @@ +Installation of vym - view your mind +==================================== + +Contents +-------- + +A) openSUSE 10.2 +B) openSUSE 10.3 and 11.0 +C) Mac OS X 10.3+ + +More systems like Debian are likely to be added later. Please +send feedback about installation on your Operating System to +vym@InSilmaril.de + +For general questions please contact the vym mailinglist: + + vym-forum@lists.sourceforge.net + + +A) openSUSE 10.2 +================ + +vym needs a newer version of Trolltechs Qt libraries than the one on the +10.2 installation media. This new version can be installed easily in +YaST: + + - Select "Installation Source" + - Add a HTTP source: + Server: repos.opensuse.org + Directory: /KDE:/Qt/openSUSE_10.2/ + Authentication: Anonymous + + - Select "Software Management" + - Search for "libqt4" + - Install all found packages. (They have a version >= 4.3.0-55.1) + +B) openSUSE 10.2 and later +========================== + +Get the rpms e.g. from here: + +http://download.opensuse.org/repositories/home://insilmaril/ + +and install the (as root): + +yast -i vym-[VERSION].rpm + +C) Mac OS X 10.3+ +================= + +After opening the disk image vym-1.9.0.dmg you can copy vym.app to +/Applications. This will need administrator rights. + + +This release of vym includes the Qt libraries. For more information on +Qt see http://www.trolltech.com. + + + diff -r e37153bea487 -r 394b2f297e1d branchobj.cpp --- a/branchobj.cpp Thu Jul 17 09:27:20 2008 +0000 +++ b/branchobj.cpp Thu Jul 17 11:11:55 2008 +0000 @@ -1,12 +1,16 @@ #include "branchobj.h" -#include "texteditor.h" + +// #include "texteditor.h" +#include "geometry.h" #include "mapeditor.h" #include "mainwindow.h" +#include "misc.h" + +class TextEditor; extern TextEditor *textEditor; extern Main *mainWindow; extern FlagRowObj *standardFlagsDefault; -extern QAction *actionEditOpenURL; ///////////////////////////////////////////////////////////////// @@ -14,6 +18,7 @@ ///////////////////////////////////////////////////////////////// BranchObj* BranchObj::itLast=NULL; +BranchObj* BranchObj::itFirst=NULL; BranchObj::BranchObj () :OrnamentedObj() @@ -24,39 +29,50 @@ depth=-1; } -BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c) +BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s) { -// cout << "Const BranchObj (c) called from MapCenterObj (c)\n"; - canvas=c; +// cout << "Const BranchObj (s) called from MapCenterObj (s)\n"; + parObj=NULL; + scene=s; } -BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c) +BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s) { -// cout << "Const BranchObj (c,p)\n"; - canvas=c; +// cout << "Const BranchObj (s,p)\n"; + scene=s; 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() ) ) ); + angle=getAngle (QPointF (x() - parObj->getChildPos().x() , + (y() - parObj->getChildPos().y() ) ) ); init(); } BranchObj::~BranchObj () { - //cout << "Destr BranchObj\n"; + // If I'm animated, I need to un-animate myself first + if (anim.isAnimated() ) + { + anim.setAnimated (false); + mapEditor->getModel()->stopAnimation (this); + } + + + //cout << "Destr BranchObj of "<getLastBranch(); - if (!bo) po->unScroll(); + bo=((BranchObj*)parObj)->getLastBranch(); + if (bo) po->unScroll(); } + clear(); } bool BranchObj::operator< ( const BranchObj & other ) @@ -69,40 +85,23 @@ 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); + if (parObj) + { + absPos=getRandPos(); + absPos+=parObj->getChildPos(); + } - 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; + lastSelectedBranch=0; setChildObj(this); scrolled=false; tmpUnscrolled=false; - url=""; - vymLink=""; + includeImagesVer=false; + includeImagesHor=false; } void BranchObj::copy (BranchObj* other) @@ -110,24 +109,18 @@ OrnamentedObj::copy(other); branch.clear(); - BranchObj* b; - for (b=other->branch.first(); b;b=other->branch.next() ) + for (int i=0; ibranch.size(); ++i) // Make deep copy of b // Because addBranch again calls copy for the childs, // Those will get a deep copy, too - addBranch(b); + addBranch(other->branch.at(i) ); - FloatImageObj *fi; - for (fi=other->floatimage.first(); fi;fi=other->floatimage.next() ) - addFloatImage (fi); - + for (int i=0; ifloatimage.size(); ++i) + addFloatImage (other->floatimage.at(i)); scrolled=other->scrolled; tmpUnscrolled=other->tmpUnscrolled; setVisibility (other->visible); - url=other->url; - vymLink=other->vymLink; - angle=other->angle; positionBBox(); @@ -135,26 +128,42 @@ void BranchObj::clear() { - branch.clear(); - floatimage.clear(); + setVisibility (true); + + while (!floatimage.isEmpty()) + delete floatimage.takeFirst(); + + while (!xlink.isEmpty()) + delete xlink.takeFirst(); + + while (!branch.isEmpty()) + delete branch.takeFirst(); +} + +bool isAbove (BranchObj* a, BranchObj *b) +{ + if (a->angle < b->angle) + return true; + else + return false; } int BranchObj::getNum() { if (parObj) - return ((BranchObj*)(parObj))->getNum ((BranchObj*)(this)); + return ((BranchObj*)parObj)->getNum (this); else return 0; } int BranchObj::getNum(BranchObj *bo) { - return branch.findRef (bo); + return branch.indexOf (bo); } int BranchObj::getFloatImageNum(FloatImageObj *fio) { - return floatimage.findRef (fio); + return floatimage.indexOf(fio); } int BranchObj::countBranches() @@ -167,7 +176,12 @@ return floatimage.count(); } -void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off) +int BranchObj::countXLinks() +{ + return xlink.count(); +} + +void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off) { // Temporary link to lmo // m is position of mouse pointer @@ -181,19 +195,10 @@ // 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; - } + parObj=o; depth=parObj->getDepth()+1; @@ -207,17 +212,17 @@ if (depth==1) { // new parent is the mapcenter itself - QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(), + QPointF p= normalise ( QPointF (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; + qreal y; if (off==0) { // new parent is just a branch, link to it - QRect t=o->getBBoxSizeWithChilds(); + QRectF t=o->getBBoxSizeWithChilds(); if (o->getLastBranch()) y=t.y() + t.height() ; else @@ -235,14 +240,14 @@ // Don't try to find that branch, guess 12 pixels y=o->getChildPos().y() -height() + 12; } - if (o->getOrientation()==OrientLeftOfCenter) + if (o->getOrientation()==LinkableMapObj::LeftOfCenter) 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? + requestReposition(); } void BranchObj::unsetParObjTmp() @@ -254,6 +259,7 @@ parObjTmpBuf=NULL; depth=parObj->getDepth()+1; setLinkStyle (getDefLinkStyle() ); + updateLink(); } } @@ -265,23 +271,18 @@ void BranchObj::toggleScroll() { - BranchObj *bo; if (scrolled) { scrolled=false; systemFlags->deactivate("scrolledright"); - for (bo=branch.first(); bo; bo=branch.next() ) - { - bo->setVisibility(true); - } + for (int i=0; isetVisibility(true); } else { scrolled=true; systemFlags->activate("scrolledright"); - for (bo=branch.first(); bo; bo=branch.next() ) - { - bo->setVisibility(false); - } + for (int i=0; isetVisibility(false); } calcBBoxSize(); positionBBox(); @@ -350,18 +351,19 @@ standardFlags->setVisibility(v); LinkableMapObj::setVisibility (v); + // Only change childs, if I am not scrolled 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); + int i; + for (i=0; isetVisibility (v,toDepth); + for (i=0; isetVisibility (v); + for (i=0; isetVisibility (); } } // depth <= toDepth - move (absPos.x(), absPos.y() ); requestReposition(); } @@ -376,53 +378,60 @@ // Overloaded from LinkableMapObj // BranchObj can use color of heading - if (mapEditor->getLinkColorHint()==HeadingColor) - LinkableMapObj::setLinkColor (heading->getColor() ); - else - LinkableMapObj::setLinkColor (); + if (mapEditor) + { + if (mapEditor->getMapLinkColorHint()==HeadingColor) + LinkableMapObj::setLinkColor (heading->getColor() ); + else + LinkableMapObj::setLinkColor (); + } } -void BranchObj::setColor (QColor col, bool colorChilds) +void BranchObj::setColorSubtree(QColor col) { - heading->setColor(col); - setLinkColor(); - if (colorChilds) - { - BranchObj *bo; - for (bo=branch.first(); bo; bo=branch.next() ) - bo->setColor(col,colorChilds); - } + setColor (col); + for (int i=0; isetColorSubtree(col); } - BranchObj* BranchObj::first() { itLast=NULL; + itFirst=this; return this; } BranchObj* BranchObj::next() { + BranchObj *bo; BranchObj *lmo; - BranchObj *bo=branch.first(); - BranchObj *po=(BranchObj*)(parObj); + BranchObj *po=(BranchObj*)parObj; + + if (branch.isEmpty()) + bo=NULL; + else + bo=branch.first(); if (!itLast) - { // We are just beginning at the mapCenter + { + // no itLast, we are just beginning if (bo) { + // we have childs, return first one itLast=this; return bo; } else { - itLast=NULL; + // No childs, so there is no next + itLast=this; return NULL; } } - if (itLast==parObj) - { // We come from above + // We have an itLast + if (itLast==po) + { // We come from parent if (bo) { // there are childs, go there @@ -433,7 +442,7 @@ { // no childs, try to go up again if (po) { - // go up + // go back to parent and try to find next there itLast=this; lmo=po->next(); itLast=this; @@ -442,22 +451,35 @@ } else { - // can't go up, I am mapCenter + // can't go up, I am mapCenter, no next itLast=NULL; return NULL; } } } - // Try to find last child, we came from, in my own childs + // We don't come from parent, but from brother or childs + + // Try to find last child, where we came from, in my own childs bool searching=true; - while (bo && searching) + int i=0; + while (inext(); @@ -484,12 +507,11 @@ } // couldn't find last child, it must be a nephew of mine - bo=branch.first(); - if (bo) + if (branch.size()>0) { // proceed with my first child itLast=this; - return bo; + return branch.first(); } else { @@ -521,14 +543,22 @@ itLast=it; } +void BranchObj::positionContents() +{ + for (int i=0; ireposition(); + OrnamentedObj::positionContents(); +} void BranchObj::move (double x, double y) { OrnamentedObj::move (x,y); + for (int i=0; ireposition(); positionBBox(); } -void BranchObj::move (QPoint p) +void BranchObj::move (QPointF p) { move (p.x(), p.y()); } @@ -536,13 +566,12 @@ void BranchObj::moveBy (double x, double y) { OrnamentedObj::moveBy (x,y); + for (int i=0; imoveBy (x,y); positionBBox(); - BranchObj* b; - for (b=branch.first(); b;b=branch.next() ) - b->moveBy (x,y); } - -void BranchObj::moveBy (QPoint p) + +void BranchObj::moveBy (QPointF p) { moveBy (p.x(), p.y()); } @@ -550,38 +579,31 @@ 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(); + QPointF ap=getAbsPos(); + bbox.moveTopLeft (ap); + positionContents(); // set the frame - frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); + frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); + + // Update links to other branches + for (int i=0; iupdateXLink(); } 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; + QSizeF heading_r=heading->getSize(); + qreal heading_w=(qreal) heading_r.width() ; + qreal heading_h=(qreal) heading_r.height() ; + QSizeF sysflags_r=systemFlags->getSize(); + qreal sysflags_h=sysflags_r.height(); + qreal sysflags_w=sysflags_r.width(); + QSizeF stanflags_r=standardFlags->getSize(); + qreal stanflags_h=stanflags_r.height(); + qreal stanflags_w=stanflags_r.width(); + qreal w; + qreal h; // set width to sum of all widths w=heading_w + sysflags_w + stanflags_w; @@ -589,106 +611,186 @@ h=max (sysflags_h,stanflags_h); h=max (h,heading_h); - w+=frame->getBorder(); - h+=frame->getBorder(); - bbox.setSize (QSize (w,h)); + // Save the dimension of flags and heading + ornamentsBBox.setSize ( QSizeF(w,h)); + + // clickBox includes Flags and Heading + clickBox.setSize (ornamentsBBox.size() ); + + // Floatimages + QPointF rp; + + topPad=botPad=leftPad=rightPad=0; + if (includeImagesVer || includeImagesHor) + { + if (countFloatImages()>0) + { + for (int i=0; igetRelPos(); + if (includeImagesVer) + { + if (rp.y() < 0) + topPad=max (topPad,-rp.y()-h); + if (rp.y()+floatimage.at(i)->height() > 0) + botPad=max (botPad,rp.y()+floatimage.at(i)->height()); + } + if (includeImagesHor) + { + if (orientation==LinkableMapObj::RightOfCenter) + { + if (-rp.x()-w > 0) + leftPad=max (leftPad,-rp.x()-w); + if (rp.x()+floatimage.at(i)->width() > 0) + rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()); + } else + { + if (rp.x()< 0) + leftPad=max (leftPad,-rp.x()); + if (rp.x()+floatimage.at(i)->width() > w) + rightPad=max (rightPad,rp.x()+floatimage.at(i)->width()-w); + } + } + } + } + h+=topPad+botPad; + w+=leftPad+rightPad; + } + + // Frame thickness + w+=frame->getPadding(); + h+=frame->getPadding(); + + // Finally set size + bbox.setSize (QSizeF (w,h)); } -LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO) +void BranchObj::setDockPos() +{ + // Sets childpos and parpos depending on orientation + if (getOrientation()==LinkableMapObj::LeftOfCenter ) + { + childPos=QPointF ( + ornamentsBBox.bottomLeft().x(), + bottomlineY); + parPos=QPointF ( + ornamentsBBox.bottomRight().x(), + bottomlineY); + } else + { + childPos=QPointF ( + ornamentsBBox.bottomRight().x(), + bottomlineY); + parPos=QPointF ( + ornamentsBBox.bottomLeft().x(), + bottomlineY); + } +} + +LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO) { // Search branches - BranchObj *b; LinkableMapObj *lmo; - for (b=branch.first(); b; b=branch.next() ) + for (int i=0; ifindMapObj(p, excludeLMO); + lmo=branch.at(i)->findMapObj(p, excludeLMO); + if (lmo != NULL) return lmo; + } + + + // Search myself + if (inBox (p,clickBox) && (this != excludeLMO) && isVisibleObj() ) + return this; + + // Search float images + for (int i=0; igetClickBox()) && + (floatimage.at(i) != excludeLMO) && + floatimage.at(i)->getParObj()!= excludeLMO && + floatimage.at(i)->isVisibleObj() + ) return floatimage.at(i); + + return NULL; +} + +LinkableMapObj* BranchObj::findID (QString sid) +{ + // Search branches + LinkableMapObj *lmo; + for (int i=0; ifindID (sid); if (lmo != NULL) return lmo; } // Search myself - if (inBBox (p) && (this != excludeLMO) && isVisibleObj() ) - return this; + if (sid==objID) 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; - + for (int i=0; iinBox(p) && + (floatimage.at(i) != excludeLMO) && + floatimage.at(i)->getParObj()!= excludeLMO && + floatimage.at(i)->isVisibleObj() + ) return floatimage.at(i); +*/ 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) +void BranchObj::setHideTmp (HideTmpMode mode) { - url=s; - if (!url.isEmpty()) - systemFlags->activate("url"); - else - systemFlags->deactivate("url"); - calcBBoxSize(); // recalculate bbox - positionBBox(); // rearrange contents - forceReposition(); + if (mode==HideExport && (hideExport|| hasHiddenExportParent() ) ) + { + // Hide stuff according to hideExport flag and parents + setVisibility (false); + hidden=true; + }else + { + // Do not hide, but still take care of scrolled status + if (hasScrolledParent(this)) + setVisibility (false); + else + setVisibility (true); + hidden=false; + } + + // And take care of my childs + for (int i=0; isetHideTmp (mode); } -QString BranchObj::getURL() +bool BranchObj::hasHiddenExportParent() { - return url; + // Calls parents recursivly to + // find out, if we or parents are temp. hidden + + if (hidden || hideExport) return true; + + BranchObj* bo=(BranchObj*)parObj; + if (bo) + return bo->hasHiddenExportParent(); + else + return false; } -void BranchObj::setVymLink(QString s) +QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { - 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(); -} + // Cloudy stuff can be hidden during exports + if (hidden) return ""; -QString BranchObj::getVymLink() -{ - return vymLink; -} - -QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset) -{ + // Update of note is usually done while unselecting a branch + if (isNoteInEditor) getNoteFromTextEditor(); + QString s,a; QString scrolledAttr; if (scrolled) @@ -696,90 +798,192 @@ 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)); + attribut("x1",QString().setNum(absPos.x()-offset.x())) + + attribut("y1",QString().setNum(absPos.y()-offset.y())) + + attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) + + attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); } else areaAttr=""; - s=beginElement ("branch" +scrolledAttr +posAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr); + // Providing an ID for a branch makes export to XHTML easier + QString idAttr; + if (countXLinks()>0) + idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model + else + idAttr=""; + + s=beginElement ("branch" + +getOrnXMLAttr() + +scrolledAttr + +areaAttr + +idAttr + +getIncludeImageAttr() ); incIndent(); // save heading - s=s+valueElement("heading", getHeading(), + s+=valueElement("heading", getHeading(), attribut ("textColor",QColor(heading->getColor()).name())); + // Save frame + if (frame->getFrameType()!=FrameObj::NoFrame) + s+=frame->saveToDir (); + // save names of flags set s+=standardFlags->saveToDir(tmpdir,prefix,0); + // Save FloatImages + for (int i=0; isaveToDir (tmpdir,prefix); + // 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); + for (int i=0; isaveToDir(tmpdir,prefix,offset); + + // Save XLinks + QString ol; // old link + QString cl; // current link + for (int i=0; isaveToDir(); + if (cl!=ol) + { + s+=cl; + ol=cl; + } else + { + qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading())); + } + } + 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 () +void BranchObj::addXLink (XLinkObj *xlo) { - FloatImageObj *newfi=new FloatImageObj (canvas,this); + xlink.append (xlo); + +} + +void BranchObj::removeXLinkRef (XLinkObj *xlo) +{ + xlink.removeAt (xlink.indexOf(xlo)); +} + +void BranchObj::deleteXLink(XLinkObj *xlo) +{ + xlo->deactivate(); + if (!xlo->isUsed()) delete (xlo); +} + +void BranchObj::deleteXLinkAt (int i) +{ + XLinkObj *xlo=xlink.at(i); + xlo->deactivate(); + if (!xlo->isUsed()) delete(xlo); +} + +XLinkObj* BranchObj::XLinkAt (int i) +{ + return xlink.at(i); +} + +int BranchObj::countXLink() +{ + return xlink.count(); +} + + +BranchObj* BranchObj::XLinkTargetAt (int i) +{ + if (i>=0 && iotherBranch (this); + } + return NULL; +} + +void BranchObj::setIncludeImagesVer(bool b) +{ + includeImagesVer=b; + calcBBoxSize(); + positionBBox(); + requestReposition(); +} + +bool BranchObj::getIncludeImagesVer() +{ + return includeImagesVer; +} + +void BranchObj::setIncludeImagesHor(bool b) +{ + includeImagesHor=b; + calcBBoxSize(); + positionBBox(); + requestReposition(); +} + +bool BranchObj::getIncludeImagesHor() +{ + return includeImagesHor; +} + +QString BranchObj::getIncludeImageAttr() +{ + QString a; + if (includeImagesVer) + a=attribut ("incImgV","true"); + else + a=attribut ("incImgV","false"); + if (includeImagesHor) + a+=attribut ("incImgH","true"); + else + a+=attribut ("incImgH","false"); + return a; +} + +FloatImageObj* BranchObj::addFloatImage () +{ + FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); if (hasScrolledParent(this) ) newfi->setVisibility (false); else newfi->setVisibility(visible); + /* + calcBBoxSize(); + positionBBox(); + */ requestReposition(); return newfi; } -LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio) +FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio) { - FloatImageObj *newfi=new FloatImageObj (canvas,this); + FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); newfi->copy (fio); if (hasScrolledParent(this) ) newfi->setVisibility (false); else newfi->setVisibility(visible); + /* + calcBBoxSize(); + positionBBox(); + */ requestReposition(); return newfi; } @@ -801,62 +1005,92 @@ void BranchObj::removeFloatImage (FloatImageObj *fio) { - floatimage.remove (fio); + int i=floatimage.indexOf (fio); + if (i>-1) delete (floatimage.takeAt (i)); + calcBBoxSize(); + positionBBox(); requestReposition(); } void BranchObj::savePosInAngle () { // Save position in angle - BranchObj *b; - int i=0; - for (b=branch.first(); b; b=branch.next() ) + for (int i=0; iangle=i; +} + +void BranchObj::setDefAttr (BranchModification mod) +{ + int fontsize; + switch (depth) { - b->angle=i; - i++; - } + case 0: fontsize=16; break; + case 1: fontsize=12; break; + default: fontsize=10; break; + } + + setLinkColor (); + setLinkStyle(getDefLinkStyle()); + QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0"); + font.setPointSize(fontsize); + heading->setFont(font ); + + if (mod==NewBranch) + setColor (((BranchObj*)(parObj))->getColor()); + + calcBBoxSize(); } BranchObj* BranchObj::addBranch() { - BranchObj* newbo=new BranchObj(canvas,this); + BranchObj* newbo=new BranchObj(scene,this); branch.append (newbo); newbo->setParObj(this); - newbo->setColor(getColor(),false); - newbo->setLinkColor(); + newbo->setDefAttr(NewBranch); newbo->setHeading ("new"); - newbo->setLinkStyle (newbo->getDefLinkStyle()); if (scrolled) newbo->setVisibility (false); else newbo->setVisibility(visible); + newbo->updateLink(); requestReposition(); return newbo; } BranchObj* BranchObj::addBranch(BranchObj* bo) { - BranchObj* newbo=new BranchObj(canvas,this); + BranchObj* newbo=new BranchObj(scene,this); branch.append (newbo); newbo->copy(bo); newbo->setParObj(this); - newbo->setHeading (newbo->getHeading()); // adjust fontsize to depth - newbo->setLinkStyle (newbo->getDefLinkStyle()); + newbo->setDefAttr(MovedBranch); if (scrolled) newbo->setVisibility (false); else newbo->setVisibility(bo->visible); + newbo->updateLink(); requestReposition(); return newbo; } +BranchObj* BranchObj::addBranchPtr(BranchObj* bo) +{ + branch.append (bo); + bo->setParObj (this); + bo->depth=depth+1; + bo->setDefAttr(MovedBranch); + if (scrolled) tmpUnscroll(); + setLastSelectedBranch (bo); + return bo; +} + BranchObj* BranchObj::insertBranch(int pos) { savePosInAngle(); // Add new bo and resort branches BranchObj *newbo=addBranch (); newbo->angle=pos-0.5; - branch.sort(); + qSort (branch.begin(),branch.end(), isAbove); return newbo; } @@ -866,133 +1100,288 @@ // Add new bo and resort branches bo->angle=pos-0.5; BranchObj *newbo=addBranch (bo); - branch.sort(); + qSort (branch.begin(),branch.end(), isAbove); return newbo; } +BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos) +{ + savePosInAngle(); + // Add new bo and resort branches + bo->angle=pos-0.5; + branch.append (bo); + bo->setParObj (this); + bo->depth=depth+1; + bo->setDefAttr (MovedBranch); + if (scrolled) tmpUnscroll(); + setLastSelectedBranch (bo); + qSort (branch.begin(),branch.end(), isAbove); + return bo; +} + +void BranchObj::removeBranchHere(BranchObj* borem) +{ + // This removes the branch bo from list, but + // inserts its childs at the place of bo + BranchObj *bo; + bo=borem->getLastBranch(); + int pos=borem->getNum(); + while (bo) + { + bo->linkTo (this,pos+1); + bo=borem->getLastBranch(); + } + removeBranch (borem); +} + +void BranchObj::removeChilds() +{ + clear(); +} + void BranchObj::removeBranch(BranchObj* bo) { // if bo is not in branch remove returns false, we // don't care... - branch.remove (bo); + + int i=branch.indexOf(bo); + if (i>=0) + { + delete (bo); + branch.removeAt (i); + } else + qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n"); + requestReposition(); +} + +void BranchObj::removeBranchPtr(BranchObj* bo) +{ + int i=branch.indexOf(bo); + + if (i>=0) + branch.removeAt (i); + else + qWarning ("BranchObj::removeBranchPtr tried to remove non existing branch?!\n"); requestReposition(); } void BranchObj::setLastSelectedBranch (BranchObj* bo) { - lastSelectedBranch=branch.find(bo); + lastSelectedBranch=branch.indexOf(bo); } BranchObj* BranchObj::getLastSelectedBranch () { - if (lastSelectedBranch>=0) + if (lastSelectedBranch>=0) { - BranchObj* bo=branch.at(lastSelectedBranch); - if (bo) return bo; - } - return branch.first(); + if ( branch.size()>lastSelectedBranch) + return branch.at(lastSelectedBranch); + if (branch.size()>0) + return branch.last(); + } + return NULL; } BranchObj* BranchObj::getFirstBranch () { - return branch.first(); + if (branch.size()>0) + return branch.first(); + else + return NULL; } BranchObj* BranchObj::getLastBranch () { - return branch.last(); + if (branch.size()>0) + return branch.last(); + else + return NULL; } -BranchObj* BranchObj::getBranchNum (const uint &i) +BranchObj* BranchObj::getBranchNum (int i) { - return branch.at(i); + if (i>=0 && igetFirstBranch()) + return false; + else + return true; +} -BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself) +BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // modify my childlist { savePosInAngle(); - int i=branch.find(bo1); + int i=branch.indexOf(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); + qSort (branch.begin(),branch.end(), isAbove); + return branch.at(i); } else - return branch.at(i); + return NULL; } -BranchObj* BranchObj::moveBranchDown(BranchObj* bo1) +bool BranchObj::canMoveBranchDown() +{ + if (!parObj|| depth==1) return false; + BranchObj* par=(BranchObj*)parObj; + if (this==par->getLastBranch()) + return false; + else + return true; +} + +BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// modify my childlist { savePosInAngle(); - int i=branch.find(bo1); + int i=branch.indexOf(bo1); int j; - if (branch.next()) + if (i angle++; branch.at(j)->angle--; - branch.sort(); - return branch.at(j); + qSort (branch.begin(),branch.end(), isAbove); + return branch.at(i); } else - return branch.at(i); + return NULL; } -void BranchObj::alignRelativeTo (QPoint ref) +void BranchObj::sortChildren() { -/* FIXME testing - if (!getHeading().isEmpty()) - cout << "BO::alignRelTo "<