Commit 61bc6bb0 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Allow skeleton switching in editor.

parent 40619502
/*
* Copyright 2013-2014 Andreas Cord-Landwehr <cordlandwehr@kde.org>
* Copyright 2013-2015 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -20,6 +20,7 @@
#include "application.h"
#include "core/skeleton.h"
#include "core/course.h"
#include "core/language.h"
#include "core/resourcemanager.h"
......@@ -71,6 +72,7 @@ void Application::registerQmlTypes()
qmlRegisterType<LearnerProfile::ProfileManager>("artikulate", 1, 0, "ProfileManager");
qmlRegisterType<LearnerProfile::LearningGoal>("artikulate", 1, 0, "LearningGoal");
qmlRegisterType<Unit>("artikulate", 1, 0, "Unit");
qmlRegisterType<Skeleton>("artikulate", 1, 0, "Skeleton");
qmlRegisterType<Course>("artikulate", 1, 0, "Course");
qmlRegisterType<Language>("artikulate", 1, 0, "Language");
qmlRegisterType<ResourceManager>("artikulate", 1, 0, "ResourceManager");
......
......@@ -19,6 +19,7 @@
*/
#include "editorsession.h"
#include "skeleton.h"
#include "core/language.h"
#include "core/course.h"
#include "core/unit.h"
......@@ -28,6 +29,7 @@
EditorSession::EditorSession(QObject *parent)
: QObject(parent)
, m_skeleton(nullptr)
, m_language(nullptr)
, m_course(nullptr)
, m_unit(nullptr)
......@@ -38,6 +40,24 @@ EditorSession::EditorSession(QObject *parent)
}
Skeleton * EditorSession::skeleton() const
{
return m_skeleton;
}
void EditorSession::setSkeleton(Skeleton *skeleton)
{
if (m_skeleton == skeleton) {
return;
}
qDebug() << "set skeleton";
setLanguage(nullptr);
setCourse(nullptr);
setUnit(nullptr);
m_skeleton = skeleton;
emit skeletonChanged();
}
Language * EditorSession::language() const
{
return m_language;
......
......@@ -26,6 +26,7 @@
#include "phrase.h"
class QString;
class Skeleton;
class Language;
class Course;
class Unit;
......@@ -39,6 +40,7 @@ class PhonemeGroup;
class ARTIKULATELIB_EXPORT EditorSession : public QObject
{
Q_OBJECT
Q_PROPERTY(Skeleton *skeleton READ skeleton WRITE setSkeleton NOTIFY skeletonChanged)
Q_PROPERTY(Language *language READ language WRITE setLanguage NOTIFY languageChanged)
Q_PROPERTY(Course *course READ course WRITE setCourse NOTIFY courseChanged)
Q_PROPERTY(Unit *unit READ unit WRITE setUnit NOTIFY unitChanged)
......@@ -51,6 +53,8 @@ class ARTIKULATELIB_EXPORT EditorSession : public QObject
public:
explicit EditorSession(QObject *parent = nullptr);
Skeleton * skeleton() const;
void setSkeleton(Skeleton *skeleton);
Language * language() const;
void setLanguage(Language *language);
Course * course() const;
......@@ -73,6 +77,7 @@ private:
Phrase * previousPhrase() const;
Q_SIGNALS:
void skeletonChanged();
void languageChanged();
void courseChanged();
void unitChanged();
......@@ -82,6 +87,7 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(EditorSession)
Skeleton *m_skeleton;
Language *m_language;
Course *m_course;
Unit *m_unit;
......
......@@ -179,7 +179,7 @@ void SkeletonModel::updateMappings()
}
}
QVariant SkeletonModel::course(int row) const
QVariant SkeletonModel::skeleton(int row) const
{
return data(index(row, 0), SkeletonModel::DataRole);
}
\ No newline at end of file
}
......@@ -54,7 +54,7 @@ public:
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
int count() const;
Q_INVOKABLE QVariant course(int index) const;
Q_INVOKABLE QVariant skeleton(int index) const;
Q_SIGNALS:
void skeletonChanged(int index);
......
......@@ -72,6 +72,18 @@ Item
text: "no repository set"
color: "red"
}
ComboBox {
Layout.minimumWidth: 200
Layout.fillWidth: true
enabled: !buttonEditSkeleton.checked
model: SkeletonModel {
resourceManager: g_resourceManager
}
textRole: "title"
onCurrentIndexChanged: {
editorSession.skeleton = skeletonModel.skeleton(currentIndex)
}
}
}
RowLayout {
......@@ -145,8 +157,8 @@ Item
}
textRole: "title"
onCurrentIndexChanged: {
if (skeletonModel.course(currentIndex)) {
editorSession.course = skeletonModel.course(currentIndex)
if (skeletonModel.skeleton(currentIndex)) {
editorSession.skeleton = skeletonModel.skeleton(currentIndex)
}
}
onVisibleChanged: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment