2012-11-26 11:29:22 +00:00
|
|
|
#ifndef CSM_WOLRD_IDTABLE_H
|
|
|
|
#define CSM_WOLRD_IDTABLE_H
|
|
|
|
|
2013-11-14 10:39:14 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
#include "idtablebase.hpp"
|
2013-07-30 08:27:17 +00:00
|
|
|
#include "universalid.hpp"
|
2013-08-08 10:49:30 +00:00
|
|
|
#include "columns.hpp"
|
2013-07-30 08:27:17 +00:00
|
|
|
|
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
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
class IdTable : public IdTableBase
|
2012-11-26 11:29:22 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2013-11-14 10:39:14 +00:00
|
|
|
private:
|
|
|
|
|
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:
|
|
|
|
|
2014-06-05 08:28:10 +00:00
|
|
|
IdTable (CollectionBase *idCollection, unsigned int features = 0);
|
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
|
|
|
|
2014-03-02 21:43:44 +00:00
|
|
|
void cloneRecord(const std::string& origin,
|
|
|
|
const std::string& destination,
|
2014-01-20 12:59:00 +00:00
|
|
|
UniversalId::Type type = UniversalId::Type_None);
|
2014-01-27 18:40:05 +00:00
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
virtual 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;
|
2013-08-08 10:49:30 +00:00
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
virtual int searchColumnIndex (Columns::ColumnId id) const;
|
2013-08-08 10:49:30 +00:00
|
|
|
///< Return index of column with the given \a id. If no such column exists, -1 is returned.
|
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
virtual int findColumnIndex (Columns::ColumnId id) const;
|
2013-08-08 10:49:30 +00:00
|
|
|
///< Return index of column with the given \a id. If no such column exists, an exception is
|
|
|
|
/// thrown.
|
2013-11-14 10:39:14 +00:00
|
|
|
|
|
|
|
void reorderRows (int baseIndex, const std::vector<int>& newOrder);
|
|
|
|
///< Reorder the rows [baseIndex, baseIndex+newOrder.size()) according to the indices
|
|
|
|
/// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex).
|
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
virtual std::pair<UniversalId, std::string> view (int row) const;
|
2014-03-02 21:43:44 +00:00
|
|
|
///< Return the UniversalId and the hint for viewing \a row. If viewing is not
|
|
|
|
/// supported by this table, return (UniversalId::Type_None, "").
|
2014-03-08 14:27:43 +00:00
|
|
|
|
2014-07-04 11:24:35 +00:00
|
|
|
/// Is \a id flagged as deleted?
|
|
|
|
virtual bool isDeleted (const std::string& id) const;
|
|
|
|
|
2014-03-08 14:27:43 +00:00
|
|
|
int getColumnId(int column) const;
|
2012-11-26 11:29:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|