diff -r ffb95cd03156 -r 8c028a5d9083 vymmodel.cpp --- a/vymmodel.cpp Thu Apr 30 11:52:49 2009 +0000 +++ b/vymmodel.cpp Fri May 01 10:30:29 2009 +0000 @@ -1186,7 +1186,7 @@ mainWindow->updateHistory (undoSet); updateActions(); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); } bool VymModel::isUndoAvailable() @@ -1521,7 +1521,7 @@ reposition(); // selection.update(); //FIXME-4 - ensureSelectionVisible(); + emitShowSelection(); } } @@ -1554,7 +1554,7 @@ if (getSelectedBranch()!=itFind) { select(itFind); - ensureSelectionVisible(); + emitShowSelection(); } */ if (textEditor->findText(s,flags)) @@ -1615,7 +1615,7 @@ updateActions(); reposition(); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); } */ } @@ -1969,7 +1969,7 @@ reposition(); //FIXME-3 VM needed? scene()->update(); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); } */ } @@ -1988,7 +1988,7 @@ reposition(); //FIXME-3 VM needed? scene()->update(); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); } */ } @@ -2004,7 +2004,7 @@ saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getObjectName(bo))); bo->sortChildren(); reposition(); - ensureSelectionVisible(); + emitShowSelection(); } } */ @@ -2055,7 +2055,7 @@ MapCenterItem *mci=addMapCenter (contextPos); //FIXME-3 selection.select (mco); updateActions(); - ensureSelectionVisible(); + emitShowSelection(); saveState ( mci, "delete()", @@ -2120,52 +2120,59 @@ // -2 add branch to selection // -1 insert in children of parent below selection // 0..n insert in children of parent at pos - BranchObj *newbo=NULL; - BranchObj *bo=getSelectedBranchObj(); //FIXME-2 - BranchItem *bi=getSelectedBranchItem(); - if (bo) + 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=bi; - QModelIndex parix=index(parbi); - int n=parbi->childCount(); - - emit (layoutAboutToBeChanged() ); - beginInsertRows (parix,n,n+1); //FIXME-1 check if n is correct: should be index below _last_ branch... - bi=new BranchItem (cData); - bi->setHeading (QApplication::translate("Heading of new branch in map", "new")); - - parbi->appendChild (bi); + parbi=selbi; + parix=index(parbi); + n=parbi->childCount(); + cout <<"n="<appendChild (newbi); endInsertRows (); - emit (newChildObject (parix)); - emit (layoutChanged() ); - - // save scroll state. If scrolled, automatically select - // new branch in order to tmp unscroll parent... - newbo=bi->createMapObj(mapScene); - select (bi); }else if (num==-1) { - /* - num=bi->num()+1; - bo=(BranchObj*)bo->getParObj(); - if (bo) newbo=bo->insertBranch(num); //FIXME-1 VM still missing - */ + // 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) { - /* - num=bi->num(); - bo=(BranchObj*)bo->getParObj(); - if (bo) newbo=bo->insertBranch(num); //FIXME-1 VM still missing - */ + // insert above selection + parbi=(BranchItem*)selbi->parent(); + parix=index(parbi); + n=selbi->childNumber(); + beginInsertRows (parix,n,n); + parbi->insertBranch(n,newbi); + endInsertRows (); } + emit (newChildObject (parix)); + 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 bi; + return NULL; } BranchItem* VymModel::addNewBranch(int pos) @@ -2179,7 +2186,7 @@ if (selbi) { - // FIXME-2 VM do we still need this in model? setCursor (Qt::ArrowCursor); + // FIXME-3 VM do we still need this in model? setCursor (Qt::ArrowCursor); newbi=addNewBranchInt (pos-2); @@ -2295,7 +2302,7 @@ removeRows (n,1,parentIndex); endRemoveRows(); select (pi); - ensureSelectionVisible(); + emitShowSelection(); reposition(); emit (layoutChanged() ); @@ -2317,7 +2324,7 @@ par->removeFloatImage(fio); select (par); reposition(); - ensureSelectionVisible(); + emitShowSelection(); return; } */ @@ -2400,8 +2407,7 @@ ); */ bi->toggleScroll(); - //selection.update(); - // FIXME-3 VM needed? scene()->update(); + mapScene->update(); //Needed for _quick_ update return true; } return false; @@ -2411,7 +2417,7 @@ { if (bi) { - if (bi->isScrolled()) return false; + if (!bi->isScrolled()) return false; if (bi->branchCount()==0) return false; if (bi->depth()==0) return false; @@ -2428,8 +2434,7 @@ ); */ bi->toggleScroll(); - // selection.update(); - // FIXME-3 VM needed? scene()->update(); + mapScene->update(); // Needed for _quick_ update return true; } return false; @@ -2447,7 +2452,7 @@ } } -void VymModel::unscrollChildren() // FIXME-1 first, next moved to vymmodel +void VymModel::unscrollChildren() // FIXME-2 first, next moved to vymmodel { /* @@ -2464,6 +2469,11 @@ */ } +void VymModel::emitExpandAll() +{ + emit (expandAll() ); +} + void VymModel::addFloatImage (const QPixmap &img) //FIXME-2 { /* @@ -2660,7 +2670,7 @@ reposition(); updateActions(); //selection.update(); - ensureSelectionVisible(); + emitShowSelection(); } } @@ -2725,7 +2735,7 @@ if (bo) { selection.select(bo); - ensureSelectionVisible(); + emitShowSelection(); } } */ @@ -4517,7 +4527,7 @@ void VymModel::updateSelection(const QItemSelection &newsel) { emit (selectionChanged(newsel,newsel)); // needed e.g. to update geometry in editor - ensureSelectionVisible(); + emitShowSelection(); sendSelection(); } @@ -4642,10 +4652,10 @@ selection.reselect(); } -void VymModel::ensureSelectionVisible() //FIXME-3 needed? in vymmodel.h commented... -{ - LinkableMapObj *lmo=getSelectedLMO(); - if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() ); +void VymModel::emitShowSelection() +{ + if (!blockReposition) + emit (showSelection() ); } void VymModel::emitNoteHasChanged (TreeItem *ti) @@ -4909,7 +4919,7 @@ if (ti2) { select(ti2); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); sendSelection(); } } @@ -4926,7 +4936,7 @@ if (ti2) { select(ti2); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); sendSelection(); } } @@ -4952,7 +4962,7 @@ if (!par) return; select(par); selection.update(); - ensureSelectionVisible(); + emitShowSelection(); sendSelection(); } }