JustAnotherDnDGame 0.1.0
Jeu de rôle tactique au d20, vue de dessus, en C++/Qt
Loading...
Searching...
No Matches
CharacterSheetModel.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Valentin Eloy
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include <QAbstractItemModel>
7#include <QObject>
8#include <QString>
9#include <QtQmlIntegration>
10#include <map>
11#include <string>
12
14
19
20namespace hmi {
21
50class CharacterSheetModel : public QObject {
51 Q_OBJECT
52 QML_ELEMENT
53
54 Q_PROPERTY(QString name READ name NOTIFY changed)
55 Q_PROPERTY(QString species READ species NOTIFY changed)
56 Q_PROPERTY(QString background READ background NOTIFY changed)
57 Q_PROPERTY(QString classAndLevel READ classAndLevel NOTIFY changed)
58 Q_PROPERTY(QString level READ level NOTIFY changed)
59 Q_PROPERTY(QString experience READ experience NOTIFY changed)
60
61 Q_PROPERTY(QString hitPoints READ hitPoints NOTIFY changed)
62 Q_PROPERTY(QString hitPointsMax READ hitPointsMax NOTIFY changed)
63 Q_PROPERTY(QString hitDice READ hitDice NOTIFY changed)
64 Q_PROPERTY(QString armorClass READ armorClass NOTIFY changed)
65 Q_PROPERTY(QString initiative READ initiative NOTIFY changed)
66 Q_PROPERTY(QString speed READ speed NOTIFY changed)
67 Q_PROPERTY(QString proficiencyBonus READ proficiencyBonus NOTIFY changed)
68 Q_PROPERTY(QString passivePerception READ passivePerception NOTIFY changed)
69
70 Q_PROPERTY(QAbstractItemModel* abilities READ abilities CONSTANT)
71 Q_PROPERTY(QAbstractItemModel* savingThrows READ savingThrows CONSTANT)
72 Q_PROPERTY(QAbstractItemModel* skills READ skills CONSTANT)
73
74public:
75 explicit CharacterSheetModel(QObject* parent = nullptr);
76
89 Q_INVOKABLE void loadDemonstrationCharacter();
90
91 [[nodiscard]] QString name() const {
92 return value("sheet.name");
93 }
94 [[nodiscard]] QString species() const {
95 return value("sheet.species");
96 }
97 [[nodiscard]] QString background() const {
98 return value("sheet.background");
99 }
100 [[nodiscard]] QString classAndLevel() const {
101 return value("sheet.class_and_level");
102 }
103 [[nodiscard]] QString level() const {
104 return value("sheet.level");
105 }
106 [[nodiscard]] QString experience() const {
107 return value("sheet.experience");
108 }
109 [[nodiscard]] QString hitPoints() const {
110 return value("sheet.hit_points");
111 }
112 [[nodiscard]] QString hitPointsMax() const {
113 return value("sheet.hit_points_max");
114 }
115 [[nodiscard]] QString hitDice() const {
116 return value("sheet.hit_dice");
117 }
118 [[nodiscard]] QString armorClass() const {
119 return value("sheet.armor_class");
120 }
121 [[nodiscard]] QString initiative() const {
122 return value("sheet.initiative");
123 }
124 [[nodiscard]] QString speed() const {
125 return value("sheet.speed");
126 }
127 [[nodiscard]] QString proficiencyBonus() const {
128 return value("sheet.proficiency_bonus");
129 }
130 [[nodiscard]] QString passivePerception() const {
131 return value("sheet.passive_perception");
132 }
133
134 [[nodiscard]] QAbstractItemModel* abilities() {
135 return &_abilities;
136 }
137 [[nodiscard]] QAbstractItemModel* savingThrows() {
138 return &_savingThrows;
139 }
140 [[nodiscard]] QAbstractItemModel* skills() {
141 return &_skills;
142 }
143
144signals:
149 void changed();
150
151private:
154 [[nodiscard]] QString value(const char* key) const;
155
156 std::map<std::string, std::string> _values;
160};
161
162} // namespace hmi
Les parties répétitives d'un écran, exposées au QML comme un modèle (LOT-86).
QString level
Definition CharacterSheetModel.h:58
QString proficiencyBonus() const
Definition CharacterSheetModel.h:127
QString passivePerception
Definition CharacterSheetModel.h:68
CharacterSheetModel(QObject *parent=nullptr)
Definition CharacterSheetModel.cpp:42
QML_ELEMENTQString name
Definition CharacterSheetModel.h:54
QString hitDice() const
Definition CharacterSheetModel.h:115
std::map< std::string, std::string > _values
Definition CharacterSheetModel.h:156
QString hitPoints
Definition CharacterSheetModel.h:61
QAbstractItemModel * savingThrows
Definition CharacterSheetModel.h:71
QString level() const
Definition CharacterSheetModel.h:103
QString background
Definition CharacterSheetModel.h:56
QString hitDice
Definition CharacterSheetModel.h:63
QString classAndLevel() const
Definition CharacterSheetModel.h:100
QString background() const
Definition CharacterSheetModel.h:97
QAbstractItemModel * skills()
Definition CharacterSheetModel.h:140
QString hitPoints() const
Definition CharacterSheetModel.h:109
QString initiative() const
Definition CharacterSheetModel.h:121
QString speed
Definition CharacterSheetModel.h:66
QAbstractItemModel * skills
Definition CharacterSheetModel.h:72
QString speed() const
Definition CharacterSheetModel.h:124
Q_INVOKABLE void loadDemonstrationCharacter()
Charge le personnage de démonstration livré en donnée.
Definition CharacterSheetModel.cpp:53
QAbstractItemModel * abilities()
Definition CharacterSheetModel.h:134
QString species() const
Definition CharacterSheetModel.h:94
QString hitPointsMax
Definition CharacterSheetModel.h:62
QString value(const char *key) const
Definition CharacterSheetModel.cpp:45
QString classAndLevel
Definition CharacterSheetModel.h:57
QString species
Definition CharacterSheetModel.h:55
SheetRowModel _savingThrows
Definition CharacterSheetModel.h:158
QString initiative
Definition CharacterSheetModel.h:65
SheetRowModel _abilities
Definition CharacterSheetModel.h:157
void changed()
Émis quand la fiche change en bloc.
SheetRowModel _skills
Definition CharacterSheetModel.h:159
QString experience
Definition CharacterSheetModel.h:59
QAbstractItemModel * savingThrows()
Definition CharacterSheetModel.h:137
QAbstractItemModel * abilities
Definition CharacterSheetModel.h:70
QString passivePerception() const
Definition CharacterSheetModel.h:130
QString experience() const
Definition CharacterSheetModel.h:106
QString hitPointsMax() const
Definition CharacterSheetModel.h:112
QString armorClass
Definition CharacterSheetModel.h:64
QString armorClass() const
Definition CharacterSheetModel.h:118
QString proficiencyBonus
Definition CharacterSheetModel.h:67
Liste de lignes libellé/valeur, pour un Repeater ou une ListView.
Definition SheetRowModel.h:42
Definition AudioEngine.cpp:15