Commit dd398892 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr

Fix basic editor operations for phrase editing

parent b9533bc4
......@@ -31,6 +31,7 @@ public:
virtual void setForeignId(const QString &id) = 0;
virtual void setCourse(std::shared_ptr<ICourse> course) = 0;
virtual void setTitle(const QString &title) = 0;
virtual void setI18nTitle(const QString &title) = 0;
virtual void addPhrase(std::shared_ptr<IEditablePhrase> phrase, int index) = 0;
virtual void removePhrase(std::shared_ptr<IPhrase> phrase) = 0;
......
......@@ -23,6 +23,7 @@ class ARTIKULATECORE_EXPORT IUnit : public QObject
Q_OBJECT
Q_PROPERTY(QString id READ id NOTIFY idChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString i18nTitle READ i18nTitle NOTIFY titleChanged)
public:
virtual ~IUnit() = default;
......@@ -30,6 +31,7 @@ public:
virtual QString foreignId() const = 0;
virtual std::shared_ptr<ICourse> course() const = 0;
virtual QString title() const = 0;
virtual QString i18nTitle() const = 0;
virtual QVector<std::shared_ptr<IPhrase>> phrases() const = 0;
virtual std::shared_ptr<IUnit> self() const = 0;
......
......@@ -105,6 +105,20 @@ void Unit::setTitle(const QString &title)
}
}
QString Unit::i18nTitle() const
{
return m_i18nTitle;
}
void Unit::setI18nTitle(const QString &title)
{
if (QString::compare(title, m_i18nTitle) != 0) {
m_i18nTitle = title;
emit titleChanged();
emit modified();
}
}
QVector<std::shared_ptr<IPhrase>> Unit::phrases() const
{
return m_phrases;
......
......@@ -37,6 +37,8 @@ public:
void setCourse(std::shared_ptr<ICourse> course) override;
QString title() const override;
void setTitle(const QString &title) override;
QString i18nTitle() const override;
void setI18nTitle(const QString &title) override;
QVector<std::shared_ptr<IPhrase>> phrases() const override;
void addPhrase(std::shared_ptr<IEditablePhrase> phrase, int index) override;
void removePhrase(std::shared_ptr<IPhrase> phrase) override;
......@@ -54,6 +56,7 @@ private:
QString m_foreignId;
std::weak_ptr<ICourse> m_course;
QString m_title;
QString m_i18nTitle;
QVector<std::shared_ptr<IPhrase>> m_phrases;
};
......
......@@ -11,10 +11,15 @@ import QtQml.Models 2.2
import org.kde.kirigami 2.7 as Kirigami
import artikulate 1.0
Kirigami.ScrollablePage {
Kirigami.Page {
id: root
title: i18n("Edit Course")
background: Rectangle {
color: Kirigami.Theme.backgroundColor
Kirigami.Theme.colorSet: Kirigami.Theme.View
}
actions {
left: Kirigami.Action {
text: i18n("Previous")
......
......@@ -7,6 +7,7 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.7 as Kirigami
import artikulate 1.0
Item {
......@@ -34,46 +35,11 @@ Item {
textEdit.height + phraseTypeSetter.height;
}
}
ColumnLayout {
Column {
id: textEdit
height: inputLine.height + originalPhraseInfo.height
width: parent.width
spacing: 5
Row {
id: originalPhraseInfo
property string originalPhrase : (root.phrase != null) ? root.phrase.i18nText : ""
spacing: 10
visible: { root.phrase != null && originalPhrase != "" && !root.isSkeletonPhrase}
Text {
text: i18n("Original Phrase:") + " " + originalPhraseInfo.originalPhrase
width: root.width - 70
wrapMode: Text.WordWrap
}
}
RowLayout { // controls for setting phrase
id: inputLine
TextArea {
id: phraseInput
property Phrase phrase: root.phrase
Layout.fillWidth: true
Layout.maximumHeight: 100
text: root.phrase.text
onTextChanged: {
if (root.phrase == null) {
return
}
root.phrase.text = text
}
onPhraseChanged: {
if (root.phrase != null)
text = root.phrase.text
else
text = ""
}
}
}
PhraseEditorTypeComponent {
id: phraseTypeSetter
phrase: root.phrase
......@@ -135,16 +101,38 @@ Item {
ColumnLayout {
id: phraseRow
Row {
Text {
text: i18n("Unit Title:")
Kirigami.FormLayout {
Kirigami.Separator {
Kirigami.FormData.label: g_editorSession.unit.i18nTitle === "" ? "Unit" : i18n("Unit: ") + g_editorSession.unit.i18nTitle
Kirigami.FormData.isSection: true
}
TextField {
width: 300
id: i18nUnit
Kirigami.FormData.label: i18n("Localized Unit:")
text: g_editorSession.unit.title
onEditingFinished: {
g_editorSession.unit.title = text
}
Connections {
target: root
onPhraseChanged: i18nUnit.text = Qt.binding(function() { return g_editorSession.unit.title })
}
}
Kirigami.Separator {
Kirigami.FormData.label: i18n("Phrase: ") + root.phrase.i18nText
Kirigami.FormData.isSection: true
}
TextField {
id: i18nPhrase
Kirigami.FormData.label: i18n("Localized Phrase:")
text: root.phrase.text
onEditingFinished: {
root.phrase.text = text
}
Connections {
target: root
onPhraseChanged: i18nPhrase.text = Qt.binding(function() { return root.phrase.i18nText })
}
}
}
......
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