OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
idtable.hpp
Go to the documentation of this file.
1 #ifndef CSM_WOLRD_IDTABLE_H
2 #define CSM_WOLRD_IDTABLE_H
3 
4 #include <vector>
5 
6 #include "idtablebase.hpp"
7 #include "universalid.hpp"
8 #include "columns.hpp"
9 
10 namespace CSMWorld
11 {
12  class CollectionBase;
13  struct RecordBase;
14 
15  class IdTable : public IdTableBase
16  {
17  Q_OBJECT
18 
19  private:
20 
22 
23  // not implemented
24  IdTable (const IdTable&);
25  IdTable& operator= (const IdTable&);
26 
27  public:
28 
29  IdTable (CollectionBase *idCollection, unsigned int features = 0);
31 
32  virtual ~IdTable();
33 
34  virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;
35 
36  virtual int columnCount (const QModelIndex & parent = QModelIndex()) const;
37 
38  virtual QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
39 
40  virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
41 
42  virtual bool setData ( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
43 
44  virtual Qt::ItemFlags flags (const QModelIndex & index) const;
45 
46  virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
47 
48  virtual QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex())
49  const;
50 
51  virtual QModelIndex parent (const QModelIndex& index) const;
52 
53  void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
55 
56  void addRecordWithData (const std::string& id, const std::map<int, QVariant>& data,
59 
60  void cloneRecord(const std::string& origin,
61  const std::string& destination,
63 
64  virtual QModelIndex getModelIndex (const std::string& id, int column) const;
65 
66  void setRecord (const std::string& id, const RecordBase& record,
69 
70  const RecordBase& getRecord (const std::string& id) const;
71 
72  virtual int searchColumnIndex (Columns::ColumnId id) const;
74 
75  virtual int findColumnIndex (Columns::ColumnId id) const;
78 
79  void reorderRows (int baseIndex, const std::vector<int>& newOrder);
82 
83  virtual std::pair<UniversalId, std::string> view (int row) const;
86 
88  virtual bool isDeleted (const std::string& id) const;
89 
90  virtual int getColumnId(int column) const;
91 
92  protected:
93 
94  virtual CollectionBase *idCollection() const;
95  };
96 }
97 
98 #endif
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Definition: idtable.cpp:97
CollectionBase * mIdCollection
Definition: idtable.hpp:21
void setRecord(const std::string &id, const RecordBase &record, UniversalId::Type type=UniversalId::Type_None)
Add record or overwrite existing record.
Definition: idtable.cpp:188
virtual QModelIndex getModelIndex(const std::string &id, int column) const
This method can return only indexes to the top level table cells.
Definition: idtable.cpp:183
Definition: idtable.hpp:15
virtual int searchColumnIndex(Columns::ColumnId id) const
Return index of column with the given id. If no such column exists, -1 is returned.
Definition: idtable.cpp:215
virtual QModelIndex parent(const QModelIndex &index) const
Definition: idtable.cpp:138
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: idtable.cpp:33
virtual int getColumnId(int column) const
Definition: idtable.cpp:275
void reorderRows(int baseIndex, const std::vector< int > &newOrder)
Definition: idtable.cpp:225
Type
Definition: universalid.hpp:40
IdTable(const IdTable &)
IdTable & operator=(const IdTable &)
void cloneRecord(const std::string &origin, const std::string &destination, UniversalId::Type type=UniversalId::Type_None)
Definition: idtable.cpp:171
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: idtable.cpp:53
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: idtable.cpp:124
virtual ~IdTable()
Definition: idtable.cpp:14
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: idtable.cpp:76
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Definition: idtable.cpp:110
const RecordBase & getRecord(const std::string &id) const
Definition: idtable.cpp:210
Base class for record collections.
Definition: collectionbase.hpp:23
virtual int findColumnIndex(Columns::ColumnId id) const
Definition: idtable.cpp:220
Definition: record.hpp:8
ColumnId
Definition: columns.hpp:13
virtual CollectionBase * idCollection() const
Definition: idtable.cpp:280
Definition: idtablebase.hpp:12
Definition: universalid.hpp:42
virtual std::pair< UniversalId, std::string > view(int row) const
Definition: idtable.cpp:233
virtual bool isDeleted(const std::string &id) const
Is id flagged as deleted?
Definition: idtable.cpp:270
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: idtable.cpp:25
void addRecord(const std::string &id, UniversalId::Type type=UniversalId::Type_None)
Definition: idtable.cpp:143
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: idtable.cpp:17
void addRecordWithData(const std::string &id, const std::map< int, QVariant > &data, UniversalId::Type type=UniversalId::Type_None)
Definition: idtable.cpp:154