OpenMW
apps/opencs/model/world/refidcollection.hpp
Go to the documentation of this file.
00001 #ifndef CSM_WOLRD_REFIDCOLLECTION_H
00002 #define CSM_WOLRD_REFIDCOLLECTION_H
00003 
00004 #include <vector>
00005 #include <map>
00006 #include <deque>
00007 
00008 #include "columnbase.hpp"
00009 #include "collectionbase.hpp"
00010 #include "refiddata.hpp"
00011 
00012 namespace ESM
00013 {
00014     class ESMWriter;
00015 }
00016 
00017 namespace CSMWorld
00018 {
00019     class RefIdAdapter;
00020 
00021     class RefIdColumn : public ColumnBase
00022     {
00023             bool mEditable;
00024             bool mUserEditable;
00025 
00026         public:
00027 
00028             RefIdColumn (int columnId, Display displayType,
00029                 int flag = Flag_Table | Flag_Dialogue, bool editable = true,
00030                 bool userEditable = true);
00031 
00032             virtual bool isEditable() const;
00033 
00034             virtual bool isUserEditable() const;
00035     };
00036 
00037     class RefIdCollection : public CollectionBase
00038     {
00039         private:
00040 
00041             RefIdData mData;
00042             std::deque<RefIdColumn> mColumns;
00043             std::map<UniversalId::Type, RefIdAdapter *> mAdapters;
00044 
00045         private:
00046 
00047             const RefIdAdapter& findAdaptor (UniversalId::Type) const;
00049 
00050         public:
00051 
00052             RefIdCollection();
00053 
00054             virtual ~RefIdCollection();
00055 
00056             virtual int getSize() const;
00057 
00058             virtual std::string getId (int index) const;
00059 
00060             virtual int getIndex (const std::string& id) const;
00061 
00062             virtual int getColumns() const;
00063 
00064             virtual const ColumnBase& getColumn (int column) const;
00065 
00066             virtual QVariant getData (int index, int column) const;
00067 
00068             virtual void setData (int index, int column, const QVariant& data);
00069 
00070             virtual void removeRows (int index, int count);
00071 
00072             virtual void appendBlankRecord (const std::string& id, UniversalId::Type type);
00074 
00075             virtual int searchId (const std::string& id) const;
00078 
00079             virtual void replace (int index, const RecordBase& record);
00083 
00084             virtual void appendRecord (const RecordBase& record, UniversalId::Type type);
00088 
00089             virtual const RecordBase& getRecord (const std::string& id) const;
00090 
00091             virtual const RecordBase& getRecord (int index) const;
00092 
00093             void load (ESM::ESMReader& reader, bool base, UniversalId::Type type);
00094 
00095             virtual int getAppendIndex (const std::string& id, UniversalId::Type type) const;
00097 
00098             virtual std::vector<std::string> getIds (bool listDeleted) const;
00102 
00103             virtual bool reorderRows (int baseIndex, const std::vector<int>& newOrder);
00108 
00109             void save (int index, ESM::ESMWriter& writer) const;
00110     };
00111 }
00112 
00113 #endif