# HG changeset patch # User insilmaril # Date 1242645761 0 # Node ID 01f2f6d6789d8026658bf5dd1551ce3762c55853 # Parent 57ce1ba6d1cba508c3db572760da7733d2332a73 Fixed addBranchBefore diff -r 57ce1ba6d1cb -r 01f2f6d6789d branchitem.cpp --- a/branchitem.cpp Mon May 18 09:41:31 2009 +0000 +++ b/branchitem.cpp Mon May 18 11:22:41 2009 +0000 @@ -45,7 +45,7 @@ branchCounter++; } -QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-1 +QString BranchItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-3 Check if everything is saved... { // Cloudy stuff can be hidden during exports if (hidden) return QString(); @@ -150,7 +150,7 @@ return s; } -void BranchItem::updateVisibility() // FIXME-1 +void BranchItem::updateVisibility() // FIXME-3 Check if this is needed after all... { } diff -r 57ce1ba6d1cb -r 01f2f6d6789d branchobj.cpp --- a/branchobj.cpp Mon May 18 09:41:31 2009 +0000 +++ b/branchobj.cpp Mon May 18 11:22:41 2009 +0000 @@ -892,7 +892,7 @@ */ /* - FIXME-1 for (int i=0; iisHidden()) r=addBBox(floatimage.at(i)->getTotalBBox(),r); */ diff -r 57ce1ba6d1cb -r 01f2f6d6789d mainwindow.cpp --- a/mainwindow.cpp Mon May 18 09:41:31 2009 +0000 +++ b/mainwindow.cpp Mon May 18 11:22:41 2009 +0000 @@ -2826,7 +2826,7 @@ VymModel *m=currentModel(); if (m) { - BranchItem *bi=m->createBranch(); //FIXME-1 missing: m->addNewBranchBefore(); + BranchItem *bi=m->addNewBranchBefore(); if (bi) m->select (bi); diff -r 57ce1ba6d1cb -r 01f2f6d6789d mapcenteritem.cpp --- a/mapcenteritem.cpp Mon May 18 09:41:31 2009 +0000 +++ b/mapcenteritem.cpp Mon May 18 11:22:41 2009 +0000 @@ -16,7 +16,7 @@ qDeleteAll(childItems); } -QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-1 +QString MapCenterItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) //FIXME-3 Check if everything is saved... { // Cloudy stuff can be hidden during exports if (hidden) return QString(); diff -r 57ce1ba6d1cb -r 01f2f6d6789d treeitem.cpp --- a/treeitem.cpp Mon May 18 09:41:31 2009 +0000 +++ b/treeitem.cpp Mon May 18 11:22:41 2009 +0000 @@ -68,7 +68,7 @@ QString TreeItem::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { - cout << "TreeItem::saveToDir called directly for ("<saveToDir(tmpdir,prefix); } - cout << "VM::saveToDir 1 \n"; // Save local settings s+=settings.getDataXML (destPath); - cout << "VM::saveToDir 2 \n"; // Save selection if (getSelectedItem() && !saveSel ) s+=xml.valueElement("select",getSelectString()); @@ -1619,23 +1617,19 @@ return QString(); } -QStringList VymModel::getURLs() // FIXME-1 first, next moved to vymmodel -{ - return QStringList(); - /* +QStringList VymModel::getURLs() +{ QStringList urls; - BranchObj *bo=getSelectedBranch(); - if (bo) - { - bo=bo->first(); - while (bo) - { - if (!bo->getURL().isEmpty()) urls.append( bo->getURL()); - bo=bo->next(); - } + BranchItem *cur=getSelectedBranchItem(); + BranchItem *prev=NULL; + int d=0; + next (cur,prev,d); + while (cur) + { + if (!cur->getURL().isEmpty()) urls.append( cur->getURL()); + cur=next (cur,prev,d); } return urls; - */ } void VymModel::linkFloatImageTo(const QString &dstString) // FIXME-2 @@ -1976,7 +1970,11 @@ BranchItem* VymModel::createBranch() { - return addNewBranchInt (-2); + BranchItem *selbi=getSelectedBranchItem(); + if (selbi) + return addNewBranchInt (selbi,-2); + else + return NULL; } TreeItem* VymModel::createImage() //FIXME-2 @@ -2069,64 +2067,60 @@ return mci; } -BranchItem* VymModel::addNewBranchInt(int num) +BranchItem* VymModel::addNewBranchInt(BranchItem *dst,int num) //FIXME-4 simplify... { // Depending on pos: // -3 insert in children of parent above selection // -2 add branch to selection // -1 insert in children of parent below selection // 0..n insert in children of parent at pos - BranchItem *selbi=getSelectedBranchItem(); - if (selbi) + + // Create TreeItem + QList cData; + cData << "new" << "undef"<<"undef"; + + BranchItem *parbi; + QModelIndex parix; + int n; + BranchItem *newbi=new BranchItem (cData); + newbi->setHeading (QApplication::translate("Heading of new branch in map", "new")); + + emit (layoutAboutToBeChanged() ); + + if (num==-2) { - // Create TreeItem - QList cData; - cData << "new" << "undef"<<"undef"; - - BranchItem *parbi; - QModelIndex parix; - int n; - BranchItem *newbi=new BranchItem (cData); - newbi->setHeading (QApplication::translate("Heading of new branch in map", "new")); - - emit (layoutAboutToBeChanged() ); - - if (num==-2) - { - parbi=selbi; - parix=index(parbi); - n=parbi->childCount(); - beginInsertRows (parix,n,n+1); - parbi->appendChild (newbi); - endInsertRows (); - }else if (num==-1) - { - // insert below selection - parbi=(BranchItem*)selbi->parent(); - parix=index(parbi); - n=selbi->childNumber()+1; - beginInsertRows (parix,n,n); - parbi->insertBranch(n,newbi); - endInsertRows (); - }else if (num==-3) - { - // insert above selection - parbi=(BranchItem*)selbi->parent(); - parix=index(parbi); - n=selbi->childNumber(); - beginInsertRows (parix,n,n); - parbi->insertBranch(n,newbi); - endInsertRows (); - } - emit (layoutChanged() ); - - // save scroll state. If scrolled, automatically select - // new branch in order to tmp unscroll parent... - newbi->createMapObj(mapScene); - select (newbi); - return newbi; - } - return NULL; + parbi=dst; + parix=index(parbi); + n=parbi->childCount(); + beginInsertRows (parix,n,n+1); + parbi->appendChild (newbi); + endInsertRows (); + }else if (num==-1) + { + // insert below selection + parbi=(BranchItem*)dst->parent(); + parix=index(parbi); + n=dst->childNumber()+1; + beginInsertRows (parix,n,n); + parbi->insertBranch(n,newbi); + endInsertRows (); + }else if (num==-3) + { + // insert above selection + parbi=(BranchItem*)dst->parent(); + parix=index(parbi); + n=dst->childNumber(); + beginInsertRows (parix,n,n); + parbi->insertBranch(n,newbi); + endInsertRows (); + } + emit (layoutChanged() ); + + // save scroll state. If scrolled, automatically select + // new branch in order to tmp unscroll parent... + newbi->createMapObj(mapScene); + select (newbi); + return newbi; } BranchItem* VymModel::addNewBranch(int pos) @@ -2140,9 +2134,10 @@ if (selbi) { - // FIXME-3 VM do we still need this in model? setCursor (Qt::ArrowCursor); - - newbi=addNewBranchInt (pos-2); + // FIXME-3 setCursor (Qt::ArrowCursor); //Still needed? + + + newbi=addNewBranchInt (selbi,pos-2); if (newbi) { @@ -2170,40 +2165,35 @@ } -BranchItem* VymModel::addNewBranchBefore() //FIXME-2 -{ -/* - BranchObj *newbo=NULL; - BranchObj *bo = getSelectedBranch(); - if (bo && selectionType()==TreeItem::Branch) - // We accept no MapCenterObj here, so we _have_ a parent +BranchItem* VymModel::addNewBranchBefore() //FIXME-0 +{ + BranchItem *newbi=NULL; + BranchItem *selbi=getSelectedBranchItem(); + if (selbi && selbi->getType()==TreeItem::Branch) + // We accept no MapCenter here, so we _have_ a parent { - QPointF p=bo->getRelPos(); - - - BranchObj *parbo=(BranchObj*)(bo->getParObj()); + //QPointF p=bo->getRelPos(); + // add below selection - newbo=parbo->insertBranch(bo->getTreeItem()->num()+1); //FIXME-1 VM still missing - - if (newbo) + newbi=addNewBranchInt (selbi,-1); + + if (newbi) { - newbo->move2RelPos (p); + //newbi->move2RelPos (p); // Move selection to new branch - bo->linkTo (newbo,-1); - - saveState (newbo, "deleteKeepChildren ()", newbo, "addBranchBefore ()", - QString ("Add branch before %1").arg(getObjectName(bo))); - - reposition(); + relinkBranch (selbi,newbi,0); + + saveState (newbi, "deleteKeepChildren ()", newbi, "addBranchBefore ()", + QString ("Add branch before %1").arg(getObjectName(selbi))); + + // FIXME-3 needed? reposition(); // selection.update(); FIXME-3 } } - latestSelectionString=selection.getSelectString(); - return newbo; - */ - return NULL; + //FIXME-3 needed? latestSelectionString=selection.getSelectString(); + return newbi; } bool VymModel::relinkBranch (BranchItem *branch, BranchItem *dst, int pos) @@ -2681,23 +2671,19 @@ } -QStringList VymModel::getVymLinks() // FIXME-1 first, next moved to vymmodel -{ - return QStringList(); -/* +QStringList VymModel::getVymLinks() +{ QStringList links; - BranchObj *bo=getSelectedBranch(); - if (bo) - { - bo=bo->first(); - while (bo) - { - if (!bo->getVymLink().isEmpty()) links.append( bo->getVymLink()); - bo=bo->next(); - } + BranchItem *cur=getSelectedBranchItem(); + BranchItem *prev=NULL; + int d=0; + next (cur,prev,d); + while (cur) + { + if (!cur->getVymLink().isEmpty()) links.append( cur->getVymLink()); + cur=next (cur,prev,d); } return links; -*/ } @@ -2756,7 +2742,6 @@ void VymModel::parseAtom(const QString &atom) { - //BranchObj *selb=getSelectedBranch(); // FIXME-4 TreeItem* selti=getSelectedItem(); BranchItem *selbi=getSelectedBranchItem(); QString s,t; @@ -2903,12 +2888,14 @@ if (!selti) { parser.setError (Aborted,"Nothing selected"); - } else if (! selbi ) + } else if ( selectionType()!=TreeItem::Branch && + selectionType()!=TreeItem::MapCenter && + selectionType()!=TreeItem::Image ) { - parser.setError (Aborted,"Type of selection is not a branch"); + parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(0)) { - //FIXME-1 missing action for copy + copy(); } ///////////////////////////////////////////////////////////////////// } else if (com=="cut") diff -r 57ce1ba6d1cb -r 01f2f6d6789d vymmodel.h --- a/vymmodel.h Mon May 18 09:41:31 2009 +0000 +++ b/vymmodel.h Mon May 18 11:22:41 2009 +0000 @@ -306,7 +306,7 @@ */ private: - BranchItem* addNewBranchInt(int); // pos allows to add above/below selection + BranchItem* addNewBranchInt(BranchItem *dst, int pos); // pos allows to add above/below selection public: /*! \Add new branch