OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
refidcollection.hpp
Go to the documentation of this file.
1 #ifndef CSM_WOLRD_REFIDCOLLECTION_H
2 #define CSM_WOLRD_REFIDCOLLECTION_H
3 
4 #include <vector>
5 #include <map>
6 #include <deque>
7 
8 #include "columnbase.hpp"
9 #include "collectionbase.hpp"
10 #include "nestedcollection.hpp"
11 #include "refiddata.hpp"
12 
13 namespace ESM
14 {
15  class ESMWriter;
16 }
17 
18 namespace CSMWorld
19 {
20  class RefIdAdapter;
21  struct NestedTableWrapperBase;
22  class NestedRefIdAdapterBase;
23 
24  class RefIdColumn : public NestableColumn
25  {
26  bool mEditable;
28 
29  public:
30 
31  RefIdColumn (int columnId, Display displayType,
32  int flag = Flag_Table | Flag_Dialogue, bool editable = true,
33  bool userEditable = true);
34 
35  virtual bool isEditable() const;
36 
37  virtual bool isUserEditable() const;
38  };
39 
41  {
42  private:
43 
45  std::deque<RefIdColumn> mColumns;
46  std::map<UniversalId::Type, RefIdAdapter *> mAdapters;
47 
48  std::vector<std::pair<const ColumnBase*, std::map<UniversalId::Type, NestedRefIdAdapterBase*> > > mNestedAdapters;
49 
50  private:
51 
54 
55  const NestedRefIdAdapterBase& getNestedAdapter(const ColumnBase &column, UniversalId::Type type) const;
56 
57  public:
58 
60 
61  virtual ~RefIdCollection();
62 
63  virtual int getSize() const;
64 
65  virtual std::string getId (int index) const;
66 
67  virtual int getIndex (const std::string& id) const;
68 
69  virtual int getColumns() const;
70 
71  virtual const ColumnBase& getColumn (int column) const;
72 
73  virtual QVariant getData (int index, int column) const;
74 
75  virtual void setData (int index, int column, const QVariant& data);
76 
77  virtual void removeRows (int index, int count);
78 
79  virtual void cloneRecord(const std::string& origin,
80  const std::string& destination,
81  const UniversalId::Type type);
82 
83  virtual void appendBlankRecord (const std::string& id, UniversalId::Type type);
85 
86  virtual int searchId (const std::string& id) const;
89 
90  virtual void replace (int index, const RecordBase& record);
94 
95  virtual void appendRecord (const RecordBase& record, UniversalId::Type type);
99 
100  virtual const RecordBase& getRecord (const std::string& id) const;
101 
102  virtual const RecordBase& getRecord (int index) const;
103 
104  void load (ESM::ESMReader& reader, bool base, UniversalId::Type type);
105 
106  virtual int getAppendIndex (const std::string& id, UniversalId::Type type) const;
108 
109  virtual std::vector<std::string> getIds (bool listDeleted) const;
113 
114  virtual bool reorderRows (int baseIndex, const std::vector<int>& newOrder);
119 
120  virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const;
121 
122  virtual NestedTableWrapperBase* nestedTable(int row, int column) const;
123 
124  virtual void setNestedTable(int row, int column, const NestedTableWrapperBase& nestedTable);
125 
126  virtual int getNestedRowsCount(int row, int column) const;
127 
128  virtual int getNestedColumnsCount(int row, int column) const;
129 
130  NestableColumn *getNestableColumn(int column);
131 
132  virtual void setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn);
133 
134  virtual void removeNestedRows(int row, int column, int subRow);
135 
136  virtual void addNestedRow(int row, int col, int position);
137 
138  void save (int index, ESM::ESMWriter& writer) const;
139 
140  const RefIdData& getDataSet() const; //I can't figure out a better name for this one :(
141  void copyTo (int index, RefIdCollection& target) const;
142  };
143 }
144 
145 #endif
Definition: nestedtablewrapper.hpp:6
std::deque< RefIdColumn > mColumns
Definition: refidcollection.hpp:45
virtual QVariant getData(int index, int column) const
Definition: refidcollection.cpp:741
virtual void replace(int index, const RecordBase &record)
Definition: refidcollection.cpp:805
virtual void removeRows(int index, int count)
< Merge modified into base.
Definition: refidcollection.cpp:776
Definition: esmreader.hpp:21
Definition: columnbase.hpp:167
void load(ESM::ESMReader &reader, bool base, UniversalId::Type type)
Definition: refidcollection.cpp:841
virtual int getNestedColumnsCount(int row, int column) const
Definition: refidcollection.cpp:879
Display
Definition: columnbase.hpp:39
const RefIdData & getDataSet() const
Definition: refidcollection.cpp:866
Type
Definition: universalid.hpp:40
NestableColumn * getNestableColumn(int column)
Definition: refidcollection.cpp:887
virtual int getColumns() const
Definition: refidcollection.cpp:731
virtual void cloneRecord(const std::string &origin, const std::string &destination, const UniversalId::Type type)
Definition: refidcollection.cpp:810
Definition: refiddata.hpp:219
RefIdColumn(int columnId, Display displayType, int flag=Flag_Table|Flag_Dialogue, bool editable=true, bool userEditable=true)
Definition: refidcollection.cpp:14
Definition: columnbase.hpp:33
virtual void appendBlankRecord(const std::string &id, UniversalId::Type type)
Definition: refidcollection.cpp:790
virtual bool isEditable() const
Definition: refidcollection.cpp:19
virtual int searchId(const std::string &id) const
Definition: refidcollection.cpp:795
virtual NestedTableWrapperBase * nestedTable(int row, int column) const
Definition: refidcollection.cpp:910
virtual int getIndex(const std::string &id) const
Definition: refidcollection.cpp:721
Definition: refidadapter.hpp:24
virtual int getNestedRowsCount(int row, int column) const
Definition: refidcollection.cpp:871
virtual int getSize() const
Definition: refidcollection.cpp:711
Definition: esmwriter.hpp:17
RefIdCollection()
Definition: refidcollection.cpp:39
Definition: refidcollection.hpp:24
virtual void setData(int index, int column, const QVariant &data)
Definition: refidcollection.cpp:758
virtual void removeNestedRows(int row, int column, int subRow)
Definition: refidcollection.cpp:781
virtual void setNestedTable(int row, int column, const NestedTableWrapperBase &nestedTable)
Definition: refidcollection.cpp:901
virtual std::vector< std::string > getIds(bool listDeleted) const
Definition: refidcollection.cpp:851
const RefIdAdapter & findAdapter(UniversalId::Type) const
Throws an exception if no adaptor for Type can be found.
Definition: refidcollection.cpp:29
virtual bool reorderRows(int baseIndex, const std::vector< int > &newOrder)
Definition: refidcollection.cpp:856
virtual int getAppendIndex(const std::string &id, UniversalId::Type type) const
Definition: refidcollection.cpp:846
virtual void addNestedRow(int row, int col, int position)
Definition: refidcollection.cpp:892
virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const
Definition: refidcollection.cpp:750
Definition: refidcollection.hpp:40
void save(int index, ESM::ESMWriter &writer) const
Definition: refidcollection.cpp:861
void copyTo(int index, RefIdCollection &target) const
Definition: refidcollection.cpp:937
std::vector< std::pair< const ColumnBase *, std::map< UniversalId::Type, NestedRefIdAdapterBase * > > > mNestedAdapters
Definition: refidcollection.hpp:48
virtual std::string getId(int index) const
Definition: refidcollection.cpp:716
Definition: columnbase.hpp:15
Base class for record collections.
Definition: collectionbase.hpp:23
const NestedRefIdAdapterBase & getNestedAdapter(const ColumnBase &column, UniversalId::Type type) const
Definition: refidcollection.cpp:918
virtual const ColumnBase & getColumn(int column) const
Definition: refidcollection.cpp:736
RefIdData mData
Definition: refidcollection.hpp:44
Definition: record.hpp:8
virtual bool isUserEditable() const
Can this column be edited directly by the user?
Definition: refidcollection.cpp:24
virtual ~RefIdCollection()
Definition: refidcollection.cpp:696
std::map< UniversalId::Type, RefIdAdapter * > mAdapters
Definition: refidcollection.hpp:46
virtual void setNestedData(int row, int column, const QVariant &data, int subRow, int subColumn)
Definition: refidcollection.cpp:767
Definition: columnbase.hpp:34
virtual void appendRecord(const RecordBase &record, UniversalId::Type type)
Definition: refidcollection.cpp:819
virtual const RecordBase & getRecord(const std::string &id) const
Definition: refidcollection.cpp:831
Definition: refidadapter.hpp:49
Definition: nestedcollection.hpp:13
bool mUserEditable
Definition: refidcollection.hpp:27
bool mEditable
Definition: refidcollection.hpp:26