Debian Codegraph @

liblearnerprofile/src/learner.h

raw
1 /*
2 SPDX-FileCopyrightText: 2013-2016 Andreas Cord-Landwehr <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6
7 #ifndef LEARNER_H
8 #define LEARNER_H
9
10 #include "learninggoal.h"
11 #include "liblearnerprofile_export.h"
12 #include <QObject>
13
14 namespace LearnerProfile
15 {
16 class LearnerPrivate;
17 class LearningGoal;
18
19 /**
20 * \class Learner
21 */
22 class LIBLEARNERPROFILE_EXPORT Learner : public QObject
23 {
24 Q_OBJECT
25 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
26 Q_PROPERTY(int id READ identifier WRITE setIdentifier NOTIFY identifierChanged)
27 Q_PROPERTY(QString imageUrl READ imageUrl NOTIFY imageChanged)
28 Q_PROPERTY(QList<LearnerProfile::LearningGoal *> goals READ goals NOTIFY goalCountChanged)
29
30 public:
31 // TODO workaround for QT-BUG-26415, fixed in Qt5.0
32 // we must simulate the LearningGoal::Category enum in Learner to be able to allow its usage
33 // as parameter for Q_INVOKABLE method
34 // can be removed with Qt 5.0 migration
35 Q_ENUMS(Category)
36 enum Category { Unspecified = 0, Language = 1 };
37
38 explicit Learner(QObject *parent = nullptr);
39 ~Learner() override;
40
41 QString name() const;
42 void setName(const QString &name);
43 /**
44 * \return URL to image
45 * \note since it is a local file the path begins with "file://"
46 */
47 QString imageUrl() const;
48 Q_INVOKABLE void clearImage();
49 void importImage(const QString &path);
50 int identifier() const;
51 void setIdentifier(int identifier);
52 /**
53 * \return list of all learning goals of learner
54 */
55 QList<LearningGoal *> goals() const;
56 Q_INVOKABLE void addGoal(LearnerProfile::LearningGoal *goal);
57 Q_INVOKABLE void removeGoal(LearnerProfile::LearningGoal *goal);
58 Q_INVOKABLE bool hasGoal(LearnerProfile::LearningGoal *goal) const;
59 void setActiveGoal(LearnerProfile::LearningGoal *goal);
60 Q_INVOKABLE void setActiveGoal(LearnerProfile::Learner::Category category, const QString &identifier);
61 Q_INVOKABLE LearnerProfile::LearningGoal *activeGoal(LearnerProfile::Learner::Category category) const;
62
63 Q_SIGNALS:
64 void nameChanged();
65 void imageChanged();
66 void identifierChanged();
67 void goalAboutToBeAdded(LearningGoal *, int);
68 void goalAdded();
69 void goalAboutToBeRemoved(int);
70 void goalRemoved(Learner *, LearningGoal *);
71 void goalCountChanged();
72 void activeGoalChanged();
73
74 private:
75 Q_DISABLE_COPY(Learner)
76 const QScopedPointer<LearnerPrivate> d;
77 };
78 }
79
80 #endif // LEARNER_H