diff -r 959bd133cd1a -r 16a8ef1d82b2 vymview.cpp --- a/vymview.cpp Thu Oct 01 13:23:20 2009 +0000 +++ b/vymview.cpp Fri Oct 02 09:40:57 2009 +0000 @@ -22,34 +22,45 @@ treeEditor->setColumnWidth (0,150); treeEditor->setAnimated (true); - - selModel=treeEditor->selectionModel(); + proxySelModel=treeEditor->selectionModel(); + selModel=new QItemSelectionModel (model); + + //model->setSelectionModel (proxySelModel); model->setSelectionModel (selModel); - connect ( - selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), - this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &))); // Create good old MapEditor mapEditor=model->getMapEditor(); if (!mapEditor) mapEditor=new MapEditor (model); - connect ( - selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), - mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); + // Connect selections + + // Proxymodel changed + connect ( + proxySelModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), + this,SLOT (changeProxySelection(const QItemSelection &,const QItemSelection &))); + + // Model changed + connect ( + selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), + this,SLOT (changeSelection(const QItemSelection &,const QItemSelection &))); + + connect ( + model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), + mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); + //FIXME-3 above and below necessary??? + connect ( + selModel, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), + mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); + + // Connect data changed signals connect ( model, SIGNAL (dataChanged(const QModelIndex &, const QModelIndex &)), mapEditor,SLOT (updateData(const QModelIndex &) ) ); - connect ( model, SIGNAL (sortFilterChanged (const QString &)), treeEditor, SLOT (setSortFilter (const QString &) ) ); - // VymModel may want to update selection or other data, e.g. during animation - connect ( - model, SIGNAL (selectionChanged(const QItemSelection &, const QItemSelection &)), - mapEditor,SLOT (updateSelection(const QItemSelection &,const QItemSelection &))); - connect ( model, SIGNAL (noteHasChanged(QModelIndex) ), mainWindow, SLOT (updateNoteEditor (QModelIndex) ) ); @@ -69,22 +80,10 @@ addWidget (treeEditor); addWidget (mapEditor); -/* - tv=new QTreeView; - QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this); - proxyModel->setDynamicSortFilter (true); - proxyModel->setSourceModel(model); - //proxyModel->setFilterFixedString ("a",Qt::CaseInsensitive,QRegExp::FixedString); - proxyModel->setFilterRegExp(QRegExp("e", Qt::CaseInsensitive)); - proxyModel->setFilterKeyColumn(0); - tv->setModel (proxyModel); - addWidget (tv); -*/ // Set geometry QList widths; widths<<200; widths<<600; -// widths<<200; setSizes(widths); } @@ -108,28 +107,29 @@ mapEditor->setFocus(); } -QItemSelectionModel* VymView::selectionModel() -{ - if (treeEditor) - return selModel; - else - std::cout <<"VymView::selectionModel: hey, no treeEditor so far???\n"; - return NULL; -} - void VymView::changeSelection (const QItemSelection &newsel, const QItemSelection &oldsel) { // Notify mainwindow to update satellites like NoteEditor, if needed (model==currenModel...) mainWindow->changeSelection (model,newsel,oldsel); // FIXME-5 maybe connect VymModel <-> MainWindow directly? // would require to also get current model in mainWindow + proxySelModel->select ( + treeEditor->getProxyModel()->mapSelectionFromSource (newsel), + QItemSelectionModel::ClearAndSelect ); + showSelection(); +} - showSelection(); // if called here, no tmpParObj can be set... +void VymView::changeProxySelection (const QItemSelection &newsel, const QItemSelection &oldsel) +{ + // Notify mainwindow to update satellites, but map selection to + // original model first + + // Re-emit but map selection first + model->emitSelectionChanged (treeEditor->getProxyModel()->mapSelectionToSource (newsel)); } void VymView::expandAll() { treeEditor->expandAll(); - //tv->expandAll(); } void VymView::showSelection()