[Ktutorial-commits] SF.net SVN: ktutorial:[219] trunk/ktutorial/ktutorial-editor/src
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-03-30 07:12:49
|
Revision: 219
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=219&view=rev
Author: danxuliu
Date: 2010-03-30 07:12:38 +0000 (Tue, 30 Mar 2010)
Log Message:
-----------
Add "Open Recent" action
Modified Paths:
--------------
trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp
trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h
Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-30 05:03:47 UTC (rev 218)
+++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-30 07:12:38 UTC (rev 219)
@@ -28,6 +28,7 @@
#include <KFileFilterCombo>
#include <KLocalizedString>
#include <KMessageBox>
+#include <KRecentFilesAction>
#include <KUndoStack>
#include <KIO/NetAccess>
@@ -73,7 +74,16 @@
setupGUI();
}
-void KTutorialEditor::loadTutorialFromUrl(const KUrl& url) {
+KTutorialEditor::~KTutorialEditor() {
+ mRecentFilesAction->saveEntries(KGlobal::config()->group("RecentFiles"));
+}
+
+//public slots:
+
+//Don't use a reference to the URL, as if it is the argument in
+//urlSelected(KUrl) signal emitted by mRecentFilesAction, it is removed in
+//mRecentFilesAction->addUrl(KUrl), which leads to a crash
+void KTutorialEditor::loadTutorialFromUrl(KUrl url) {
Tutorial* tutorial;
try {
tutorial = Serialization(this).loadTutorial(url);
@@ -93,6 +103,7 @@
}
setTutorialToBeEdited(tutorial);
+ mRecentFilesAction->addUrl(url);
mTutorialUrl = url;
mUndoStack->setClean();
//Force clean state, as setting an empty stack as clean would not emit
@@ -206,6 +217,10 @@
KStandardAction::open(this, SLOT(openTutorial()), actionCollection());
+ mRecentFilesAction = KStandardAction::openRecent(
+ this, SLOT(loadTutorialFromUrl(KUrl)), actionCollection());
+ mRecentFilesAction->loadEntries(KGlobal::config()->group("RecentFiles"));
+
KStandardAction::save(this, SLOT(saveTutorial()), actionCollection());
KStandardAction::saveAs(this, SLOT(saveTutorialAs()), actionCollection());
@@ -503,6 +518,7 @@
return false;
}
+ mRecentFilesAction->addUrl(dialog->selectedUrl());
mTutorialUrl = dialog->selectedUrl();
mUndoStack->setClean();
//Force clean state, as setting an empty stack as clean would not emit
Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-30 05:03:47 UTC (rev 218)
+++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-30 07:12:38 UTC (rev 219)
@@ -24,6 +24,7 @@
class CommandWidget;
class EditionWidget;
+class KRecentFilesAction;
class KUndoStack;
class QTreeView;
class Reaction;
@@ -44,13 +45,22 @@
KTutorialEditor();
/**
+ * Destroys this KTutorialEditor.
+ * The entries in the recent files action are saved in the configuration.
+ */
+ virtual ~KTutorialEditor();
+
+public Q_SLOTS:
+
+ /**
* Loads the tutorial to be edited from the given URL.
- * The tutorial URL is updated and a clean state is forced.
+ * The tutorial URL is updated and added to the recent files action, and a
+ * clean state is forced.
* An error message is shown if the tutorial couldn't be opened.
*
* @param url The URL to load the tutorial from.
*/
- void loadTutorialFromUrl(const KUrl& url);
+ void loadTutorialFromUrl(KUrl url);
protected:
@@ -108,6 +118,11 @@
QDockWidget* mReactionActionDock;
/**
+ * The "Open Recent" action.
+ */
+ KRecentFilesAction* mRecentFilesAction;
+
+ /**
* The stack of undoable commands.
*/
KUndoStack* mUndoStack;
@@ -242,7 +257,8 @@
/**
* Shows a KFileDialog to select the file to save the tutorial to.
- * The tutorial URL is updated and a clean state is forced.
+ * The tutorial URL is updated and added to the recent files action, and a
+ * clean state is forced.
* An error message is shown if the tutorial couldn't be saved.
*
* @return True if the tutorial was successfully saved, false otherwise.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|