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
qabstractfilter.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 QABSTRACTFILTER_H
22 #define QABSTRACTFILTER_H
23 
24 #include <QMap>
25 #include <QMenu>
26 #include <QStyleOptionViewItem>
27 #include <QVariant>
28 
29 #include <qaivlib_global.h>
30 
31 class QFilterGroup;
33 class QAbstractFilterPrivate;
34 
36 
41 class QAIVLIBSHARED_EXPORT QAbstractFilter
42 {
43 public:
55  static const int UserType = 65536;
56  enum {
57  Type = -1
58  };
66  QAbstractFilter(const QMap<QString,QVariant> & properties);
70  ~QAbstractFilter();
74  int column() const;
80  virtual void addContextMenuActions(QMenu *menu, QWidget *receiver);
85  virtual QWidget* createEditor(QFilterViewItemDelegate* delegate, QWidget* parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const = 0;
89  virtual QVariant data(int role = Qt::DisplayRole) const = 0;
93  QColor highlightColor() const;
98  bool isEnabled() const;
102  bool isValid() const;
106  virtual bool matches(const QVariant & value, int type = -1) const = 0;
110  QVariant property(const QString & key, const QVariant & defaultValue = QVariant()) const;
114  QMap<QString,QVariant> properties() const;
118  int row() const;
122  virtual void setEditorData(QWidget * editor, const QModelIndex & index) = 0;
127  void setHighlightColor(const QColor & color);
128 
129  virtual void setModelData(QWidget* editor, QAbstractItemModel * model, const QModelIndex & index) = 0;
134  void setEnabled( bool on );
138  void setProperty(const QString & name, const QVariant & value);
142  int type() const;
143 
144  virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem & option, const QModelIndex & index) = 0;
145 protected:
149  QAbstractFilter(int type, int row, int column);
150 private:
151  friend class QAbstractFilterModel;
152  void setRow(int row);
153 
154  QAbstractFilterPrivate* d;
155 };
156 
162 template <class T> inline T qfilter_cast(QAbstractFilter* filter)
163 {
164  return int(static_cast<T>(0)->Type) == int(QAbstractFilter::Type)
165  || (filter && int(static_cast<T>(0)->Type) == filter->type()) ? static_cast<T>(filter) : 0;
166 }
167 
173 template <class T> inline T qfilter_cast(const QAbstractFilter* filter)
174 {
175  return int(static_cast<T>(0)->Type) == int(QAbstractFilter::Type)
176  || (filter && int(static_cast<T>(0)->Type) == filter->type()) ? static_cast<T>(filter) : 0;
177 }
178 
179 #endif // QABSTRACTFILTER_H
T qfilter_cast(QAbstractFilter *filter)
Definition: qabstractfilter.h:162
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
int type() const
Definition: qabstractfilter.cpp:150
QAbstractFilter * filter(const QModelIndex &index) const
Definition: qabstractfiltermodel.cpp:128
The QFilterViewItemDelegate class provides display and editing facilities for filter from a filter mo...
Definition: qfilterviewitemdelegate.h:30