# HG changeset patch # User insilmaril # Date 1240834035 0 # Node ID a8a5c7288f5710918b7f5a1a4f8be3cd84507ee0 # Parent ed5b407975b3dc4046e86ff9b2219f54c3be59ad relinking branches and removing branches works diff -r ed5b407975b3 -r a8a5c7288f57 branchitem.cpp --- a/branchitem.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/branchitem.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -17,8 +17,12 @@ BranchItem::~BranchItem() { - cout << "Destr. BranchItem\n"; - qDeleteAll(childItems); +// cout << "Destr. BranchItem "<tmpUnscrolled; } +void BranchItem::insertBranch (int pos, BranchItem *branch) +{ + if (pos<0) pos=0; + if (pos>branchCounter) pos=branchCounter; + childItems.insert(pos+branchOffset,branch); + branch->parentItem=this; + branch->setModel (model); + + if (branchCounter==0) + branchOffset=childItems.count()-1; + branchCounter++; +} + QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { // Cloudy stuff can be hidden during exports @@ -310,12 +327,11 @@ BranchObj* BranchItem::createMapObj(QGraphicsScene *scene) { // Initialize BranchObj, order of things is important... - cout << "BI::createMO scene="<setParObj(parent()->getLMO() ); newbo->setTreeItem (this); newbo->setDefAttr(BranchObj::NewBranch); - //newbo->updateLink(); + //newbo->updateLink(); //FIXME-3 lmo=newbo; return newbo; diff -r ed5b407975b3 -r a8a5c7288f57 branchitem.h --- a/branchitem.h Thu Apr 23 12:15:31 2009 +0000 +++ b/branchitem.h Mon Apr 27 12:07:15 2009 +0000 @@ -12,11 +12,14 @@ { public: BranchItem(const QList &data, TreeItem *parent = 0); - ~BranchItem(); + virtual ~BranchItem(); void copy (BranchItem *item); + void insertBranch (int pos,BranchItem *branch); + QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset); + virtual void updateVisibility(); protected: diff -r ed5b407975b3 -r a8a5c7288f57 branchobj.cpp --- a/branchobj.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/branchobj.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -430,7 +430,6 @@ qWarning ("BranchObj::udpateHeading treeItem==NULL"); return; } - cout << "BO::updateHeading: "<getHeading().toStdString()<setText (treeItem->getHeading() ); updateContentSize(); } diff -r ed5b407975b3 -r a8a5c7288f57 mainwindow.cpp --- a/mainwindow.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/mainwindow.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -2252,7 +2252,7 @@ if (m) m->exportASCII(); } -void Main::fileExportCSV() //FIXME-2 not scriptable yet +void Main::fileExportCSV() //FIXME-3 not scriptable yet { VymModel *m=currentModel(); if (m) @@ -2271,7 +2271,7 @@ } } -void Main::fileExportLaTeX() //FIXME-2 not scriptable yet +void Main::fileExportLaTeX() //FIXME-3 not scriptable yet { VymModel *m=currentModel(); if (m) @@ -2290,7 +2290,7 @@ } } -void Main::fileExportKDE3Bookmarks() //FIXME-2 not scriptable yet +void Main::fileExportKDE3Bookmarks() //FIXME-3 not scriptable yet { ExportKDE3Bookmarks ex; VymModel *m=currentModel(); @@ -2301,7 +2301,7 @@ } } -void Main::fileExportKDE4Bookmarks() //FIXME-2 not scriptable yet +void Main::fileExportKDE4Bookmarks() //FIXME-3 not scriptable yet { ExportKDE4Bookmarks ex; VymModel *m=currentModel(); @@ -2312,7 +2312,7 @@ } } -void Main::fileExportTaskjuggler() //FIXME-2 not scriptable yet +void Main::fileExportTaskjuggler() //FIXME-3 not scriptable yet { ExportTaskjuggler ex; VymModel *m=currentModel(); @@ -2331,7 +2331,7 @@ } } -void Main::fileExportOOPresentation() //FIXME-2 not scriptable yet +void Main::fileExportOOPresentation() //FIXME-3 not scriptable yet { ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office"); // TODO add preview in dialog diff -r ed5b407975b3 -r a8a5c7288f57 mapcenteritem.h --- a/mapcenteritem.h Thu Apr 23 12:15:31 2009 +0000 +++ b/mapcenteritem.h Mon Apr 27 12:07:15 2009 +0000 @@ -8,7 +8,7 @@ { public: MapCenterItem(const QList &data, TreeItem *parent = 0); - ~MapCenterItem(); + virtual ~MapCenterItem(); QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset); }; diff -r ed5b407975b3 -r a8a5c7288f57 mapeditor.cpp --- a/mapeditor.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/mapeditor.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -918,17 +918,19 @@ if (e->state() & Qt::ShiftModifier && dst->getParObj()) { // Link above dst preDstParStr=model->getSelectString (dst->getParObj()); - bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()); //FIXME-2 not needed + model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)dsti)->num()); } else if (e->state() & Qt::ControlModifier && dst->getParObj()) { // Link below dst preDstParStr=model->getSelectString (dst->getParObj()); - bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1); + bsel->linkTo ( (BranchObj*)(bdst->getParObj()), seli->num()+1);//FIXME-2 not needed + model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti->parent(),((BranchItem*)seli)->num()+1); } else { // Append to dst preDstParStr=model->getSelectString(dst); - bsel->linkTo (bdst,-1); + bsel->linkTo (bdst,-1);//FIXME-2 not needed model->relinkBranch ((BranchItem*)seli,(BranchItem*)dsti); if (dsti->depth()==0) bsel->move (savePos); } @@ -955,7 +957,6 @@ if (seli->depth()==1) { - cout << "ME::releaseMouse d=1\n"; // FIXME_1 better use depth // The select string might be different _after_ moving around. // Therefor reposition and then use string of old selection, too model->reposition(); diff -r ed5b407975b3 -r a8a5c7288f57 treeitem.cpp --- a/treeitem.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/treeitem.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -11,11 +11,41 @@ TreeItem::TreeItem(const QList &data, TreeItem *parent) { + init(); + parentItem = parent; + itemData = data; +} + +TreeItem::~TreeItem() +{ + //cout << "Destructor TreeItem "<getType() ) + { + case TreeItem::MapCenter: + delete (MapCenterItem*)ti; + break; + case TreeItem::Branch: + delete (BranchItem*)ti; + break; + default: + delete ti; + break; + } + } +} + + +void TreeItem::init() +{ model=NULL; - parentItem = parent; - itemData = data; - lmo=NULL; + parentItem = NULL; + itemData.clear(); + lmo=NULL; branchOffset=0; branchCounter=0; @@ -33,13 +63,6 @@ } -TreeItem::~TreeItem() -{ - cout << "Destructor TreeItem\n"; - //if (lmo) delete (lmo); - qDeleteAll(childItems); -} - QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { cout << "TreeItem::saveToDir called directly for ("<parentItem=this; item->setModel (model); if (item->type == Branch || item->type ==MapCenter) diff -r ed5b407975b3 -r a8a5c7288f57 treeitem.h --- a/treeitem.h Thu Apr 23 12:15:31 2009 +0000 +++ b/treeitem.h Mon Apr 27 12:07:15 2009 +0000 @@ -22,6 +22,8 @@ TreeItem(const QList &data, TreeItem *parent = 0); ~TreeItem(); + void init(); + QString saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset); diff -r ed5b407975b3 -r a8a5c7288f57 treemodel.cpp --- a/treemodel.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/treemodel.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -80,11 +80,8 @@ return QModelIndex(); if (!parentItem) - { - cout <<"TreeModel::parent ti=="<getHeading().toStdString()<childNumber(), 0, parentItem); } @@ -195,7 +192,18 @@ cout << "TreeModel::removeRows removing i="<getChildNum (row); pi->removeChild (row); // does not delete object! - delete (ti); + switch (ti->getType()) + { + case TreeItem::MapCenter: + delete (BranchItem*)ti; + break; + case TreeItem::Branch: + delete (BranchItem*)ti; + break; + default: + delete ti; + break; + } } endRemoveRows (); return true; diff -r ed5b407975b3 -r a8a5c7288f57 version.h --- a/version.h Thu Apr 23 12:15:31 2009 +0000 +++ b/version.h Mon Apr 27 12:07:15 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version, not for production!" -#define __VYM_BUILD_DATE "2009-04-23" +#define __VYM_BUILD_DATE "2009-04-27" bool checkVersion(const QString &); diff -r ed5b407975b3 -r a8a5c7288f57 vymmodel.cpp --- a/vymmodel.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/vymmodel.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -176,7 +176,7 @@ void VymModel::updateActions() // FIXME-2 maybe don't update if blockReposition is set { - cout << "VymModel::updateActions \n"; + //cout << "VM::updateActions \n"; // Tell mainwindow to update states of actions mainWindow->updateActions(); } @@ -984,7 +984,6 @@ void VymModel::setChanged() { - cout << "VM::setChanged()\n"; if (!mapChanged) { autosaveTimer->start(settings.value("/mainwindow/autosave/ms/",300000).toInt()); @@ -2071,7 +2070,6 @@ QList cData; cData << "VM:addMapCenter" << "undef"<<"undef"; MapCenterItem *mci=new MapCenterItem (cData,rootItem); - cout << "VM::addMapCenter mci="<setType (TreeItem::MapCenter); mci->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); rootItem->appendChild (mci); @@ -2142,15 +2140,15 @@ BranchItem *parbi=bi; QModelIndex parix=index(parbi); - int n=parbi->branchCount(); + int n=parbi->childCount(); emit (layoutAboutToBeChanged() ); - beginInsertRows (parix,n,n+1); - bi=new BranchItem (cData,parbi); + beginInsertRows (parix,n,n+1); //FIXME-1 check if n is correct: should be index below _last_ branch... + bi=new BranchItem (cData); bi->setType (TreeItem::Branch); bi->setHeading (QApplication::translate("Heading of new branch in map", "new")); - parbi->appendChild (bi); + parbi->appendChild (bi); endInsertRows (); emit (newChildObject (parix)); emit (layoutChanged() ); @@ -2158,18 +2156,7 @@ // save scroll state. If scrolled, automatically select // new branch in order to tmp unscroll parent... newbo=bi->createMapObj(mapScene); - /* - newbo=bo->addBranch(); - - if (newbo) - { - bi->setLMO (newbo); - newbo->setTreeItem (bi); - select (bi); - } - */ select (bi); - }else if (num==-1) { /* @@ -2271,14 +2258,29 @@ cout << "VM::relinkBranch "<getHeadingStd()<<" to "<getHeadingStd()<<" at pos="<parent(); - BranchItem *dstpi=(BranchItem*)dst->parent(); - if (pos<0) - { - // Append as last branch to dst - branchpi->removeChild (branch->childNum() ); - dst->appendChild (branch); - } + // Remove at current position + int n=branch->childNum(); + beginRemoveRows (index(branchpi),n,n); + branchpi->removeChild (n); + endRemoveRows(); + + if (pos<0 ||pos>dst->branchCount() ) pos=dst->branchCount(); + + // Append as last branch to dst + if (dst->branchCount()==0) + n=0; + else + n=dst->getFirstBranch()->childNumber(); + cout << "*** dst->bCount="<branchCount()<<" n="<branchCount(); i++) rootItem->getBranchObjNum(i)->reposition(); // for positioning heading } diff -r ed5b407975b3 -r a8a5c7288f57 xml-vym.cpp --- a/xml-vym.cpp Thu Apr 23 12:15:31 2009 +0000 +++ b/xml-vym.cpp Mon Apr 27 12:07:15 2009 +0000 @@ -356,8 +356,8 @@ //lastOO=lastBranch; //lastBranchItem=(BranchItem*)(lastBranch->getTreeItem()); + if (!readOOAttr(a)) return false; /* - if (!readOOAttr(a)) return false; if (!a.value( "scrolled").isEmpty() ) lastBranchItem->toggleScroll(); @@ -410,7 +410,8 @@ bool parseVYMHandler::readOOAttr (const QXmlAttributes& a) { - if (lastOO) + BranchObj *bo=(BranchObj*)lastBranchItem->getLMO(); + if (bo) { bool okx,oky; float x,y; @@ -422,8 +423,8 @@ y=a.value("relPosY").toFloat (&oky); if (okx && oky ) { - lastOO->setUseRelPos (true); - lastOO->move2RelPos (x,y); + bo->setUseRelPos (true); + bo->move2RelPos (x,y); } else return false; // Couldn't read relPos @@ -436,11 +437,12 @@ x=a.value("absPosX").toFloat (&okx); y=a.value("absPosY").toFloat (&oky); if (okx && oky ) - lastOO->move(x,y); + bo->move(x,y); else return false; // Couldn't read absPos } } + /* FIXME-2 if (!a.value( "id").isEmpty() ) lastBranchItem->setID (a.value ("id")); if (!a.value( "url").isEmpty() ) @@ -458,6 +460,7 @@ else lastOO->setHideLinkUnselected(false); } + */ } return true; }