aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <[email protected]>2015-09-08 22:39:33 +0200
committerAndreas Cord-Landwehr <[email protected]>2015-09-08 22:39:33 +0200
commit725dd57872c9242743e3d53e67429ee9e3fcd283 (patch)
tree06a0166d0d39bf41548e452117b758242bf3ca18
parent517fe9b009fde7bdbf9e64629079da9cd98a3b4b (diff)
Add save option to editor again.
-rw-r--r--src/artikulateui_editor.rc3
-rw-r--r--src/core/resourcemanager.cpp13
-rw-r--r--src/core/resourcemanager.h5
-rw-r--r--src/core/resources/courseresource.cpp1
-rw-r--r--src/mainwindow_editor.cpp9
-rw-r--r--src/mainwindow_editor.h1
6 files changed, 32 insertions, 0 deletions
diff --git a/src/artikulateui_editor.rc b/src/artikulateui_editor.rc
index f88c2e1..04dc7dd 100644
--- a/src/artikulateui_editor.rc
+++ b/src/artikulateui_editor.rc
@@ -7,6 +7,9 @@
http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd" >
<MenuBar>
+ <Menu name="file" >
+ <Action name="save" />
+ </Menu>
<Menu name="settings" >
<Action name="settings" />
</Menu>
diff --git a/src/core/resourcemanager.cpp b/src/core/resourcemanager.cpp
index c4af864..30d58d4 100644
--- a/src/core/resourcemanager.cpp
+++ b/src/core/resourcemanager.cpp
@@ -150,6 +150,19 @@ void ResourceManager::loadLanguageResources()
}
}
+void ResourceManager::sync()
+{
+ QMap< QString, QList< CourseResource* > >::iterator iter;
+ for (iter = m_courseResources.begin(); iter != m_courseResources.end(); ++iter) {
+ foreach (auto courseRes, iter.value()) {
+ courseRes->sync();
+ }
+ }
+ foreach (auto courseRes, m_skeletonResources) {
+ courseRes->sync();
+ }
+}
+
void ResourceManager::registerLearningGoals(LearnerProfile::ProfileManager *profileManger)
{
foreach (LanguageResource *languageResource, languageResources()) {
diff --git a/src/core/resourcemanager.h b/src/core/resourcemanager.h
index ea38ffe..1a70391 100644
--- a/src/core/resourcemanager.h
+++ b/src/core/resourcemanager.h
@@ -72,6 +72,11 @@ public:
void loadLanguageResources();
/**
+ * save all changes to course resources
+ */
+ void sync();
+
+ /**
* Register loaded languages as learning goals in profile manager.
*
* TODO this should not be done by explicit call, but by putting data at shared data storage
diff --git a/src/core/resources/courseresource.cpp b/src/core/resources/courseresource.cpp
index 9efeff4..2eb3631 100644
--- a/src/core/resources/courseresource.cpp
+++ b/src/core/resources/courseresource.cpp
@@ -162,6 +162,7 @@ void CourseResource::sync()
return;
}
+//TODO
// // not writing back if not modified
// if (!d->m_courseResource->modified()) {
// qDebug() << "Aborting sync, course was not modified.";
diff --git a/src/mainwindow_editor.cpp b/src/mainwindow_editor.cpp
index e4c7f9d..3ff7405 100644
--- a/src/mainwindow_editor.cpp
+++ b/src/mainwindow_editor.cpp
@@ -90,6 +90,10 @@ MainWindowEditor::MainWindowEditor()
m_widget->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "artikulate/qml/Editor.qml")));
m_widget->setResizeMode(QQuickWidget::SizeRootObjectToView);
+
+ QAction *newAct = KStandardAction::save(this, SLOT(save()), actionCollection());
+ actionCollection()->addAction("save", newAct);
+
createGUI("artikulateui_editor.rc");
setCentralWidget(m_widget);
}
@@ -143,6 +147,11 @@ void MainWindowEditor::showSettingsDialog()
dialog->exec();
}
+void MainWindowEditor::save()
+{
+ m_resourceManager->sync();
+}
+
bool MainWindowEditor::queryClose()
{
if (!m_editorSession->course() || m_editorSession->course()->modified() == false) {
diff --git a/src/mainwindow_editor.h b/src/mainwindow_editor.h
index 83b0e7a..ee2980b 100644
--- a/src/mainwindow_editor.h
+++ b/src/mainwindow_editor.h
@@ -58,6 +58,7 @@ public:
public Q_SLOTS:
void showSettingsDialog();
+ void save();
Q_SIGNALS:
void modeChanged(bool);