| 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 LEARNINGGOALMODEL_H |
| 8 |
#define LEARNINGGOALMODEL_H |
| 9 |
|
| 10 |
#include "liblearnerprofile_export.h" |
| 11 |
#include <QAbstractListModel> |
| 12 |
#include <QObject> |
| 13 |
|
| 14 |
#include "../profilemanager.h" |
| 15 |
class LearningGoalModelPrivate; |
| 16 |
|
| 17 |
namespace LearnerProfile |
| 18 |
{ |
| 19 |
class ProfileManager; |
| 20 |
class LearningGoal; |
| 21 |
class Learner; |
| 22 |
|
| 23 |
class LIBLEARNERPROFILE_EXPORT LearningGoalModel : public QAbstractListModel |
| 24 |
{ |
| 25 |
Q_OBJECT |
| 26 |
Q_PROPERTY(LearnerProfile::ProfileManager *profileManager READ profileManager WRITE setProfileManager NOTIFY profileManagerChanged) |
| 27 |
Q_PROPERTY(LearnerProfile::Learner *learner READ learner WRITE setLearner NOTIFY learnerChanged) |
| 28 |
|
| 29 |
public: |
| 30 |
enum learningGoalRoles { TitleRole = Qt::UserRole + 1, IdRole, DataRole }; |
| 31 |
|
| 32 |
explicit LearningGoalModel(QObject *parent = nullptr); |
| 33 |
~LearningGoalModel() override; |
| 34 |
/** |
| 35 |
* Reimplemented from QAbstractListModel::roleNames() |
| 36 |
*/ |
| 37 |
virtual QHash<int, QByteArray> roleNames() const override; |
| 38 |
void setProfileManager(ProfileManager *profileManager); |
| 39 |
ProfileManager *profileManager() const; |
| 40 |
void setLearner(Learner *learner); |
| 41 |
Learner *learner() const; |
| 42 |
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
| 43 |
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
| 44 |
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
| 45 |
Q_INVOKABLE QVariant learningGoal(int index) const; |
| 46 |
|
| 47 |
Q_SIGNALS: |
| 48 |
void profileManagerChanged(); |
| 49 |
void learnerChanged(); |
| 50 |
void learningGoalChanged(int index); |
| 51 |
|
| 52 |
private Q_SLOTS: |
| 53 |
void onLearningGoalAboutToBeAdded(LearningGoal *goal, int index); |
| 54 |
void onLearningGoalAdded(); |
| 55 |
void onLearningGoalAboutToBeRemoved(int index); |
| 56 |
void emitLearningGoalChanged(int row); |
| 57 |
|
| 58 |
private: |
| 59 |
const QScopedPointer<LearningGoalModelPrivate> d; |
| 60 |
}; |
| 61 |
} |
| 62 |
|
| 63 |
#endif // LEARNINGGOALMODEL_H |