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 }