Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
MistakeRecord.h
1/*
2 * MistakeRecord.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2022-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 MISTAKERECORD_H
22#define MISTAKERECORD_H
23
24#include <QObject>
25#include <QVariant>
26
28class Q_DECL_EXPORT MistakeRecord
29{
30 Q_GADGET
31 Q_PROPERTY(int position READ position WRITE setPosition)
32 Q_PROPERTY(Type type READ type WRITE setType)
33 Q_PROPERTY(QString previousText READ previousText WRITE setPreviousText)
34 Q_PROPERTY(QVariant previousVariant READ previousVariant WRITE setPreviousVariant)
35 Q_PROPERTY(int previousPosition READ previousPosition WRITE setPreviousPosition)
36 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
37 Q_PROPERTY(bool merged READ merged WRITE setMerged)
38 public:
39 enum Type
40 {
41 Type_Addition = 0,
42 Type_Deletion = 1,
43 Type_Change = 2
44 };
45 Q_ENUM(Type)
46
47 int position(void) { return m_position; };
48 void setPosition(int pos) { m_position = pos; };
49 Type type(void) { return m_type; };
50 void setType(Type type) { m_type = type; };
51 QString previousText(void) { return m_previousText; };
52 void setPreviousText(QString text) { m_previousText = text; };
53 QVariant previousVariant(void) { return m_previousVariant; };
54 void setPreviousVariant(QVariant value) { m_previousVariant = value; };
55 int previousPosition(void) { return m_previousPosition; };
56 void setPreviousPosition(int pos) { m_previousPosition = pos; };
57 bool enabled(void) { return m_enabled; };
58 void setEnabled(bool enabled) { m_enabled = enabled; };
59 bool merged(void) { return m_merged; };
60 void setMerged(bool merged) { m_merged = merged; };
61
62 private:
63 int m_position;
64 Type m_type;
65 QString m_previousText;
66 QVariant m_previousVariant;
67 int m_previousPosition;
68 bool m_enabled = true;
69 bool m_merged = false;
70
71 friend inline bool operator==(const MistakeRecord &r1, const MistakeRecord &r2)
72 {
73 bool posCheck = r1.m_position == r2.m_position;
74 bool typeCheck = r1.m_type == r2.m_type;
75 bool previousTextCheck = r1.m_previousText == r2.m_previousText;
76 bool previousVariantCheck = r1.m_previousVariant == r2.m_previousVariant;
77 bool previousPositionCheck = r1.m_previousPosition == r2.m_previousPosition;
78 bool enabledCheck = r1.m_enabled == r2.m_enabled;
79 bool mergedCheck = r1.m_merged == r2.m_merged;
80 return (posCheck && typeCheck && previousTextCheck && previousVariantCheck && previousPositionCheck && enabledCheck && mergedCheck);
81 }
82};
83
84#endif // MISTAKERECORD_H
The MistakeRecord class can be used to store mistake records.
Definition MistakeRecord.h:29