QAdvanced Item View  0.4
The QAIV (Qt Advanced Item Views) library provides GUI and utility classes extending the capabilities of the Qt item views.
 All Classes Functions Variables Enumerations Enumerator Properties Groups Pages
qabstractfiltermodel.h
1 /******************************************************************************
2 ** This file is part of qadvanceditemviews.
3 **
4 ** Copyright (c) 2011-2012 Martin Hoppe martin@2x2hoppe.de
5 **
6 ** qadvanceditemviews is free software: you can redistribute it
7 ** and/or modify it under the terms of the GNU Lesser General
8 ** Public License as published by the Free Software Foundation,
9 ** either version 3 of the License, or (at your option) any
10 ** later version.
11 **
12 ** qadvanceditemviews is distributed in the hope that it will be
13 ** useful, but WITHOUT ANY WARRANTY; without even the implied
14 ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 ** See the GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with qadvanceditemviews.
19 ** If not, see <http://www.gnu.org/licenses/>.
20 ******************************************************************************/
21 #ifndef QABSTRACTFILTERMODEL_H
22 #define QABSTRACTFILTERMODEL_H
23 
24 #include <QAbstractItemModel>
25 #include <QAction>
26 #include <QMenu>
27 
28 #include <qaiv.h>
29 #include <qaivlib_global.h>
30 
32 class QAbstractFilter;
33 class QFilterGroup;
34 
35 class QAbstractFilterModelPrivate;
36 
38 
41 class QAIVLIBSHARED_EXPORT QAbstractFilterModel : public QAbstractItemModel
42 {
43  Q_OBJECT
44 public:
45  struct FilterTypeEntry {
46  int type;
47  QIcon icon;
48  QString text;
49  QString tooltip;
50  };
54  enum ItemDataRole {
55  ValueFilterTypeRole = Qt::UserRole + 42
56  ,DefaultFilterTypeRole
57  ,ColumnFilterTypesRole
58  };
62  QAbstractFilterModel(QObject* parent = 0);
71  int columnCount(const QModelIndex & parent = QModelIndex()) const;
75  virtual QAbstractFilter* createFilter(const QModelIndex & index, const QVariantMap & properties) const = 0;
82  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
86  QFilterGroup* filterGroup(const QModelIndex & index) const;
90  QFilterGroup* groupAt(int row) const;
94  QAbstractFilter* filter(const QModelIndex & index) const;
95  QIcon filterDisabledIcon() const;
96  QIcon filterEnabledIcon() const;
97  QList<QAbstractFilter*> filtersAtRow(int row) const;
101  Qt::ItemFlags flags(const QModelIndex & index) const;
102 
103  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
104 
105  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
106 
107  bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
108 
109  QAdvancedItemViews::FilterMatchMode matchMode() const;
110 
115  QModelIndex parent(const QModelIndex & index) const;
119  QList<FilterTypeEntry> registeredFilterTypes() const;
120 
121  bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
122 
123  int rowCount( const QModelIndex & parent = QModelIndex() ) const;
124 
125  bool setData( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
129  void setDefaultFilterType(int column, int type);
130  void setFilterDisabledIcon(const QIcon & icon);
131  void setFilterEnabledIcon(const QIcon & icon);
132  bool setHeaderData (int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole);
133 
134  void setMatchMode(QAdvancedItemViews::FilterMatchMode flag);
135 
136  void setMode(QAdvancedItemViews::FilterProxyMode mode);
141  void setSourceModel(QAbstractItemModel* model);
145  QAbstractItemModel* sourceModel() const;
146 signals:
147  void matchModeChanged(QAdvancedItemViews::FilterMatchMode mode);
148  void modeChanged(QAdvancedItemViews::FilterProxyMode mode);
149 protected:
153  bool registerFilter(int type, const QString & text, const QString & toolTip = QString());
157  bool registerFilter(int type, const QIcon & icon, const QString & text, const QString & toolTip = QString());
158 private slots:
159  void sourceModelLayoutChanged();
160 private:
161  QAbstractFilterModelPrivate* d;
162 };
163 
164 #endif // QABSTRACTFILTERMODEL_H
The QAbstractFilterProxyModel provides an abstract base class for filter models.
Definition: qabstractfilterproxymodel.h:32
Definition: qabstractfiltermodel.h:45
The QAbstractFilterModel class provides the abstract interface for filter model classes.
Definition: qabstractfiltermodel.h:41
The QFilterGroup class groups filter definitions.
Definition: qfiltergroup.h:31
The QAbstractFilter class provides a base class for filter definitions used with a QAdvancedTableView...
Definition: qabstractfilter.h:41
FilterProxyMode
This enum describes the modes of a filter proxy.
Definition: qaiv.h:79
FilterMatchMode
This enumj describes the filter match mode.
Definition: qaiv.h:84
ItemDataRole
Definition: qabstractfiltermodel.h:54