Quark  0.1
AbstractTableModelBase.h++
Go to the documentation of this file.
1 #ifndef __libquark_gui_AbstractTableModelBase_hxx
2 #define __libquark_gui_AbstractTableModelBase_hxx
3 
4 #include <QAbstractItemModel>
5 #include <QFlags>
6 #include <QVector>
7 
8 #include <quark/Field.h++>
9 #include <quark/Quark.h++>
10 
11 namespace quark {
12 namespace gui {
13 
20 class LIBQUARK_API AbstractTableModelBase : public QAbstractItemModel
21 {
22  Q_OBJECT;
23 
24  public:
25 
27  enum Option {
29  None = 0,
31  Sorted = 1 << 0,
33  ReverseSorted = 1 << 2
34  };
35 
36  Q_DECLARE_FLAGS(Options, Option);
37 
39  virtual ~AbstractTableModelBase();
40 
42  void setEditable(bool editable)
43  { _editable = editable; }
44 
46  bool isEditable() const
47  { return(_editable); }
48 
50  bool isSorted() const;
51 
53  int fieldCount() const;
54 
56  const Field& getField(int field) const;
57 
59  QString getFieldName(int field) const;
60 
62  static const int DescriptionRole;
63 
65  static const int SortRole;
66 
67  protected:
68 
70  AbstractTableModelBase(Options options = 0, QObject *parent = NULL);
71 
81  Field& addField(const QString &name);
82 
83  private:
84 
85  Options _options;
86  bool _editable;
87  QVector<Field> _fields;
88 };
89 
90 } // namespace gui
91 } // namespace quark
92 
93 Q_DECLARE_OPERATORS_FOR_FLAGS(quark::gui::AbstractTableModelBase::Options);
94 
95 #endif // __libquark_gui_AbstractTableModelBase_hxx
96 
97 
Option
Model options.
Definition: AbstractTableModelBase.h++:27
A class representing a field (a column) in a Quark table model.
Definition: Field.h++:17
void setEditable(bool editable)
Sets the editability of the model.
Definition: AbstractTableModelBase.h++:42
A non-parameterized abstract base class for Quark table models.
Definition: AbstractTableModelBase.h++:20
Definition: BarChartView.h++:6
static const int SortRole
An item&#39;s sort role.
Definition: AbstractTableModelBase.h++:65
Q_DECLARE_OPERATORS_FOR_FLAGS(quark::gui::AbstractTableModelBase::Options)
#define LIBQUARK_API
Definition: Quark.h++:18
static const int DescriptionRole
An item&#39;s description role.
Definition: AbstractTableModelBase.h++:62
bool isEditable() const
Tests the editability of the model.
Definition: AbstractTableModelBase.h++:46