Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
HistoryParser.h
1/*
2 * HistoryParser.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2022-2023 - adazem009
6 * Copyright (C) 2023 - Roker2
7 *
8 * Open-Typer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * Open-Typer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef HISTORYPARSER_H
23#define HISTORYPARSER_H
24
25#include <QObject>
26#include <QFile>
27#include <QJsonDocument>
28#include <QJsonObject>
29#include <QJsonArray>
30#include <QVariant>
31#include "HistoryEntry.h"
32#include "global/IFileUtils.h"
33
35class Q_DECL_EXPORT HistoryParser : public QObject
36{
37 Q_OBJECT
38 INJECT(IFileUtils, fileUtils)
39 Q_PROPERTY(QString lessonPack READ lessonPack WRITE setLessonPack NOTIFY lessonPackChanged)
40 Q_PROPERTY(int lesson READ lesson WRITE setLesson NOTIFY lessonChanged)
41 Q_PROPERTY(int sublesson READ sublesson WRITE setSublesson NOTIFY sublessonChanged)
42 Q_PROPERTY(int exercise READ exercise WRITE setExercise NOTIFY exerciseChanged)
43 Q_PROPERTY(int count READ count NOTIFY countChanged)
44 public:
45 QString lessonPack(void);
46 void setLessonPack(QString value);
47 int lesson(void);
48 void setLesson(int value);
49 int sublesson(void);
50 void setSublesson(int value);
51 int exercise(void);
52 void setExercise(int value);
53 int count(void);
54 Q_INVOKABLE HistoryEntry at(int index);
55 Q_INVOKABLE void append(HistoryEntry entry);
56 Q_INVOKABLE void append(int grossHitsPerMinute, int mistakes, int timeSecs);
57
58 private:
59 static QJsonDocument historyDocument(void);
60 static QJsonValue historyPackValue(QString pack);
61 QString m_lessonPack;
62 int m_lesson = 0;
63 int m_sublesson = 0;
64 int m_exercise = 0;
65
66 static const QString historyFile;
67 static const QString speedProperty;
68 static const QString mistakesProperty;
69 static const QString timeProperty;
70
71 signals:
72 void lessonPackChanged(QString value);
73 void lessonChanged(int value);
74 void sublessonChanged(int value);
75 void exerciseChanged(int value);
76 void countChanged(int value);
77};
78
79#endif // HISTORYPARSER_H
The HistoryEntry class is an entry in the exercise history.
Definition HistoryEntry.h:28
The HistoryParser class provides functions for exercise history and statistics.
Definition HistoryParser.h:36
Definition IFileUtils.h:28