OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
nestedtableproxymodel.hpp
Go to the documentation of this file.
1 #ifndef CSM_WOLRD_NESTEDTABLEPROXYMODEL_H
2 #define CSM_WOLRD_NESTEDTABLEPROXYMODEL_H
3 
4 #include <vector>
5 
6 #include <QAbstractProxyModel>
7 
8 #include "universalid.hpp"
9 #include "columns.hpp"
10 #include "columnbase.hpp"
11 
16 namespace CSMWorld
17 {
18  class CollectionBase;
19  struct RecordBase;
20  class IdTree;
21 
23  {
24  Q_OBJECT
25 
26  const int mParentColumn;
28  std::string mId;
29 
30  public:
31  NestedTableProxyModel(const QModelIndex& parent,
32  ColumnBase::Display displayType,
33  IdTree* parentModel);
34  //parent is the parent of columns to work with. Columnid provides information about the column
35 
36  std::string getParentId() const;
37 
38  int getParentColumn() const;
39 
40  CSMWorld::IdTree* model() const;
41 
42  virtual QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
43 
44  virtual QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
45 
46  virtual int rowCount(const QModelIndex& parent) const;
47 
48  virtual int columnCount(const QModelIndex& parent) const;
49 
50  virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
51 
52  virtual QModelIndex parent(const QModelIndex& index) const;
53 
54  virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const;
55 
56  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
57 
58  virtual bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
59 
60  virtual Qt::ItemFlags flags(const QModelIndex& index) const;
61 
62  private:
64 
65  bool indexIsParent(const QModelIndex& index);
66 
67  private slots:
68  void forwardRowsAboutToInserted(const QModelIndex & parent, int first, int last);
69 
70  void forwardRowsInserted(const QModelIndex & parent, int first, int last);
71 
72  void forwardRowsAboutToRemoved(const QModelIndex & parent, int first, int last);
73 
74  void forwardRowsRemoved(const QModelIndex & parent, int first, int last);
75 
76  void forwardResetStart(const QString& id);
77 
78  void forwardResetEnd(const QString& id);
79 
80  void forwardDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
81  };
82 }
83 
84 #endif
int getParentColumn() const
Definition: nestedtableproxymodel.cpp:122
virtual int rowCount(const QModelIndex &parent) const
Definition: nestedtableproxymodel.cpp:60
NestedTableProxyModel(const QModelIndex &parent, ColumnBase::Display displayType, IdTree *parentModel)
Definition: nestedtableproxymodel.cpp:6
void forwardRowsInserted(const QModelIndex &parent, int first, int last)
Definition: nestedtableproxymodel.cpp:141
void forwardRowsAboutToRemoved(const QModelIndex &parent, int first, int last)
Definition: nestedtableproxymodel.cpp:156
Display
Definition: columnbase.hpp:39
virtual QModelIndex parent(const QModelIndex &index) const
Definition: nestedtableproxymodel.cpp:87
std::string mId
Definition: nestedtableproxymodel.hpp:28
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: nestedtableproxymodel.cpp:99
void forwardDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: nestedtableproxymodel.cpp:185
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: nestedtableproxymodel.cpp:74
CSMWorld::IdTree * model() const
Definition: nestedtableproxymodel.cpp:127
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: nestedtableproxymodel.cpp:107
void forwardResetEnd(const QString &id)
Definition: nestedtableproxymodel.cpp:179
std::string getParentId() const
Definition: nestedtableproxymodel.cpp:117
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: nestedtableproxymodel.cpp:92
Definition: nestedtableproxymodel.hpp:22
void forwardResetStart(const QString &id)
Definition: nestedtableproxymodel.cpp:173
const int mParentColumn
Definition: nestedtableproxymodel.hpp:26
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Definition: nestedtableproxymodel.cpp:112
IdTree * mMainModel
Definition: nestedtableproxymodel.hpp:27
void setupHeaderVectors(ColumnBase::Display columnId)
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
Definition: nestedtableproxymodel.cpp:54
bool indexIsParent(const QModelIndex &index)
Definition: nestedtableproxymodel.cpp:149
Definition: idtree.hpp:25
virtual int columnCount(const QModelIndex &parent) const
Definition: nestedtableproxymodel.cpp:67
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
Definition: nestedtableproxymodel.cpp:40
void forwardRowsRemoved(const QModelIndex &parent, int first, int last)
Definition: nestedtableproxymodel.cpp:165
void forwardRowsAboutToInserted(const QModelIndex &parent, int first, int last)
Definition: nestedtableproxymodel.cpp:132