EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
column.h
1#pragma once
2
3// Application headers
4namespace ehm_dal::tables {
5class AbstractTable;
6enum class TableIndex : char;
7}
8
9// Qt headers
10#include <QString>
11
12namespace ehm_dal::column_data {
13
14// --- Column index/data --- //
18class Column
19{
20public:
21 // Settings
26 NO_SETTINGS = 1 << 0,
27 HIDE_EVERYWHERE = 1 << 1,
30 HIDE_FROM_UI = 1 << 4,
32 READ_ONLY = 1 << 6,
33 COLOUR_POINTER = 1 << 7,
35 POINTER_LIST = 1 << 9,
36 RAW_POINTER = 1 << 10,
37 CACHED_COLUMN = 1 << 11
38 };
39
40 // Column types
44 enum class ColumnType : quint8 {
45 // Bool
46 BOOL,
47 // Containers
48 CONTAINER,
49 // Date
50 DATE,
51 YEAR,
52 // Numerical
53 ATTRIBUTE_20,
54 ATTRIBUTE_99,
55 ATTRIBUTE_200,
56 ATTRIBUTE_POTENTIAL,
57 CHAR,
58 UCHAR,
59 CURRENCY,
60 DOUBLE,
61 FLOAT,
62 INT,
63 UINT,
64 SHORT,
65 USHORT,
66 // Pointer
67 FLAG,
68 POINTER,
69 POINTER_BITMASK_FLAG_TABLE,
70 POINTER_COLOUR_TABLE,
71 POINTER_DATABASE_TABLE,
72 POINTER_FLAG_TABLE,
75 // Primary key
76 PRIMARY_KEY_ID,
77 PRIMARY_KEY_UID,
78 // Special
79 EXTRA_RULES,
80 // Text
81 STRING
82 };
83
84 Column();
85 // Non-pointer constructor
93 Column(const qint32 position,
94 const QString &name,
95 const ColumnType type,
96 const quint16 settings = NO_SETTINGS);
97 // Pointer constructor
105 Column(const qint32 position,
106 const QString &name,
107 std::shared_ptr<ehm_dal::tables::AbstractTable> table,
108 const quint16 settings = NO_SETTINGS);
109
110 // Get data - basic attributes
114 Qt::ItemFlags flags() const;
118 inline qint32 id() const { return position_; } // Column position/index
122 inline QString name() const { return name_; } // Column name
123 Q_DECL_DEPRECATED inline qint32 position() const
124 {
125 return id();
126 } // Column position/index (to be deprecated)
127
128 // Get data - general attributes
132 inline bool isCached() const { return (settings_ & CACHED_COLUMN); }
136 inline bool isCheckable() const { return type_ == ColumnType::BOOL; }
140 inline bool isContainer() const { return type_ == ColumnType::CONTAINER; }
144 inline bool isReadOnly() const { return (settings_ & READ_ONLY); }
145
146 // Get data - table pointer
151 inline bool isColourPointer() const { return (settings_ & COLOUR_POINTER); }
161 bool isFlagTablePointer() const;
166 inline bool isNameStringPointer() const { return (settings_ & NAME_STRING_POINTER); }
170 inline bool isPointerList() const { return (settings_ & POINTER_LIST); }
174 inline bool isRawPointer() const { return (settings_ & RAW_POINTER); }
182 QString relatedTableName() const;
183
184 // Get data - visibility
188 inline bool hiddenEverywhere() const { return (settings_ & HIDE_EVERYWHERE); }
192 inline bool hiddenFromFilters() const
193 {
194 return (settings_ & HIDE_FROM_FILTERS) || hiddenEverywhere();
195 }
199 inline bool hiddenFromTables() const
200 {
201 return (settings_ & HIDE_FROM_TABLES) || (settings_ & HIDE_FROM_UI_AND_TABLES)
203 }
207 inline bool hiddenFromUi() const
208 {
209 return (settings_ & HIDE_FROM_UI_AND_TABLES) || (settings_ & HIDE_FROM_UI)
210 || hiddenEverywhere();
211 }
215 inline bool visibleToFilters() const { return !hiddenFromFilters(); }
216
217private:
218 enum ENUM_FLAGS { NO_COLUMN_INDEX = -1 }; // Private magic number
219
220 // Attributes
221 qint32 position_{NO_COLUMN_INDEX};
222 QString name_{QStringLiteral("No column name")};
223 quint16 settings_{NO_SETTINGS};
224 ColumnType type_;
225
226 // Table pointer
227 std::shared_ptr<ehm_dal::tables::AbstractTable> table_;
228 void initTablePointer();
229
230 // Settings
231 void initSettings();
232};
233
234} // namespace ehm_dal::column_data
235
The Column class represents a column of data in a Table.
Definition: column.h:19
bool hiddenFromUi() const
Returns whether the column is hidden from the user interface.
Definition: column.h:207
QString name() const
Returns the column name.
Definition: column.h:122
qint32 id() const
Returns the column position/index.
Definition: column.h:118
bool isContainer() const
Returns whether the column represents a container.
Definition: column.h:140
Column(const qint32 position, const QString &name, std::shared_ptr< ehm_dal::tables::AbstractTable > table, const quint16 settings=NO_SETTINGS)
Constructs a Column representing an ehm_dal::data_types::AbstractPointer data type.
ColumnType
The ColumnType enum represents the data type of the Column.
Definition: column.h:44
bool isDatabaseTablePointer() const
Returns whether the column points to a ehm_dal::Database table. This is only applicable to columns re...
bool isReadOnly() const
Returns whether the column contains read only data.
Definition: column.h:144
Column(const qint32 position, const QString &name, const ColumnType type, const quint16 settings=NO_SETTINGS)
Constructs a Column representing a data type other than an ehm_dal::data_types::AbstractPointer.
bool visibleToFilters() const
Returns whether the column is visible to filters.
Definition: column.h:215
ehm_dal::tables::TableIndex relatedTableIndex() const
Returns the ehm_dal::tables::TableIndex of the source ehm_dal::tables::AbstractTable.
QString relatedTableName() const
Returns the table name of the source ehm_dal::tables::AbstractTable.
bool hiddenEverywhere() const
Returns whether the column is hidden everywhere.
Definition: column.h:188
bool isFlagTablePointer() const
Returns whether the column points to a ehm_dal::flag::FlagDatabase table. This is only applicable to ...
COLUMN_SETTINGS
The COLUMN_SETTINGS enum represents settings for a Column.
Definition: column.h:25
@ HIDE_FROM_TABLES
Definition: column.h:29
@ HIDE_EVERYWHERE
Definition: column.h:27
@ HIDE_FROM_UI_AND_TABLES
Definition: column.h:31
@ NAME_STRING_POINTER
Definition: column.h:34
@ COLOUR_POINTER
Definition: column.h:33
@ HIDE_FROM_UI
Definition: column.h:30
@ READ_ONLY
Definition: column.h:32
@ CACHED_COLUMN
Definition: column.h:37
@ HIDE_FROM_FILTERS
Definition: column.h:28
@ POINTER_LIST
Definition: column.h:35
@ RAW_POINTER
Definition: column.h:36
bool hiddenFromFilters() const
Returns whether the column is hidden from filters.
Definition: column.h:192
bool isPointerList() const
Returns whether the column represents a list of pointers.
Definition: column.h:170
bool isCached() const
Returns whether the column is cached.
Definition: column.h:132
bool isRawPointer() const
Returns whether the column represents a raw pointer to point to data.
Definition: column.h:174
Qt::ItemFlags flags() const
Returns the Qt::ItemFlags in respect of the column.
bool isColourPointer() const
Returns whether the column points to a ehm_dal::schema::Colour. This is only applicable to columns re...
Definition: column.h:151
bool hiddenFromTables() const
Returns whether the column is hidden from tables.
Definition: column.h:199
bool isNameStringPointer() const
Returns whether the column points to a ehm_dal::data_types::NamePointer. This is only applicable to c...
Definition: column.h:166
bool isCheckable() const
Returns whether the column is checkable.
Definition: column.h:136
The Table class represents a database table and provides access to rows of data.
Definition: abstract_table.h:29
namespace ehm_dal::tables
Definition: column.h:4
TableIndex
The TableIndex enum represents the id number of each table within the database.
Definition: table_index.h:14