[rkward-cvs] SF.net SVN: rkward: [958] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Nov 27 22:54:31 UTC 2006
Revision: 958
http://svn.sourceforge.net/rkward/?rev=958&view=rev
Author: tfry
Date: 2006-11-27 14:54:30 -0800 (Mon, 27 Nov 2006)
Log Message:
-----------
Implemented the workplaceSaveMode option. Was harder than expected...
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/dataeditor/rkeditor.cpp
trunk/rkward/rkward/dataeditor/rkeditor.h
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
trunk/rkward/rkward/settings/rksettingsmodulegeneral.h
trunk/rkward/rkward/settings/rksettingsmoduler.cpp
trunk/rkward/rkward/windows/qxembedcopy.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/rkwindowcatcher.h
trunk/rkward/rkward/windows/rkworkplace.cpp
trunk/rkward/rkward/windows/rkworkplace.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/ChangeLog 2006-11-27 22:54:30 UTC (rev 958)
@@ -1,3 +1,4 @@
+- add option to save workplace layout not per workspace, but at the end of the session
- add options ("printcmd") to settings
- fix help menu for detached windows
- R X11 device windows are now managed by rkward, with the following initial features:
Modified: trunk/rkward/rkward/dataeditor/rkeditor.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/dataeditor/rkeditor.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -27,11 +27,11 @@
getObject ()->setObjectOpened (this, false);
}
-QString RKEditor::getRDescription () {
+QString RKEditor::getDescription () {
RK_TRACE (EDITOR);
RK_ASSERT (getObject ());
-//TODO: is this quoted correctly?
- return (RObject::rQuote ("data:" + getObject ()->getFullName ()));
+
+ return ("data:" + getObject ()->getFullName ());
}
#include "rkeditor.moc"
Modified: trunk/rkward/rkward/dataeditor/rkeditor.h
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.h 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/dataeditor/rkeditor.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -66,7 +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 ();
+ QString getDescription ();
bool isModified () { return false; };
KParts::Part *getPart () { return part; };
protected:
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/rkward.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -218,6 +218,10 @@
delete result;
}
+ if (RKSettingsModuleGeneral::workplaceSaveMode () == RKSettingsModuleGeneral::SaveWorkplaceWithSession) {
+ RKWorkplace::mainWorkplace ()->restoreWorkplace (RKSettingsModuleGeneral::getSavedWorkplace (kapp->config ()));
+ }
+
setCaption (QString::null); // our version of setCaption takes care of creating a correct caption, so we do not need to provide it here
}
@@ -477,6 +481,9 @@
slotSetStatusBarText (i18n ("Exiting..."));
saveOptions ();
+ if (RKSettingsModuleGeneral::workplaceSaveMode () == RKSettingsModuleGeneral::SaveWorkplaceWithSession) {
+ RKSettingsModuleGeneral::setSavedWorkplace (RKWorkplace::mainWorkplace ()->makeWorkplaceDescription (), kapp->config ());
+ }
if (!RObjectList::getGlobalEnv ()->isEmpty ()) {
int res;
Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -77,7 +77,6 @@
workplace_save_chooser->setButton (static_cast<int> (workplace_save_mode));
connect (workplace_save_chooser, SIGNAL (clicked (int)), this, SLOT (boxChanged (int)));
main_vbox->addWidget (workplace_save_chooser);
- #warning option unfinished!
main_vbox->addStretch ();
}
@@ -110,6 +109,7 @@
RK_TRACE (SETTINGS);
new_files_path = files_choser->getLocation ();
startup_action = (StartupDialog::Result) startup_action_choser->currentItem ();
+ workplace_save_mode = (WorkplaceSaveMode) workplace_save_chooser->selectedId ();
}
void RKSettingsModuleGeneral::save (KConfig *config) {
@@ -143,4 +143,18 @@
workplace_save_mode = (WorkplaceSaveMode) config->readNumEntry ("save mode", SaveWorkplaceWithWorkspace);
}
+QString RKSettingsModuleGeneral::getSavedWorkplace (KConfig *config) {
+ RK_TRACE (SETTINGS);
+
+ config->setGroup ("Workplace");
+ return (config->readEntry ("last saved layout", QString::null));
+}
+
+void RKSettingsModuleGeneral::setSavedWorkplace (const QString &description, KConfig *config) {
+ RK_TRACE (SETTINGS);
+
+ config->setGroup ("Workplace");
+ config->writeEntry ("last saved layout", description);
+}
+
#include "rksettingsmodulegeneral.moc"
Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.h 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -55,8 +55,9 @@
static void setStartupAction (StartupDialog::Result action) { startup_action = action; };
static WorkplaceSaveMode workplaceSaveMode () { return workplace_save_mode; };
/** retrieve the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
- static QString getSavedWorkplace ();
- static void setSavedWorkplace (const QString &description);
+ static QString getSavedWorkplace (KConfig *config);
+/** set the saved workplace description. Meaningful only is workplaceSaveMode () == SaveWorkplaceWithSession */
+ static void setSavedWorkplace (const QString &description, KConfig *config);
public slots:
void pathChanged ();
void boxChanged (int);
Modified: trunk/rkward/rkward/settings/rksettingsmoduler.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduler.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/settings/rksettingsmoduler.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -130,7 +130,7 @@
connect (checkbounds_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
grid->addWidget (checkbounds_input, row, 1);
- grid->addWidget (new QLabel (i18n ("Command used to send file to printer"), this), ++row, 0);
+ grid->addWidget (new QLabel (i18n ("Command used to send files to printer"), this), ++row, 0);
printcmd_input = new QLineEdit (options_printcmd, this);
connect (printcmd_input, SIGNAL (textChanged (const QString &)), this, SLOT (textChanged (const QString &)));
grid->addWidget (printcmd_input, row, 1);
Modified: trunk/rkward/rkward/windows/qxembedcopy.cpp
===================================================================
--- trunk/rkward/rkward/windows/qxembedcopy.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/qxembedcopy.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -978,7 +978,7 @@
Window parent = 0;
get_parent(w, &parent);
if (parent == qt_xrootwin()) break;
- else qDebug ("not really withdrawn, yet in loop #%d", i);
+ else if ((i%20) == 0) qDebug ("not really withdrawn, yet in loop #%d", i);
}
USLEEP(1000);
}
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -103,10 +103,10 @@
delete m_doc;
}
-QString RKCommandEditorWindow::getRDescription () {
+QString RKCommandEditorWindow::getDescription () {
RK_TRACE (COMMANDEDITOR);
- return (RObject::rQuote ("script:" + m_doc->url ().url ()));
+ return ("script:" + m_doc->url ().url ());
}
void RKCommandEditorWindow::closeEvent (QCloseEvent *e) {
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -106,7 +106,7 @@
/** copy current selection. Wrapper for use by external classes */
void copy ();
- QString getRDescription ();
+ QString getDescription ();
KParts::Part *getPart () { return m_doc; };
/** Return current url */
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -32,7 +32,6 @@
#include "../rkglobals.h"
#include "../rkward.h"
-#include "../core/robject.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../misc/rkcommonfunctions.h"
#include "../windows/rkworkplace.h"
@@ -66,10 +65,10 @@
khtmlpart = 0; // in case we try to redelete in a parent class
}
-QString RKHTMLWindow::getRDescription () {
+QString RKHTMLWindow::getDescription () {
RK_TRACE (APP);
- return (RObject::rQuote ("help:" + khtmlpart->url ().url ()));
+ return ("help:" + khtmlpart->url ().url ());
}
bool RKHTMLWindow::isModified () {
@@ -211,10 +210,10 @@
khtmlpart = 0; // in case we try to redelete in a parent class
}
-QString RKOutputWindow::getRDescription () {
+QString RKOutputWindow::getDescription () {
RK_TRACE (APP);
- return (RObject::rQuote ("output:" + output_url.url ()));
+ return ("output:" + output_url.url ());
}
bool RKOutputWindow::openURL (const KURL &url) {
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -56,7 +56,7 @@
@param action_collection A KActionCollection to insert actions in. */
void addCommonActions (KActionCollection *action_collection);
- QString getRDescription ();
+ QString getDescription ();
bool isModified ();
KParts::Part *getPart ();
public slots:
@@ -110,7 +110,7 @@
/** 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 ();
+ QString getDescription ();
public slots:
/** flush current output. */
void flushOutput ();
Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -58,8 +58,8 @@
/** @returns The corresponding KPart for this window */
virtual KParts::Part *getPart () = 0;
/** This is used in RKWorkplace::saveWorkplace () to save the info about the workplace. Make sure to add corresponding code to RKWorkplace::restoreWorkplace (), so your window(s) get restored when loading a Workspace
- at returns An internal descriptive string suitable for storage in R. */
- virtual QString getRDescription () = 0;
+ at returns An internal descriptive string. */
+ virtual QString getDescription () = 0;
/** Reimplemented from QWidget::setCaption () to emit the signal captionChanged () when the caption is changed. */
void setCaption (const QString &caption);
/** Is this window attached (or detached)?
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -95,7 +95,7 @@
KParts::Part *getPart ();
/** TODO */
- QString getRDescription () { return "unimplemented"; };
+ QString getDescription () { return "x11:unimplemented"; };
/** TODO? */
bool isModified () { return false; };
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2006-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2006-11-27 22:54:30 UTC (rev 958)
@@ -33,6 +33,7 @@
#include "../dataeditor/rkeditordataframe.h"
#include "../dataeditor/rkeditordataframepart.h"
#include "../settings/rksettingsmoduleoutput.h"
+#include "../settings/rksettingsmodulegeneral.h"
#include "../rbackend/rinterface.h"
#include "../windows/rkwindowcatcher.h"
#include "../rbackend/rcommand.h"
@@ -280,8 +281,22 @@
return (static_cast<RKMDIWindow *> (view ()->activePage ()));
}
+QString RKWorkplace::makeWorkplaceDescription () {
+ RK_TRACE (APP);
+
+ QString workplace_description;
+ bool first = true;
+ for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
+ if (first) first = false;
+ else workplace_description.append ("\n");
+ workplace_description.append ((*it)->getDescription ());
+ }
+ return workplace_description;
+}
+
void RKWorkplace::saveWorkplace (RCommandChain *chain) {
RK_TRACE (APP);
+ if (RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace) return;
QString workplace_description = "c (";
@@ -289,22 +304,32 @@
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.append (RObject::rQuote ((*it)->getDescription ()));
}
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);
+ if (RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace) return;
RKGlobals::rInterface ()->issueCommand (".rk.workplace.save", RCommand::App | RCommand::Sync | RCommand::GetStringVector, i18n ("Restore Workplace layout"), this, RESTORE_WORKPLACE_COMMAND, chain);
}
+void RKWorkplace::restoreWorkplace (const QString &description) {
+ RK_TRACE (APP);
+
+ QStringList list = QStringList::split ("\n", description);
+ for (QStringList::const_iterator it = list.constBegin (); it != list.constEnd (); ++it) {
+ restoreWorkplaceItem (*it);
+ }
+}
+
void RKWorkplace::clearWorkplaceDescription (RCommandChain *chain) {
RK_TRACE (APP);
+ if (RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace) return;
RKGlobals::rInterface ()->issueCommand ("remove (.rk.workplace.save)", RCommand::App | RCommand::Sync | RCommand::ObjectListUpdate, QString::null, 0, 0, chain);
}
@@ -314,23 +339,29 @@
RK_ASSERT (command->getFlags () == RESTORE_WORKPLACE_COMMAND);
for (unsigned int i = 0; i < command->getDataLength (); ++i) {
- QString desc = command->getStringVector ()[i];
- QString type = desc.section (QChar (':'), 0, 0);
- QString specification = desc.section (QChar (':'), 1);
+ restoreWorkplaceItem (command->getStringVector ()[i]);
+ }
+}
- if (type == "data") {
- RObject *object = RObjectList::getObjectList ()->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);
- }
+void RKWorkplace::restoreWorkplaceItem (const QString &desc) {
+ RK_TRACE (APP);
+
+ QString type = desc.section (QChar (':'), 0, 0);
+ QString specification = desc.section (QChar (':'), 1);
+
+ if (type == "data") {
+ RObject *object = RObjectList::getObjectList ()->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-11-27 18:55:16 UTC (rev 957)
+++ trunk/rkward/rkward/windows/rkworkplace.h 2006-11-27 22:54:30 UTC (rev 958)
@@ -99,16 +99,23 @@
@param state: A bitwise OR of RKWorkplaceObjectState */
void closeAll (int type=RKMDIWindow::AnyType, int state=RKMDIWindow::AnyState);
-/** Write a description of all current windows to the R backend. This can later be read by restoreWorkplace ()
+/** Write a description of all current windows to the R backend. This can later be read by restoreWorkplace (). Has no effect, if RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace
@param chain command chain to place the command in */
void saveWorkplace (RCommandChain *chain=0);
/** Load a description of windows from the R backend (created by saveWorkplace ()), and (try to) restore all windows accordingly
+Has no effect, if RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace
@param chain command chain to place the command in */
void restoreWorkplace (RCommandChain *chain=0);
+/** Like the other restoreWorkplace (), but takes the description as a parameter rather than reading from the R workspace. To be used, when RKSettingsModuleGeneral::workplaceSaveMode () == RKSettingsModuleGeneral::SaveWorkplaceWithSeesion
+ at param description workplace description */
+ void restoreWorkplace (const QString &description);
/** Clear the description as set by saveWorkplace () from the R backend. Simply removes the internal object. Since the description is only needed while the workplace is being saved / restored, this should be called shortly after saveWorkplace () and restoreWorkplace ()
+Has no effect, if RKSettingsModuleGeneral::workplaceSaveMode () != RKSettingsModuleGeneral::SaveWorkplaceWithWorkspace
@param cahin command chain to place the command in */
void clearWorkplaceDescription (RCommandChain *chain=0);
+ QString makeWorkplaceDescription ();
+
/** In the current design there is only ever one workplace. Use this static function to reference it.
@returns a pointer to the workplace */
static RKWorkplace *mainWorkplace () { return main_workplace; };
@@ -130,6 +137,8 @@
void addWindow (RKMDIWindow *window, bool attached=true);
/** static pointer to the workplace. @See mainWorkplace () */
static RKWorkplace *main_workplace;
+
+ void restoreWorkplaceItem (const QString &desc);
};
#endif
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