EHM DAL 0.2.5
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 --- //
19{
20public:
21 // Settings
26 NO_SETTINGS = 1 << 0,
27 //CHILD_TABLE = 1 << 1, // Is a child table
28 //FLAGS_TABLE = CHILD_TABLE, // Both tables are treated the same
31 HAS_UID_COLUMN = 1 << 4,
32 FORCE_CACHING = 1 << 5,
34 SORTABLE_TABLE = 1 << 7,
37 };
38
39 // Base column indexes
46 FirstColumn = 0,
47 Id = FirstColumn,
57 };
58
59 // Constructor
64 ColumnData(const quint16 settings = NO_SETTINGS);
66
67 // Add column data
72 void add(const Column &column);
77 void add(const ColumnData &data);
78
79 // Cache status
83 inline bool isCached() const { return is_cached_; }
88 inline void setCacheComplete(const bool is_cached) { is_cached_ = is_cached; }
89
90 // Get data
94 qint32 columnCount() const;
99 const Column *column(const qint32 column_id) const;
104 QSize dimensions(const qint32 column_id) const;
108 inline qint32 firstDerivedColumnIndex() const { return first_derived_column_index_; }
112 Qt::ItemFlags flags(const QModelIndex &index) const;
116 inline bool isInitialised() const { return is_initialised_; }
120 QString name(const qint32 column_id) const;
121
122 // Get data - settings
126 inline bool hasExtraColumns() const { return (settings_ & DO_NOT_USE_EXTRA_COLUMNS) == 0; }
130 inline bool hasIdColumn() const { return (settings_ & HAS_NO_ID_COLUMN) == 0; }
134 inline bool hasRebuildPriority() const { return (settings_ & REBUILD_PRIORITY); }
138 inline bool hasUidColumn() const { return (settings_ & HAS_UID_COLUMN); }
142 inline bool isSortable() const { return (settings_ & SORTABLE_TABLE); }
146 inline bool usesIdentifierSingleString() const
147 {
148 return settings_ & USES_IDENTIFIER_SINGLE_STRING;
149 }
153 inline bool usesIdentifierStringList() const { return settings_ & USES_IDENTIFIER_STRING_LIST; }
154
155 // Identifier
160
161 // Operator overloading
162 bool operator==(const ColumnData &rhs) const;
163 inline bool operator!=(const ColumnData &rhs) const { return !(*this == rhs); }
164
165 // Set data
169 void clearAll();
170
171 // Sanity checking
176 bool isValid(const qint32 column_id) const;
177
178private:
179 std::vector<Column> columns_;
180 qint32 first_derived_column_index_{0};
181
182 // Cached status
183 bool is_cached_{true}; // Indicates whether initial caching is complete
184
185 // Initialisation
186 bool is_initialised_{false};
187 void init();
188
189 // Settings
190 quint16 settings_{NO_SETTINGS};
191};
192
193} // namespace ehm_dal::column_data
194
195
The ColumnData class represents a container of ehm_dal::column_data::Column and attributes relating t...
Definition: column_data.h:19
bool isSortable() const
Returns whether or not COLUMN_DATA_SETTINGS::SORTABLE_TABLE is true.
Definition: column_data.h:142
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:134
bool usesIdentifierStringList() const
Returns whether or not COLUMN_DATA_SETTINGS::USES_IDENTIFIER_STRING_LIST is true.
Definition: column_data.h:153
bool usesIdentifierSingleString() const
Returns whether or not COLUMN_DATA_SETTINGS::USES_IDENTIFIER_SINGLE_STRING is true.
Definition: column_data.h:146
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:25
@ SORTABLE_TABLE
Definition: column_data.h:34
@ USES_IDENTIFIER_SINGLE_STRING
Definition: column_data.h:35
@ FORCE_CACHING
Definition: column_data.h:32
@ USES_IDENTIFIER_STRING_LIST
Definition: column_data.h:36
@ REBUILD_PRIORITY
Definition: column_data.h:33
@ HAS_UID_COLUMN
Definition: column_data.h:31
@ DO_NOT_USE_EXTRA_COLUMNS
Definition: column_data.h:29
@ HAS_NO_ID_COLUMN
Definition: column_data.h:30
bool isCached() const
Returns whether any cached columns are present.
Definition: column_data.h:83
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:45
@ FirstIdOnlyDerivedColumnIndex
Definition: column_data.h:55
@ IsModifiedByDbXfer
Definition: column_data.h:52
@ Text
Definition: column_data.h:56
@ FirstStandardDerivedColumnIndex
Definition: column_data.h:54
@ Uid
Definition: column_data.h:48
@ SubHeadingText
Definition: column_data.h:50
@ DbXferImportId
Definition: column_data.h:53
@ ValidationStatus
Definition: column_data.h:51
@ Id
Definition: column_data.h:47
@ DisplayText
Definition: column_data.h:49
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:126
bool hasIdColumn() const
Returns whether or not COLUMN_DATA_SETTINGS::HAS_NO_ID_COLUMN is false.
Definition: column_data.h:130
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:138
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:108
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:88
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:116
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