EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
ehm_dal::schema::AbstractTableItem Class Referenceabstract

The AbstractTableItem class represents a row in a Table with an id field. More...

#include <abstract_table_item.h>

Inheritance diagram for ehm_dal::schema::AbstractTableItem:

Public Member Functions

 AbstractTableItem ()
 Default constructor.
 
virtual ~AbstractTableItem ()
 Default destructor.
 
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 relationship between the child 'item' from the child table and the present table.
 
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 qint32 childItemId (const ehm_dal::tables::TableIndex child_table) const
 Returns the item id number for the child data under the related child_table.
 
virtual qint32 childRowCount (const ehm_dal::tables::TableIndex child_table) const
 Returns the number of related child items in respect of child_table.
 
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 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.
 
qint32 id () const
 Returns the row id. The first row of a table is 0, the second row is 1, etc.
 
QVariant id (const qint32 role)
 Returns the row id in a manner compatible with QAbstractTableModel item roles. This is generally unecessary and qint32 AbstractTableItem::id() should be used where possible.
 
virtual QString text () const =0
 Returns the row's display text. This provides a convenient way to obtain a simple description of the row.
 
Q_DECL_DEPRECATED QString displayText () const
 
virtual qint32 uid () const
 Returns the row's unique database id. Not all tables use a uid.
 
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 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 QString identifier () const
 Returns the item's text identifier for matching against.
 
virtual QStringList identifierList () const
 Returns a list of all of the item's identifiers for matching against. This includes the main identifier() string as well as any alternatives.
 
virtual bool init ()=0
 Initialises the table item members. This only needs to be called once per item.
 
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 calls init(). This should be called whenever adding a new item to a table. This should not be called during file i/o.
 
virtual qint32 parentItemId () const
 Returns the item id of the items parent item. Applies to tree structures only.
 
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.
 
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 void fixErrors ()
 Fixes any known errors with the item. E.g. errors introduced with a prior version of EHM DAL or the Editor.
 

Protected Member Functions

virtual bool deletable () const
 
template<IntegralNumber T>
QVariant fromHexVector (const std::vector< T > &raw_data, const qint32 role) const
 
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 returned if another role is selected.
 

Protected Attributes

qint32 id_
 

Friends

QDataStream & operator>> (QDataStream &in, AbstractTableItem &data)
 
QDataStream & operator<< (QDataStream &out, const AbstractTableItem &data)
 

Detailed Description

The AbstractTableItem class represents a row in a Table with an id field.

Member Function Documentation

◆ addChildItem()

virtual void ehm_dal::schema::AbstractTableItem::addChildItem ( std::shared_ptr< AbstractTableItem item,
const ehm_dal::tables::TableIndex  child_table 
)
virtual

Adds the child item item from the child_table to the present tree table. This represents a tree relationship between the child 'item' from the child table and the present table.

Parameters
itemchild item to be added
child_tablesource table

Reimplemented in ehm_dal::schema::Club, ehm_dal::schema::ClubCompetition, ehm_dal::schema::Staff, and ehm_dal::schema::StaffAward.

◆ alloc()

bool ehm_dal::schema::AbstractTableItem::alloc ( const qint32  new_id)

Initialises the table item and allocates and item id to new_id and a uid (if applicable) and then calls init(). This should be called whenever adding a new item to a table. This should not be called during file i/o.

Parameters
new_idId number to be allocated to the item
Returns
true if members were initialised or false if nothing requires initialising.

◆ childData()

virtual QVariant ehm_dal::schema::AbstractTableItem::childData ( const QModelIndex &  index,
qint32  role,
ehm_dal::column_data::ColumnData column_data,
const ehm_dal::tables::TableIndex  child_table 
) const
virtual

Returns child data stored under the given role for the selected index.

Parameters
indexof the child item
roleitem data role. Qt::DisplayRole and Qt::EditRole are the most frequently used
column_datarelating to the child schema
child_tablecontaining the child data
Returns
a QVariant containing a copy of the data.

Reimplemented in ehm_dal::schema::Club, ehm_dal::schema::ClubCompetition, ehm_dal::schema::Staff, and ehm_dal::schema::StaffAward.

◆ childItemId()

virtual qint32 ehm_dal::schema::AbstractTableItem::childItemId ( const ehm_dal::tables::TableIndex  child_table) const
virtual

Returns the item id number for the child data under the related child_table.

Parameters
child_table

Reimplemented in ehm_dal::schema::Staff.

◆ childRowCount()

virtual qint32 ehm_dal::schema::AbstractTableItem::childRowCount ( const ehm_dal::tables::TableIndex  child_table) const
virtual

Returns the number of related child items in respect of child_table.

Parameters
child_table

Reimplemented in ehm_dal::schema::Club, ehm_dal::schema::ClubCompetition, ehm_dal::schema::Staff, and ehm_dal::schema::StaffAward.

◆ data() [1/2]

QVariant ehm_dal::schema::AbstractTableItem::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.

Parameters
columnthe selected column
roleitem data role. Qt::DisplayRole and Qt::EditRole are the most frequently used
Returns
a QVariant containing a copy of the data

◆ data() [2/2]

virtual QVariant ehm_dal::schema::AbstractTableItem::data ( const QModelIndex &  index,
qint32  role,
ehm_dal::column_data::ColumnData column_data 
) const
virtual

Returns the row's data stored under the given role for the column referred to by the index.

Parameters
indexIndex of the selected column. The index's row is disregarded
roleitem data role. Qt::DisplayRole and Qt::EditRole are the most frequently used
Returns
a QVariant containing a copy of the data.

Reimplemented in ehm_dal::schema::ClubRecords.

◆ fixErrors()

virtual void ehm_dal::schema::AbstractTableItem::fixErrors ( )
inlinevirtual

Fixes any known errors with the item. E.g. errors introduced with a prior version of EHM DAL or the Editor.

Reimplemented in ehm_dal::schema::Club.

◆ fromValue()

QVariant ehm_dal::schema::AbstractTableItem::fromValue ( const QVariant &  value,
const qint32  role 
) const
protected

Returns a value as a QVariant if the role is Qt::DisplayRole or Qt::EditRole. A blank QVariant is returned if another role is selected.

Parameters
valueValue to be returned
roleData role
Returns
a QVariant

◆ id() [1/2]

qint32 ehm_dal::schema::AbstractTableItem::id ( ) const
inline

Returns the row id. The first row of a table is 0, the second row is 1, etc.

Returns
the row id

◆ id() [2/2]

QVariant ehm_dal::schema::AbstractTableItem::id ( const qint32  role)

Returns the row id in a manner compatible with QAbstractTableModel item roles. This is generally unecessary and qint32 AbstractTableItem::id() should be used where possible.

Parameters
roleItem data role.
Returns
a QVariant containing a copy of the data.

◆ identifierList()

virtual QStringList ehm_dal::schema::AbstractTableItem::identifierList ( ) const
virtual

Returns a list of all of the item's identifiers for matching against. This includes the main identifier() string as well as any alternatives.

Reimplemented in ehm_dal::schema::ClubCompetition.

◆ init()

◆ parentItemId()

virtual qint32 ehm_dal::schema::AbstractTableItem::parentItemId ( ) const
virtual

◆ read()

◆ setChildData()

virtual bool ehm_dal::schema::AbstractTableItem::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 
)
virtual

Sets the role data for the child item at index to value.

Parameters
indexthe selected index
valuevalue to apply to the item
roleitem data role; typically Qt::EditRole
modified_columnscontainer for storing column ids of any additional columns updated
column_datarelating to the column
child_tablethe child's table
Returns
whether or not any data was successfully set

Reimplemented in ehm_dal::schema::Club, ehm_dal::schema::ClubCompetition, ehm_dal::schema::Staff, and ehm_dal::schema::StaffAward.

◆ setData() [1/2]

bool ehm_dal::schema::AbstractTableItem::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.

Parameters
columnthe selected column
valuevalue to apply to the item
roleitem data role; typically Qt::EditRole
modified_columnscontainer for storing column ids of any additional columns updated
column_datarelating to the column
Returns
whether or not any data was successfully modified

◆ setData() [2/2]

virtual bool ehm_dal::schema::AbstractTableItem::setData ( const QModelIndex &  index,
const QVariant &  value,
qint32  role,
std::vector< qint32 > &  modified_columns,
ehm_dal::column_data::ColumnData column_data 
)
virtual

Sets the role data for the item at index to value.

Parameters
indexthe selected index
valuevalue to apply to the item
roleitem data role; typically Qt::EditRole
modified_columnscontainer for storing column ids of any additional columns updated
column_datarelating to the column
Returns
whether or not any data was successfully modified

Reimplemented in ehm_dal::schema::ClubRecords.

◆ text()

◆ uid()

virtual qint32 ehm_dal::schema::AbstractTableItem::uid ( ) const
virtual

Returns the row's unique database id. Not all tables use a uid.

Returns
the row unique id. A uid of -1 denotes that no uid has been set.

Reimplemented in ehm_dal::schema::AbstractUidTableItem.

◆ write()