OpenMW
apps/opencs/model/world/idtable.hpp
Go to the documentation of this file.
00001 #ifndef CSM_WOLRD_IDTABLE_H
00002 #define CSM_WOLRD_IDTABLE_H
00003 
00004 #include <vector>
00005 
00006 #include <QAbstractItemModel>
00007 
00008 #include "universalid.hpp"
00009 #include "columns.hpp"
00010 
00011 namespace CSMWorld
00012 {
00013     class CollectionBase;
00014     class RecordBase;
00015 
00016     class IdTable : public QAbstractItemModel
00017     {
00018             Q_OBJECT
00019 
00020         public:
00021 
00022             enum Reordering
00023             {
00024                 Reordering_None,
00025                 Reordering_WithinTopic
00026             };
00027 
00028         private:
00029 
00030             CollectionBase *mIdCollection;
00031             Reordering mReordering;
00032 
00033             // not implemented
00034             IdTable (const IdTable&);
00035             IdTable& operator= (const IdTable&);
00036 
00037         public:
00038 
00039             IdTable (CollectionBase *idCollection, Reordering reordering = Reordering_WithinTopic);
00041 
00042             virtual ~IdTable();
00043 
00044             virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;
00045 
00046             virtual int columnCount (const QModelIndex & parent = QModelIndex()) const;
00047 
00048             virtual QVariant data  (const QModelIndex & index, int role = Qt::DisplayRole) const;
00049 
00050             virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00051 
00052             virtual bool setData ( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00053 
00054             virtual Qt::ItemFlags flags (const QModelIndex & index) const;
00055 
00056             virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
00057 
00058             virtual QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex())
00059                 const;
00060 
00061             virtual QModelIndex parent (const QModelIndex& index) const;
00062 
00063             void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
00065 
00066             QModelIndex getModelIndex (const std::string& id, int column) const;
00067 
00068             void setRecord (const std::string& id, const RecordBase& record);
00070 
00071             const RecordBase& getRecord (const std::string& id) const;
00072 
00073             int searchColumnIndex (Columns::ColumnId id) const;
00075 
00076             int findColumnIndex (Columns::ColumnId id) const;
00079 
00080             void reorderRows (int baseIndex, const std::vector<int>& newOrder);
00083 
00084             Reordering getReordering() const;
00085     };
00086 }
00087 
00088 #endif