EHM DAL 0.2.5
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
schedule_matrix.h
1#pragma once
2
3// Application headers
4#include "include/spreadsheet/spreadsheet.h"
5#include "include/tools/schedule_generator/schedule_template_generator/schedule_club.h"
6
7// Qt headers
8#include <QAbstractTableModel>
9
10// --- Schedule matrix --- //
11namespace ehm_dal::tools::schedule_template_generator {
16class ScheduleMatrix : public QAbstractTableModel
17{
18public:
19 ScheduleMatrix(const std::vector<std::shared_ptr<ScheduleClub>> &sorted_clubs_list);
20
21 // Counts
22 qint32 cellCount(const QModelIndex &parent = QModelIndex()) const;
23 inline qint32 columnCount(const QModelIndex &parent = QModelIndex()) const override
24 {
25 return cellCount(parent);
26 }
27 inline qint32 rowCount(const QModelIndex &parent = QModelIndex()) const override
28 {
29 return cellCount(parent);
30 }
31
32 // File i/o
33 bool exportMatrix(ehm_dal::spreadsheet::Spreadsheet &sheet);
34 bool importMatrix(ehm_dal::spreadsheet::Spreadsheet &sheet);
35
36 // Get data
37 QVariant data(const QModelIndex &index, qint32 role = Qt::DisplayRole) const override;
38 Qt::ItemFlags flags(const QModelIndex &index) const override;
39 QVariant headerData(qint32 section,
40 Qt::Orientation orientation,
41 qint32 role = Qt::DisplayRole) const override;
42 bool isDataCell(const qint32 cell_position) const;
43 bool isDataCell(const QModelIndex &index) const;
44 inline bool isTotalCell(const qint32 cell_position) const { return !isDataCell(cell_position); }
45 bool isTotalCell(const QModelIndex &index) const { return !isDataCell(index); }
46
47 // Set data
48 bool setData(const QModelIndex &index,
49 const QVariant &value,
50 qint32 role = Qt::EditRole) override;
51
52 // Totals cells
53 qint32 columnTotal(const qint32 column) const;
54 qint32 rowTotal(const qint32 row) const;
55 qint32 totalCellPosition() const;
56
57private:
58 std::vector<std::shared_ptr<ehm_dal::tools::schedule_template_generator::ScheduleClub>> clubs_;
59};
60} // namespace ehm_dal::tools::schedule_template_generator
Definition: spreadsheet.h:30
The ScheduleMatrix class provides the interface for viewing and editing the numbers of games to be pl...
Definition: schedule_matrix.h:17