From e07de4e0a1bd56aab8f4ee81d6db252e442c3d7a Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 13 Oct 2013 07:25:50 +0200 Subject: Add filter bar to MappingTreeWidget Move matchRecursive from ArchiveModel to SmTreeModel so we can use it here, too. --- mappingtreewidget.h | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'mappingtreewidget.h') diff --git a/mappingtreewidget.h b/mappingtreewidget.h index d72dffa..9fe5739 100644 --- a/mappingtreewidget.h +++ b/mappingtreewidget.h @@ -8,7 +8,8 @@ #ifndef MAPPINGTREEWIDGET_H #define MAPPINGTREEWIDGET_H -#include +#include +#include #include "smtreeview.h" @@ -16,9 +17,10 @@ class MappingTreeView; class MappingTreeModel; class QComboBox; class QCheckBox; -class QSortFilterProxyModel; class QStringListModel; class MappingTreeResultModel; +class QLineEdit; +class MappingTreeProxy; // defined in mappingtreemodel.h struct MappingData; @@ -44,6 +46,8 @@ class MappingTreeWidget : public QWidget { void editChild(); void selectionChanged(); void moveChild(); + void filter(); + void clearFilter(); signals: void mappingChanged(int); @@ -52,9 +56,12 @@ class MappingTreeWidget : public QWidget { const QModelIndex selected() const; MappingTreeView *mTree; MappingTreeModel *mModel; - QSortFilterProxyModel *mProxy; + MappingTreeProxy *mProxy; QStringListModel *mTypesModel; QComboBox *mTypeBox; + QLineEdit *mFilter; + QPushButton *mDoFilter; + QPushButton *mClearFilter; QPushButton *mAddType; QPushButton *mDeleteType; QAction *mAddChildA; @@ -124,4 +131,19 @@ class MappingEditDialog : public QDialog { QPushButton *mCancel; }; +class MappingTreeProxy : public QSortFilterProxyModel { + Q_OBJECT + public: + explicit MappingTreeProxy(QObject *parent = 0); + + public slots: + void setFilter(const QString &filter); + + protected: + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + + private: + QRegExp mFilter; +}; + #endif // MAPPINGTREEWIDGET_H -- cgit v1.2.3-70-g09d2