Commit 2511d38a authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Provide list of learner's learning goals.

parent d938e016
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
* Copyright 2013-2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -35,8 +35,8 @@ using namespace LearnerProfile;
class LearningGoalModelPrivate {
public:
LearningGoalModelPrivate()
: m_profileManager(0)
, m_learner(0)
: m_profileManager(nullptr)
, m_learner(nullptr)
, m_signalMapper(new QSignalMapper())
{
}
......@@ -89,7 +89,8 @@ LearningGoalModel::LearningGoalModel(QObject *parent)
: QAbstractListModel(parent)
, d(new LearningGoalModelPrivate)
{
connect(d->m_signalMapper, SIGNAL(mapped(int)), SLOT(emitLearningGoalChanged(int)));
connect(d->m_signalMapper, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped),
this, &LearningGoalModel::emitLearningGoalChanged);
}
LearningGoalModel::~LearningGoalModel()
......@@ -143,15 +144,18 @@ void LearningGoalModel::setLearner(Learner *learner)
return;
}
emit beginResetModel();
if (d->m_learner != 0) {
if (d->m_learner) {
learner->disconnect(this);
}
d->m_learner = learner;
d->updateGoals();
d->updateMappings();
connect(learner, SIGNAL(goalAboutToBeAdded(LearningGoal*,int)), this, SLOT(onLearningGoalAboutToBeAdded(LearningGoal*,int)));
connect(learner, SIGNAL(goalAdded()), this, SLOT(onLearningGoalAdded()));
connect(learner, SIGNAL(goalAboutToBeRemoved(int)), this, SLOT(onLearningGoalAboutToBeRemoved(int)));
connect(learner, &Learner::goalAboutToBeAdded,
this, &LearningGoalModel::onLearningGoalAboutToBeAdded);
connect(learner, &Learner::goalAdded,
this, &LearningGoalModel::onLearningGoalAdded);
connect(learner, &Learner::goalAboutToBeRemoved, this,
&LearningGoalModel::onLearningGoalAboutToBeRemoved);
emit learnerChanged();
emit endResetModel();
}
......
/*
* Copyright 2013 Andreas Cord-Landwehr <cordlandwehr@kde.org>
* Copyright 2013-2016 Andreas Cord-Landwehr <cordlandwehr@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -46,7 +46,7 @@ public:
DataRole
};
explicit LearningGoalModel(QObject *parent = 0);
explicit LearningGoalModel(QObject *parent = nullptr);
virtual ~LearningGoalModel();
/**
* Reimplemented from QAbstractListModel::roleNames()
......
......@@ -30,22 +30,17 @@ Item {
property alias label: label
signal selected
height: Math.max(label.height + 15 + 15, 15 + 15 + 30)
state: ListView.isCurrentItem? "selected": mouseArea.containsMouse? "hover": "normal"
state: mouseArea.containsMouse? "hover": ListView.isCurrentItem? "selected": "normal"
SystemPalette {
id: palette
colorGroup: root.enabled ? SystemPalette.Active : SystemPalette.Disabled
}
Rectangle {
id: bg
color: "#3daee6"
border.color: "#3daee6"
border.width: 2
opacity: 0
radius: 4
anchors {
fill: parent
topMargin: 5
rightMargin: 5
bottomMargin: 5
leftMargin: 5
}
border.width: 0
anchors.fill: parent
}
Item {
......@@ -74,6 +69,7 @@ Item {
Label {
id: label
elide: Text.ElideRight
color: palette.buttonText
anchors {
left: iconItem.visible? iconItem.right: parent.left
leftMargin: iconItem.visible ? Math.floor(theme.smallIconSize/2) : 0
......@@ -96,47 +92,24 @@ Item {
name: "normal"
PropertyChanges {
target: bg
color: "#3daee6"
opacity: 0
color: palette.base
opacity: 1
}
},
State {
name: "hover"
PropertyChanges {
target: bg
opacity: 0.3
color: "#3daee6"
color: palette.highlight
opacity: ListView.isCurrentItem? 0.8 : 0.4
}
},
State {
name: "selected"
PropertyChanges {
target: bg
opacity: 0.7
color: "#c0e7f9"
}
}
]
transitions: [
Transition {
from: "normal"
to: "hover"
NumberAnimation {
target: bg
property: "opacity"
duration: 250
easing.type: Easing.OutCubic
}
},
Transition {
from: "hover"
to: "normal"
NumberAnimation {
target: bg
property: "opacity"
duration: 250
easing.type: Easing.OutCubic
color: palette.highlight
opacity: 1
}
}
]
......
......@@ -20,23 +20,46 @@
import QtQuick 2.1
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Layouts 1.2
import artikulate 1.0
Item {
id: root
ColumnLayout {
id: main
anchors.fill: parent
Label {
text: i18n("User Profile Settings")
font.pointSize: 1.5 * theme.fontPointSize
TabView {
anchors {
fill: parent
}
frameVisible: false
Tab {
title: i18n("Learner")
ColumnLayout {
id: main
anchors {
fill: parent
margins: 10
}
Label {
text: i18n("User Profile Settings")
font.pointSize: 1.5 * theme.fontPointSize
}
ProfileUserItem {
profile: g_profileManager.activeProfile
ProfileUserItem {
profile: g_profileManager.activeProfile
}
}
}
Tab {
title: i18n("Languages")
ProfileUserGoalsItem {
anchors {
fill: parent
margins: 10
}
profileManager: g_profileManager
}
}
}
}
\ No newline at end of file
}
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
* Copyright 2013-2014 Andreas Cord-Landwehr <cordlandwehr@kde.org>
* Copyright 2013-2016 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
......@@ -27,7 +27,6 @@ Item {
id: root
anchors.fill: parent
property Learner profile: null
property ProfileManager profileManager: null
ScrollView {
......@@ -39,37 +38,20 @@ Item {
leftMargin: 5
}
ListView {
id: languageList
id: goalList
width: root.width
height: favoriteLanguages.height
clip: true
model: LearningGoalModel {
profileManager: root.profileManager
learner: profileManager.activeProfile
}
delegate : CheckListItem {
delegate: ListItem {
id: goalSelector
property LearningGoal goal: model.dataRole
width: languageList.width - 10
width: goalList.width - 10
title: model.title
iconName: "favorites"
onStateChanged: {
if (checked) {
root.profile.addGoal(goal)
} else {
root.profile.removeGoal(goal)
}
}
checked: { // initialization with initial profile
root.profile != null ? root.profile.hasGoal(goal) : false
}
Connections { // update after profile changes
target: root
onProfileChanged: {
if (root.profile != null) {
goalSelector.checked = root.profile.hasGoal(goal)
}
}
}
onSelected: goalList.currentIndex = index
}
}
}
......
......@@ -63,10 +63,10 @@ Item {
ColumnLayout {
anchors {
fill: parent
topMargin: 10
rightMargin: 10
bottomMargin: 10
leftMargin: 10
topMargin: 0
rightMargin: 0
bottomMargin: 0
leftMargin: 0
}
Item {
id: contentArea
......
......@@ -17,7 +17,7 @@
<file>PhraseEditorTypeComponent.qml</file>
<file>ProfileSettingsItem.qml</file>
<file>ProfileDetailsItem.qml</file>
<file>ProfileDetailsViewFavorites.qml</file>
<file>ProfileUserGoalsItem.qml</file>
<file>ProfileUserItem.qml</file>
<file>ProfileUserImageItem.qml</file>
<file>ProfileSelector.qml</file>
......
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