1 /*
2 SPDX-FileCopyrightText: 2013-2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5 */
6
7 #include "application.h"
8
9 #include "core/contributorrepository.h"
10 #include "core/drawertrainingactions.h"
11 #include "core/editorsession.h"
12 #include "core/ieditablerepository.h"
13 #include "core/ilanguage.h"
14 #include "core/iresourcerepository.h"
15 #include "core/isessionactions.h"
16 #include "core/language.h"
17 #include "core/phoneme.h"
18 #include "core/phonemegroup.h"
19 #include "core/phrase.h"
20 #include "core/player.h"
21 #include "core/recorder.h"
22 #include "core/resources/editablecourseresource.h"
23 #include "core/resources/skeletonresource.h"
24 #include "core/trainingaction.h"
25 #include "core/trainingsession.h"
26 #include "core/unit.h"
27 #include "models/coursefiltermodel.h"
28 #include "models/coursemodel.h"
29 #include "models/languagemodel.h"
30 #include "models/languageresourcemodel.h"
31 #include "models/learningprogressmodel.h"
32 #include "models/phonemegroupmodel.h"
33 #include "models/phonememodel.h"
34 #include "models/phonemeunitmodel.h"
35 #include "models/phrasefiltermodel.h"
36 #include "models/phraselistmodel.h"
37 #include "models/phrasemodel.h"
38 #include "models/profilemodel.h"
39 #include "models/skeletonmodel.h"
40 #include "models/unitfiltermodel.h"
41 #include "models/unitmodel.h"
42 #include "qmlcontrols/iconitem.h"
43
44 #include "liblearnerprofile/src/learner.h"
45 #include "liblearnerprofile/src/learninggoal.h"
46 #include "liblearnerprofile/src/models/learninggoalmodel.h"
47 #include "liblearnerprofile/src/profilemanager.h"
48
49 #include <QObject>
50 #include <QQmlComponent>
51 #include <QQmlContext>
52 #include <QQmlEngine>
53
Application(int & argc,char ** argv)54 Application::Application(int &argc, char **argv)
55 : QApplication(argc, argv)
56 {
57 registerQmlTypes();
58 }
59
resourceRepository() const60 IResourceRepository *Application::resourceRepository() const
61 {
62 return m_resourceRepository;
63 }
64
editableRepository() const65 IEditableRepository *Application::editableRepository() const
66 {
67 return qobject_cast<IEditableRepository *>(m_resourceRepository);
68 }
69
installResourceRepository(IResourceRepository * resourceRepository)70 void Application::installResourceRepository(IResourceRepository *resourceRepository)
71 {
72 m_resourceRepository = resourceRepository;
73 }
74
registerQmlTypes()75 void Application::registerQmlTypes()
76 {
77 qmlRegisterUncreatableType<TrainingSession>("artikulate", 1, 0, "TrainingSession", QStringLiteral("TrainingSession is unique object provided by the backend"));
78 qmlRegisterUncreatableType<EditorSession>("artikulate", 1, 0, "EditorSession", QStringLiteral("EditorSession is unique object provided by the backend"));
79 qmlRegisterUncreatableType<ContributorRepository>("artikulate", 1, 0, "ContributorRepository", QStringLiteral("ContributorRepository is unique object provided by the backend"));
80 qmlRegisterUncreatableType<LearnerProfile::ProfileManager>("artikulate", 1, 0, "ProfileManager", QStringLiteral("ProfileManager is unique object provided by the backend"));
81 qmlRegisterUncreatableType<EditableCourseResource>("artikulate", 1, 0, "EditableCourseResource", QStringLiteral("EditableCourseResource objects are backend objects"));
82 qmlRegisterUncreatableType<SkeletonResource>("artikulate", 1, 0, "SkeletonResource", QStringLiteral("SkeletonResource objects are backend objects"));
83 qmlRegisterUncreatableType<Phrase>("artikulate", 1, 0, "Phrase", QStringLiteral("Phrase objects are backend objects"));
84 qmlRegisterUncreatableType<Unit>("artikulate", 1, 0, "Unit", QStringLiteral("Unit objects are backend objects"));
85
86 // interfaces
87 qmlRegisterInterface<ICourse>("ICourse");
88 qmlRegisterInterface<IEditableCourse>("IEditableCourse");
89 qmlRegisterInterface<IEditablePhrase>("IEditablePhrase");
90 qmlRegisterInterface<ILanguage>("ILanguage");
91 qmlRegisterInterface<IPhrase>("IPhrase");
92 qmlRegisterInterface<IResourceRepository>("IEditableRepository");
93 qmlRegisterInterface<IResourceRepository>("IResourceRepository");
94 qmlRegisterInterface<ISessionActions>("ISessionActions");
95 qmlRegisterInterface<IUnit>("IUnit");
96
97 // concrete instantiable types
98 qmlRegisterType<DrawerTrainingActions>("artikulate", 1, 0, "DrawerTrainingActions");
99 qmlRegisterType<IconItem>("artikulate", 1, 0, "Icon");
100 qmlRegisterType<Language>("artikulate", 1, 0, "Language");
101 qmlRegisterType<LearnerProfile::Learner>("artikulate", 1, 0, "Learner");
102 qmlRegisterType<LearnerProfile::LearningGoal>("artikulate", 1, 0, "LearningGoal");
103 qmlRegisterType<Phoneme>("artikulate", 1, 0, "Phoneme");
104 qmlRegisterType<PhonemeGroup>("artikulate", 1, 0, "PhonemeGroup");
105 qmlRegisterType<Player>("artikulate", 1, 0, "Player");
106 qmlRegisterType<Recorder>("artikulate", 1, 0, "Recorder");
107 qmlRegisterType<TrainingAction>("artikulate", 1, 0, "TrainingAction");
108
109 // models
110 qmlRegisterType<CourseFilterModel>("artikulate", 1, 0, "CourseFilterModel");
111 qmlRegisterType<CourseModel>("artikulate", 1, 0, "CourseModel");
112 qmlRegisterType<LanguageModel>("artikulate", 1, 0, "LanguageModel");
113 qmlRegisterType<LanguageResourceModel>("artikulate", 1, 0, "LanguageResourceModel");
114 qmlRegisterType<LearnerProfile::LearningGoalModel>("artikulate", 1, 0, "LearningGoalModel");
115 qmlRegisterType<PhonemeGroupModel>("artikulate", 1, 0, "PhonemeGroupModel");
116 qmlRegisterType<PhonemeModel>("artikulate", 1, 0, "PhonemeModel");
117 qmlRegisterType<PhonemeUnitModel>("artikulate", 1, 0, "PhonemeUnitModel");
118 qmlRegisterType<PhraseFilterModel>("artikulate", 1, 0, "PhraseFilterModel");
119 qmlRegisterType<PhraseListModel>("artikulate", 1, 0, "PhraseListModel");
120 qmlRegisterType<PhraseModel>("artikulate", 1, 0, "PhraseModel");
121 qmlRegisterType<ProfileModel>("artikulate", 1, 0, "ProfileModel");
122 qmlRegisterType<SkeletonModel>("artikulate", 1, 0, "SkeletonModel");
123 qmlRegisterType<UnitFilterModel>("artikulate", 1, 0, "UnitFilterModel");
124 qmlRegisterType<UnitModel>("artikulate", 1, 0, "UnitModel");
125 // qmlRegisterType<LearningProgressModel>("artikulate", 1, 0, "LearningProgressModel");//TODO must be ported to new trainingsession
126 }
127