2012-11-26 11:29:22 +00:00
|
|
|
#ifndef CSM_WOLRD_IDTABLE_H
|
|
|
|
#define CSM_WOLRD_IDTABLE_H
|
|
|
|
|
2013-03-21 09:07:25 +00:00
|
|
|
#include <QAbstractItemModel>
|
2012-11-26 11:29:22 +00:00
|
|
|
|
2013-07-30 08:27:17 +00:00
|
|
|
#include "universalid.hpp"
|
|
|
|
|
2012-11-26 11:29:22 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2013-06-17 09:42:02 +00:00
|
|
|
class CollectionBase;
|
2012-12-06 13:56:04 +00:00
|
|
|
class RecordBase;
|
2012-11-26 11:29:22 +00:00
|
|
|
|
2013-03-21 09:07:25 +00:00
|
|
|
class IdTable : public QAbstractItemModel
|
2012-11-26 11:29:22 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2013-06-17 09:42:02 +00:00
|
|
|
CollectionBase *mIdCollection;
|
2012-11-26 11:29:22 +00:00
|
|
|
|
|
|
|
// not implemented
|
|
|
|
IdTable (const IdTable&);
|
|
|
|
IdTable& operator= (const IdTable&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-06-17 09:42:02 +00:00
|
|
|
IdTable (CollectionBase *idCollection);
|
2012-11-26 11:29:22 +00:00
|
|
|
///< The ownership of \a idCollection is not transferred.
|
|
|
|
|
|
|
|
virtual ~IdTable();
|
|
|
|
|
2012-12-03 20:44:16 +00:00
|
|
|
virtual int rowCount (const QModelIndex & parent = QModelIndex()) const;
|
2012-11-26 11:29:22 +00:00
|
|
|
|
2012-12-03 20:44:16 +00:00
|
|
|
virtual int columnCount (const QModelIndex & parent = QModelIndex()) const;
|
2012-11-26 11:29:22 +00:00
|
|
|
|
2012-12-03 20:44:16 +00:00
|
|
|
virtual QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
|
2012-11-26 11:29:22 +00:00
|
|
|
|
2012-12-03 20:44:16 +00:00
|
|
|
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
2012-11-29 13:45:34 +00:00
|
|
|
|
2012-12-03 20:44:16 +00:00
|
|
|
virtual bool setData ( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
2012-11-29 13:45:34 +00:00
|
|
|
|
2012-12-03 20:44:16 +00:00
|
|
|
virtual Qt::ItemFlags flags (const QModelIndex & index) const;
|
|
|
|
|
|
|
|
virtual bool removeRows (int row, int count, const QModelIndex& parent = QModelIndex());
|
|
|
|
|
2013-03-21 09:07:25 +00:00
|
|
|
virtual QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex())
|
|
|
|
const;
|
|
|
|
|
|
|
|
virtual QModelIndex parent (const QModelIndex& index) const;
|
|
|
|
|
2013-07-30 08:27:17 +00:00
|
|
|
void addRecord (const std::string& id, UniversalId::Type type = UniversalId::Type_None);
|
|
|
|
///< \param type Will be ignored, unless the collection supports multiple record types
|
2012-12-03 20:44:16 +00:00
|
|
|
|
|
|
|
QModelIndex getModelIndex (const std::string& id, int column) const;
|
2012-12-06 13:56:04 +00:00
|
|
|
|
2013-04-29 15:52:01 +00:00
|
|
|
void setRecord (const std::string& id, const RecordBase& record);
|
2012-12-06 13:56:04 +00:00
|
|
|
///< Add record or overwrite existing recrod.
|
|
|
|
|
|
|
|
const RecordBase& getRecord (const std::string& id) const;
|
2012-11-26 11:29:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|