[rkward-cvs] SF.net SVN: rkward: [767] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Sep 27 14:02:48 UTC 2006
Revision: 767
http://svn.sourceforge.net/rkward/?rev=767&view=rev
Author: tfry
Date: 2006-09-27 07:02:29 -0700 (Wed, 27 Sep 2006)
Log Message:
-----------
Save and restore workplace layout (this was the initial motivation for the MDI rework)
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/TODO
trunk/rkward/rkward/agents/rkloadagent.cpp
trunk/rkward/rkward/agents/rksaveagent.cpp
trunk/rkward/rkward/dataeditor/rkeditor.cpp
trunk/rkward/rkward/dataeditor/rkeditor.h
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
trunk/rkward/rkward/windows/rkcommandeditorwindow.h
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.h
trunk/rkward/rkward/windows/rkmdiwindow.h
trunk/rkward/rkward/windows/rkworkplace.cpp
trunk/rkward/rkward/windows/rkworkplace.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/ChangeLog 2006-09-27 14:02:29 UTC (rev 767)
@@ -1,3 +1,5 @@
+- when saving/loading the workspace, save / restore all windows (not just data editors)
+- remember workspace filename after saving
- fix a long standing (but hard to trigger) crash while closing data editor window
- fix "Open R Script File" filename ending filter
- add mismatching brace detection to syntax highlighting
Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/TODO 2006-09-27 14:02:29 UTC (rev 767)
@@ -90,13 +90,6 @@
- check whether we're running in a PTY, and warn otherwise. Currently the R backend needs this.
- on exit, check whether there are still RCommands left in the backend and wait/request user-interaction before tearing down the thread. After all, the last command might have been a "save"!
- How about always doing exiting via a "q ()" command in the backend, instead? That way we could always be sure, all previous commands have been completed before the q ()!
- - save Workplace when saving Workspace
- - data editors (Already there, but should be reworked)
- - Output window
- - help pages
- - script files
- - auto-restore when loading Workspace
- - Probably a new class is called for, that keeps track of open and detached windows. Some simplifications may then be possible in RKEditorManager and DetachedWindowContainer.
- error-handling/raising in .rk.do.call
- I've changed the simple RInterface::issueCommand (QString, ...) command to return a pointer to the RCommand created. This will allow for lots of small cleanups. Do them.
- well, on second thought, it might be better to rely more on RCommand::id () instead of pointers. Why? The id is unique (until integer overflow). The pointer may be reused after a delete -> potential problem when trying to cancel command which is actually already deleted (and potentially other cases)
Modified: trunk/rkward/rkward/agents/rkloadagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkloadagent.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/agents/rkloadagent.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -88,6 +88,7 @@
return;
}
RKWorkplace::mainWorkplace ()->restoreWorkplace ();
+ RKWorkplace::mainWorkplace ()->clearWorkplaceDescription ();
delete this;
}
Modified: trunk/rkward/rkward/agents/rksaveagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rksaveagent.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/agents/rksaveagent.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -46,6 +46,7 @@
RKWorkplace::mainWorkplace ()->saveWorkplace (save_chain);
RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
+ RKWorkplace::mainWorkplace ()->clearWorkplaceDescription (save_chain);
}
RKSaveAgent::~RKSaveAgent () {
Modified: trunk/rkward/rkward/dataeditor/rkeditor.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/dataeditor/rkeditor.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -16,11 +16,22 @@
***************************************************************************/
#include "rkeditor.h"
+#include "../debug.h"
+
RKEditor::RKEditor (QWidget *parent) : RKMDIWindow (parent, RKMDIWindow::DataEditorWindow) {
+ RK_TRACE (EDITOR);
}
RKEditor::~RKEditor () {
+ RK_TRACE (EDITOR);
getObject ()->setObjectOpened (this, false);
}
+QString RKEditor::getRDescription () {
+ RK_TRACE (EDITOR);
+ RK_ASSERT (getObject ());
+//TODO: is this quoted correctly?
+ return (RObject::rQuote ("data:" + getObject ()->getFullName ()));
+}
+
#include "rkeditor.moc"
Modified: trunk/rkward/rkward/dataeditor/rkeditor.h
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.h 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/dataeditor/rkeditor.h 2006-09-27 14:02:29 UTC (rev 767)
@@ -66,6 +66,7 @@
/** Tell the editor to (unconditionally) update its representation of the object data (in the range given in the ChangeSet) */
virtual void updateObjectData (RObject *object, RObject::ChangeSet *changes) = 0;
+ QString getRDescription ();
bool isModified () { return false; };
KParts::Part *getPart () { return part; };
protected:
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/rkward.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -678,7 +678,8 @@
void RKwardApp::slotOutputShow () {
RK_TRACE (APP);
- RKOutputWindow::refreshOutput (true, true);
+
+ RKWorkplace::mainWorkplace ()->openOutputWindow (KURL ());
}
void RKwardApp::setCaption (const QString &) {
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -47,6 +47,7 @@
#include "../rkeditormanager.h"
#include "../misc/rkcommonfunctions.h"
+#include "../core/robject.h"
#include "../rkglobals.h"
#include "../rkward.h"
#include "../khelpdlg.h"
@@ -90,6 +91,12 @@
delete m_doc;
}
+QString RKCommandEditorWindow::getRDescription () {
+ RK_TRACE (COMMANDEDITOR);
+
+ return (RObject::rQuote ("script:" + m_doc->url ().url ()));
+}
+
void RKCommandEditorWindow::closeEvent (QCloseEvent *e) {
if (isModified ()) {
int status = KMessageBox::warningYesNo (this, i18n ("The document \"%1\" has been modified. Close it anyway?").arg (caption ()), i18n ("File not saved"));
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h 2006-09-27 14:02:29 UTC (rev 767)
@@ -63,6 +63,7 @@
/** copy current selection. Wrapper for use by external classes */
void copy ();
+ QString getRDescription ();
KParts::Part *getPart () { return m_doc; };
public slots:
/** update Tab caption according to the current url. Display the filename-component of the URL, or - if not available - a more elaborate description of the url. Also appends a "[modified]" if approriate */
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -32,6 +32,7 @@
#include "../rkglobals.h"
#include "../rkward.h"
+#include "../core/robject.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../misc/rkcommonfunctions.h"
#include "../windows/rkworkplace.h"
@@ -61,6 +62,12 @@
RK_TRACE (APP);
}
+QString RKHTMLWindow::getRDescription () {
+ RK_TRACE (APP);
+
+ return (RObject::rQuote ("help:" + khtmlpart->url ().url ()));
+}
+
bool RKHTMLWindow::isModified () {
RK_TRACE (APP);
return false;
@@ -197,6 +204,12 @@
}
}
+QString RKOutputWindow::getRDescription () {
+ RK_TRACE (APP);
+
+ return (RObject::rQuote ("output:" + output_url.url ()));
+}
+
bool RKOutputWindow::openURL (const KURL &url) {
RK_TRACE (APP);
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h 2006-09-27 14:02:29 UTC (rev 767)
@@ -55,6 +55,8 @@
/** Add common actions to the given action collection (currently only "copy")
@param action_collection A KActionCollection to insert actions in. */
void addCommonActions (KActionCollection *action_collection);
+
+ QString getRDescription ();
bool isModified ();
KParts::Part *getPart ();
public slots:
@@ -68,7 +70,7 @@
void loadDone ();
protected:
/** Here we store the position of the scroll bar before refresh. Used to scroll to the same position after a reload */
- int scroll_position;
+ int scroll_position;
/** the KHTMLPart doing all the real work */
KHTMLPart * khtmlpart;
/** update caption according to given URL */
@@ -107,6 +109,8 @@
/** return a pointer to the current output. If there is no output window, one will be created (and shown) automatically */
static RKOutputWindow* getCurrentOutput ();
+
+ QString getRDescription ();
public slots:
/** flush current output. */
void flushOutput ();
Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h 2006-09-27 14:02:29 UTC (rev 767)
@@ -52,6 +52,7 @@
virtual QString fullCaption ();
virtual QString shortCaption ();
virtual KParts::Part *getPart () = 0;
+ virtual QString getRDescription () = 0;
void setCaption (const QString &caption);
virtual QWidget *getWindow ();
signals:
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2006-09-27 14:02:29 UTC (rev 767)
@@ -32,11 +32,15 @@
#include "../dataeditor/rkeditor.h"
#include "../dataeditor/rkeditordataframe.h"
#include "../dataeditor/rkeditordataframepart.h"
+#include "../rbackend/rinterface.h"
+#include "../rbackend/rcommand.h"
#include "../rkglobals.h"
#include "../rkward.h"
#include "../debug.h"
+#define RESTORE_WORKPLACE_COMMAND 1
+
// static
RKWorkplace *RKWorkplace::main_workplace = 0;
@@ -242,16 +246,54 @@
void RKWorkplace::saveWorkplace (RCommandChain *chain) {
RK_TRACE (APP);
- // TODO
+ QString workplace_description = "c (";
+
+ bool first = true;
+ for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
+ if (first) first = false;
+ else workplace_description.append (", ");
+ workplace_description.append ((*it)->getRDescription ());
+ }
+ workplace_description = ".rk.workplace.save <- " + workplace_description + ")";
+
+
+ RKGlobals::rInterface ()->issueCommand (workplace_description, RCommand::App | RCommand::Sync, i18n ("Save Workplace layout"), 0, 0, chain);
}
void RKWorkplace::restoreWorkplace (RCommandChain *chain) {
RK_TRACE (APP);
- // TODO
+ RKGlobals::rInterface ()->issueCommand (".rk.workplace.save", RCommand::App | RCommand::Sync | RCommand::GetStringVector, i18n ("Restore Workplace layout"), this, RESTORE_WORKPLACE_COMMAND, chain);
}
+void RKWorkplace::clearWorkplaceDescription (RCommandChain *chain) {
+ RK_TRACE (APP);
+
+ RKGlobals::rInterface ()->issueCommand ("remove (.rk.workplace.save)", RCommand::App | RCommand::Sync, QString::null, 0, 0, chain);
+}
+
void RKWorkplace::rCommandDone (RCommand *command) {
+ RK_TRACE (APP);
+
+ RK_ASSERT (command->getFlags () == RESTORE_WORKPLACE_COMMAND);
+ for (int i = 0; i < command->stringVectorLength (); ++i) {
+ QString desc = command->getStringVector ()[i];
+ QString type = desc.section (QChar (':'), 0, 0);
+ QString specification = desc.section (QChar (':'), 1);
+
+ if (type == "data") {
+ RObject *object = RKGlobals::rObjectList ()->findObject (specification);
+ if (object) editObject (object, false);
+ } else if (type == "script") {
+ openScriptEditor (specification);
+ } else if (type == "output") {
+ openOutputWindow (specification);
+ } else if (type == "help") {
+ openHelpWindow (specification);
+ } else {
+ RK_ASSERT (false);
+ }
+ }
}
#include "rkworkplace.moc"
Modified: trunk/rkward/rkward/windows/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h 2006-09-27 13:05:23 UTC (rev 766)
+++ trunk/rkward/rkward/windows/rkworkplace.h 2006-09-27 14:02:29 UTC (rev 767)
@@ -74,6 +74,7 @@
void saveWorkplace (RCommandChain *chain=0);
void restoreWorkplace (RCommandChain *chain=0);
+ void clearWorkplaceDescription (RCommandChain *chain=0);
static RKWorkplace *mainWorkplace () { return main_workplace; };
signals:
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