1 /* 2 SPDX-FileCopyrightText: 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 5 */ 6 7 #ifndef PROFILEMANAGER_H 8 #define PROFILEMANAGER_H 9 10 #include "learninggoal.h" 11 #include "liblearnerprofile_export.h" 12 #include <QObject> 13 14 namespace LearnerProfile 15 { 16 class ProfileManagerPrivate; 17 class Learner; 18 class LearningGoal; 19 20 /** 21 * \class ProfileManager 22 */ 23 class LIBLEARNERPROFILE_EXPORT ProfileManager : public QObject 24 { 25 Q_OBJECT 26 Q_PROPERTY(int profileCount READ profileCount NOTIFY profileCountChanged) 27 Q_PROPERTY(LearnerProfile::Learner *activeProfile READ activeProfile WRITE setActiveProfile NOTIFY activeProfileChanged) 28 29 public: 30 enum Progress { Skip = 0, Next = 1 }; 31 32 explicit ProfileManager(QObject *parent = nullptr); 33 virtual ~ProfileManager(); 34 35 QList<Learner *> profiles() const; 36 int profileCount() const; 37 Q_INVOKABLE LearnerProfile::Learner *addProfile(const QString &name); 38 Q_INVOKABLE void removeProfile(LearnerProfile::Learner *learner); 39 Q_INVOKABLE LearnerProfile::Learner *profile(int index); 40 Q_INVOKABLE void openImageFileDialog(); 41 QList<LearningGoal *> goals() const; 42 /** 43 * Register learning goal if not registered yet. The registered goals will be stored at the 44 * internal database. 45 */ 46 LearningGoal *registerGoal(LearningGoal::Category category, const QString &identifier, const QString &name); 47 LearningGoal *goal(LearningGoal::Category category, const QString &identifier) const; 48 /** 49 * updates current learning goal by activity, adds new learning goal if necessary, 50 * stores log data for this activity 51 */ 52 void recordProgress(Learner *learner, LearningGoal *goal, const QString &container, const QString &item, int logPayload, int valuePayload); 53 /** 54 * \return progress value, or -1 if value is not available yet 55 */ 56 QHash<QString, int> progressValues(Learner *learner, LearningGoal *goal, const QString &container) const; 57 /** 58 * write all profiles to database 59 */ 60 Q_INVOKABLE void sync(); 61 /** 62 * write specified \p profile to database 63 */ 64 Q_INVOKABLE void sync(LearnerProfile::Learner *learner); 65 void setActiveProfile(LearnerProfile::Learner *learner); 66 LearnerProfile::Learner *activeProfile() const; 67 68 Q_SIGNALS: 69 void activeProfileChanged(); 70 void profileAdded(Learner *, int); 71 void profileAboutToBeRemoved(int); 72 void profileRemoved(); 73 void profileCountChanged(); 74 75 private Q_SLOTS: 76 void removeLearningGoal(Learner *learner, LearningGoal *goal); 77 78 private: 79 Q_DISABLE_COPY(ProfileManager) 80 const QScopedPointer<ProfileManagerPrivate> d; 81 }; 82 } 83 84 #endif // PROFILEMANAGER_H 85