diff --git a/autotests/mocks/languagestub.h b/autotests/mocks/languagestub.h index 2f03f6e..2fdc4c2 100644 --- a/autotests/mocks/languagestub.h +++ b/autotests/mocks/languagestub.h @@ -1,86 +1,86 @@ /* * Copyright 2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef LANGUAGESTUB_H #define LANGUAGESTUB_H #include "core/phonemegroup.h" #include "src/core/ilanguage.h" #include #include class Phoneme; class PhonemeGroup; class LanguageStub : public ILanguage { public: - LanguageStub(QString id) + explicit LanguageStub(QString id) : m_id(id) { } ~LanguageStub() override; QString id() const override { return m_id; } QString title() const override { return m_title; } void setTitle(QString title) { m_title = title; emit titleChanged(); } QString i18nTitle() const override { return "i18n title"; } QVector> phonemes() const override { QVector> phonemes; for (auto group : m_phonemeGroups) { phonemes.append(group->phonemes()); } return phonemes; } QVector> phonemeGroups() const override { return m_phonemeGroups; } std::shared_ptr addPhonemeGroup(const QString &identifier, const QString &title) { std::shared_ptr phonemeGroup(new PhonemeGroup); phonemeGroup->setId(identifier); phonemeGroup->setTitle(title); m_phonemeGroups.append(phonemeGroup); return phonemeGroup; } private: QString m_id {"UNKNOWN_ID"}; QString m_title {"title"}; QVector> m_phonemeGroups; }; #endif diff --git a/autotests/mocks/resourcerepositorystub.h b/autotests/mocks/resourcerepositorystub.h index 0f7e637..b97ac2e 100644 --- a/autotests/mocks/resourcerepositorystub.h +++ b/autotests/mocks/resourcerepositorystub.h @@ -1,115 +1,115 @@ /* * Copyright 2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef RESOURCEREPOSITORYSTUB_H #define RESOURCEREPOSITORYSTUB_H #include "core/iresourcerepository.h" #include "core/language.h" #include #include #include class ICourse; /** * @brief The ResourceRepositoryStub that only provides languages and a storage location, but nothing else */ class ResourceRepositoryStub : public IResourceRepository { Q_OBJECT public: - ResourceRepositoryStub(std::vector> languages) + explicit ResourceRepositoryStub(std::vector> languages) { for (auto &language : languages) { m_languages.append(std::move(language)); } } - ResourceRepositoryStub(std::vector> languages) + explicit ResourceRepositoryStub(std::vector> languages) { for (auto &language : languages) { m_languages.append(language); } } ResourceRepositoryStub(std::vector> languages, std::vector> courses) { for (auto &language : languages) { m_languages.append(language); } for (auto &course : courses) { m_courses.append(course); } } ~ResourceRepositoryStub() override; QUrl storageLocation() const override { return m_storageLocation; } QVector> courses() const override { return m_courses; } QVector> courses(const QString &languageId) const override { Q_UNUSED(languageId); return m_courses; // do not filter by languages } void reloadCourses() override { ; // do nothing, stub shall only provide languages } QVector> languages() const override { return m_languages; } void appendCourse(std::shared_ptr course) { emit courseAboutToBeAdded(course, m_courses.count()); m_courses.append(course); emit courseAdded(); } void removeCourse(std::shared_ptr course) { auto index = m_courses.indexOf(course); Q_ASSERT(index >= 0); if (index >= 0) { emit courseAboutToBeRemoved(index); m_courses.remove(index); emit courseRemoved(); } } private: QUrl m_storageLocation; QVector> m_languages; QVector> m_courses; }; #endif diff --git a/liblearnerprofile/src/profilemanager.cpp b/liblearnerprofile/src/profilemanager.cpp index a268726..b5430cd 100644 --- a/liblearnerprofile/src/profilemanager.cpp +++ b/liblearnerprofile/src/profilemanager.cpp @@ -1,296 +1,296 @@ /* * Copyright 2013-2014 Andreas Cord-Landwehr * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "profilemanager.h" #include "learner.h" #include "storage.h" #include "liblearner_debug.h" #include #include #include #include #include #include #include using namespace LearnerProfile; /// BEGIN: ProfileManagerPrivate namespace LearnerProfile { class ProfileManagerPrivate { public: ProfileManagerPrivate(); ~ProfileManagerPrivate() { } void sync(); QList m_profiles; Learner *m_activeProfile; QList m_goals; std::unique_ptr m_config; Storage m_storage; }; } LearnerProfile::ProfileManagerPrivate::ProfileManagerPrivate() : m_profiles(QList()) , m_activeProfile(nullptr) , m_config(new KConfig(QStringLiteral("learnerprofilerc"))) { // load all profiles from storage m_goals.append(m_storage.loadGoals()); m_profiles.append(m_storage.loadProfiles(m_goals)); // set last used profile KConfigGroup activeProfileGroup(m_config.get(), "ActiveProfile"); int lastProfileId = activeProfileGroup.readEntry("profileId", "0").toInt(); QList activeGoalsCategories = activeProfileGroup.readEntry("activeGoalsCategories", QList()); QList activeGoalsIdentifiers = activeProfileGroup.readEntry("activeGoalsIdentifiers", QList()); foreach (Learner *learner, m_profiles) { if (learner->identifier() == lastProfileId) { m_activeProfile = learner; // set active goals if (activeGoalsCategories.count() == activeGoalsIdentifiers.count()) { for (int i = 0; i < activeGoalsCategories.count(); ++i) { m_activeProfile->setActiveGoal(static_cast(activeGoalsCategories.at(i)), activeGoalsIdentifiers.at(i)); } } else { qCCritical(LIBLEARNER_LOG()) << "Inconsistent goal category / identifier pairs found: aborting."; } break; } } if (m_activeProfile == nullptr) { qCDebug(LIBLEARNER_LOG()) << "No last active profile found, falling back to first found profile"; if (m_profiles.size() > 0) { m_activeProfile = m_profiles.at(0); } } } void ProfileManagerPrivate::sync() { // sync last used profile data if (m_activeProfile) { KConfigGroup activeProfileGroup(m_config.get(), "ActiveProfile"); activeProfileGroup.writeEntry("profileId", m_activeProfile->identifier()); // compute activer learning goals by category QList goalCatogries; QList goalIdentifiers; // compute used goals foreach (LearningGoal *goal, m_activeProfile->goals()) { if (!goalCatogries.contains(static_cast(goal->category()))) { goalCatogries.append(static_cast(goal->category())); } } // compute active goals foreach (int category, goalCatogries) { goalIdentifiers.append(m_activeProfile->activeGoal(static_cast(category))->identifier()); } activeProfileGroup.writeEntry("activeGoalsCategories", goalCatogries); activeProfileGroup.writeEntry("activeGoalsIdentifiers", goalIdentifiers); } else { qCCritical(LIBLEARNER_LOG()) << "No active profile selected, aborting sync."; } m_config->sync(); // TODO only sync changed learner foreach (Learner *learner, m_profiles) { m_storage.storeProfile(learner); } } /// END: ProfileManagerPrivate ProfileManager::ProfileManager(QObject *parent) : QObject(parent) , d(new ProfileManagerPrivate) { connect(this, &ProfileManager::profileAdded, this, &ProfileManager::profileCountChanged); connect(this, &ProfileManager::profileRemoved, this, &ProfileManager::profileCountChanged); foreach (Learner *learner, d->m_profiles) { connect(learner, &Learner::goalRemoved, this, &ProfileManager::removeLearningGoal); } } ProfileManager::~ProfileManager() { for (auto learner : d->m_profiles) { learner->deleteLater(); } for (auto goal : d->m_goals) { goal->deleteLater(); } } QList ProfileManager::profiles() const { return d->m_profiles; } int ProfileManager::profileCount() const { return profiles().length(); } void ProfileManager::openImageFileDialog() { const QString imagePath = QFileDialog::getOpenFileName(nullptr, i18n("Open Image"), QLatin1String(""), i18n("Image Files (*.png *.jpg *.bmp)")); d->m_activeProfile->importImage(imagePath); } Learner *ProfileManager::addProfile(const QString &name) { Learner *learner = new Learner(this); learner->setName(name); // set id int maxUsedId = 0; foreach (Learner *cpLearner, d->m_profiles) { if (cpLearner->identifier() >= maxUsedId) { maxUsedId = cpLearner->identifier(); } } learner->setIdentifier(maxUsedId + 1); d->m_profiles.append(learner); d->m_storage.storeProfile(learner); emit profileAdded(learner, d->m_profiles.count() - 1); if (activeProfile() == nullptr) { setActiveProfile(learner); } - connect(learner, SIGNAL(goalRemoved(Learner *, LearningGoal *)), this, SLOT(removeLearningGoal(Learner *, LearningGoal *))); + connect(learner, &Learner::goalRemoved, this, &ProfileManager::removeLearningGoal); return learner; } void ProfileManager::removeProfile(Learner *learner) { int index = d->m_profiles.indexOf(learner); if (index < 0) { qCWarning(LIBLEARNER_LOG()) << "Profile was not found, aborting"; return; } emit profileAboutToBeRemoved(index); d->m_profiles.removeAt(index); d->m_storage.removeProfile(learner); if (d->m_activeProfile == learner) { if (d->m_profiles.isEmpty()) { setActiveProfile(nullptr); } else { setActiveProfile(d->m_profiles.at(0)); } } emit profileRemoved(); } void ProfileManager::removeLearningGoal(Learner *learner, LearningGoal *goal) { d->m_storage.removeRelation(learner, goal); } Learner *ProfileManager::profile(int index) { if (index < 0 || index >= profiles().count()) { return nullptr; } return profiles().at(index); } QList ProfileManager::goals() const { return d->m_goals; } LearningGoal *ProfileManager::registerGoal(LearningGoal::Category category, const QString &identifier, const QString &name) { // test whether goal is already registered foreach (LearningGoal *cmpGoal, d->m_goals) { if (cmpGoal->category() == category && cmpGoal->identifier() == identifier) { return cmpGoal; } } LearningGoal *goal = new LearningGoal(category, identifier, this); goal->setName(name); d->m_goals.append(goal); d->m_storage.storeGoal(goal); return goal; } LearnerProfile::LearningGoal *LearnerProfile::ProfileManager::goal(LearningGoal::Category category, const QString &identifier) const { foreach (LearningGoal *goal, d->m_goals) { if (goal->category() == category && goal->identifier() == identifier) { return goal; } } return nullptr; } void ProfileManager::recordProgress(Learner *learner, LearningGoal *goal, const QString &container, const QString &item, int logPayload, int valuePayload) { if (!learner) { qCDebug(LIBLEARNER_LOG()) << "No learner set, no data stored"; return; } d->m_storage.storeProgressLog(learner, goal, container, item, logPayload, QDateTime::currentDateTime()); d->m_storage.storeProgressValue(learner, goal, container, item, valuePayload); } QHash ProfileManager::progressValues(Learner *learner, LearningGoal *goal, const QString &container) const { if (!learner || !goal) { return QHash(); } return d->m_storage.readProgressValues(learner, goal, container); } void ProfileManager::sync() { d->sync(); } void ProfileManager::sync(Learner *learner) { d->m_storage.storeProfile(learner); } Learner *ProfileManager::activeProfile() const { return d->m_activeProfile; } void ProfileManager::setActiveProfile(Learner *learner) { if (learner == d->m_activeProfile) { return; } d->m_activeProfile = learner; emit activeProfileChanged(); } diff --git a/src/core/drawertrainingactions.h b/src/core/drawertrainingactions.h index c35561d..acd564f 100644 --- a/src/core/drawertrainingactions.h +++ b/src/core/drawertrainingactions.h @@ -1,55 +1,55 @@ /* * Copyright 2018-2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DRAWERTRAININGACTIONS_H #define DRAWERTRAININGACTIONS_H #include "artikulatecore_export.h" #include "isessionactions.h" #include class Course; class ARTIKULATECORE_EXPORT DrawerTrainingActions : public QObject { Q_OBJECT Q_PROPERTY(ISessionActions *session READ session WRITE setSession NOTIFY sessionChanged) Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) public: - DrawerTrainingActions(QObject *parent = nullptr); + explicit DrawerTrainingActions(QObject *parent = nullptr); void setSession(ISessionActions *session); ISessionActions *session() const; QList actions() const; Q_SIGNALS: void actionsChanged(); void sessionChanged(); /** * Notify that course view shall be displayed. */ void triggerPhraseView(); private: ISessionActions *m_session {nullptr}; TrainingAction *m_defaultAction {nullptr}; }; #endif diff --git a/src/core/isessionactions.h b/src/core/isessionactions.h index 84161bb..9ac82b5 100644 --- a/src/core/isessionactions.h +++ b/src/core/isessionactions.h @@ -1,65 +1,65 @@ /* * Copyright 2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef ISESSIONACTIONS_H #define ISESSIONACTIONS_H #include "artikulatecore_export.h" #include #include class ICourse; class IPhrase; class TrainingAction; /** * \class ISessionActions * * Interface for both training and editor sessions that exposes simple iterator functionalities for a selecte course. * The interface provides all properties that are needed to create a navigatible menu. */ class ARTIKULATECORE_EXPORT ISessionActions : public QObject { Q_OBJECT public: - ISessionActions(QObject *parent) + explicit ISessionActions(QObject *parent) : QObject(parent) { } virtual ~ISessionActions() = default; virtual TrainingAction *activeAction() const = 0; virtual void setActivePhrase(IPhrase *phrase) = 0; /** * \brief Return tree of training actions * * The return actions form a 2-level hierarchy: * - the first level are all units * - the unit actions may contain sub-actions, which are the phrases */ virtual QVector trainingActions() const = 0; Q_SIGNALS: void courseChanged(); void actionsChanged(); void phraseChanged(); }; Q_DECLARE_INTERFACE(ISessionActions, "ISessionActions") #endif diff --git a/src/core/trainingaction.h b/src/core/trainingaction.h index e618ccd..5e51406 100644 --- a/src/core/trainingaction.h +++ b/src/core/trainingaction.h @@ -1,97 +1,97 @@ /* * Copyright 2018-2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef TRAININGACTION_H #define TRAININGACTION_H #include "artikulatecore_export.h" #include "iphrase.h" #include "trainingactionicon.h" #include "trainingsession.h" #include #include #include class DrawerTrainingActions; class ARTIKULATECORE_EXPORT TrainingAction : public QAbstractListModel { Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QString title READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QObject *icon READ icon CONSTANT) Q_PROPERTY(bool visible MEMBER m_visible CONSTANT) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool checked READ checked NOTIFY checkedChanged) Q_PROPERTY(QString tooltip MEMBER m_tooltip CONSTANT) Q_PROPERTY(QAbstractItemModel *children READ actionModel NOTIFY actionsChanged) Q_PROPERTY(bool checkable MEMBER m_checkable CONSTANT) Q_PROPERTY(int length READ actionsCount NOTIFY actionsChanged) public: enum ModelRoles { ModelDataRole = Qt::UserRole + 1 }; - TrainingAction(QObject *parent = nullptr); - TrainingAction(const QString &text, QObject *parent = nullptr); + explicit TrainingAction(QObject *parent = nullptr); + explicit TrainingAction(const QString &text, QObject *parent = nullptr); TrainingAction(std::shared_ptr phrase, ISessionActions *session, QObject *parent = nullptr); Q_INVOKABLE void trigger(); bool enabled() const; void setEnabled(bool enabled); QString text() const; void setText(QString text); void setChecked(bool checked); bool checked() const; QObject *icon(); IPhrase *phrase() const; QAbstractListModel *actionModel(); QVector actions() const; int actionsCount() const; bool hasActions() { return m_actions.count() > 0; } TrainingAction *action(int index) const; void appendAction(TrainingAction *action); void clearActions(); QHash roleNames() const override; int columnCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; Q_SIGNALS: void actionsChanged(); void enabledChanged(bool enabled); void checkedChanged(bool checked); void textChanged(QString text); private: QVector m_actions; QString m_text; TrainingActionIcon m_icon; bool m_visible {true}; bool m_enabled {true}; bool m_checked {false}; bool m_checkable {false}; QString m_tooltip {QString()}; std::shared_ptr m_phrase; ISessionActions *m_session {nullptr}; }; #endif diff --git a/src/mainwindow_editor.h b/src/mainwindow_editor.h index 4d0656b..d61908b 100644 --- a/src/mainwindow_editor.h +++ b/src/mainwindow_editor.h @@ -1,63 +1,63 @@ /* * Copyright 2015 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MAINWINDOW_EDITOR_H #define MAINWINDOW_EDITOR_H #include "core/contributorrepository.h" #include "core/trainingsession.h" #include class EditorSession; class QQuickWidget; class MainWindowEditor : public QQmlApplicationEngine { Q_OBJECT public: /** * Default Constructor */ - MainWindowEditor(ContributorRepository *repository); + explicit MainWindowEditor(ContributorRepository *repository); /** * Default Destructor */ virtual ~MainWindowEditor(); ContributorRepository *resourceRepository() const; void setupActions(); public Q_SLOTS: void showSettingsDialog(); void save(); void quit(); Q_SIGNALS: void modeChanged(bool); private: ContributorRepository *m_repository; EditorSession *m_editorSession; }; #endif diff --git a/src/models/coursemodel.h b/src/models/coursemodel.h index 6bb8ef1..59f225a 100644 --- a/src/models/coursemodel.h +++ b/src/models/coursemodel.h @@ -1,62 +1,62 @@ /* * Copyright 2013-2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef COURSEMODEL_H #define COURSEMODEL_H #include "artikulatecore_export.h" #include #include class IResourceRepository; class ICourse; class Language; class ARTIKULATECORE_EXPORT CourseModel : public QAbstractListModel { Q_OBJECT public: enum courseRoles { TitleRole = Qt::UserRole + 1, I18nTitleRole, DescriptionRole, IdRole, LanguageRole, DataRole }; explicit CourseModel(QObject *parent = nullptr); - CourseModel(IResourceRepository *repository, QObject *parent = nullptr); + explicit CourseModel(IResourceRepository *repository, QObject *parent = nullptr); ~CourseModel() override = default; QHash roleNames() const override; IResourceRepository *resourceRepository() const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; Q_INVOKABLE QVariant course(int index) const; protected: void setResourceRepository(IResourceRepository *resourceRepository); private Q_SLOTS: void onCourseAboutToBeAdded(std::shared_ptr course, int index); void onCourseAdded(); void onCourseAboutToBeRemoved(int row); private: IResourceRepository *m_resourceRepository {nullptr}; QVector m_updateConnections; }; #endif // COURSEMODEL_H diff --git a/src/models/skeletonmodel.h b/src/models/skeletonmodel.h index f423b5f..92baffe 100644 --- a/src/models/skeletonmodel.h +++ b/src/models/skeletonmodel.h @@ -1,63 +1,63 @@ /* * Copyright 2013-2019 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SKELETONMODEL_H #define SKELETONMODEL_H #include "artikulatecore_export.h" #include #include class IEditableRepository; class IEditableCourse; class ICourse; class ARTIKULATECORE_EXPORT SkeletonModel : public QAbstractListModel { Q_OBJECT public: enum skeletonRoles { TitleRole = Qt::UserRole + 1, DescriptionRole, IdRole, DataRole }; explicit SkeletonModel(QObject *parent = nullptr); - SkeletonModel(IEditableRepository *repository, QObject *parent = nullptr); + explicit SkeletonModel(IEditableRepository *repository, QObject *parent = nullptr); ~SkeletonModel() override = default; QHash roleNames() const override; IEditableRepository *resourceRepository() const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; Q_INVOKABLE QVariant skeleton(int index) const; protected: void setResourceRepository(IEditableRepository *resourceRepository); private Q_SLOTS: void onSkeletonAboutToBeAdded(std::shared_ptr skeleton, int index); void onSkeletonAdded(); void onSkeletonAboutToBeRemoved(int row); void onSkeletonRemoved(); private: IEditableRepository *m_repository {nullptr}; QVector m_updateConnections; }; #endif // SKELETONMODEL_H