Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
ClassManager.h
1/*
2 * ClassManager.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 CLASSMANAGER_H
22#define CLASSMANAGER_H
23
24#include <QObject>
25#include <QJsonDocument>
26#include "IClassManager.h"
27#include "global/ISettings.h"
28#include "global/IFileUtils.h"
29
35class Q_DECL_EXPORT ClassManager : public IClassManager
36{
37 Q_OBJECT
38 INJECT(ISettings, settings)
39 INJECT(IFileUtils, fileUtils)
40 Q_PROPERTY(QQmlListProperty<Class> classes READ classes NOTIFY classesChanged)
41 Q_PROPERTY(QStringList classNames READ classNames NOTIFY classNamesChanged)
42 public:
43 static std::shared_ptr<ClassManager> instance();
44 void init();
45
46 QQmlListProperty<Class> classes(void) override;
47 void setClasses(QList<Class *> newClasses) override;
48
49 QStringList classNames(void) override;
50
51 Q_INVOKABLE void createNewClass(void) override;
52 Q_INVOKABLE void removeClass(Class *classPtr) override;
53 Q_INVOKABLE int targetHitsPerMinute(void) override;
54 Q_INVOKABLE int targetHitsPerMinute(int selectedClass) override;
55
56 private:
57 QString configLocation();
58 void write(void);
59 static std::shared_ptr<ClassManager> m_instance;
60 QList<Class *> m_classes;
61 QStringList m_classNames;
62 QJsonDocument doc;
63
64 static const QString nameProperty;
65 static const QString descriptionProperty;
66 static const QString gradingProperty;
67 static const QString targetHitsProperty;
68};
69
70#endif // CLASSMANAGER_H
The ClassManager class provides access to grading configuration of each class.
Definition ClassManager.h:36
The Class class encapsulates a class in grading configuration.
Definition Class.h:33
Definition IClassManager.h:30
Definition IFileUtils.h:28
Definition ISettings.h:31