EHM DAL 0.2.5
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
column_index_list.h
1#pragma once
2
3// Application headers
4#include "include/column_data/column.h"
5namespace ehm_dal::tables {
6class AbstractTable;
7}
8
9// Qt headers
10#include <QModelIndex>
11#include <memory>
12#include <vector>
13
14namespace ehm_dal::column_data {
15
16// --- List/container of column indexes --- //
24{
25public:
31 ColumnIndexList(std::shared_ptr<ehm_dal::tables::AbstractTable> table);
32
33 // Add column indexes
39 void add(std::shared_ptr<ehm_dal::tables::AbstractTable> table, const qint32 column_index);
45 void add(std::shared_ptr<ehm_dal::tables::AbstractTable> table,
46 const std::vector<qint32> &column_indexes);
51 void addAll(std::shared_ptr<ehm_dal::tables::AbstractTable> table);
52
53 // Get data: columns
58 const Column *column(const qint32 column_index) const;
64 std::optional<qint32> columnId(const qint32 column_index) const;
73 QModelIndex index(const qint32 row, const qint32 column_index) const;
85 QModelIndex index(const qint32 row,
86 const qint32 column_index,
87 const qint32 parent_row,
88 const qint32 parent_column = 0) const;
94 std::shared_ptr<ehm_dal::tables::AbstractTable> table(const qint32 column_index) const;
95
96 // Get data: container attributes
101 qint32 columnCount() const;
106 qint32 rowCount(const qint32 table_index = 0) const;
107
108private:
109 struct ColumnIndex
110 {
111 qint32 column_id_{0};
112 qint32 table_index_{0};
113
114 ColumnIndex(const qint32 table_index, const qint32 column_id);
115 };
116
117 // Column and table data
118 std::vector<ColumnIndex> indexes_;
119 std::vector<std::shared_ptr<ehm_dal::tables::AbstractTable>> tables_;
120
121 // Add column indexes
127 qint32 addTable(std::shared_ptr<ehm_dal::tables::AbstractTable> table);
128};
129} // namespace ehm_dal::column_data
The Column class represents a column of data in a Table.
Definition: column.h:19
The ColumnIndexList class is a container/list of ehm_dal::column_data::Column indexes from ehm_dal:...
Definition: column_index_list.h:24
void add(std::shared_ptr< ehm_dal::tables::AbstractTable > table, const std::vector< qint32 > &column_indexes)
Adds all of the column_indexes from the table to the column list.
const Column * column(const qint32 column_index) const
Returns a raw pointer to the Column with a column index of column_index.
ColumnIndexList(std::shared_ptr< ehm_dal::tables::AbstractTable > table)
Constructs a ColumnIndexList using all columns from table
qint32 columnCount() const
Returns the number of columns.
std::optional< qint32 > columnId(const qint32 column_index) const
Returns the column id of the Column with a column index of column_index.
qint32 rowCount(const qint32 table_index=0) const
Returns the number of rows for the selected table.
QModelIndex index(const qint32 row, const qint32 column_index, const qint32 parent_row, const qint32 parent_column=0) const
Returns a QModelIndex for row and column_index with a parent of parent_row and parent_column using th...
void addAll(std::shared_ptr< ehm_dal::tables::AbstractTable > table)
Adds all columns from the table to the column list.
QModelIndex index(const qint32 row, const qint32 column_index) const
Returns a QModelIndex for row and column_index using the table to which column_index relates....
std::shared_ptr< ehm_dal::tables::AbstractTable > table(const qint32 column_index) const
Returns a shared_pointer to the AbstractTable relating tocolumn_index.
void add(std::shared_ptr< ehm_dal::tables::AbstractTable > table, const qint32 column_index)
Adds the column_index from the table to the column list.
namespace ehm_dal::tables
Definition: column.h:4