# HG changeset patch # User insilmaril # Date 1232464996 0 # Node ID 84ae10f6e3a3bb6069ce102e4642e885ab35ec34 # Parent ac4be290c750e37e26db01487310924772368712 More work on removing Selection class diff -r ac4be290c750 -r 84ae10f6e3a3 branchobj.cpp --- a/branchobj.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/branchobj.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -1080,7 +1080,7 @@ bo->depth=depth+1; bo->setDefAttr(MovedBranch); if (scrolled) tmpUnscroll(); - setLastSelectedBranch (bo); + //setLastSelectedBranch (bo); //FIXME needed? return bo; } @@ -1114,7 +1114,7 @@ bo->depth=depth+1; bo->setDefAttr (MovedBranch); if (scrolled) tmpUnscroll(); - setLastSelectedBranch (bo); + //setLastSelectedBranch (bo); //FIXME needed? qSort (branch.begin(),branch.end(), isAbove); return bo; } @@ -1167,6 +1167,7 @@ void BranchObj::setLastSelectedBranch (BranchObj* bo) { + cout << "BO::setLastSelectedBranch for "<setText(note.getNote() ); @@ -1569,10 +1570,7 @@ // set selected and visible LinkableMapObj::select(); - // Tell parent that I am selected now: - BranchObj* po=(BranchObj*)(parObj); - if (po) // TODO Try to get rid of this cast... - po->setLastSelectedBranch(this); + //if (po) po->setLastSelectedBranch(this); // temporary unscroll, if we have scrolled parents somewhere if (parObj) ((BranchObj*)(parObj))->tmpUnscroll(); diff -r ac4be290c750 -r 84ae10f6e3a3 mainwindow.cpp --- a/mainwindow.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/mainwindow.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -2870,7 +2870,7 @@ VymModel *m=currentModel(); if (m) { - BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *bo=m->getSelectedBranch(); BranchObj *newbo=m->addNewBranch(0); prevSelection=m->getSelectString(bo); @@ -2897,7 +2897,7 @@ VymModel *m=currentModel(); if (m) { - BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *bo=m->getSelectedBranch(); BranchObj *newbo=m->addNewBranchBefore(); if (newbo) @@ -2919,7 +2919,7 @@ VymModel *m=currentModel(); if ( m) { - BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *bo=m->getSelectedBranch(); BranchObj *newbo=m->addNewBranch (-1); if (newbo) @@ -2941,7 +2941,7 @@ VymModel *m=currentModel(); if (m) { - BranchObj *bo=(BranchObj*)m->getSelection(); + BranchObj *bo=m->getSelectedBranch(); BranchObj *newbo=m->addNewBranch (1); if (newbo) @@ -3405,7 +3405,7 @@ actionFilePrint->setEnabled (true); // Selection - selection=m->getSelection(); + selection=m->getSelectedLMO(); // Link style in context menu switch (m->getMapLinkStyle()) diff -r ac4be290c750 -r 84ae10f6e3a3 mapeditor.cpp --- a/mapeditor.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/mapeditor.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -271,7 +271,7 @@ QString("%1 (\"%2\")").arg(r).arg(f), QString("Toggling standard flag \"%1\" of %2").arg(f).arg(model->getObjectName(bo))); bo->toggleStandardFlag (f,mainWindow->useFlagGroups()); - model->updateSelection(); + model->updateSelection(); // geometry has changed } } @@ -391,7 +391,7 @@ if (lmo) { // MapObj was found - if (model->getSelection() != lmo) + if (model->getSelectedLMO() != lmo) { // select the MapObj model->select(lmo); @@ -550,19 +550,6 @@ //QModelIndex ix=model->index( ti->row(), ti->column(), model->index (0,0,QModelIndex()) ); QModelIndex ix=model->index(ti); model->getSelectionModel()->select (ix,QItemSelectionModel::ClearAndSelect ); - /* - if (model->getSelectionModel()->hasSelection() ) - { - QModelIndex ixsel=model->getSelectionModel()->selectedIndexes().first(); - TreeItem *tisel= static_cast(ixsel.internalPointer()); - ; - cout << " ti="<button() == Qt::LeftButton ) @@ -585,14 +572,14 @@ if (bo) { copyingObj=true; - bo->addBranch ((BranchObj*)model->getSelection()); + bo->addBranch (model->getSelectedBranch()); model->unselect(); model->select(bo->getLastBranch()); model->reposition(); } } - movingObj=model->getSelection(); + movingObj=model->getSelectedLMO(); } else // Middle Button Toggle Scroll // (On Mac OS X this won't work, but we still have @@ -620,7 +607,7 @@ void MapEditor::mouseMoveEvent(QMouseEvent* e) { QPointF p = mapToScene(e->pos()); - LinkableMapObj *lmosel=model->getSelection(); + LinkableMapObj *lmosel=model->getSelectedLMO(); // Move the selected MapObj if ( lmosel && movingObj) @@ -649,7 +636,7 @@ fio->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fio->setRelPos(); fio->updateLink(); //no need for reposition, if we update link here - model->updateSelection(); + model->updateSelection(); // position has changed // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent @@ -736,7 +723,7 @@ } // depth>0 QItemSelection sel=model->getSelectionModel()->selection(); - updateSelection(sel,sel); + updateSelection(sel,sel); // position has changed } // no FloatImageObj @@ -767,7 +754,7 @@ { QPointF p = mapToScene(e->pos()); LinkableMapObj *dst; - LinkableMapObj *lmosel=model->getSelection(); + LinkableMapObj *lmosel=model->getSelectedLMO(); // Have we been picking color? if (pickingColor) { @@ -1094,6 +1081,7 @@ index=newsel.indexes().at(i); ti= static_cast(index.internalPointer()); lmo=ti->getLMO(); + cout << " ME::updateSelection of "<<((BranchObj*)lmo)->getHeading().toStdString()<<"\n"; bbox=lmo->getBBox(); sb->setRect ( bbox.x(),bbox.y(), @@ -1104,7 +1092,7 @@ } } -void MapEditor::updateCurrent (const QModelIndex &newsel,const QModelIndex &) +void MapEditor::updateCurrent (const QModelIndex &,const QModelIndex &) //FIXME not used? { /* FIXME testing diff -r ac4be290c750 -r 84ae10f6e3a3 selection.cpp --- a/selection.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/selection.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -1,4 +1,6 @@ #include +#include +using namespace std; #include "selection.h" @@ -12,6 +14,7 @@ Selection::Selection() { blocked=false; + model=NULL; } Selection::~Selection() @@ -23,20 +26,7 @@ model=m; } -void Selection::copy(const Selection &other) -{ - selectList=other.selectList; - lastSelectList=other.lastSelectList; -} - -void Selection::clear() -{ - unselect(); - lastSelectList.clear(); -} - - -void Selection::update() // FIXME VM emit signal in VM instead +void Selection::update() // FIXME VM emit signal in VM instead and get rid of this { /* QRectF bbox; @@ -54,25 +44,23 @@ } bool Selection::select(LinkableMapObj *lmo) // TODO no multiselections yet { + return model->select (lmo); + /* if (!selectList.isEmpty()) unselect(); selectList.append (lmo); - /* FIXME VM move to ME - QGraphicsRectItem *sb = scene->addRect( - QRectF(0,0,0,0), - QPen(color), - color); - sb->setZValue(Z_SELBOX); - sb->show(); - selboxList.append (sb); - */ lmo->select(); update(); mainWindow->updateSatellites (model); + cout << "Sel::select lmo e\n"; return true; + */ } bool Selection::select (const QString &s) // TODO no multiselections yet { + return model->select (s); + /* + cout << "Sel::select s=\n"; LinkableMapObj *lmo=model->findObjBySelect(s); // Finally select the found object @@ -83,7 +71,7 @@ return true; } return false; - + */ } bool Selection::reselect () // TODO no multiselections yet @@ -99,18 +87,20 @@ void Selection::unselect() { + model->unselect(); + /* + cout << "Sel::unselect\n"; if (!selectList.isEmpty() ) { for (int i=0; i< selectList.count(); ++i) selectList.at(i)->unselect(); lastSelectList=selectList; selectList.clear(); - /* FIXME VM move to ME - while (!selboxList.isEmpty() ) - delete selboxList.takeFirst(); + // FIXME VM move to ME + //while (!selboxList.isEmpty() ) + // delete selboxList.takeFirst(); + } */ - - } } bool Selection::isBlocked() @@ -133,11 +123,14 @@ return selectList.isEmpty(); } +/* uint Selection::count() { return selectList.count(); } +*/ +/* Selection::Type Selection::type() // TODO no multiselections yet { if (!selectList.isEmpty()) @@ -149,7 +142,9 @@ } return Undefined; } +*/ +/* LinkableMapObj* Selection::first() { if (!selectList.isEmpty()) @@ -166,18 +161,6 @@ return NULL; } -BranchObj* Selection::getBranch() -{ - if (!selectList.isEmpty()) - { - LinkableMapObj *sel=selectList.first(); - if (typeid (*sel)==typeid (BranchObj) || - typeid (*sel)==typeid (MapCenterObj)) - return (BranchObj*)sel; - } - return NULL; -} - TreeItem* Selection::getBranchItem() { BranchObj* bo=getBranch(); @@ -190,6 +173,7 @@ return model->getSelectionModel()->selectedIndexes().first(); // TODO no multiselections yet } +*/ FloatImageObj* Selection::getFloatImage() { diff -r ac4be290c750 -r 84ae10f6e3a3 selection.h --- a/selection.h Thu Jan 15 00:52:35 2009 +0000 +++ b/selection.h Tue Jan 20 15:23:16 2009 +0000 @@ -21,8 +21,6 @@ enum Type {Undefined,Branch,MapCenter,FloatImage}; Selection (); ~Selection(); - void copy(const Selection&); - void clear(); void setModel (VymModel *); void update(); bool select (LinkableMapObj*); @@ -33,13 +31,13 @@ void block(); void unblock(); bool isEmpty(); - uint count(); - Type type(); - LinkableMapObj * first(); // first in selection list - LinkableMapObj * single(); // NULL, if multiple selected - BranchObj* getBranch(); - TreeItem* getBranchItem(); - QModelIndex getBranchIndex(); //!< Returns index of first selected branch or mapcenter +// uint count(); +// Type type(); +// LinkableMapObj * first(); // first in selection list +// LinkableMapObj * single(); // NULL, if multiple selected +// BranchObj* getBranch(); +// TreeItem* getBranchItem(); +// QModelIndex getBranchIndex(); //!< Returns index of first selected branch or mapcenter FloatImageObj* getFloatImage(); QString getSelectString(); diff -r ac4be290c750 -r 84ae10f6e3a3 treeitem.h --- a/treeitem.h Thu Jan 15 00:52:35 2009 +0000 +++ b/treeitem.h Tue Jan 20 15:23:16 2009 +0000 @@ -9,7 +9,7 @@ class TreeItem { public: - enum Type {Undefined,MapCenter,Branch}; + enum Type {Undefined,MapCenter,Branch,Image}; TreeItem(const QList &data, TreeItem *parent = 0); ~TreeItem(); diff -r ac4be290c750 -r 84ae10f6e3a3 version.h --- a/version.h Thu Jan 15 00:52:35 2009 +0000 +++ b/version.h Tue Jan 20 15:23:16 2009 +0000 @@ -7,7 +7,7 @@ #define __VYM_VERSION "1.13.0" //#define __VYM_CODENAME "Codename: RC-1" #define __VYM_CODENAME "Codename: development version" -#define __VYM_BUILD_DATE "2008-12-10" +#define __VYM_BUILD_DATE "2009-01-20" bool checkVersion(const QString &); diff -r ac4be290c750 -r 84ae10f6e3a3 vymmodel.cpp --- a/vymmodel.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/vymmodel.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -67,7 +67,7 @@ void VymModel::clear() { cout << "VymModel::clear rows="<clearSelection(); // Remove stuff while (!mapCenters.isEmpty()) // FIXME VM needs to be in treemodel only... @@ -123,8 +123,6 @@ // selections selModel=NULL; - selection.setModel (this); - selection.unselect(); // find routine itFind=NULL; @@ -342,12 +340,12 @@ if (lmode==NewMap) { - selection.clear(); + selModel->clearSelection(); // FIXME VM not needed??? model->setMapEditor(this); // (map state is set later at end of load...) } else { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (!bo) return aborted; if (lmode==ImportAdd) saveStateChangingPart( @@ -589,10 +587,10 @@ else { // Save part of map - if (selection.type()==Selection::FloatImage) + if (selectionType()==TreeItem::Image) saveFloatImage(); else - saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection.getBranch()); + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),getSelectedBranch()); // TODO take care of multiselections } @@ -660,7 +658,7 @@ void VymModel::addMapInsertInt (const QString &path, int pos) { - BranchObj *sel=selection.getBranch(); + BranchObj *sel=getSelectedBranch(); if (sel) { QString pathDir=path.left(path.findRev("/")); @@ -696,7 +694,7 @@ FloatImageObj* VymModel::loadFloatImageInt (QString fn) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { FloatImageObj *fio; @@ -712,7 +710,7 @@ void VymModel::loadFloatImage () { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { @@ -810,7 +808,7 @@ void VymModel::importDirInt(BranchObj *dst, QDir d) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { // Traverse directories @@ -857,7 +855,7 @@ void VymModel::importDirInt (const QString &s) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveStateChangingPart (bo,bo,QString ("importDir (\"%1\")").arg(s),QString("Import directory structure from %1").arg(s)); @@ -869,7 +867,7 @@ void VymModel::importDir() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QStringList filters; @@ -1490,7 +1488,7 @@ void VymModel::setHeading(const QString &s) { - BranchObj *sel=selection.getBranch(); + BranchObj *sel=getSelectedBranch(); if (sel) { saveState( @@ -1500,7 +1498,8 @@ "setHeading (\""+s+"\")", QString("Set heading of %1 to \"%2\"").arg(getObjectName(sel)).arg(s) ); sel->setHeading(s ); - TreeItem *ti=selection.getBranchItem(); + /* FIXME testing only + TreeItem *ti=getSelectedBranchItem(); if (ti) { ti->setHeading (s); @@ -1517,6 +1516,7 @@ //cout <<" (r,c)=("<setHeading(s); @@ -1556,9 +1556,9 @@ // Searching in Note if (itFind->getNote().contains(s,cs)) { - if (selection.single()!=itFind) + if (getSelectedBranch()!=itFind) { - selection.select(itFind); + select(itFind); ensureSelectionVisible(); } if (textEditor->findText(s,flags)) @@ -1570,7 +1570,7 @@ // Searching in Heading if (searching && itFind->getHeading().contains (s,cs) ) { - selection.select(itFind); + select(itFind); ensureSelectionVisible(); searching=false; } @@ -1583,7 +1583,7 @@ //cout <<"still searching... "<getHeading())<getURL(); @@ -1627,7 +1627,7 @@ QString VymModel::getURL() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) return bo->getURL(); else @@ -1637,7 +1637,7 @@ QStringList VymModel::getURLs() { QStringList urls; - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo=bo->first(); @@ -1683,7 +1683,7 @@ void VymModel::setFrameType(const FrameObj::FrameType &t) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QString s=bo->getFrameTypeName(); @@ -1697,7 +1697,7 @@ void VymModel::setFrameType(const QString &s) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState (bo, QString("setFrameType (\"%1\")").arg(bo->getFrameTypeName()), @@ -1710,7 +1710,7 @@ void VymModel::setFramePenColor(const QColor &c) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState (bo, QString("setFramePenColor (\"%1\")").arg(bo->getFramePenColor().name() ), @@ -1721,7 +1721,7 @@ void VymModel::setFrameBrushColor(const QColor &c) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState (bo, QString("setFrameBrushColor (\"%1\")").arg(bo->getFrameBrushColor().name() ), @@ -1732,7 +1732,7 @@ void VymModel::setFramePadding (const int &i) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState (bo, QString("setFramePadding (\"%1\")").arg(bo->getFramePadding() ), @@ -1745,7 +1745,7 @@ void VymModel::setFrameBorderWidth(const int &i) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState (bo, QString("setFrameBorderWidth (\"%1\")").arg(bo->getFrameBorderWidth() ), @@ -1758,7 +1758,7 @@ void VymModel::setIncludeImagesVer(bool b) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QString u= b ? "false" : "true"; @@ -1778,7 +1778,7 @@ void VymModel::setIncludeImagesHor(bool b) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QString u= b ? "false" : "true"; @@ -1798,11 +1798,11 @@ void VymModel::setHideLinkUnselected (bool b) { - LinkableMapObj *sel=selection.single(); + LinkableMapObj *sel=getSelectedLMO(); if (sel && - (selection.type() == Selection::Branch || - selection.type() == Selection::MapCenter || - selection.type() == Selection::FloatImage )) + (selectionType() == TreeItem::Branch || + selectionType() == TreeItem::MapCenter || + selectionType() == TreeItem::Image )) { QString u= b ? "false" : "true"; QString r=!b ? "false" : "true"; @@ -1820,7 +1820,7 @@ void VymModel::setHideExport(bool b) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo->setHideInExport (b); @@ -1843,7 +1843,7 @@ void VymModel::toggleHideExport() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) setHideExport ( !bo->hideInExport() ); } @@ -1851,8 +1851,11 @@ void VymModel::copy() { - LinkableMapObj *sel=selection.single(); - if (sel) + LinkableMapObj *sel=getSelectedLMO(); + if (sel && + (selectionType() == TreeItem::Branch || + selectionType() == TreeItem::MapCenter || + selectionType() == TreeItem::Image )) { if (redosAvail == 0) { @@ -1893,7 +1896,7 @@ void VymModel::paste() { - BranchObj *sel=selection.getBranch(); + BranchObj *sel=getSelectedBranch(); if (sel) { saveStateChangingPart( @@ -1909,10 +1912,10 @@ void VymModel::cut() { - LinkableMapObj *sel=selection.single(); - if ( sel && (selection.type() == Selection::Branch || - selection.type()==Selection::MapCenter || - selection.type()==Selection::FloatImage)) + LinkableMapObj *sel=getSelectedLMO(); + if ( sel && (selectionType() == TreeItem::Branch || + selectionType()==TreeItem::MapCenter || + selectionType()==TreeItem::Image)) { /* No savestate! savestate is called in cutNoSave saveStateChangingPart( @@ -1930,7 +1933,7 @@ void VymModel::moveBranchUp() { - BranchObj* bo=selection.getBranch(); + BranchObj* bo=getSelectedBranch(); BranchObj* par; if (bo) { @@ -1947,7 +1950,7 @@ void VymModel::moveBranchDown() { - BranchObj* bo=selection.getBranch(); + BranchObj* bo=getSelectedBranch(); BranchObj* par; if (bo) { @@ -1964,7 +1967,7 @@ void VymModel::sortChildren() { - BranchObj* bo=selection.getBranch(); + BranchObj* bo=getSelectedBranch(); if (bo) { if(bo->countBranches()>1) @@ -1980,12 +1983,12 @@ void VymModel::createMapCenter() { MapCenterObj *mco=addMapCenter (QPointF (0,0) ); - selection.select (mco); + select (mco); } void VymModel::createBranch() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below @@ -2002,7 +2005,7 @@ if (newbo) { newbo->setTreeItem (ti); - selection.select (newbo); // FIXME VM really needed here? + select (newbo); // FIXME VM really needed here? } } } @@ -2075,7 +2078,7 @@ // -1 insert in children of parent below selection // 0..n insert in children of parent at pos BranchObj *newbo=NULL; - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { if (num==-2) @@ -2106,7 +2109,7 @@ // -1 add above // 0 add as child // +1 add below - BranchObj *bo = selection.getBranch(); + BranchObj *bo = getSelectedBranch(); BranchObj *newbo=NULL; if (bo) @@ -2143,8 +2146,8 @@ BranchObj* VymModel::addNewBranchBefore() { BranchObj *newbo=NULL; - BranchObj *bo = selection.getBranch(); - if (bo && selection.type()==Selection::Branch) + BranchObj *bo = getSelectedBranch(); + if (bo && selectionType()==TreeItem::Branch) // We accept no MapCenterObj here, so we _have_ a parent { QPointF p=bo->getRelPos(); @@ -2174,9 +2177,9 @@ void VymModel::deleteSelection() { - BranchObj *bo = selection.getBranch(); + BranchObj *bo = getSelectedBranch(); - if (bo && selection.type()==Selection::MapCenter) + if (bo && selectionType()==TreeItem::MapCenter) { // BranchObj* par=(BranchObj*)(bo->getParObj()); selection.unselect(); @@ -2193,15 +2196,15 @@ reposition(); return; } - if (bo && selection.type()==Selection::Branch) + if (bo && selectionType()==TreeItem::Branch) { - QModelIndex ix=selection.getBranchIndex(); + QModelIndex ix=getSelectedIndex(); BranchObj* par=(BranchObj*)bo->getParObj(); - selection.unselect(); + unselect(); saveStateRemovingPart (bo, QString ("Delete %1").arg(getObjectName(bo))); par->removeBranch(bo); - selection.select (par); + select (par); ensureSelectionVisible(); reposition(); selection.update(); @@ -2217,9 +2220,9 @@ "delete ()", QString("Delete %1").arg(getObjectName(fio)) ); - selection.unselect(); + unselect(); par->removeFloatImage(fio); - selection.select (par); + select (par); reposition(); selection.update(); ensureSelectionVisible(); @@ -2229,7 +2232,7 @@ void VymModel::deleteKeepChildren() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); BranchObj *par; if (bo) { @@ -2258,14 +2261,14 @@ par->removeBranchHere(bo); reposition(); select (sel); - selection.getBranch()->move2RelPos (p); + getSelectedBranch()->move2RelPos (p); reposition(); } } void VymModel::deleteChildren() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveStateChangingPart( @@ -2332,8 +2335,8 @@ void VymModel::toggleScroll() { - BranchObj *bo=selection.getBranch(); - if (selection.type()==Selection::Branch ) + BranchObj *bo=getSelectedBranch(); + if (selectionType()==TreeItem::Branch ) { if (bo->isScrolled()) unscrollBranch (bo); @@ -2344,7 +2347,7 @@ void VymModel::unscrollChildren() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo->first(); @@ -2357,7 +2360,7 @@ } void VymModel::addFloatImage (const QPixmap &img) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { FloatImageObj *fio=bo->addFloatImage(); @@ -2374,7 +2377,7 @@ void VymModel::colorBranch (QColor c) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState( @@ -2390,7 +2393,7 @@ void VymModel::colorSubtree (QColor c) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveStateChangingPart( @@ -2405,7 +2408,7 @@ QColor VymModel::getCurrentHeadingColor() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) return bo->getColor(); QMessageBox::warning(0,"Warning","Can't get color of heading,\nthere's no branch selected"); @@ -2416,7 +2419,7 @@ void VymModel::editURL() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bool ok; @@ -2431,7 +2434,7 @@ void VymModel::editLocalURL() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QStringList filters; @@ -2459,14 +2462,14 @@ void VymModel::editHeading2URL() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) setURL (bo->getHeading()); } void VymModel::editBugzilla2URL() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading(); @@ -2476,7 +2479,7 @@ void VymModel::editFATE2URL() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading(); @@ -2494,7 +2497,7 @@ void VymModel::editVymLink() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QStringList filters; @@ -2526,7 +2529,7 @@ void VymModel::setVymLink (const QString &s) { // Internal function, no saveState needed - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo->setVymLink(s); @@ -2539,7 +2542,7 @@ void VymModel::deleteVymLink() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { saveState( @@ -2558,7 +2561,7 @@ QString VymModel::getVymLink() { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) return bo->getVymLink(); else @@ -2569,7 +2572,7 @@ QStringList VymModel::getVymLinks() { QStringList links; - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo=bo->first(); @@ -2585,7 +2588,7 @@ void VymModel::followXLink(int i) { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo=bo->XLinkTargetAt(i); @@ -2599,7 +2602,7 @@ void VymModel::editXLink(int i) // FIXME VM missing saveState { - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { XLinkObj *xlo=bo->XLinkAt(i); @@ -2632,7 +2635,7 @@ void VymModel::parseAtom(const QString &atom) { - BranchObj *selb=selection.getBranch(); + BranchObj *selb=getSelectedBranch(); QString s,t; double x,y; int n; @@ -2791,9 +2794,9 @@ if (selection.isEmpty()) { parser.setError (Aborted,"Nothing selected"); - } else if ( selection.type()!=Selection::Branch && - selection.type()!=Selection::MapCenter && - selection.type()!=Selection::FloatImage ) + } else if ( selectionType()!=TreeItem::Branch && + selectionType()!=TreeItem::MapCenter && + selectionType()!=TreeItem::Image ) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(0)) @@ -2807,7 +2810,7 @@ { parser.setError (Aborted,"Nothing selected"); } - /*else if (selection.type() != Selection::Branch && selection.type() != Selection::FloatImage ) + /*else if (selectionType() != TreeItem::Branch && selectionType() != TreeItem::Image ) { parser.setError (Aborted,"Type of selection is wrong."); } @@ -2964,7 +2967,7 @@ } } } - } else if ( selection.type() == Selection::FloatImage) + } else if ( selectionType() == TreeItem::Image) { if (parser.checkParCount(1)) { @@ -3027,9 +3030,9 @@ if (selection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if ( selection.type()!=Selection::Branch && - selection.type()!=Selection::MapCenter && - selection.type()!=Selection::FloatImage ) + } else if ( selectionType()!=TreeItem::Branch && + selectionType()!=TreeItem::MapCenter && + selectionType()!=TreeItem::Image ) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(2)) @@ -3047,9 +3050,9 @@ if (selection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if ( selection.type()!=Selection::Branch && - selection.type()!=Selection::MapCenter && - selection.type()!=Selection::FloatImage ) + } else if ( selectionType()!=TreeItem::Branch && + selectionType()!=TreeItem::MapCenter && + selectionType()!=TreeItem::Image ) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(2)) @@ -3230,7 +3233,7 @@ ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameType") { - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage) + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection does not allow setting frame type"); } @@ -3242,7 +3245,7 @@ ///////////////////////////////////////////////////////////////////// } else if (com=="setFramePenColor") { - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage) + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection does not allow setting of pen color"); } @@ -3254,7 +3257,7 @@ ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameBrushColor") { - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage) + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection does not allow setting brush color"); } @@ -3266,7 +3269,7 @@ ///////////////////////////////////////////////////////////////////// } else if (com=="setFramePadding") { - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage) + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection does not allow setting frame padding"); } @@ -3278,7 +3281,7 @@ ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameBorderWidth") { - if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage) + if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection does not allow setting frame border width"); } @@ -3309,7 +3312,7 @@ if (selection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if (! selection.getBranch() ) + } else if (! getSelectedBranch() ) { parser.setError (Aborted,"Type of selection is not a branch"); } else if (parser.checkParCount(1)) @@ -3360,7 +3363,7 @@ if (selection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if (selection.type()!=Selection::Branch && selection.type() != Selection::MapCenter &&selection.type()!=Selection::FloatImage) + } else if (selectionType()!=TreeItem::Branch && selectionType() != TreeItem::MapCenter &&selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); } else if (parser.checkParCount(1)) @@ -3402,7 +3405,7 @@ if (selection.isEmpty() ) { parser.setError (Aborted,"Nothing selected"); - } else if ( selection.type()!=Selection::Branch && selection.type()!= Selection::MapCenter && selection.type()!=Selection::FloatImage) + } else if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image) { parser.setError (Aborted,"Type of selection does not allow hiding the link"); } else if (parser.checkParCount(1)) @@ -3772,7 +3775,7 @@ void VymModel::updateNoteFlag() { setChanged(); - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { bo->updateNoteFlag(); @@ -4077,20 +4080,24 @@ void VymModel::move(const double &x, const double &y) { - LinkableMapObj *sel=selection.single(); - if (sel) + BranchObj *bo = getSelectedBranch(); + if (bo && + (selectionType()==TreeItem::Branch || + selectionType()==TreeItem::MapCenter || + selectionType()==TreeItem::Image + )) { - QPointF ap(sel->getAbsPos()); + QPointF ap(bo->getAbsPos()); QPointF to(x, y); if (ap != to) { QString ps=qpointfToString(ap); - QString s=selection.getSelectString(); + QString s=getSelectString(); saveState( s, "move "+ps, s, "move "+qpointfToString(to), - QString("Move %1 to %2").arg(getObjectName(sel)).arg(ps)); - sel->move(x,y); + QString("Move %1 to %2").arg(getObjectName(bo)).arg(ps)); + bo->move(x,y); reposition(); selection.update(); } @@ -4099,22 +4106,27 @@ void VymModel::moveRel (const double &x, const double &y) { - LinkableMapObj *sel=selection.single(); - if (sel) + BranchObj *bo = getSelectedBranch(); + if (bo && + (selectionType()==TreeItem::Branch || + selectionType()==TreeItem::MapCenter || + selectionType()==TreeItem::Image + )) + if (bo) { - QPointF rp(sel->getRelPos()); + QPointF rp(bo->getRelPos()); QPointF to(x, y); if (rp != to) { - QString ps=qpointfToString (sel->getRelPos()); - QString s=getSelectString(sel); + QString ps=qpointfToString (bo->getRelPos()); + QString s=getSelectString(bo); saveState( s, "moveRel "+ps, s, "moveRel "+qpointfToString(to), - QString("Move %1 to relative position %2").arg(getObjectName(sel)).arg(ps)); - ((OrnamentedObj*)sel)->move2RelPos (x,y); + QString("Move %1 to relative position %2").arg(getObjectName(bo)).arg(ps)); + ((OrnamentedObj*)bo)->move2RelPos (x,y); reposition(); - sel->updateLink(); + bo->updateLink(); selection.update(); } } @@ -4140,7 +4152,9 @@ bo->reposition(); i++; } - emit (selectionChanged(selModel->selection(), selModel->selection()) ); + QItemSelection sel=selModel->selection(); + emit (selectionChanged(sel,sel)); + mapScene->update(); if (!animObjList.isEmpty()) animationTimer->start(); } @@ -4324,7 +4338,24 @@ void VymModel::updateSelection() { - selection.update(); + cout << "VM::updateSelection ()\n"; + QItemSelection newsel=selModel->selection(); + updateSelection (newsel); +} + +void VymModel::updateSelection(const QItemSelection &oldsel) +{ + QItemSelection newsel=selModel->selection(); + cout << "VM::updateSelection new="; + if (!newsel.indexes().isEmpty() ) + cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column(); + cout << " old="; + if (!oldsel.indexes().isEmpty() ) + cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column(); + cout <selection(); + + if (lmo) { - selection.update(); - ensureSelectionVisible(); - sendSelection (); + TreeItem *ti=lmo->getTreeItem(); + QModelIndex ix=index(ti); + selModel->select (ix,QItemSelectionModel::ClearAndSelect ); + //updateSelection(oldsel); return true; } return false; @@ -4424,7 +4459,7 @@ void VymModel::unselect() { - selection.unselect(); + selModel->clearSelection(); } void VymModel::reselect() @@ -4434,7 +4469,7 @@ void VymModel::ensureSelectionVisible() { - LinkableMapObj *lmo=selection.single(); + LinkableMapObj *lmo=getSelectedLMO(); if (lmo &&mapEditor) mapEditor->ensureVisible (lmo->getBBox() ); } @@ -4452,10 +4487,10 @@ void VymModel::selectNextBranchInt() { // Increase number of branch - LinkableMapObj *sel=selection.single(); + LinkableMapObj *sel=getSelectedBranch(); if (sel) { - QString s=selection.getSelectString(); + QString s=getSelectString(); QString part; QString typ; QString num; @@ -4479,7 +4514,7 @@ // try to increase the parental number in order to // find a successor with same depth - int d=selection.single()->getDepth(); + int d=getSelectedLMO()->getDepth(); int oldDepth=d; int i; bool found=false; @@ -4500,7 +4535,7 @@ } else { // Special case, look at orientation - if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter) + if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter) num=QString ("%1").arg(num.toUInt()+1); else num=QString ("%1").arg(num.toUInt()-1); @@ -4514,7 +4549,7 @@ b=select (s); if (b) { - if ( selection.getBranch()->countBranches()>0) + if ( getSelectedBranch()->countBranches()>0) s+=",bo:0"; else break; @@ -4533,7 +4568,7 @@ void VymModel::selectPrevBranchInt() { // Decrease number of branch - BranchObj *bo=selection.getBranch(); + BranchObj *bo=getSelectedBranch(); if (bo) { QString s=selection.getSelectString(); @@ -4561,7 +4596,7 @@ // try to decrease the parental number in order to // find a precessor with same depth - int d=selection.single()->getDepth(); + int d=getSelectedLMO()->getDepth(); int oldDepth=d; int i; bool found=false; @@ -4582,7 +4617,7 @@ } else { // Special case, look at orientation - if (selection.single()->getOrientation()==LinkableMapObj::RightOfCenter) + if (getSelectedLMO()->getOrientation()==LinkableMapObj::RightOfCenter) num=QString ("%1").arg(num.toInt()-1); else num=QString ("%1").arg(num.toInt()+1); @@ -4595,8 +4630,8 @@ { b=select (s); if (b) - if ( selection.getBranch()->countBranches()>0) - s+=",bo:"+ QString ("%1").arg( selection.getBranch()->countBranches()-1 ); + if ( getSelectedBranch()->countBranches()>0) + s+=",bo:"+ QString ("%1").arg( getSelectedBranch()->countBranches()-1 ); else break; else @@ -4615,8 +4650,8 @@ { if (selection.isBlocked() ) return; - BranchObj *bo=selection.getBranch(); - if (bo && selection.type()==Selection::Branch) + BranchObj *bo=getSelectedBranch(); + if (bo && selectionType()==TreeItem::Branch) { if (bo->getOrientation()==LinkableMapObj::RightOfCenter) selectPrevBranchInt(); @@ -4632,8 +4667,8 @@ { if (selection.isBlocked() ) return; - BranchObj *bo=selection.getBranch(); - if (bo && selection.type()==Selection::Branch) + BranchObj *bo=getSelectedBranch(); + if (bo && selectionType()==TreeItem::Branch) { if (bo->getOrientation()==LinkableMapObj::RightOfCenter) selectNextBranchInt(); @@ -4650,57 +4685,40 @@ { if (selection.isBlocked() ) return; - BranchObj* bo; + QItemSelection oldsel=selModel->selection(); + BranchObj* par; - LinkableMapObj *sel=selection.single(); + LinkableMapObj *sel=getSelectedBranch(); if (sel) { - if (selection.type()== Selection::MapCenter) + if (selectionType()== TreeItem::MapCenter) { - par=selection.getBranch(); - bo=par->getLastSelectedBranch(); - if (bo) - { - // Workaround for reselecting on left and right side - if (bo->getOrientation()==LinkableMapObj::RightOfCenter) - bo=par->getLastBranch(); - if (bo) - { - bo=par->getLastBranch(); - selection.select(bo); - selection.update(); - ensureSelectionVisible(); - sendSelection(); - } - } + QModelIndex ix=getSelectedIndex(); + selModel->select (index (rowCount(ix)-1,0,ix),QItemSelectionModel::ClearAndSelect ); } else { par=(BranchObj*)(sel->getParObj()); if (sel->getOrientation()==LinkableMapObj::RightOfCenter) { - if (selection.type() == Selection::Branch || - selection.type() == Selection::FloatImage) + // right of center + if (selectionType() == TreeItem::Branch || + selectionType() == TreeItem::Image) { - selection.select(par); - selection.update(); - ensureSelectionVisible(); - sendSelection(); + QModelIndex ix=getSelectedIndex(); + ix=parent(ix); + selModel->select (ix,QItemSelectionModel::ClearAndSelect ); } } else { - if (selection.type() == Selection::Branch ) + // left of center + if (selectionType() == TreeItem::Branch ) { - bo=selection.getBranch()->getLastSelectedBranch(); - if (bo) - { - selection.select(bo); - selection.update(); - ensureSelectionVisible(); - sendSelection(); - } + selectLastSelectedBranch(); + return; } } } + updateSelection (oldsel); } } @@ -4708,14 +4726,16 @@ { if (selection.isBlocked() ) return; + QItemSelection oldsel=selModel->selection(); + BranchObj* bo; BranchObj* par; - LinkableMapObj *sel=selection.single(); + LinkableMapObj *sel=getSelectedBranch(); if (sel) { - if (selection.type()==Selection::MapCenter) + if (selectionType()==TreeItem::MapCenter) { - par=selection.getBranch(); + par=getSelectedBranch(); bo=par->getLastSelectedBranch(); if (bo) { @@ -4725,45 +4745,48 @@ if (bo) { selection.select(bo); - selection.update(); - ensureSelectionVisible(); - sendSelection(); + //selection.update(); + //ensureSelectionVisible(); + //sendSelection(); } } } else { - par=(BranchObj*)(selection.single()->getParObj()); - if (selection.single()->getOrientation()==LinkableMapObj::LeftOfCenter) + par=(BranchObj*)(getSelectedLMO()->getParObj()); + if (getSelectedLMO()->getOrientation()==LinkableMapObj::LeftOfCenter) { - if (selection.type() == Selection::Branch || - selection.type() == Selection::FloatImage) + if (selectionType() == TreeItem::Branch || + selectionType() == TreeItem::Image) { - selection.select(par); - selection.update(); - ensureSelectionVisible(); - sendSelection(); + QModelIndex ix=getSelectedIndex(); + ix=parent(ix); + selModel->select (ix,QItemSelectionModel::ClearAndSelect ); } } else { - if (selection.type() == Selection::Branch) + if (selectionType() == TreeItem::Branch) { - bo=selection.getBranch()->getLastSelectedBranch(); + bo=getSelectedBranch()->getLastSelectedBranch(); if (bo) { selection.select(bo); - selection.update(); - ensureSelectionVisible(); - sendSelection(); + //selection.update(); + //ensureSelectionVisible(); + //sendSelection(); } } } } + QItemSelection newsel=selModel->selection(); + emit (selectionChanged(newsel,oldsel)); + ensureSelectionVisible(); + sendSelection(); } } void VymModel::selectFirstBranch() { - BranchObj *bo1=selection.getBranch(); + BranchObj *bo1=getSelectedBranch(); BranchObj *bo2; BranchObj* par; if (bo1) @@ -4782,7 +4805,7 @@ void VymModel::selectLastBranch() { - BranchObj *bo1=selection.getBranch(); + BranchObj *bo1=getSelectedBranch(); BranchObj *bo2; BranchObj* par; if (bo1) @@ -4800,33 +4823,94 @@ } } +void VymModel::selectLastSelectedBranch() +{ + QItemSelection oldsel=selModel->selection(); + + BranchObj *bo1=getSelectedBranch(); + BranchObj *bo2; + if (bo1) + { + cout << "bo1="<getHeading().toStdString()<getLastSelectedBranch(); + if (bo2) + { + cout << "bo2="<getHeading().toStdString()<getParObj()); if (!par) return; - selection.select(par); + select(par); selection.update(); ensureSelectionVisible(); sendSelection(); } } -Selection::Type VymModel::selectionType() +TreeItem::Type VymModel::selectionType() { - return selection.type(); + QModelIndexList list=selModel->selectedIndexes(); + if (list.isEmpty()) return TreeItem::Undefined; + TreeItem *ti = static_cast(list.first().internalPointer()); + return ti->getType(); + } -LinkableMapObj* VymModel::getSelection() +LinkableMapObj* VymModel::getSelectedLMO() { - return selection.single(); + QModelIndexList list=selModel->selectedIndexes(); + if (!list.isEmpty() ) + { + TreeItem *ti = static_cast(list.first().internalPointer()); + TreeItem::Type type=ti->getType(); + if (type ==TreeItem::Branch || type==TreeItem::MapCenter || type==TreeItem::Image) + { + return ti->getLMO(); + } + } + return NULL; } + BranchObj* VymModel::getSelectedBranch() { - return selection.getBranch(); + QModelIndexList list=selModel->selectedIndexes(); + if (!list.isEmpty() ) + { + TreeItem *ti = static_cast(list.first().internalPointer()); + TreeItem::Type type=ti->getType(); + if (type ==TreeItem::Branch || type==TreeItem::MapCenter) + { + return (BranchObj*)ti->getLMO(); + } + } + return NULL; + +} + +TreeItem* VymModel::getSelectedTreeItem() +{ + // FIXME this may not only be branch, but also float etc... + BranchObj* bo=getSelectedBranch(); + if (bo) return bo->getTreeItem(); // FIXME VM get directly from treemodl + return NULL; +} + +QModelIndex VymModel::getSelectedIndex() +{ + QModelIndexList list=selModel->selectedIndexes(); + if (list.isEmpty() ) + return QModelIndex(); + else + return list.first(); } FloatImageObj* VymModel::getSelectedFloatImage() @@ -4854,7 +4938,7 @@ s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum()); else { - //cout << "VM::getSelectString lmo="<getNum()); } diff -r ac4be290c750 -r 84ae10f6e3a3 vymmodel.h --- a/vymmodel.h Thu Jan 15 00:52:35 2009 +0000 +++ b/vymmodel.h Tue Jan 20 15:23:16 2009 +0000 @@ -554,16 +554,20 @@ void selectRightBranch(); void selectFirstBranch(); void selectLastBranch(); + void selectLastSelectedBranch(); void selectParent(); public: - Selection::Type selectionType(); - LinkableMapObj* getSelection(); + TreeItem::Type selectionType(); + LinkableMapObj* getSelectedLMO(); BranchObj* getSelectedBranch(); + TreeItem* getSelectedTreeItem(); + QModelIndex getSelectedIndex(); FloatImageObj* getSelectedFloatImage(); QString getSelectString (); QString getSelectString (LinkableMapObj *lmo); + void updateSelection(const QItemSelection &oldsel); void updateSelection(); void selectMapLinkColor(); void selectMapSelectionColor(); diff -r ac4be290c750 -r 84ae10f6e3a3 vymview.cpp --- a/vymview.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/vymview.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -37,7 +37,7 @@ model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), me,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); - //me->viewport()->setFocus(); + //me->viewport()->setFocus(); //FIXME needed? me->setAntiAlias (mainWindow->isAliased()); me->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform()); @@ -46,7 +46,7 @@ // Set geometry QList sizes; - sizes.append (150); + sizes.append (120); sizes.append (600); setSizes (sizes); } @@ -66,6 +66,6 @@ // FIXME Currently this works only from treeview->ME treeview->expandAll(); //FIXME only for testing - ((VymModel*)treeview->model())->select (); + //((VymModel*)treeview->model())->select (); } diff -r ac4be290c750 -r 84ae10f6e3a3 xml-vym.cpp --- a/xml-vym.cpp Thu Jan 15 00:52:35 2009 +0000 +++ b/xml-vym.cpp Tue Jan 20 15:23:16 2009 +0000 @@ -35,13 +35,13 @@ { QColor col; /* Testing + */ cout << "startElement <"<< qPrintable(eName) <<"> state="<createMapCenter(); + cout << "ok0\n"; lastBranch=model->getSelectedBranch(); + cout << "ok1 lastBranch="<getSelection(); + LinkableMapObj* lmo=model->getSelectedLMO(); if (lmo && ( (typeid(*lmo) == typeid(BranchObj) ) || (typeid(*lmo) == typeid(MapCenterObj) ) ) ) { @@ -175,7 +177,7 @@ { // This is used in vymparts, which have no mapcenter! isVymPart=true; - LinkableMapObj* lmo=model->getSelection(); + LinkableMapObj* lmo=model->getSelectedLMO(); if (!lmo) { // If a vym part is _loaded_ (not imported),