EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
column_data.h
1#pragma once
2
3// Qt headers
4#include <QModelIndex> // TODO This could be forward-declared if another Qt source is included here
5class QSize;
6#include <vector>
7
8namespace ehm_dal::column_data {
9
10class Column;
11
12// --- Column index data container --- //
18{
19public:
20 // Settings
25 NO_SETTINGS = 1 << 0,
26 //CHILD_TABLE = 1 << 1, // Is a child table
27 //FLAGS_TABLE = CHILD_TABLE, // Both tables are treated the same
30 HAS_UID_COLUMN = 1 << 4,
31 FORCE_CACHING = 1 << 5,
33 SORTABLE_TABLE = 1 << 7,
36 };
37
38 // Base column indexes
45 FirstColumn = 0,
46 Id = FirstColumn,
56 };
57
58 // Constructor
63 ColumnData(const quint16 settings = NO_SETTINGS);
65
66 // Add column data
71 void add(const Column &column);
76 void add(const ColumnData &data);
77
78 // Cache status
82 inline bool isCached() const { return is_cached_; }
87 inline void setCacheComplete(const bool is_cached) { is_cached_ = is_cached; }
88
89 // Get data
93 qint32 columnCount() const;
98 const Column *column(const qint32 column_id) const;
103 QSize dimensions(const qint32 column_id) const;
107 inline qint32 firstDerivedColumnIndex() const { return first_derived_column_index_; }
111 Qt::ItemFlags flags(const QModelIndex &index) const;
115 inline bool isInitialised() const { return is_initialised_; }
119 QString name(const qint32 column_id) const;
120
121 // Get data - settings
125 inline bool hasExtraColumns() const { return (settings_ & DO_NOT_USE_EXTRA_COLUMNS) == 0; }
129 inline bool hasIdColumn() const { return (settings_ & HAS_NO_ID_COLUMN) == 0; }
133 inline bool hasRebuildPriority() const { return (settings_ & REBUILD_PRIORITY); }
137 inline bool hasUidColumn() const { return (settings_ & HAS_UID_COLUMN); }
141 inline bool isSortable() const { return (settings_ & SORTABLE_TABLE); }
145 inline bool usesIdentifierSingleString() const
146 {
147 return settings_ & USES_IDENTIFIER_SINGLE_STRING;
148 }
152 inline bool usesIdentifierStringList() const { return settings_ & USES_IDENTIFIER_STRING_LIST; }
153
154 // Identifier
159
160 // Operator overloading
161 bool operator==(const ColumnData &rhs) const;
162 inline bool operator!=(const ColumnData &rhs) const { return !(*this == rhs); }
163
164 // Set data
168 void clearAll();
169
170 // Sanity checking
175 bool isValid(const qint32 column_id) const;
176
177private:
178 std::vector<Column> columns_;
179 qint32 first_derived_column_index_{0};
180
181 // Cached status
182 bool is_cached_{true}; // Indicates whether initial caching is complete
183
184 // Initialisation
185 bool is_initialised_{false};
186 void init();
187
188 // Settings
189 quint16 settings_{NO_SETTINGS};
190};
191
192} // namespace ehm_dal::column_data
193
194
The ColumnData class represents a container of ehm_dal::column_data::Column and attributes relating t...
Definition: column_data.h:18
bool isSortable() const
Returns whether or not COLUMN_DATA_SETTINGS::SORTABLE_TABLE is true.
Definition: column_data.h:141
Qt::ItemFlags flags(const QModelIndex &index) const
Returns the Qt::ItemFlags in respect of the column from index.
bool hasRebuildPriority() const
Returns whether or not COLUMN_DATA_SETTINGS::REBUILD_PRIORITY is true.
Definition: column_data.h:133
bool usesIdentifierStringList() const
Returns whether or not COLUMN_DATA_SETTINGS::USES_IDENTIFIER_STRING_LIST is true.
Definition: column_data.h:152
bool usesIdentifierSingleString() const
Returns whether or not COLUMN_DATA_SETTINGS::USES_IDENTIFIER_SINGLE_STRING is true.
Definition: column_data.h:145
const Column * column(const qint32 column_id) const
Returns a raw pointer to the Column with a column index of column_id.
qint32 columnCount() const
Returns the number of columns.
COLUMN_DATA_SETTINGS
The COLUMN_DATA_SETTINGS enum represents settings for ColumnData.
Definition: column_data.h:24
@ SORTABLE_TABLE
Definition: column_data.h:33
@ USES_IDENTIFIER_SINGLE_STRING
Definition: column_data.h:34
@ FORCE_CACHING
Definition: column_data.h:31
@ USES_IDENTIFIER_STRING_LIST
Definition: column_data.h:35
@ REBUILD_PRIORITY
Definition: column_data.h:32
@ HAS_UID_COLUMN
Definition: column_data.h:30
@ DO_NOT_USE_EXTRA_COLUMNS
Definition: column_data.h:28
@ HAS_NO_ID_COLUMN
Definition: column_data.h:29
bool isCached() const
Returns whether any cached columns are present.
Definition: column_data.h:82
void add(const ColumnData &data)
Adds all of the columns from data to the column data.
COLUMN_DATA_INDEXES
The COLUMN_DATA_INDEXES enum sets out the base Column indexes within the ColumnData....
Definition: column_data.h:44
@ FirstIdOnlyDerivedColumnIndex
Definition: column_data.h:54
@ IsModifiedByDbXfer
Definition: column_data.h:51
@ Text
Definition: column_data.h:55
@ FirstStandardDerivedColumnIndex
Definition: column_data.h:53
@ Uid
Definition: column_data.h:47
@ SubHeadingText
Definition: column_data.h:49
@ DbXferImportId
Definition: column_data.h:52
@ ValidationStatus
Definition: column_data.h:50
@ Id
Definition: column_data.h:46
@ DisplayText
Definition: column_data.h:48
QString name(const qint32 column_id) const
Returns the name of the Column with a column index of column_id.
bool hasExtraColumns() const
Returns whether or not COLUMN_DATA_SETTINGS::DO_NOT_USE_EXTRA_COLUMNS is false.
Definition: column_data.h:125
bool hasIdColumn() const
Returns whether or not COLUMN_DATA_SETTINGS::HAS_NO_ID_COLUMN is false.
Definition: column_data.h:129
bool isValid(const qint32 column_id) const
Checks whether a 'Column' is present with a column index equal to column_id
bool hasUidColumn() const
Returns whether or not COLUMN_DATA_SETTINGS::HAS_UID_COLUMN is true.
Definition: column_data.h:137
void validateIdentifierSetting()
Validates the identifier setting in order to ensure it is correctly set.
qint32 firstDerivedColumnIndex() const
Returns the first column index of the class derived from ColumnData.
Definition: column_data.h:107
QSize dimensions(const qint32 column_id) const
Returns the dimensions of the Column with a column index of column_id.
void setCacheComplete(const bool is_cached)
Sets the cached status of any cached columns.
Definition: column_data.h:87
void clearAll()
Clear all column data (including any default columns).
bool isInitialised() const
Returns whether or not any columns have been added to the column data.
Definition: column_data.h:115
void add(const Column &column)
Adds the column to the column data. Note this moves column.
ColumnData(const quint16 settings=NO_SETTINGS)
Default constructor.
The Column class represents a column of data in a Table.
Definition: column.h:19