File indexing completed on 2024-04-14 14:08:44
0001 /* GCompris - ActivityInfo.h 0002 * 0003 * SPDX-FileCopyrightText: 2014 Bruno Coudoin <bruno.coudoin@gcompris.net> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 #ifndef ACTIVITYINFO_H 0011 #define ACTIVITYINFO_H 0012 0013 #include <QObject> 0014 #include <QString> 0015 #include <QStringList> 0016 #include <QQmlListProperty> 0017 #include "Dataset.h" 0018 0019 /** 0020 * @class ActivityInfo 0021 * @short A QML component holding meta information about an activity. 0022 * @ingroup components 0023 * 0024 * Each GCompris activity has to provide some meta data about itself in form 0025 * of an ActivityInfo definition. This data will be used to register it in the 0026 * ActivityInfoTree, and populate the full screen help dialog. 0027 * 0028 * @sa DialogHelp 0029 */ 0030 class ActivityInfo : public QObject 0031 { 0032 Q_OBJECT 0033 0034 /** 0035 * Name of the main activity QML file. 0036 * 0037 * Example: "activity/Activity.qml" 0038 */ 0039 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 0040 0041 /** 0042 * Section(s) this activity belongs to. 0043 * 0044 * An activity can belong to one or multiple activity sections 0045 * (separated by whitespace) out of: 0046 * computer, discovery, experiment, fun, math, puzzle, 0047 * reading, strategy. 0048 */ 0049 Q_PROPERTY(QString section READ section WRITE setSection NOTIFY sectionChanged) 0050 0051 /** 0052 * Difficulty of the activity. 0053 * 0054 * A difficulty level from 1 (easiest) to 6 (most difficult). 0055 */ 0056 Q_PROPERTY(quint32 difficulty READ difficulty WRITE setDifficulty NOTIFY difficultyChanged) 0057 0058 /** 0059 * Minimal difficulty of the activity dataset. 0060 * 0061 * A difficulty level from 1 (easiest) to 6 (most difficult). 0062 */ 0063 Q_PROPERTY(quint32 minimalDifficulty READ minimalDifficulty WRITE setMinimalDifficulty NOTIFY minimalDifficultyChanged) 0064 0065 /** 0066 * Maximal difficulty of the activity dataset. 0067 * 0068 * A difficulty level from 1 (easiest) to 6 (most difficult). 0069 */ 0070 Q_PROPERTY(quint32 maximalDifficulty READ maximalDifficulty WRITE setMaximalDifficulty NOTIFY maximalDifficultyChanged) 0071 0072 /** 0073 * Relative path to the icon of the activity. 0074 * 0075 * Example: "activity/activity.svg" 0076 */ 0077 Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) 0078 0079 /** 0080 * Author of the activity. 0081 */ 0082 Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged) 0083 0084 /** 0085 * Title of the activity. 0086 */ 0087 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) 0088 0089 /** 0090 * Description of the activity. 0091 */ 0092 Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged) 0093 0094 /** 0095 * Goal that this activity wants to achieve. 0096 */ 0097 Q_PROPERTY(QString goal READ goal WRITE setGoal NOTIFY goalChanged) 0098 0099 /** 0100 * Prerequisite for using this activity. 0101 */ 0102 Q_PROPERTY(QString prerequisite READ prerequisite WRITE setPrerequisite NOTIFY prerequisiteChanged) 0103 0104 /** 0105 * Manual describing the activity's usage. 0106 */ 0107 Q_PROPERTY(QString manual READ manual WRITE setManual NOTIFY manualChanged) 0108 0109 /** 0110 * Credits to third parties. 0111 */ 0112 Q_PROPERTY(QString credit READ credit WRITE setCredit NOTIFY creditChanged) 0113 0114 Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged) 0115 0116 /** 0117 * This activity is enabled. 0118 */ 0119 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) 0120 0121 /** 0122 * Version in which this activity has been created 0123 */ 0124 Q_PROPERTY(int createdInVersion READ createdInVersion WRITE setCreatedInVersion NOTIFY createdInVersionChanged) 0125 0126 /** 0127 * Contains a list of string defining the folder names for the different datasets. 0128 */ 0129 Q_PROPERTY(QStringList levels READ levels WRITE setLevels NOTIFY levelsChanged) 0130 0131 /** 0132 * Current datasets used for the activity (it is among the 'levels' list) 0133 */ 0134 Q_PROPERTY(QStringList currentLevels READ currentLevels WRITE setCurrentLevels NOTIFY currentLevelsChanged) 0135 0136 /** 0137 * True if the activity has a configuration 0138 */ 0139 Q_PROPERTY(bool hasConfig READ hasConfig CONSTANT) 0140 0141 /** 0142 * True if the activity has a dataset 0143 */ 0144 Q_PROPERTY(bool hasDataset READ hasDataset CONSTANT) 0145 0146 public: 0147 /// @cond INTERNAL_DOCS 0148 explicit ActivityInfo(QObject *parent = nullptr); 0149 0150 QString name() const; 0151 void setName(const QString &); 0152 QString section() const; 0153 void setSection(const QString &); 0154 quint32 difficulty() const; 0155 void setDifficulty(const quint32 &); 0156 quint32 minimalDifficulty() const; 0157 void setMinimalDifficulty(const quint32 &); 0158 quint32 maximalDifficulty() const; 0159 void setMaximalDifficulty(const quint32 &); 0160 QString icon() const; 0161 void setIcon(const QString &); 0162 QString author() const; 0163 void setAuthor(const QString &); 0164 QString title() const; 0165 void setTitle(const QString &); 0166 QString description() const; 0167 void setDescription(const QString &); 0168 QString goal() const; 0169 void setGoal(const QString &); 0170 QString prerequisite() const; 0171 void setPrerequisite(const QString &); 0172 QString manual() const; 0173 void setManual(const QString &); 0174 QString credit() const; 0175 void setCredit(const QString &); 0176 bool favorite() const; 0177 void setFavorite(const bool); 0178 bool enabled() const; 0179 void setEnabled(const bool); 0180 int createdInVersion() const; 0181 void setCreatedInVersion(const int); 0182 QStringList levels() const; 0183 void setLevels(const QStringList &); 0184 QStringList currentLevels() const; 0185 void setCurrentLevels(const QStringList &); 0186 bool hasConfig() const; 0187 bool hasDataset() const; 0188 QQmlListProperty<Dataset> datasets(); 0189 void fillDatasets(QQmlEngine *engine); 0190 void enableDatasetsBetweenDifficulties(quint32 levelMin, quint32 levelMax); 0191 0192 void addDataset(const QString &name, Dataset *dataset); 0193 Q_INVOKABLE Dataset *getDataset(const QString &name) const; 0194 0195 /* 0196 * Reset all the current levels to be enabled. 0197 */ 0198 void resetLevels(); 0199 0200 Q_SIGNALS: 0201 void nameChanged(); 0202 void sectionChanged(); 0203 void difficultyChanged(); 0204 void minimalDifficultyChanged(); 0205 void maximalDifficultyChanged(); 0206 void iconChanged(); 0207 void authorChanged(); 0208 void titleChanged(); 0209 void descriptionChanged(); 0210 void goalChanged(); 0211 void prerequisiteChanged(); 0212 void manualChanged(); 0213 void creditChanged(); 0214 void favoriteChanged(); 0215 void enabledChanged(); 0216 void createdInVersionChanged(); 0217 void levelsChanged(); 0218 void currentLevelsChanged(); 0219 void datasetsChanged(); 0220 /// @endcond 0221 0222 private: 0223 QString m_name; 0224 QString m_section; 0225 quint32 m_difficulty; 0226 quint32 m_minimalDifficulty; 0227 quint32 m_maximalDifficulty; 0228 QString m_icon; 0229 QString m_author; 0230 QString m_title; 0231 QString m_description; 0232 QString m_goal; 0233 QString m_prerequisite; 0234 QString m_manual; 0235 QString m_credit; 0236 bool m_favorite; 0237 bool m_enabled; 0238 int m_createdInVersion; 0239 QStringList m_levels; 0240 QStringList m_currentLevels; 0241 0242 /* The key is the name of the dataset */ 0243 QMap<QString, Dataset *> m_datasets; 0244 /* 0245 * Set current level once we have the name and the levels 0246 */ 0247 void setCurrentLevels(); 0248 0249 /* 0250 * Compute minimal and maximal difficulty depending on the current levels. 0251 */ 0252 void computeMinMaxDifficulty(); 0253 }; 0254 0255 #endif // ACTIVITYINFO_H