[rkward-cvs] SF.net SVN: rkward:[2637] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Sep 2 12:16:26 UTC 2009
Revision: 2637
http://rkward.svn.sourceforge.net/rkward/?rev=2637&view=rev
Author: tfry
Date: 2009-09-02 12:16:26 +0000 (Wed, 02 Sep 2009)
Log Message:
-----------
Fix some potential path issues on Windows.
This commit also contains a few cleanups of real old and real ugly code.
Modified Paths:
--------------
trunk/rkward/rkward/agents/rkloadagent.cpp
trunk/rkward/rkward/agents/rksaveagent.cpp
trunk/rkward/rkward/agents/rksaveagent.h
trunk/rkward/rkward/misc/getfilenamewidget.cpp
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
Modified: trunk/rkward/rkward/agents/rkloadagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkloadagent.cpp 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/agents/rkloadagent.cpp 2009-09-02 12:16:26 UTC (rev 2637)
@@ -2,7 +2,7 @@
rkloadagent - description
-------------------
begin : Sun Sep 5 2004
- copyright : (C) 2004, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -39,14 +39,10 @@
QString filename;
if (!url.isLocalFile ()) {
-#if !KDE_IS_VERSION (3, 2, 0)
- KIO::NetAccess::download (url, tmpfile);
-#else
KIO::NetAccess::download (url, tmpfile, RKWardMainWindow::getMain ());
-#endif
filename = tmpfile;
} else {
- filename = url.path ();
+ filename = url.toLocalFile ();
}
Modified: trunk/rkward/rkward/agents/rksaveagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rksaveagent.cpp 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/agents/rksaveagent.cpp 2009-09-02 12:16:26 UTC (rev 2637)
@@ -2,7 +2,7 @@
rksaveagent - description
-------------------
begin : Sun Aug 29 2004
- copyright : (C) 2004 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -30,21 +30,24 @@
#include "../debug.h"
-RKSaveAgent::RKSaveAgent (KUrl url, bool save_file_as, DoneAction when_done, KUrl load_url) {
+RKSaveAgent::RKSaveAgent (KUrl url, bool save_file_as, DoneAction when_done, KUrl load_url) : QObject () {
RK_TRACE (APP);
save_url = url;
RKSaveAgent::when_done = when_done;
RKSaveAgent::load_url = load_url;
save_chain = 0;
if (save_url.isEmpty () || save_file_as) {
- if (!askURL ()) return;
+ if (!askURL ()) {
+ deleteLater();
+ return;
+ }
}
RKWorkplace::mainWorkplace ()->flushAllData ();
save_chain = RKGlobals::rInterface ()->startChain (0);
RKWorkplace::mainWorkplace ()->saveWorkplace (save_chain);
- RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
+ RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.toLocalFile () + "\")", RCommand::App, QString::null, this), save_chain);
RKWorkplace::mainWorkplace ()->clearWorkplaceDescription (save_chain);
}
@@ -54,12 +57,11 @@
bool RKSaveAgent::askURL () {
RK_TRACE (APP);
- save_url = KFileDialog::getSaveFileName (save_url.path (), "*.R");
+ save_url = KFileDialog::getSaveFileName (save_url, "*.R");
if (save_url.isEmpty ()) {
if (when_done != DoNothing) {
- if (KMessageBox::warningYesNo (0, i18n ("No filename given. Your data was NOT saved. Do you still want to proceed?")) == KMessageBox::No) when_done = DoNothing;
+ if (KMessageBox::warningYesNo (0, i18n ("No filename given. Your data was NOT saved. Do you still want to proceed?")) != KMessageBox::Yes) when_done = DoNothing;
}
- done ();
return false;
}
return true;
@@ -68,35 +70,30 @@
void RKSaveAgent::rCommandDone (RCommand *command) {
RK_TRACE (APP);
if (command->hasError ()) {
+ int res;
if (when_done != DoNothing) {
- int res;
res = KMessageBox::warningYesNoCancel (0, i18n ("Saving to file '%1' failed. What do you want to do?", save_url.path ()), i18n ("Save failed"), KGuiItem (i18n ("Try saving with a different filename")), KGuiItem (i18n ("Saving failed")));
- if (res == KMessageBox::Yes) {
- if (askURL ()) RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
- return;
- } else if (res == KMessageBox::No) {
- done ();
- return;
- } else {
- when_done = DoNothing;
- done ();
- return;
- }
} else {
- if (KMessageBox::warningYesNo (0, i18n ("Saving to file '%1' failed. Do you want to try saving to a different filename?", save_url.path ())) == KMessageBox::Yes) {
- if (askURL ()) RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
+ res = KMessageBox::warningYesNo (0, i18n ("Saving to file '%1' failed. Do you want to try saving to a different filename?", save_url.path ()));
+ }
+
+ if (res == KMessageBox::Yes) {
+ if (askURL ()) {
+ RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.toLocalFile () + "\")", RCommand::App, QString::null, this), save_chain);
return;
- } else {
- done ();
- return;
}
+ } else if (res == KMessageBox::No) {
+ done ();
+ return;
}
+
+ // else
+ when_done = DoNothing;
} else {
RObjectList::getObjectList ()->setWorkspaceURL (save_url);
RKWardMainWindow::getMain ()->setCaption (QString::null); // trigger update of caption
- done ();
- return;
}
+ done ();
}
void RKSaveAgent::done () {
@@ -106,9 +103,6 @@
}
if (when_done == Load) {
RKWardMainWindow::getMain ()->fileOpenNoSave (load_url);
- delete this;
- } else {
- delete this;
}
+ deleteLater ();
}
-
Modified: trunk/rkward/rkward/agents/rksaveagent.h
===================================================================
--- trunk/rkward/rkward/agents/rksaveagent.h 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/agents/rksaveagent.h 2009-09-02 12:16:26 UTC (rev 2637)
@@ -2,7 +2,7 @@
rksaveagent - description
-------------------
begin : Sun Aug 29 2004
- copyright : (C) 2004 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -20,6 +20,7 @@
#include "../rbackend/rcommandreceiver.h"
#include <kurl.h>
+#include <QObject>
class RCommandChain;
@@ -28,7 +29,7 @@
@author Thomas Friedrichsmeier
*/
-class RKSaveAgent : public RCommandReceiver {
+class RKSaveAgent : public RCommandReceiver, public QObject {
public:
enum DoneAction { DoNothing=0, Load=1 };
Modified: trunk/rkward/rkward/misc/getfilenamewidget.cpp
===================================================================
--- trunk/rkward/rkward/misc/getfilenamewidget.cpp 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/misc/getfilenamewidget.cpp 2009-09-02 12:16:26 UTC (rev 2637)
@@ -75,7 +75,7 @@
}
QString GetFileNameWidget::getLocation () {
- return (edit->url ().path ());
+ return (edit->url ().toLocalFile ());
}
void GetFileNameWidget::setBackgroundColor (const QColor & color) {
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/rkward.cpp 2009-09-02 12:16:26 UTC (rev 2637)
@@ -285,18 +285,10 @@
void RKWardMainWindow::startR () {
RK_TRACE (APP);
RK_ASSERT (!RKGlobals::rInterface ());
-
- QDir dir (RKSettingsModuleGeneral::filesPath());
- if (!dir.exists ()) {
- QDir current (dir.currentPath ());
- current.mkdir (dir.path ());
- }
- dir = dir.filePath (".packagetemp");
- if (!dir.exists ()) {
- QDir current (dir.currentPath ());
- current.mkdir (dir.path ());
- }
-
+
+ // make sure our general purpose files directory exists
+ RK_ASSERT (QDir ().mkpath (RKSettingsModuleGeneral::filesPath()));
+
RKGlobals::rinter = new RInterface ();
new RObjectList ();
Modified: trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp 2009-09-02 12:16:26 UTC (rev 2637)
@@ -219,14 +219,14 @@
for (int i = 0; i < COL_COUNT; ++i) results_view->resizeColumnToContents (i);
setEnabled(true);
} else if (command->getFlags () == GET_HELP_URL) {
- KUrl url;
+ QString help_file;
if (command->getDataLength ()) {
RK_ASSERT (command->getDataType () == RData::StringVector);
- url.setPath(command->getStringVector ()[0]);
+ help_file = command->getStringVector ()[0];
}
- if (QFile::exists (url.path ())) {
- RKWardMainWindow::getMain ()->openHTML (url);
+ if (QFile::exists (help_file)) {
+ RKWardMainWindow::getMain ()->openHTML (KUrl::fromPath (help_file));
return;
} else {
KMessageBox::sorry (this, i18n ("No help found on '%1'. Maybe the corresponding package is not installed/loaded, or maybe you mistyped the command. Try using Help->Search R Help for more options.", command->command ().section ("\"", 1, 1)), i18n ("No help found"));
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2009-09-02 08:58:05 UTC (rev 2636)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2009-09-02 12:16:26 UTC (rev 2637)
@@ -420,7 +420,7 @@
int res = KMessageBox::questionYesNo (this, i18n ("Do you really want to flush the output? It will not be possible to restore it."), i18n ("Flush output?"));
if (res==KMessageBox::Yes) {
- QFile out_file (current_url.path ());
+ QFile out_file (current_url.toLocalFile ());
QDir out_dir = QFileInfo (out_file).absoluteDir ();
out_file.remove ();
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