# HG changeset patch # User insilmaril # Date 1254403400 0 # Node ID 959bd133cd1a3ba1c8d5f746d25a898cdbc689a2 # Parent 2c42ad499ac39c500ffcde76f983d983378814e4 preparing sortFilter diff -r 2c42ad499ac3 -r 959bd133cd1a mainwindow.cpp --- a/mainwindow.cpp Thu Oct 01 11:48:58 2009 +0000 +++ b/mainwindow.cpp Thu Oct 01 13:23:20 2009 +0000 @@ -3605,12 +3605,19 @@ void Main::testFunction1() { if (!currentMapEditor()) return; - currentMapEditor()->testFunction1(); + //currentMapEditor()->testFunction1(); /* + */ VymModel *m=currentModel(); if (!m) return; - m->clearItem (m->getSelectedItem()); - */ + + bool ok; + QString text = QInputDialog::getText( + "VYM", "Enter Filter:", QLineEdit::Normal, // FIXME-3 no translation yet + m->getSortFilter(), &ok, NULL); + if ( ok) + // user entered something and pressed OK + m->setSortFilter (text); } void Main::testFunction2() diff -r 2c42ad499ac3 -r 959bd133cd1a mapeditor.cpp --- a/mapeditor.cpp Thu Oct 01 11:48:58 2009 +0000 +++ b/mapeditor.cpp Thu Oct 01 13:23:20 2009 +0000 @@ -196,7 +196,6 @@ if (lmo) { QRectF r=lmo->getBBox(); - cout << "ME::scrollTo "<getHeadingStd()<<" tL="< -#include #include #include @@ -19,14 +18,12 @@ /* // MySortFilterProxyModel *proxyModel = new MySortFilterProxyModel(this); // FIXME-1 trying to use proxy... - QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel (this); + proxyModel = new QSortFilterProxyModel (this); proxyModel->setSourceModel(model); - proxyModel->setFilterRegExp(QRegExp("x", Qt::CaseInsensitive)); - proxyModel->setFilterKeyColumn(0); - proxyModel->setDynamicSortFilter (true); -// setModel(proxyModel); + proxyModel->setDynamicSortFilter (false); + setModel(proxyModel); */ setModel(model); @@ -52,6 +49,14 @@ //cout <<"Destructor TreeEditor for "<getMapName().toStdString()<setFilterRegExp(QRegExp(s, Qt::CaseInsensitive)); + proxyModel->setFilterKeyColumn(0); + proxyModel->setDynamicSortFilter (true); +} + void TreeEditor::cursorUp() { model->select (indexAbove (model->getSelectedIndex() )); diff -r 2c42ad499ac3 -r 959bd133cd1a treeeditor.h --- a/treeeditor.h Thu Oct 01 11:48:58 2009 +0000 +++ b/treeeditor.h Thu Oct 01 13:23:20 2009 +0000 @@ -2,6 +2,7 @@ #define TREEEDITOR_H #include +#include class VymModel; @@ -16,13 +17,16 @@ TreeEditor(VymModel *m); ~TreeEditor(); +public slots: + void setSortFilter (QString f); + private slots: void cursorUp(); void cursorDown(); private: VymModel *model; - VymModel *proxyModel; + QSortFilterProxyModel *proxyModel; }; #endif diff -r 2c42ad499ac3 -r 959bd133cd1a vymmodel.cpp --- a/vymmodel.cpp Thu Oct 01 11:48:58 2009 +0000 +++ b/vymmodel.cpp Thu Oct 01 13:23:20 2009 +0000 @@ -1507,6 +1507,17 @@ return c; } +void VymModel::setSortFilter (const QString &s) +{ + sortFilter=s; + emit (sortFilterChanged (sortFilter)); +} + +QString VymModel::getSortFilter () +{ + return sortFilter; +} + void VymModel::setHeading(const QString &s) { BranchItem *selbi=getSelectedBranch(); diff -r 2c42ad499ac3 -r 959bd133cd1a vymmodel.h --- a/vymmodel.h Thu Oct 01 11:48:58 2009 +0000 +++ b/vymmodel.h Thu Oct 01 13:23:20 2009 +0000 @@ -244,7 +244,14 @@ QString getDate(); int branchCount(); -public: + void setSortFilter (const QString &); + QString getSortFilter (); +protected: + QString sortFilter; +signals: + void sortFilterChanged (QString ); //!< Notify editors of new filter + +public: void setHeading(const QString &); //!< Set heading of item QString getHeading (); //!< Get heading of item diff -r 2c42ad499ac3 -r 959bd133cd1a vymview.cpp --- a/vymview.cpp Thu Oct 01 11:48:58 2009 +0000 +++ b/vymview.cpp Thu Oct 01 13:23:20 2009 +0000 @@ -40,6 +40,11 @@ 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 &)),