diff -r 7a71a914afdb -r 6d2b32f305f9 branchobj.cpp --- a/branchobj.cpp Thu May 07 08:48:53 2009 +0000 +++ b/branchobj.cpp Wed May 13 08:26:27 2009 +0000 @@ -6,12 +6,8 @@ #include "mainwindow.h" #include "misc.h" -//class TextEditor; //FIXME-3 - -//extern TextEditor *textEditor; -//extern Main *mainWindow; -//extern FlagRowObj *standardFlagsDefault; - +extern FlagRow *standardFlagsMaster; +extern FlagRow *systemFlagsMaster; ///////////////////////////////////////////////////////////////// // BranchObj @@ -325,12 +321,12 @@ QSizeF heading_r=heading->getSize(); qreal heading_w=(qreal) heading_r.width() ; qreal heading_h=(qreal) heading_r.height() ; - QSizeF sysflags_r; //FIXME-1 =systemFlags->getSize(); - qreal sysflags_h=0;//sysflags_r.height(); - qreal sysflags_w=0;//sysflags_r.width(); - QSizeF stanflags_r; //FIXME-1 =standardFlags->getSize(); - qreal stanflags_h=0; //stanflags_r.height(); - qreal stanflags_w=0; //stanflags_r.width(); + 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; @@ -416,105 +412,67 @@ } } -void BranchObj::updateHeading() +void BranchObj::updateData() { + bool changed=false; if (!treeItem) { qWarning ("BranchObj::udpateHeading treeItem==NULL"); return; } - heading->setText (treeItem->getHeading() ); - updateContentSize(); + QString s=treeItem->getHeading(); + if (s!=heading->text()) + { + heading->setText (s); + changed=true; + } + QStringList TIactiveFlags=treeItem->activeStandardFlagNames(); + + // Add missing standard flags active in TreeItem + for (int i=0;i<=TIactiveFlags.size()-1;i++) + { + if (!standardFlags->isActive (TIactiveFlags.at(i) )) + { + Flag *f=standardFlagsMaster->getFlag(TIactiveFlags.at(i)); + if (f) standardFlags->activate (f); + changed=true; + } + } + // Remove standard flags no longer active in TreeItem + QStringList BOactiveFlags=standardFlags->activeFlagNames(); + for (int i=0;ideactivate (BOactiveFlags.at(i)); + changed=true; + } + + // Add missing system flags active in TreeItem + TIactiveFlags=treeItem->activeSystemFlagNames(); + for (int i=0;iisActive (TIactiveFlags.at(i) )) + { + Flag *f=systemFlagsMaster->getFlag(TIactiveFlags.at(i)); + if (f) systemFlags->activate (f); + changed=true; + } + } + // Remove system flags no longer active in TreeItem + BOactiveFlags=systemFlags->activeFlagNames(); + for (int i=0;ideactivate (BOactiveFlags.at(i)); + changed=true; + } + } + + if (changed) + updateContentSize(); } -QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) -{ - // Cloudy stuff can be hidden during exports - // FIXME-1 if (hidden) return ""; - - // Update of note is usually done while unselecting a branch - // if (isNoteInEditor) getNoteFromTextEditor(); //FIXME-2 moved to TreeItem - - QString s,a; - /* - QString scrolledAttr; - if ( ((BranchItem*)treeItem)->isScrolled() ) - scrolledAttr=attribut ("scrolled","yes"); - else - scrolledAttr=""; - - // save area, if not scrolled - QString areaAttr; - if (!((BranchItem*) (treeItem->parent()) )->isScrolled() ) - { - areaAttr= - 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=""; - - // Providing an ID for a branch makes export to XHTML easier - QString idAttr; - if (treeItem->xlinkCount()>0) - idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model - else - idAttr=""; - - s=beginElement ("branch" - +getOrnXMLAttr() - +scrolledAttr - +areaAttr - +idAttr - +getIncludeImageAttr() ); - incIndent(); - - // save heading - s+=valueElement("heading", treeItem->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 (!treeItem->getNoteObj().isEmpty() ) - s+=treeItem->getNoteObj().saveToDir(); - - // Save branches - for (int i=0; ibranchCount(); ++i) - s+=treeItem->getBranchObjNum(i)->saveToDir(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(treeItem->getHeading())); - } - } - - decIndent(); - s+=endElement ("branch"); - return s; -*/ -} void BranchObj::addXLink (XLinkObj *xlo) { @@ -732,66 +690,6 @@ */ } -bool BranchObj::canMoveBranchUp() // FIXME-1 move to BranchItem -{ -/* - if (!parObj || depth==1) return false; - BranchObj* par=(BranchObj*)parObj; - if (this==par->getTreeItem()->getFirstBranch()) - return false; - else - return true; - */ -return false; -} - -BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // FIXME-1 -{ -/* - savePosInAngle(); - int i=branch.indexOf(bo1); - if (i>0) - { // -1 if bo1 not found - treeItem->getBranchObjNum(i)->angle--; - treeItem->getBranchObjNum(i-1)->angle++; - qSort (branch.begin(),branch.end(), isAbove); - return treeItem->getBranchObjNum(i); - } else -*/ - return NULL; -} - -bool BranchObj::canMoveBranchDown() //FIXME-1 move to BranchItem -{ - /* - if (!parObj|| depth==1) return false; - BranchObj* par=(BranchObj*)parObj; - if (this==par->getTreeItem()->getLastBranch()) - return false; - else - return true; - */ -return false; -} - -BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// FIXME-1 -{ -/* - savePosInAngle(); - int i=branch.indexOf(bo1); - int j; - if (i branchCount()) - { - j = i+1; - treeItem->getBranchObjNum(i)->angle++; - treeItem->getBranchObjNum(j)->angle--; - qSort (branch.begin(),branch.end(), isAbove); - return treeItem->getBranchObjNum(i); - } else -*/ - return NULL; -} - void BranchObj::sortChildren() //FIXME-2 { /* @@ -1070,65 +968,6 @@ bboxTotal.setHeight(max (r.height(), bbox.height())); } -/* -void BranchObj::select() // FIXME-4 try to get rid of this in BO completely -{ - cout << "BO::select()\n"; - textEditor->setText(treeItem->getNoteObj().getNote() ); - QString fnh=treeItem->getNoteObj().getFilenameHint(); - if (fnh!="") - textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() ); - else - textEditor->setFilenameHint(getHeading() ); - textEditor->setFontHint (treeItem->getNoteObj().getFontHint() ); - //isNoteInEditor=true; - - // set selected and visible - LinkableMapObj::select(); - - //if (po) po->setLastSelectedBranch(this); needed? - - // temporary unscroll, if we have scrolled parents somewhere - if (parObj) ((BranchObj*)(parObj))->tmpUnscroll(); - - //moved to vymmodel or vymview... - // 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 - updateFlagsToolbar(); - - // Update actions - model->updateActions(); -} - */ - -/* -void BranchObj::unselect() //FIXME-4 should not be needed -{ - cout << "BO::unselect()\n"; - LinkableMapObj::unselect(); - // Delete any messages like vymLink in StatusBar - mainWindow->statusMessage (""); //this causes segfault, when MainWindow is already gone in global destructor on quitting vym - - // Save current note - if (isNoteInEditor) getNoteFromTextEditor(); - isNoteInEditor=false; - - // reset temporary unscroll, if we have scrolled parents somewhere - if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll(); - - // Erase content of editor - textEditor->setInactive(); - - // unselect all buttons in toolbar - standardFlagsDefault->updateToolbar(); -} -*/ - QString BranchObj::getSelectString() { return model->getSelectString (this);