Quark  0.1
BasicFilterTableModel.h++
Go to the documentation of this file.
1 
2 #ifndef __libquark_gui_BasicFilterTableModel_hxx
3 #define __libquark_gui_BasicFilterTableModel_hxx
4 
5 #include <QSortFilterProxyModel>
6 #include <QVariant>
7 
9 
10 namespace quark {
11 namespace gui {
12 
25 template<class T, class IS = QDataStream, class OS = QDataStream>
26 class BasicFilterTableModel : public QSortFilterProxyModel
27 {
28  public:
29 
31  virtual ~BasicFilterTableModel();
32 
34  T* getItemForIndex(const QModelIndex &index) const;
35 
37  int itemCount() const;
38 
40  bool isEmpty() const;
41 
43  T *getItemAt(int row) const;
44 
46  void setEditable(bool editable);
47 
49  bool isEditable() const;
50 
53  { return(_sourceModel); }
54 
55  protected:
56 
59  QObject *parent = NULL);
60 
70  virtual bool filterAcceptsItem(const T &item) const;
71 
81  virtual bool filterAcceptsField(int field) const;
82 
93  virtual bool fieldLessThan(int field, const QVariant &value1,
94  const QVariant &value2) const;
95 
98  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
99 
100  virtual bool filterAcceptsRow(int sourceRow,
101  const QModelIndex &sourceParent) const;
102  virtual bool filterAcceptsColumn(int sourceColumn,
103  const QModelIndex &sourceParent) const;
104  bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
105 
106  AbstractTableModel<T, IS, OS> *_sourceModel;
107 
110  private:
111 
112  bool _editable;
113 };
114 
115 #include <quark/BasicFilterTableModelImpl.h++>
116 
117 } // namespace gui
118 } // namespace quark
119 
120 #endif // __libquark_gui_BasicFilterTableModel_hxx
BasicFilterTableModel(AbstractTableModel< T, IS, OS > *sourceModel, QObject *parent=NULL)
Constructs a new BasicFilterTableModel with the given source model.
bool isEmpty() const
Tests if this model is empty.
bool isEditable() const
Tests whether this model is editable.
int itemCount() const
Returns the number of (filtered) items in this model.
void setEditable(bool editable)
Sets the editability of this model.
T * getItemAt(int row) const
Returns the filtered item at the given row in this model.
Definition: BarChartView.h++:6
virtual bool fieldLessThan(int field, const QVariant &value1, const QVariant &value2) const
Compares the values of a given field of two items in the model, for the purpose of sorting...
An abstract base class for table data models, i.e., models in which every row represents an instance ...
Definition: AbstractTableModel.h++:40
virtual ~BasicFilterTableModel()
Destructor.
AbstractTableModel< T, IS, OS > * sourceModel() const
Returns this filter model&#39;s source model.
Definition: BasicFilterTableModel.h++:52
virtual bool filterAcceptsItem(const T &item) const
Called to test whether a given item in the model is accepted by this filter.
virtual bool filterAcceptsField(int field) const
Called to test whether a given field in the model is accepted by this filter.
T * getItemForIndex(const QModelIndex &index) const
Returns the filtered item at the given index in this model.
An abstract subclass of QSortFilterProxyModel for sorting and filtering of AbstractTableModels.
Definition: BasicFilterTableModel.h++:26