4#include "include/database/pointer/pointer_flags.h"
7#include "include/database/database_version.h"
20template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
46 in.readRawData(
reinterpret_cast<char *
>(&
data.id_),
sizeof(T_IdDataType));
52 out.writeRawData(
reinterpret_cast<char *
>(&
id),
sizeof(T_IdDataType));
88 QVariant
data(
const qint32 role)
const;
96 virtual QVariant
data(
const qint32 column,
const qint32 role)
const;
100 inline virtual T_IdDataType
id()
const {
return id_; }
107 inline T_IdDataType
idBuffer()
const {
return id_; }
118 virtual QString
text()
const;
132 virtual std::shared_ptr<T_Table>
table() = 0;
136 T_TableIndex
tableId()
const {
return table_id_; }
140 inline bool operator==(
const AbstractPointer &rhs)
const {
return id() == rhs.id(); }
141 inline auto operator<=>(
const qint32 &rhs)
const {
return id() <=> rhs; }
142 inline bool operator==(
const qint32 &rhs)
const {
return id() == rhs; }
146 Q_DECL_DEPRECATED
void set(
const QVariant &value,
const qint32 role)
155 virtual void setData(
const QVariant &value,
const qint32 role);
163 bool setData(
const qint32 column,
const QVariant &value,
const qint32 role);
168 inline void setTable(
const T_TableIndex table_id) { table_id_ = table_id; }
174 inline void setId(
const qint32
id) { id_ =
static_cast<T_IdDataType
>(
id); }
181template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
182AbstractPointer<T_IdDataType, T_TableIndex, T_Table>::AbstractPointer()
185template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
187 const T_IdDataType record_id)
189 , table_id_(table_id)
196template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
200 case Qt::DisplayRole:
209template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
213 return constTable()->index(
id(), column).data(role);
216template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
219 return constTable()->index(
id(), 2).data(Qt::DisplayRole).toString();
227template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
231 return constTable()->attributes()->name();
233 return QStringLiteral(
"[No table]");
241template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
245 if (role == Qt::EditRole)
246 id_ =
static_cast<T_IdDataType
>(value.toInt());
250template<
typename T_IdDataType,
typename T_TableIndex,
typename T_Table>
252 const QVariant &value,
255 const auto index{table()->index(
id(), column)};
256 return table()->setData(index, value, role);
The AbstractPointer class represents a pointer to a table item.
Definition: abstract_pointer.h:22
virtual void setData(const QVariant &value, const qint32 role)
Sets the role data for the item at index to value.
Definition: abstract_pointer.h:242
void setTable(const T_TableIndex table_id)
Sets the table index to table_id.
Definition: abstract_pointer.h:168
virtual std::shared_ptr< T_Table > constTable() const =0
Returns a read-only pointer to the table pointed to.
QVariant data(const qint32 role) const
Returns the data stored under the given role. Qt::DisplayRole returns the item's display text and Qt:...
Definition: abstract_pointer.h:197
bool isValidTable() const
Returns whether or not the AbstractPointer has been set to a table.
Definition: abstract_pointer.h:76
virtual QString text() const
Returns the display text of the item.
Definition: abstract_pointer.h:217
virtual std::shared_ptr< T_Table > table()=0
Returns a pointer to the table pointed to.
virtual T_IdDataType id() const
Returns the item index pointed to.
Definition: abstract_pointer.h:100
bool isPointer() const
Returns whether or not the AbstractPointer has been set to an item index.
Definition: abstract_pointer.h:68
qint32 columnCount() const
Returns the number of columns in the table pointed to.
Definition: abstract_pointer.h:60
T_TableIndex tableId() const
Returns the table id of the table pointed to.
Definition: abstract_pointer.h:136
bool isValidPointer() const
Returns whether or not the AbstractPointer has been set to an item index and to a table.
Definition: abstract_pointer.h:72
QString description() const
Returns the table name of the item.
Definition: abstract_pointer.h:228
T_IdDataType parentItemId() const
parentItemId returns the buffered id which is generally only useful when first initialising the links...
Definition: abstract_pointer.h:114
T_IdDataType idBuffer() const
idBuffer returns the buffered id which is generally only useful when first initialising the links bet...
Definition: abstract_pointer.h:107
bool isNone() const
Returns whether or not the AbstractPointer is set to ehm_dal::data_types::PointerFlags::NULL_POINTER.
Definition: abstract_pointer.h:64
The DatabaseVersion class represents the database version number.
Definition: database_version.h:12
namespace ehm_dal::data_types
Definition: attribute.h:6
@ NULL_POINTER
Definition: pointer_flags.h:9