diff -r 01f2f6d6789d -r e3f722759c7e vymmodel.cpp --- a/vymmodel.cpp Mon May 18 11:22:41 2009 +0000 +++ b/vymmodel.cpp Wed May 20 15:40:14 2009 +0000 @@ -30,6 +30,7 @@ extern QString tmpVymDir; extern TextEditor *textEditor; +extern FlagRow *standardFlagsMaster; extern QString clipboardDir; extern QString clipboardFile; @@ -60,7 +61,7 @@ VymModel::~VymModel() { -// cout << "Destr VymModel\n"; + cout << "Destr VymModel\n"; autosaveTimer->stop(); fileChangedTimer->stop(); clear(); @@ -71,7 +72,7 @@ selModel->clearSelection(); //QModelIndex ri=index(rootItem); - //removeRows (0, rowCount(ri),ri); // FIXME-2 here should be at least a beginRemoveRows... + //removeRows (0, rowCount(ri),ri); // FIXME-3 here should be at least a beginRemoveRows... } void VymModel::init () @@ -232,7 +233,7 @@ xml.incIndent(); // Find the used flags while traversing the tree // FIXME-2 this can be done local to vymmodel maybe... - //FIXME-2 not used any longer: standardFlagsDefault->resetUsedCounter(); + standardFlagsMaster->resetUsedCounter(); // Reset the counters before saving // TODO constr. of FIO creates lots of objects, better do this in some other way... @@ -262,7 +263,7 @@ xml.decIndent(); s+=xml.endElement("vymmap"); - // FIXME-2 if (writeflags) standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags); + if (writeflags) standardFlagsMaster->saveToDir (tmpdir+"/flags/","",writeflags); return s; } @@ -2008,7 +2009,6 @@ MapCenterItem* VymModel::addMapCenter () { MapCenterItem *mci=addMapCenter (contextPos); - //FIXME-3 selection.select (mco); updateActions(); emitShowSelection(); saveState ( @@ -2044,26 +2044,6 @@ // Create MapObj BranchObj *newbo=mci->createMapObj(mapScene); - /* - - if (!mci->getHeading().isEmpty() ) - { - newbo->updateHeading(); - newbo->setColor (headingColor); - } -*/ - - //newbo->updateLink(); //FIXME-3 - -/* - //mapCenter->setMapEditor(mapEditor); //FIXME-3 VM needed to get defLinkStyle, mapLinkColorHint ... for later added objects - mapCenter->setTreeItem (mci); // TreeItem needs to exist before setVisibility - mci->setLMO (mapCenter); - mapCenter->updateHeading(); - mapCenter->move (absPos); - mapCenter->setVisibility (true); - //mapCenter->setHeading (QApplication::translate("Heading of mapcenter in new map", "New map")); -*/ return mci; } @@ -2095,30 +2075,22 @@ beginInsertRows (parix,n,n+1); parbi->appendChild (newbi); endInsertRows (); - }else if (num==-1) + }else if (num==-1 || num==-3) { // insert below selection parbi=(BranchItem*)dst->parent(); parix=index(parbi); - n=dst->childNumber()+1; + n=dst->childNumber()+ (3+num)/2; //-1 |-> 1;-3 |-> 0 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); + reposition(); select (newbi); return newbi; } @@ -2165,7 +2137,7 @@ } -BranchItem* VymModel::addNewBranchBefore() //FIXME-0 +BranchItem* VymModel::addNewBranchBefore() { BranchItem *newbi=NULL; BranchItem *selbi=getSelectedBranchItem(); @@ -2315,24 +2287,29 @@ } */} -void VymModel::deleteChildren() //FIXME-2 VM still missing - -{ -/* - BranchObj *bo=getSelectedBranch(); - if (bo) +void VymModel::deleteChildren() + +{ + BranchItem *selbi=getSelectedBranchItem(); + if (selbi) { saveStateChangingPart( - bo, - bo, + selbi, + selbi, "deleteChildren ()", - QString( "Remove children of branch %1").arg(getObjectName(bo)) + QString( "Remove children of branch %1").arg(getObjectName(selbi)) ); - bo->removeChildren(); + emit (layoutAboutToBeChanged() ); + + QModelIndex ix=index (selbi); + int n=selbi->branchCount()-1; + beginRemoveRows (ix,0,n); + removeRows (0,n+1,ix); + endRemoveRows(); + emit (layoutChanged() ); reposition(); } -*/} - +} bool VymModel::scrollBranch(BranchItem *bi) { @@ -4972,7 +4949,7 @@ return NULL; } -TreeItem* VymModel::getSelectedItem() +TreeItem* VymModel::getSelectedItem() { QModelIndexList list=selModel->selectedIndexes(); if (!list.isEmpty() )