2014-07-05 13:50:47 +00:00
|
|
|
#ifndef CSM_WOLRD_RESOURCETABLE_H
|
|
|
|
#define CSM_WOLRD_RESOURCETABLE_H
|
|
|
|
|
|
|
|
#include "idtablebase.hpp"
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <QModelIndex>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include <apps/opencs/model/world/columns.hpp>
|
|
|
|
|
2014-07-05 13:50:47 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class Resources;
|
2022-10-19 17:02:00 +00:00
|
|
|
class UniversalId;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
|
|
|
class ResourceTable : public IdTableBase
|
|
|
|
{
|
|
|
|
const Resources* mResources;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// \note The feature Feature_Constant will be added implicitly.
|
|
|
|
ResourceTable(const Resources* resources, unsigned int features = 0);
|
|
|
|
|
2023-05-29 11:37:19 +00:00
|
|
|
~ResourceTable() override = default;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2021-05-19 00:53:55 +00:00
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex parent(const QModelIndex& index) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex getModelIndex(const std::string& id, int column) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
/// Return index of column with the given \a id. If no such column exists, -1 is
|
2014-07-05 13:50:47 +00:00
|
|
|
/// returned.
|
2020-10-16 18:18:54 +00:00
|
|
|
int searchColumnIndex(Columns::ColumnId id) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
|
|
|
/// Return index of column with the given \a id. If no such column exists, an
|
|
|
|
/// exception is thrown.
|
2020-10-16 18:18:54 +00:00
|
|
|
int findColumnIndex(Columns::ColumnId id) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
|
|
|
/// Return the UniversalId and the hint for viewing \a row. If viewing is not
|
|
|
|
/// supported by this table, return (UniversalId::Type_None, "").
|
2020-10-16 18:18:54 +00:00
|
|
|
std::pair<UniversalId, std::string> view(int row) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
|
|
|
/// Is \a id flagged as deleted?
|
2020-10-16 18:18:54 +00:00
|
|
|
bool isDeleted(const std::string& id) const override;
|
2014-07-05 13:50:47 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int getColumnId(int column) const override;
|
2015-03-29 13:28:11 +00:00
|
|
|
|
2017-08-19 07:43:31 +00:00
|
|
|
/// Signal Qt that the data is about to change.
|
|
|
|
void beginReset();
|
|
|
|
/// Signal Qt that the data has been changed.
|
|
|
|
void endReset();
|
2014-07-05 13:50:47 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|