4namespace ehm_dal::column_data {
7namespace ehm_dal::database {
21namespace ehm_dal::schema {
59 virtual QVariant
childData(
const QModelIndex &index,
84 const QVariant &value,
86 std::vector<qint32> &modified_columns,
111 inline qint32
id()
const {
return id_; }
118 QVariant
id(
const qint32 role);
123 virtual QString
text()
const = 0;
124 Q_DECL_DEPRECATED QString displayText()
const {
return text(); }
129 virtual qint32
uid()
const;
138 QVariant
data(
const qint32 column,
147 virtual QVariant
data(
const QModelIndex &index,
175 inline virtual bool init() = 0;
201 const QVariant &value,
203 std::vector<qint32> &modified_columns,
214 virtual bool setData(
const QModelIndex &index,
215 const QVariant &value,
217 std::vector<qint32> &modified_columns,
231 inline virtual bool deletable()
const {
return false; }
232 template<IntegralNumber T>
233 QVariant fromHexVector(
const std::vector<T> &raw_data,
const qint32 role)
const;
240 QVariant
fromValue(
const QVariant &value,
const qint32 role)
const;
249 virtual QVariant internalData(
const qint32 column,
const qint32 role)
const = 0;
252 virtual bool setInternalData(
const qint32 column,
253 const QVariant &value,
255 std::vector<qint32> &modified_columns);
263template<IntegralNumber T>
264QVariant AbstractTableItem::fromHexVector(
const std::vector<T> &raw_data,
const qint32 role)
const
266 if (role != Qt::DisplayRole)
270 for (
const auto &itr : raw_data)
271 buffer << QString(
"%1").arg(
static_cast<quint8
>(itr), 2, 16, QLatin1Char(
'0'));
273 return buffer.join(QStringLiteral(
" "));
The ColumnData class represents a container of ehm_dal::column_data::Column and attributes relating t...
Definition: column_data.h:18
The DatabaseVersion class represents the database version number.
Definition: database_version.h:12
The AbstractTableItem class represents a row in a Table with an id field.
Definition: abstract_table_item.h:31
QVariant data(const qint32 column, qint32 role, ehm_dal::column_data::ColumnData *column_data) const
Returns the row's data stored under the given role for the column.
virtual qint32 parentItemId() const
Returns the item id of the items parent item. Applies to tree structures only.
bool alloc(const qint32 new_id)
Initialises the table item and allocates and item id to new_id and a uid (if applicable) and then cal...
bool setData(const qint32 column, const QVariant &value, qint32 role, std::vector< qint32 > &modified_columns, ehm_dal::column_data::ColumnData *column_data)
Sets the role data for the item at column to value.
QVariant id(const qint32 role)
Returns the row id in a manner compatible with QAbstractTableModel item roles. This is generally unec...
virtual ~AbstractTableItem()
Default destructor.
virtual QVariant data(const QModelIndex &index, qint32 role, ehm_dal::column_data::ColumnData *column_data) const
Returns the row's data stored under the given role for the column referred to by the index.
virtual bool init()=0
Initialises the table item members. This only needs to be called once per item.
virtual QStringList identifierList() const
Returns a list of all of the item's identifiers for matching against. This includes the main identifi...
QVariant fromValue(const QVariant &value, const qint32 role) const
Returns a value as a QVariant if the role is Qt::DisplayRole or Qt::EditRole. A blank QVariant is ret...
virtual bool setChildData(const QModelIndex &index, const QVariant &value, const qint32 role, std::vector< qint32 > &modified_columns, ehm_dal::column_data::ColumnData *column_data, const ehm_dal::tables::TableIndex child_table)
Sets the role data for the child item at index to value.
virtual QString text() const =0
Returns the row's display text. This provides a convenient way to obtain a simple description of the ...
virtual bool read(QDataStream &in, ehm_dal::database::DatabaseVersion &version)
Reads a table row from the QDataStream.
virtual bool write(QDataStream &out, ehm_dal::database::DatabaseVersion &version)
Writes a table row to the QDataStream.
virtual QVariant childData(const QModelIndex &index, qint32 role, ehm_dal::column_data::ColumnData *column_data, const ehm_dal::tables::TableIndex child_table) const
Returns child data stored under the given role for the selected index.
virtual void addChildItem(std::shared_ptr< AbstractTableItem > item, const ehm_dal::tables::TableIndex child_table)
Adds the child item item from the child_table to the present tree table. This represents a tree relat...
virtual qint32 childItemId(const ehm_dal::tables::TableIndex child_table) const
Returns the item id number for the child data under the related child_table.
AbstractTableItem()
Default constructor.
qint32 id() const
Returns the row id. The first row of a table is 0, the second row is 1, etc.
Definition: abstract_table_item.h:111
virtual qint32 uid() const
Returns the row's unique database id. Not all tables use a uid.
virtual void fixErrors()
Fixes any known errors with the item. E.g. errors introduced with a prior version of EHM DAL or the E...
Definition: abstract_table_item.h:224
virtual bool setData(const QModelIndex &index, const QVariant &value, qint32 role, std::vector< qint32 > &modified_columns, ehm_dal::column_data::ColumnData *column_data)
Sets the role data for the item at index to value.
virtual QString identifier() const
Returns the item's text identifier for matching against.
virtual qint32 childRowCount(const ehm_dal::tables::TableIndex child_table) const
Returns the number of related child items in respect of child_table.
Definition: abstract_table_item.h:24
namespace ehm_dal::tables
Definition: column.h:4
TableIndex
The TableIndex enum represents the id number of each table within the database.
Definition: table_index.h:14