summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakeCacheView.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2007-11-16 15:40:23 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2007-11-16 15:40:23 (GMT)
commit5cd4f2a6617e9f92e797eb86ca3555b94b5116ea (patch)
treed836184d31732126263f41401d581c92f74f4f75 /Source/QtDialog/QCMakeCacheView.cxx
parent867de7fc670ffd67c9cb8dcffae42f87de7023ed (diff)
downloadCMake-5cd4f2a6617e9f92e797eb86ca3555b94b5116ea.zip
CMake-5cd4f2a6617e9f92e797eb86ca3555b94b5116ea.tar.gz
CMake-5cd4f2a6617e9f92e797eb86ca3555b94b5116ea.tar.bz2
ENH: more robust search filter.
Diffstat (limited to 'Source/QtDialog/QCMakeCacheView.cxx')
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index 7f3d40b..5505644 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -31,6 +31,25 @@
static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") };
+// filter for searches
+class QCMakeSearchFilter : public QSortFilterProxyModel
+{
+public:
+ QCMakeSearchFilter(QObject* o) : QSortFilterProxyModel(o) {}
+protected:
+ bool filterAcceptsRow(int row, const QModelIndex& p) const
+ {
+ // accept row if either column matches
+ QModelIndex idx0 = this->sourceModel()->index(row, 0, p);
+ QModelIndex idx1 = this->sourceModel()->index(row, 1, p);
+ QString str0 = this->sourceModel()->data(idx0).toString();
+ QString str1 = this->sourceModel()->data(idx1).toString();
+
+ return str0.contains(this->filterRegExp()) ||
+ str1.contains(this->filterRegExp());
+ }
+};
+
QCMakeCacheView::QCMakeCacheView(QWidget* p)
: QTableView(p), Init(false)
{
@@ -41,12 +60,9 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p)
this->AdvancedFilter->setFilterRole(QCMakeCacheModel::AdvancedRole);
this->AdvancedFilter->setFilterRegExp(AdvancedRegExp[0]);
this->AdvancedFilter->setDynamicSortFilter(true);
- this->SearchFilter = new QSortFilterProxyModel(this);
+ this->SearchFilter = new QCMakeSearchFilter(this);
this->SearchFilter->setSourceModel(this->AdvancedFilter);
this->SearchFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
-#if QT_VERSION >= 0x040300 // breaks search in Qt 4.2
- this->SearchFilter->setFilterKeyColumn(-1); // all columns
-#endif
this->SearchFilter->setDynamicSortFilter(true);
this->setModel(this->SearchFilter);