[rkward-cvs] SF.net SVN: rkward:[3422] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Feb 7 12:42:24 UTC 2011
Revision: 3422
http://rkward.svn.sourceforge.net/rkward/?rev=3422&view=rev
Author: tfry
Date: 2011-02-07 12:42:24 +0000 (Mon, 07 Feb 2011)
Log Message:
-----------
Add simple dialog to offer loading of emergency saves.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/dialogs/CMakeLists.txt
trunk/rkward/rkward/rkward.cpp
Added Paths:
-----------
trunk/rkward/rkward/dialogs/rkrecoverdialog.cpp
trunk/rkward/rkward/dialogs/rkrecoverdialog.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2011-02-06 17:32:08 UTC (rev 3421)
+++ trunk/rkward/ChangeLog 2011-02-07 12:42:24 UTC (rev 3422)
@@ -1,3 +1,4 @@
+--- Version 0.5.5 - XXX-XX-2011
- Display logical values as "TRUE" and "FALSE" in data editor, and accept "T"/"TRUE"/"F"/"FALSE" in addition to "0"/"1" while editing
- Add support for R functions loadhistory(), savehistory(), history(), and timestamp ()
- Do not load .RData file from current directory by default (configurable)
@@ -23,7 +24,7 @@
- Fixed: Function argument hints would sometimes persist after closing a script window
- Fixed: Would fail to analyse structure of ReferenceClass-objects
- Fixed: "Vector" mode in "Paste special" action did not work correctly
-- Attempt to save workspace on crashes TODO: detect recovery-file at startup, and offer to load it.
+- Attempt to save workspace on crashes
- Also try to relay SIGABRT and SIGILL to the proper signal handlers
- Removed the remainder of the PHP scripting backend
- Fixed: Would crash on tcl/tk events in some cases
Modified: trunk/rkward/rkward/dialogs/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/dialogs/CMakeLists.txt 2011-02-06 17:32:08 UTC (rev 3421)
+++ trunk/rkward/rkward/dialogs/CMakeLists.txt 2011-02-07 12:42:24 UTC (rev 3422)
@@ -9,6 +9,7 @@
rkreadlinedialog.cpp
rkimportdialog.cpp
rkselectlistdialog.cpp
+ rkrecoverdialog.cpp
)
QT4_AUTOMOC(${dialogs_STAT_SRCS})
Added: trunk/rkward/rkward/dialogs/rkrecoverdialog.cpp
===================================================================
--- trunk/rkward/rkward/dialogs/rkrecoverdialog.cpp (rev 0)
+++ trunk/rkward/rkward/dialogs/rkrecoverdialog.cpp 2011-02-07 12:42:24 UTC (rev 3422)
@@ -0,0 +1,79 @@
+/***************************************************************************
+ rkrecoverdialog - description
+ -------------------
+ begin : Fri Feb 04 2011
+ copyright : (C) 2011 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "rkrecoverdialog.h"
+
+#include <krun.h>
+#include <klocale.h>
+
+#include <QDir>
+#include <QFileInfo>
+#include <QLabel>
+
+#include "../settings/rksettingsmodulegeneral.h"
+
+#include "../debug.h"
+
+RKRecoverDialog::RKRecoverDialog (const QStringList &recovery_files) {
+ RK_TRACE (DIALOGS);
+ RK_ASSERT (!recovery_files.isEmpty ());
+
+ setCaption (i18n ("Crash recovery file detected"));
+ setButtons (KDialog::Ok | KDialog::Cancel | KDialog::User1);
+ setButtonText (KDialog::User1, i18n ("Show in file browser"));
+ setButtonText (KDialog::Ok, i18n ("Recover"));
+ connect (this, SIGNAL (user1Clicked()), this, SLOT (showButtonClicked ()));
+
+ QLabel *label = new QLabel (this);
+ QString text = i18n ("<p><b>Crash revocery file detected</b></p>");
+ text.append (i18n ("<p>It looks like RKWard has crashed, recently. We are sorry about that! However, not everything is lost, and with a bit of luck, your data has been saved in time.</p>"));
+ text.append (i18np ("<p>A workspace recovery file exists in <i>%2</i> as <i>%4</i>.</p>", "<p>%1 workspace recovery files exist in <i>%2</i>, the most recent one of which is <i>%3</i>.</p>", recovery_files.count (), RKSettingsModuleGeneral::filesPath (), recovery_files.first ()));
+ text.append (i18n ("<p>Do you want to open this file, now? <b>Note</b>: You will be prompted again, next time you start RKWard, until you remove/rename the file, manually.</p>"));
+ label->setText (text);
+ label->setWordWrap (true);
+ setMainWidget (label);
+}
+
+RKRecoverDialog::~RKRecoverDialog () {
+ RK_TRACE (DIALOGS);
+}
+
+void RKRecoverDialog::showButtonClicked () {
+ RK_TRACE (DIALOGS);
+
+ new KRun (KUrl::fromLocalFile (RKSettingsModuleGeneral::filesPath ()), this); // KRun auto-deletes itself by default
+ reject ();
+}
+
+//static
+KUrl RKRecoverDialog::checkRecoverCrashedWorkspace () {
+ RK_TRACE (DIALOGS);
+
+ QDir dir (RKSettingsModuleGeneral::filesPath ());
+ dir.setNameFilters (QStringList ("rkward_recover*.RData"));
+ QStringList matches = dir.entryList (QDir::Files, QDir::Time);
+
+ if (!matches.isEmpty ()) {
+ RKRecoverDialog dialog (matches);
+ dialog.exec ();
+ if (dialog.result () == QDialog::Accepted) return (KUrl::fromLocalFile (dir.absoluteFilePath (matches.first ())));
+ }
+
+ return KUrl ();
+}
+
+#include "rkrecoverdialog.moc"
Added: trunk/rkward/rkward/dialogs/rkrecoverdialog.h
===================================================================
--- trunk/rkward/rkward/dialogs/rkrecoverdialog.h (rev 0)
+++ trunk/rkward/rkward/dialogs/rkrecoverdialog.h 2011-02-07 12:42:24 UTC (rev 3422)
@@ -0,0 +1,39 @@
+/***************************************************************************
+ rkrecoverdialog - description
+ -------------------
+ begin : Fri Feb 04 2011
+ copyright : (C) 2011 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef RKRECOVERDIALOG_H
+#define RKRECOVERDIALOG_H
+
+#include <kdialog.h>
+
+#include <QStringList>
+
+/** Dialog to offer loading of recovery files during startup. */
+class RKRecoverDialog : public KDialog {
+ Q_OBJECT
+public:
+/** Check whether a crash recovery file is available. If so, display a dialog, offering to load the recovery file.
+ at returns The url of the recovery file, if user selected to load it. An empty KUrl otherwise. */
+ static KUrl checkRecoverCrashedWorkspace ();
+protected:
+ RKRecoverDialog (const QStringList &recovery_files);
+ ~RKRecoverDialog ();
+private slots:
+ void showButtonClicked ();
+};
+
+#endif
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2011-02-06 17:32:08 UTC (rev 3421)
+++ trunk/rkward/rkward/rkward.cpp 2011-02-07 12:42:24 UTC (rev 3422)
@@ -66,6 +66,7 @@
#include "dialogs/startupdialog.h"
#include "dialogs/rkloadlibsdialog.h"
#include "dialogs/rkimportdialog.h"
+#include "dialogs/rkrecoverdialog.h"
#include "agents/rksaveagent.h"
#include "agents/rkloadagent.h"
#include "agents/rkquitagent.h"
@@ -235,23 +236,23 @@
setUpdatesEnabled (true);
show ();
-// bool recovered = RKRecoverDialog::checkRecoverCrashedWorkspace ();
-// if (!recovered) {
- if (!open_url.isEmpty()) {
- openWorkspace (open_url);
+ KUrl recover_url = RKRecoverDialog::checkRecoverCrashedWorkspace ();
+ if (!recover_url.isEmpty ()) open_url = recover_url;
+
+ if (!open_url.isEmpty()) {
+ openWorkspace (open_url);
+ } else {
+ StartupDialog::StartupDialogResult result = StartupDialog::getStartupAction (this, fileOpenRecentWorkspace);
+ if (!result.open_url.isEmpty ()) {
+ openWorkspace (result.open_url);
} else {
- StartupDialog::StartupDialogResult result = StartupDialog::getStartupAction (this, fileOpenRecentWorkspace);
- if (!result.open_url.isEmpty ()) {
- openWorkspace (result.open_url);
- } else {
- if (result.result == StartupDialog::ChoseFile) {
- slotFileOpenWorkspace ();
- } else if (result.result == StartupDialog::EmptyTable) {
- RKWorkplace::mainWorkplace ()->editNewDataFrame (i18n ("my.data"));
- }
+ if (result.result == StartupDialog::ChoseFile) {
+ slotFileOpenWorkspace ();
+ } else if (result.result == StartupDialog::EmptyTable) {
+ RKWorkplace::mainWorkplace ()->editNewDataFrame (i18n ("my.data"));
}
}
-// }
+ }
if (RKSettingsModuleGeneral::workplaceSaveMode () == RKSettingsModuleGeneral::SaveWorkplaceWithSession) {
RKWorkplace::mainWorkplace ()->restoreWorkplace (RKSettingsModuleGeneral::getSavedWorkplace (KGlobal::config ().data ()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list