Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
ExportTableModel.h
1/*
2 * ExportTableModel.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2023 - adazem009
6 *
7 * Open-Typer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Open-Typer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef EXPORTTABLEMODEL_H
22#define EXPORTTABLEMODEL_H
23
24#include <QAbstractTableModel>
25#include <QSize>
26#include "validator/IExerciseValidator.h"
27#include "global/ISettings.h"
28
34class Q_DECL_EXPORT ExportTableModel : public QAbstractTableModel
35{
36 Q_OBJECT
37 INJECT(ISettings, settings)
38 Q_PROPERTY(QString studentName READ studentName WRITE setStudentName NOTIFY studentNameChanged)
39 Q_PROPERTY(QString className READ className WRITE setClassName NOTIFY classNameChanged)
40 Q_PROPERTY(QString testNumber READ testNumber WRITE setTestNumber NOTIFY testNumberChanged)
41 Q_PROPERTY(QString grade READ grade WRITE setGrade NOTIFY gradeChanged)
42 Q_PROPERTY(IExerciseValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged)
43 public:
44 explicit ExportTableModel(QObject *parent = nullptr);
45 int rowCount(const QModelIndex & = QModelIndex()) const override;
46 int columnCount(const QModelIndex & = QModelIndex()) const override;
47 QVariant data(const QModelIndex &index, int role) const override;
48 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
49 void loadData(void);
50 QHash<int, QByteArray> roleNames() const override;
51 QSize span(const QModelIndex &index) const override;
52 QString studentName(void);
53 void setStudentName(QString name);
54 QString className(void);
55 void setClassName(QString name);
56 QString testNumber(void);
57 void setTestNumber(QString number);
58 QString grade(void);
59 void setGrade(QString grade);
60 IExerciseValidator *validator(void);
61 void setValidator(IExerciseValidator *validator);
62
63 private:
64 static const QMap<QPair<int, int>, QPair<int, int>> spans;
65 QMap<QPair<int, int>, QVariant> tableData;
66 QString m_studentName;
67 QString m_className;
68 QString m_testNumber;
69 QString m_grade;
70 IExerciseValidator *m_validator = nullptr;
71
72 signals:
73 void studentNameChanged(QString name);
74 void classNameChanged(QString name);
75 void testNumberChanged(QString number);
76 void gradeChanged(QString grade);
77 void validatorChanged(IExerciseValidator *validator);
78};
79
80#endif // EXPORTTABLEMODEL_H
The ExportTableModel class provides a table model for typing test results.
Definition ExportTableModel.h:35
Definition IExerciseValidator.h:30
Definition ISettings.h:31