EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
club.h
1#pragma once
2
3// Application headers
4#include "include/schema/abstract_uid_table_item.h"
5
6// Qt headers
7class QDataStream;
8#include <memory>
9
10namespace ehm_dal::data_types {
11class Pointer;
12}
13
14namespace ehm_dal::schema {
15
16// --- Clubs --- //
18{
19public:
20 Club();
21 ~Club();
22
23 // Child data
24 void addChildItem(std::shared_ptr<AbstractTableItem> item,
25 const ehm_dal::tables::TableIndex child_table) override;
26 QVariant childData(const QModelIndex &index,
27 qint32 role,
28 column_data::ColumnData *column_data,
29 const ehm_dal::tables::TableIndex child_table) const override;
30 qint32 childRowCount(const ehm_dal::tables::TableIndex child_table) const override;
31 bool setChildData(const QModelIndex &index,
32 const QVariant &value,
33 const qint32 role,
34 std::vector<qint32> &modified_columns,
36 const ehm_dal::tables::TableIndex child_table) override;
37
38 // File i/o
39 bool read(QDataStream &in, ehm_dal::database::DatabaseVersion &version) override;
40 bool write(QDataStream &out, ehm_dal::database::DatabaseVersion &version) override;
41
42 // Get data
43 QString text() const override;
44
45 // Initialisation
46 bool init() override;
47
48 // Validation
49 void fixErrors() override;
50
51 enum class ClubRosterSizes : quint8 {
52 ASSISTANT_MANAGER_SIZE = 1,
53 CAPTAIN_SIZE = 3,
54 CHAIRMAN_SIZE = 1,
55 COACH_SIZE = 5,
56 DIRECTOR_SIZE = 3,
57 HEAD_COACH_SIZE = 1,
58 HEAD_SCOUT_SIZE = 1,
59 MANAGER_SIZE = 1,
60 PHYSIO_SIZE = 3,
61 SCOUT_SIZE = 15,
62 SQUAD_SIZE = 75
63 };
64
65private:
66 struct Data;
67 std::unique_ptr<Data> data_;
68
69 // File i/o
70 void readRoster(QDataStream &in,
71 std::vector<ehm_dal::data_types::Pointer> &data,
72 const ClubRosterSizes max_size);
73 void writeRoster(QDataStream &out,
74 std::vector<ehm_dal::data_types::Pointer> &data,
75 const ClubRosterSizes max_size);
76
77 // Get data
78 QVariant internalData(const qint32 column, const qint32 role) const override;
79
80 // Initialisation
81 void initRoster(std::vector<ehm_dal::data_types::Pointer> &roster_container);
82
83 // Set data
84 bool setInternalData(const qint32 column,
85 const QVariant &value,
86 const qint32 role,
87 std::vector<qint32> &modified_columns) override;
88};
89
90} // namespace ehm_dal::schema
91
92
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
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.
The AbstractUidTableItem class represents a row in a Table with id and uid fields.
Definition: abstract_uid_table_item.h:11
Definition: club.h:18
bool write(QDataStream &out, ehm_dal::database::DatabaseVersion &version) override
Writes a table row to the QDataStream.
QVariant childData(const QModelIndex &index, qint32 role, column_data::ColumnData *column_data, const ehm_dal::tables::TableIndex child_table) const override
Returns child data stored under the given role for the selected index.
bool read(QDataStream &in, ehm_dal::database::DatabaseVersion &version) override
Reads a table row from the QDataStream.
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) override
Sets the role data for the child item at index to value.
bool init() override
Initialises the table item members. This only needs to be called once per item.
void fixErrors() override
Fixes any known errors with the item. E.g. errors introduced with a prior version of EHM DAL or the E...
void addChildItem(std::shared_ptr< AbstractTableItem > item, const ehm_dal::tables::TableIndex child_table) override
Adds the child item item from the child_table to the present tree table. This represents a tree relat...
QString text() const override
Returns the row's display text. This provides a convenient way to obtain a simple description of the ...
qint32 childRowCount(const ehm_dal::tables::TableIndex child_table) const override
Returns the number of related child items in respect of child_table.
namespace ehm_dal::data_types
Definition: attribute.h:6
TableIndex
The TableIndex enum represents the id number of each table within the database.
Definition: table_index.h:14