[rkward-cvs] SF.net SVN: rkward: [764] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Sep 27 11:16:32 UTC 2006
Revision: 764
http://svn.sourceforge.net/rkward/?rev=764&view=rev
Author: tfry
Date: 2006-09-27 04:16:08 -0700 (Wed, 27 Sep 2006)
Log Message:
-----------
More MDI work and some related cleanups.
RKWardApp now has a static member to find the app instead of a static member in RKGlobals
RKWorkplace shares RKWardApp's PartManager. This seems to solve the focus / part-activation problems
Move RKWorkplace from misc to windows
Modified Paths:
--------------
trunk/rkward/rkward/agents/rkloadagent.cpp
trunk/rkward/rkward/agents/rksaveagent.cpp
trunk/rkward/rkward/agents/showedittextfileagent.cpp
trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
trunk/rkward/rkward/dataeditor/rkeditordataframepart.cpp
trunk/rkward/rkward/khelpdlg.cpp
trunk/rkward/rkward/misc/Makefile.am
trunk/rkward/rkward/plugin/rkcomponentmap.cpp
trunk/rkward/rkward/rbackend/rinterface.cpp
trunk/rkward/rkward/rkglobals.cpp
trunk/rkward/rkward/rkglobals.h
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/rkward.h
trunk/rkward/rkward/robjectbrowser.cpp
trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp
trunk/rkward/rkward/windows/Makefile.am
trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
trunk/rkward/rkward/windows/rkmdiwindow.cpp
Added Paths:
-----------
trunk/rkward/rkward/windows/rkworkplace.cpp
trunk/rkward/rkward/windows/rkworkplace.h
Removed Paths:
-------------
trunk/rkward/rkward/misc/rkworkplace.cpp
trunk/rkward/rkward/misc/rkworkplace.h
Modified: trunk/rkward/rkward/agents/rkloadagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkloadagent.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/agents/rkloadagent.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -27,7 +27,7 @@
#include "../core/robjectlist.h"
#include "../rbackend/rinterface.h"
#include "../rkward.h"
-#include "../misc/rkworkplace.h"
+#include "../windows/rkworkplace.h"
#include "../debug.h"
@@ -35,19 +35,19 @@
RKLoadAgent::RKLoadAgent (const KURL &url, bool merge) {
RK_TRACE (APP);
- RKGlobals::rkApp ()->slotSetStatusBarText (i18n ("Loading Workspace ..."));
+ RKwardApp::getApp ()->slotSetStatusBarText (i18n ("Loading Workspace ..."));
#if !KDE_IS_VERSION (3, 2, 0)
KIO::NetAccess::download (url, tmpfile);
#else
- KIO::NetAccess::download (url, tmpfile, RKGlobals::rkApp ());
+ KIO::NetAccess::download (url, tmpfile, RKwardApp::getApp ());
#endif
update_was_delete = false;
RCommand *command;
if (!merge) {
- RKGlobals::rkApp ()->slotCloseAllEditors ();
+ RKwardApp::getApp ()->slotCloseAllEditors ();
update_was_delete = true;
command = new RCommand ("remove (list=ls (all.names=TRUE))", RCommand::App);
RKGlobals::rInterface ()->issueCommand (command);
@@ -75,8 +75,8 @@
KMessageBox::error (0, i18n ("There has been an error opening file '%1':\n%2").arg (RKGlobals::rObjectList ()->getWorkspaceURL ().path ()).arg (command->error ()), i18n ("Error loading workspace"));
RKGlobals::rObjectList ()->setWorkspaceURL (QString::null);
}
- RKGlobals::rkApp ()->slotSetStatusReady ();
- RKGlobals::rkApp ()->setCaption (QString::null); // trigger update of caption
+ RKwardApp::getApp ()->slotSetStatusReady ();
+ RKwardApp::getApp ()->setCaption (QString::null); // trigger update of caption
}
}
Modified: trunk/rkward/rkward/agents/rksaveagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rksaveagent.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/agents/rksaveagent.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -25,7 +25,7 @@
#include "../rbackend/rinterface.h"
#include "../rkglobals.h"
#include "../rkward.h"
-#include "../misc/rkworkplace.h"
+#include "../windows/rkworkplace.h"
#include "../rkeditormanager.h"
#include "../debug.h"
@@ -90,7 +90,8 @@
}
}
} else {
- RKGlobals::rkApp ()->setCaption (save_url.filename ());
+#warning TODO This line is wrong!
+ RKwardApp::getApp ()->setCaption (save_url.filename ());
done ();
return;
}
@@ -102,10 +103,10 @@
RKGlobals::rInterface ()->closeChain (save_chain);
}
if (when_done == Quit) {
- delete RKGlobals::rkApp ();
+ delete RKwardApp::getApp ();
qApp->quit ();
} else if (when_done == Load) {
- RKGlobals::rkApp ()->fileOpenNoSave (load_url);
+ RKwardApp::getApp ()->fileOpenNoSave (load_url);
delete this;
} else {
delete this;
Modified: trunk/rkward/rkward/agents/showedittextfileagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/showedittextfileagent.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/agents/showedittextfileagent.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -27,13 +27,13 @@
#include "../windows/rkcommandeditorwindow.h"
#include "../rbackend/rinterface.h"
#include "../rbackend/rembedinternal.h"
-#include "../misc/rkworkplace.h"
+#include "../windows/rkworkplace.h"
#include "../rkglobals.h"
#include "../rkward.h"
#include "../debug.h"
-ShowEditTextFileAgent::ShowEditTextFileAgent (RCallbackArgs *args, const QString &text, const QString &caption) : QObject (RKGlobals::rkApp ()) {
+ShowEditTextFileAgent::ShowEditTextFileAgent (RCallbackArgs *args, const QString &text, const QString &caption) : QObject (RKwardApp::getApp ()) {
RK_TRACE (APP);
ShowEditTextFileAgent::args = args;
Modified: trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -28,7 +28,7 @@
#include "../rkeditormanager.h"
#include "../core/rkmodificationtracker.h"
#include "rkeditordataframepart.h"
-#include "../misc/rkworkplace.h"
+#include "../windows/rkworkplace.h"
#include "../debug.h"
Modified: trunk/rkward/rkward/dataeditor/rkeditordataframepart.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframepart.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframepart.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -26,7 +26,6 @@
#include "rkeditordataframe.h"
#include "rkdrag.h"
#include "../rkward.h"
-#include "../rkglobals.h"
#include "../debug.h"
RKEditorDataFramePart::RKEditorDataFramePart (QWidget *parent) : KParts::Part (parent) {
@@ -65,18 +64,18 @@
void RKEditorDataFramePart::slotEditCut () {
RK_TRACE (EDITOR);
- RKGlobals::rkApp ()->slotSetStatusBarText (i18n ("Cutting selection..."));
+ RKwardApp::getApp ()->slotSetStatusBarText (i18n ("Cutting selection..."));
slotEditCopy ();
editor->clearSelected ();
- RKGlobals::rkApp ()->slotSetStatusReady ();
+ RKwardApp::getApp ()->slotSetStatusReady ();
}
void RKEditorDataFramePart::slotEditCopy() {
RK_TRACE (EDITOR);
- RKGlobals::rkApp ()->slotSetStatusBarText (i18n ("Copying selection to clipboard..."));
+ RKwardApp::getApp ()->slotSetStatusBarText (i18n ("Copying selection to clipboard..."));
QApplication::clipboard()->setData(editor->makeDrag ());
- RKGlobals::rkApp ()->slotSetStatusReady ();
+ RKwardApp::getApp ()->slotSetStatusReady ();
}
@@ -104,7 +103,7 @@
void RKEditorDataFramePart::doPaste () {
RK_TRACE (EDITOR);
- RKGlobals::rkApp ()->slotSetStatusBarText(i18n("Inserting clipboard contents..."));
+ RKwardApp::getApp ()->slotSetStatusBarText(i18n("Inserting clipboard contents..."));
// actually, we don't care, whether tsv or plain gets pasted - it's both
// treated the same. We should however encourage external senders to
@@ -119,7 +118,7 @@
editor->paste (data);
}
- RKGlobals::rkApp ()->slotSetStatusReady ();
+ RKwardApp::getApp ()->slotSetStatusReady ();
}
#include "rkeditordataframepart.moc"
Modified: trunk/rkward/rkward/khelpdlg.cpp
===================================================================
--- trunk/rkward/rkward/khelpdlg.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/khelpdlg.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -208,7 +208,7 @@
RK_ASSERT (command->stringVectorLength ());
url.setPath(command->getStringVector ()[0]);
if (QFile::exists (url.path ())) {
- RKGlobals::rkApp()->openHTML(url);
+ RKwardApp::getApp ()->openHTML (url);
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.").arg (command->command ().section ("\"", 1, 1)), i18n ("No help found"));
Modified: trunk/rkward/rkward/misc/Makefile.am
===================================================================
--- trunk/rkward/rkward/misc/Makefile.am 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/misc/Makefile.am 2006-09-27 11:16:08 UTC (rev 764)
@@ -3,8 +3,8 @@
noinst_LIBRARIES = libmisc.a
libmisc_a_SOURCES = rkerrordialog.cpp rkspinbox.cpp \
getfilenamewidget.cpp rkobjectlistview.cpp rkcanceldialog.cpp xmlhelper.cpp \
- multistringselector.cpp rkcommonfunctions.cpp rkprogresscontrol.cpp rkworkplace.cpp
+ multistringselector.cpp rkcommonfunctions.cpp rkprogresscontrol.cpp
noinst_HEADERS = rkerrordialog.h rkspinbox.h getfilenamewidget.h \
rkobjectlistview.h rkcanceldialog.h xmlhelper.h multistringselector.h \
- rkcommonfunctions.h rkprogresscontrol.h rkworkplace.h
+ rkcommonfunctions.h rkprogresscontrol.h
Deleted: trunk/rkward/rkward/misc/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkworkplace.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/misc/rkworkplace.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -1,258 +0,0 @@
-/***************************************************************************
- rkworkplace - description
- -------------------
- begin : Thu Sep 21 2006
- copyright : (C) 2006 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 "rkworkplace.h"
-
-#include <kparts/partmanager.h>
-#include <kmessagebox.h>
-#include <klocale.h>
-#include <kiconloader.h>
-
-#include "../windows/detachedwindowcontainer.h"
-#include "../windows/rkcommandeditorwindow.h"
-#include "../windows/rkhtmlwindow.h"
-#include "../windows/rkworkplaceview.h"
-#include "../core/robject.h"
-#include "../core/rcontainerobject.h"
-#include "../core/robjectlist.h"
-#include "../dataeditor/rkeditor.h"
-#include "../dataeditor/rkeditordataframe.h"
-#include "../dataeditor/rkeditordataframepart.h"
-#include "../rkglobals.h"
-#include "../rkward.h"
-
-#include "../debug.h"
-
-// static
-RKWorkplace *RKWorkplace::main_workplace = 0;
-
-RKWorkplace::RKWorkplace (QWidget *parent) : QObject (parent) {
- RK_TRACE (APP);
- RK_ASSERT (main_workplace == 0);
-
- main_workplace = this;
- wview = new RKWorkplaceView (parent);
- part_manager = new KParts::PartManager (RKGlobals::rkApp ());
-}
-
-RKWorkplace::~RKWorkplace () {
- RK_TRACE (APP);
-
-// closeAll (); // not needed, as the windows will autodelete themselves using QObject mechanism. Of course, closeAll () should be called *before* quitting.
-}
-
-void RKWorkplace::attachWindow (RKMDIWindow *window) {
- RK_TRACE (APP);
- RK_ASSERT (windows.find (window) != windows.end ()); // This should not happen for now.
-
- window->state = RKMDIWindow::Attached;
- view ()->addPage (window);
-
- RK_ASSERT (window->getPart ());
- part_manager->addPart (window->getPart ());
-}
-
-void RKWorkplace::detachWindow (RKMDIWindow *window) {
- RK_TRACE (APP);
- RK_ASSERT (windows.find (window) != windows.end ()); // Can't detach a window that is not attached
-
- window->state = RKMDIWindow::Detached;
-
- RK_ASSERT (window->getPart ());
- part_manager->removePart (window->getPart ());
- view ()->removePage (window);
-
- DetachedWindowContainer *detached = new DetachedWindowContainer (window);
- detached->show ();
-}
-
-void RKWorkplace::addWindow (RKMDIWindow *window) {
- RK_TRACE (APP);
-
- windows.append (window);
- connect (window, SIGNAL (destroyed (QObject *)), this, SLOT (windowDestroyed (QObject *)));
- attachWindow (window);
-}
-
-bool RKWorkplace::openScriptEditor (const KURL &url, bool use_r_highlighting, bool read_only, const QString &force_caption) {
- RK_TRACE (APP);
-
- RKCommandEditorWindow *editor = new RKCommandEditorWindow (view (), use_r_highlighting);
-
- if (!url.isEmpty ()) {
- if (!editor->openURL (url, use_r_highlighting, read_only)) {
- delete editor;
- KMessageBox::messageBox (view (), KMessageBox::Error, i18n ("Unable to open \"%1\"").arg (url.prettyURL ()), i18n ("Could not open command file"));
- return false;
- }
- }
-
- if (!force_caption.isEmpty ()) editor->setCaption (force_caption);
- addWindow (editor);
- return true;
-}
-
-void RKWorkplace::openHelpWindow (const KURL &url) {
- RK_TRACE (APP);
-
- RKHelpWindow *hw = new RKHelpWindow (view ());
- if (!url.isEmpty ()) {
- hw->openURL (url);
- }
-
- addWindow (hw);
-}
-
-void RKWorkplace::openOutputWindow (const KURL &url) {
- RK_TRACE (APP);
-
- RKOutputWindow::refreshOutput (true, true);
- if (windows.find (RKOutputWindow::getCurrentOutput ()) == windows.end ()) {
- addWindow (RKOutputWindow::getCurrentOutput ());
- }
-}
-
-bool RKWorkplace::canEditObject (RObject *object) {
- RK_TRACE (APP);
-
- if (object->isDataFrame ()) {
- return true;
- } else if (object->isVariable () && object->getContainer ()->isDataFrame ()) {
- return true;
- }
- return false;
-}
-
-RKEditor *RKWorkplace::editObject (RObject *object, bool initialize_to_empty) {
- RK_TRACE (APP);
-
- RObject *iobj = object;
- RKEditor *ed = 0;
- RKEditorDataFramePart *part = 0;
- if (!object->objectOpened ()) {
- if (object->isDataFrame ()) {
- part = new RKEditorDataFramePart (0); // TODO: reverse creation logic, just as in the other classes!
- ed = part->getEditor ();
- // TODO: add child objects, too?
- ed->openObject (object, initialize_to_empty);
- } else if (object->isVariable () && object->getContainer ()->isDataFrame ()) {
- if (!object->getContainer ()->objectOpened ()) {
- iobj = object->getContainer ();
- part = new RKEditorDataFramePart (0);
- ed = part->getEditor ();
- // TODO: add child objects, too?
- ed->openObject (iobj, initialize_to_empty);
- // ed->focusObject (obj);
- } else {
- if (object->getContainer ()->objectOpened ()) {
- object->getContainer ()->objectOpened ()->show ();
- object->getContainer ()->objectOpened ()->raise ();
- }
- }
- }
-
- if (ed) {
- ed->setCaption (iobj->getShortName ()); // TODO: move to editor
- ed->setIcon (SmallIcon ("spreadsheet"));
- addWindow (ed);
- ed->setFocus (); // somehow we need to call this explicitely
- }
- } else {
- object->objectOpened ()->show ();
- object->objectOpened ()->raise ();
- }
-
- return ed;
-}
-
-void RKWorkplace::flushAllData () {
- RK_TRACE (APP);
-
- for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
- if ((*it)->type == RKMDIWindow::DataEditorWindow) {
- static_cast<RKEditor *> (*it)->flushChanges ();
- }
- }
-}
-
-void RKWorkplace::closeWindow (RKMDIWindow *window) {
- RK_TRACE (APP);
- RK_ASSERT (windows.find (window) != windows.end ());
-
- window->close (true); // all the rest should happen in windowDestroyed ()
-}
-
-void RKWorkplace::closeActiveWindow () {
- RK_TRACE (APP);
-
- RKMDIWindow *w = activeAttachedWindow ();
- if (w) closeWindow (w);
- else RK_ASSERT (false); // this is benign, and maybe even ok, but I'd like to see when this happens
-}
-
-void RKWorkplace::closeAll (int type, int state) {
- RK_TRACE (APP);
-
- RKWorkplaceObjectList list_to_close;
- for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
- if (((*it)->type & type) && ((*it)->state & state)) {
- list_to_close.append ((*it)); // can't inline deletion
- }
- }
-
- for (RKWorkplaceObjectList::const_iterator it = list_to_close.constBegin (); it != list_to_close.constEnd (); ++it) {
- closeWindow (*it);
- }
-}
-
-void RKWorkplace::windowDestroyed (QObject *object) {
- RK_TRACE (APP);
- RKMDIWindow *window = static_cast<RKMDIWindow *> (object);
-
- RK_ASSERT (windows.find (window) != windows.end ());
- view ()->removePage (window, true);
- windows.remove (window);
-}
-
-RKMDIWindow *RKWorkplace::activeAttachedWindow () {
- RK_TRACE (APP);
-
- return (static_cast<RKMDIWindow *> (view ()->activePage ()));
-}
-
-void RKWorkplace::activateWindow (RKMDIWindow *window) {
- RK_TRACE (APP);
-
- window->raise (); // Does this do the trick?
-}
-
-void RKWorkplace::saveWorkplace (RCommandChain *chain) {
- RK_TRACE (APP);
-
- // TODO
-}
-
-void RKWorkplace::restoreWorkplace (RCommandChain *chain) {
- RK_TRACE (APP);
-
- // TODO
-}
-
-void RKWorkplace::rCommandDone (RCommand *command) {
-}
-
-#include "rkworkplace.moc"
Deleted: trunk/rkward/rkward/misc/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/misc/rkworkplace.h 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/misc/rkworkplace.h 2006-09-27 11:16:08 UTC (rev 764)
@@ -1,96 +0,0 @@
-/***************************************************************************
- rkworkplace - description
- -------------------
- begin : Thu Sep 21 2006
- copyright : (C) 2006 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 RKWORKPLACE_H
-#define RKWORKPLACE_H
-
-#include <qvaluelist.h>
-#include <qstring.h>
-#include <qtabwidget.h>
-
-#include <kurl.h>
-#include <kparts/part.h>
-
-#include "../windows/rkmdiwindow.h"
-#include "../rbackend/rcommandreceiver.h"
-
-class RObject;
-class RCommandChain;
-class RKWorkplaceView;
-class KParts::PartManager;
-class RKEditor;
-
-/** This class (only one instance will probably be around) keeps track of which windows are opened in the
-workplace, which are detached, etc. Will replace RKEditorManager.
-It also provides a QWidget (RKWorkplace::view ()), which actually manages the document windows (only those, so far. I.e. this is a half-replacement for KMdi, which will be gone in KDE 4). Currently layout of the document windows is always tabbed.
-//TODO: move to windows */
-class RKWorkplace : public QObject, public RCommandReceiver {
- Q_OBJECT
-public:
-/** ctor.
- at param parent: The parent widget for the workspace view (see view ()) */
- RKWorkplace (QWidget *parent);
- ~RKWorkplace ();
-
- RKWorkplaceView *view () { return wview; };
-
- typedef QValueList<RKMDIWindow *> RKWorkplaceObjectList;
- RKWorkplaceObjectList getObjectList () { return windows; };
-
-/** Attach an already created window. */
- void attachWindow (RKMDIWindow *window);
- void detachWindow (RKMDIWindow *window);
- RKMDIWindow *activeAttachedWindow ();
- void activateWindow (RKMDIWindow *window);
-
- bool openScriptEditor (const KURL &url=KURL (), bool use_r_highlighting=true, bool read_only=false, const QString &force_caption = QString::null);
- void openHelpWindow (const KURL &url=KURL ());
- void openOutputWindow (const KURL &url=KURL ());
-
- bool canEditObject (RObject *object);
- RKEditor *editObject (RObject *object, bool initialize_to_empty=false);
-
-/** tell all DataEditorWindow s to syncronize changes to the R backend
-// TODO: add RCommandChain parameter */
- void flushAllData ();
- void closeActiveWindow ();
- void closeWindow (RKMDIWindow *window);
-/** Closes all windows of the given type(s). Default call (no arguments) closes all windows
- at param type: A bitwise OR of RKWorkplaceObjectType
- at param state: A bitwise OR of RKWorkplaceObjectState */
- void closeAll (int type=RKMDIWindow::AnyType, int state=RKMDIWindow::AnyState);
-
- void saveWorkplace (RCommandChain *chain=0);
- void restoreWorkplace (RCommandChain *chain=0);
-
- static RKWorkplace *mainWorkplace () { return main_workplace; };
-signals:
- void lastWindowClosed (); // TODO: unused so far
-public slots:
- void windowDestroyed (QObject *window);
-protected:
- void rCommandDone (RCommand *command);
-private:
- RKWorkplaceObjectList windows;
- RKWorkplaceView *wview;
- void addWindow (RKMDIWindow *window);
- static RKWorkplace *main_workplace;
-friend class RKwardApp;
- KParts::PartManager *part_manager;
-};
-
-#endif
Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -225,7 +225,7 @@
#include "rkstandardcomponent.h"
-RKStandardComponentHandle::RKStandardComponentHandle (const QString &filename, RKComponentType type) : QObject (RKGlobals::rkApp ()), RKComponentHandle (filename, type) {
+RKStandardComponentHandle::RKStandardComponentHandle (const QString &filename, RKComponentType type) : QObject (RKwardApp::getApp ()), RKComponentHandle (filename, type) {
RK_TRACE (PLUGIN);
}
Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -153,13 +153,13 @@
RKGlobals::controlWindow ()->removeCommand (command);
command->finished ();
if (command->type () & RCommand::DirectToOutput) {
- RKGlobals::rkApp ()->newOutput ();
+ RKwardApp::getApp ()->newOutput ();
}
delete command;
} else if ((e->type () == RIDLE_EVENT)) {
- RKGlobals::rkApp ()->setRStatus (false);
+ RKwardApp::getApp ()->setRStatus (false);
} else if ((e->type () == RBUSY_EVENT)) {
- RKGlobals::rkApp ()->setRStatus (true);
+ RKwardApp::getApp ()->setRStatus (true);
} else if ((e->type () == R_EVAL_REQUEST_EVENT)) {
r_thread->pauseOutput (false); // we may be recursing downwards into event loops here. Hence we need to make sure, we don't create a deadlock
processREvalRequest (static_cast<REvalRequest *> (e->data ()));
@@ -309,7 +309,7 @@
issueCommand (".rk.rkreply <- \"Too few arguments in call to require.\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain);
}
} else if (call == "quit") {
- RKGlobals::rkApp ()->close ();
+ RKwardApp::getApp ()->close ();
// if we're still alive, quitting was cancelled
issueCommand (".rk.rkreply <- \"Quitting was cancelled\"", RCommand::App | RCommand::Sync, QString::null, 0, 0, request->in_chain);
#ifndef DISABLE_RKWINDOWCATCHER
@@ -355,7 +355,7 @@
// not to worry, just some help file to display
// TODO: maybe move this to ShowEditTextFileAgent instead
for (int n=0; n < args->int_a; ++n) {
- RKGlobals::rkApp ()->openHTML (args->chars_a[n]);
+ RKwardApp::getApp ()->openHTML (args->chars_a[n]);
}
} else {
ShowEditTextFileAgent::showEditFiles (args);
Modified: trunk/rkward/rkward/rkglobals.cpp
===================================================================
--- trunk/rkward/rkward/rkglobals.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/rkglobals.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -18,7 +18,6 @@
#include <qstring.h>
-RKwardApp *RKGlobals::app;
RInterface *RKGlobals::rinter;
RObjectList *RKGlobals::list;
RKModificationTracker *RKGlobals::mtracker;
Modified: trunk/rkward/rkward/rkglobals.h
===================================================================
--- trunk/rkward/rkward/rkglobals.h 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/rkglobals.h 2006-09-27 11:16:08 UTC (rev 764)
@@ -40,8 +40,6 @@
/** destructor. Do not use. No instance needed of this class. Only static stuff inside */
~RKGlobals ();
-/// static pointer to the app
- static RKwardApp *rkApp () { return app; }
/// static pointer to the RInterface
static RInterface *rInterface () { return rinter; };
/// static pointer to the RObjectList
@@ -67,7 +65,6 @@
private:
friend class RKwardApp;
- static RKwardApp *app;
static RInterface *rinter;
static RObjectList *list;
static RKModificationTracker *mtracker;
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/rkward.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -68,7 +68,7 @@
#include "windows/rcontrolwindow.h"
#include "windows/rkhtmlwindow.h"
#include "windows/rkworkplaceview.h"
-#include "misc/rkworkplace.h"
+#include "windows/rkworkplace.h"
#include "khelpdlg.h"
#include "rkconsole.h"
#include "debug.h"
@@ -87,9 +87,14 @@
new RKWorkplaceView (0);
}
+//static
+RKwardApp *RKwardApp::rkward_app = 0;
+
RKwardApp::RKwardApp (KURL *load_url) : DCOPObject ("rkwardapp"), KMdiMainFrm (0, 0, KMdi::IDEAlMode) {
RK_TRACE (APP);
- RKGlobals::app = this;
+ RK_ASSERT (rkward_app == 0);
+
+ rkward_app = this;
RKGlobals::rinter = 0;
RKGlobals::list = 0;
RKSettings::settings_tracker = new RKSettingsTracker (this);
@@ -97,8 +102,6 @@
// Nice docks a la Kdevelop.
setToolviewStyle(KMultiTabBar::KDEV3ICON);
-
-
///////////////////////////////////////////////////////////////////
// call inits to invoke all other construction parts
initActions();
@@ -122,26 +125,23 @@
startup_timer->start (50);
connect (startup_timer, SIGNAL (timeout ()), this, SLOT (doPostInit ()));
+ part_manager = new KParts::PartManager( this );
+ // When the manager says the active part changes,
+ // the builder updates (recreates) the GUI
+ connect (partManager (), SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
+ connect (partManager (), SIGNAL (partAdded (KParts::Part *)), this, SLOT (partAdded (KParts::Part *)));
+ connect (partManager (), SIGNAL (partRemoved (KParts::Part *)), this, SLOT (partRemoved (KParts::Part *)));
+
KMdiChildView *dummy = new KMdiChildView (this);
QVBoxLayout *layout = new QVBoxLayout (dummy);
addWindow (dummy);
new RKWorkplace (dummy);
layout->addWidget (RKWorkplace::mainWorkplace ()->view ());
- connect (RKWorkplace::mainWorkplace ()->part_manager, SIGNAL (partAdded (KParts::Part *)), this, SLOT (partAdded (KParts::Part *)));
- connect (RKWorkplace::mainWorkplace ()->part_manager, SIGNAL (partRemoved (KParts::Part *)), this, SLOT (partRemoved (KParts::Part *)));
- connect (RKWorkplace::mainWorkplace ()->part_manager, SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
connect (RKWorkplace::mainWorkplace ()->view (), SIGNAL (captionChanged (const QString &)), this, SLOT (setCaption (const QString &)));
-
- toolviews_manager = new KParts::PartManager( this );
- // When the manager says the active part changes,
- // the builder updates (recreates) the GUI
- connect (toolviews_manager, SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
- connect (toolviews_manager, SIGNAL (partAdded (KParts::Part *)), this, SLOT (partAdded (KParts::Part *)));
- connect (toolviews_manager, SIGNAL (partRemoved (KParts::Part *)), this, SLOT (partRemoved (KParts::Part *)));
- // a few calls to setCaption too many result from the lines below, but it seems to be the only way to catch all cases where the caption should be changed
+/* // a few calls to setCaption too many result from the lines below, but it seems to be the only way to catch all cases where the caption should be changed
connect (this, SIGNAL (viewActivated (KMdiChildView *)), this, SLOT (viewChanged (KMdiChildView *)));
- connect (this, SIGNAL (viewDeactivated (KMdiChildView *)), this, SLOT (viewChanged (KMdiChildView *)));
+ connect (this, SIGNAL (viewDeactivated (KMdiChildView *)), this, SLOT (viewChanged (KMdiChildView *))); */
if (!kapp->dcopClient ()->isRegistered ()) {
kapp->dcopClient ()->registerAs ("rkward");
@@ -149,14 +149,6 @@
}
}
-#warning Obsolete, remove
-void RKwardApp::addWindow (KMdiChildView *view, int flags) {
- RK_TRACE (APP);
-
- KMdiMainFrm::addWindow (view, flags);
- connect (view, SIGNAL (windowCaptionChanged (const QString &)), this, SLOT (setCaption (const QString &)));
-}
-
RKwardApp::~RKwardApp() {
RK_TRACE (APP);
closeAllViews ();
@@ -202,7 +194,7 @@
consolepart->widget ()->setIcon (SmallIcon ("konsole"));
consolepart->widget ()->setName ("r_console");
addToolWindow (consolepart->widget (), KDockWidget::DockBottom, getMainDockWidget (), 10);
- toolviews_manager->addPart (consolepart, false);
+ partManager ()->addPart (consolepart, false);
RKGlobals::helpdlg = new KHelpDlg (0);
RKGlobals::helpDialog ()->setIcon (SmallIcon ("help"));
Modified: trunk/rkward/rkward/rkward.h
===================================================================
--- trunk/rkward/rkward/rkward.h 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/rkward.h 2006-09-27 11:16:08 UTC (rev 764)
@@ -102,8 +102,9 @@
/** returns a pointer to the menu-list (in essence the menu-bar) */
RKMenuList* getMenuList () { return menu_list; };
+ KParts::PartManager *partManager () { return part_manager; };
- KParts::PartManager *toolviews_manager;
+ static RKwardApp *getApp () { return rkward_app; };
protected:
void openWorkspace (const KURL &url);
/** save Options/Settings. Includes general Options like all bar positions and status as well as the geometry and the recent file list */
@@ -196,8 +197,6 @@
void setCaption (const QString &caption);
/** a view has been activated or deactivated. We should make sure to update the main caption to fix strange quirks */
void viewChanged (KMdiChildView *) { setCaption (QString::null); };
-/** reimplemented from KMdiMainFrm to connect windowCaptionChanged to setCaption. It's beyond me, why the default implementation does not do this. */
- void addWindow (KMdiChildView *view, int flags=KMdi::StandardAdd);
/** connected to m_manager->partAdded (). Connects statusbar notifications */
void partAdded (KParts::Part *part);
@@ -205,6 +204,7 @@
void partRemoved (KParts::Part *part);
private:
QLabel* r_status_label;
+ KParts::PartManager *part_manager;
// KAction pointers to enable/disable actions
KAction* fileOpen;
@@ -251,7 +251,9 @@
KURL *initial_url;
RKMenuList *menu_list;
-
+
+ static RKwardApp *rkward_app;
+
friend class RInterface;
/** set the R status message ("R engine idel/busy") to idle or busy */
void setRStatus (bool busy);
Modified: trunk/rkward/rkward/robjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/robjectbrowser.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/robjectbrowser.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -32,7 +32,7 @@
#include "core/robjectlist.h"
#include "core/rkmodificationtracker.h"
#include "misc/rkobjectlistview.h"
-#include "misc/rkworkplace.h"
+#include "windows/rkworkplace.h"
#include "dataeditor/rkeditor.h"
#include "robjectviewer.h"
Modified: trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/settings/rksettingsmoduleplugins.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -98,7 +98,7 @@
#else
interface_pref = static_cast<PluginPrefs> (button_group->selectedId ());
#endif
- RKGlobals::rkApp ()->initPlugins();
+ RKwardApp::getApp ()->initPlugins();
}
void RKSettingsModulePlugins::save (KConfig *config) {
Modified: trunk/rkward/rkward/windows/Makefile.am
===================================================================
--- trunk/rkward/rkward/windows/Makefile.am 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/windows/Makefile.am 2006-09-27 11:16:08 UTC (rev 764)
@@ -2,8 +2,10 @@
METASOURCES = AUTO
noinst_LIBRARIES = libwindows.a
noinst_HEADERS = rkcommandeditorwindow.h rkcommandeditorwindowpart.h \
- rkhtmlwindow.h rcontrolwindow.h detachedwindowcontainer.h rkmdiwindow.h rkworkplaceview.h
+ rkhtmlwindow.h rcontrolwindow.h detachedwindowcontainer.h rkmdiwindow.h \
+ rkworkplaceview.h rkworkplace.h
libwindows_a_SOURCES = rkcommandeditorwindow.cpp rkcommandeditorwindowpart.cpp \
- rkhtmlwindow.cpp rcontrolwindow.cpp detachedwindowcontainer.cpp rkmdiwindow.cpp rkworkplaceview.cpp
+ rkhtmlwindow.cpp rcontrolwindow.cpp detachedwindowcontainer.cpp rkmdiwindow.cpp \
+ rkworkplaceview.cpp rkworkplace.cpp
rcdir = $(kde_datadir)/rkward
rc_DATA = rkcommandeditorwindowpart.rc rkoutputwindow.rc rkhelpwindow.rc detachedwindowcontainer.rc
Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -24,11 +24,11 @@
#include <qwidget.h>
#include "../rkward.h"
-#include "../misc/rkworkplace.h"
+#include "rkworkplace.h"
#include "../rkglobals.h"
#include "../debug.h"
-DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture) : KParts::MainWindow (RKGlobals::rkApp ()) {
+DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture) : KParts::MainWindow (RKwardApp::getApp ()) {
RK_TRACE (APP);
// create own GUI
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -34,7 +34,7 @@
#include "../rkward.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../misc/rkcommonfunctions.h"
-#include "../misc/rkworkplace.h"
+#include "../windows/rkworkplace.h"
#include "../windows/rkworkplaceview.h"
#include "../debug.h"
Modified: trunk/rkward/rkward/windows/rkmdiwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.cpp 2006-09-26 16:53:29 UTC (rev 763)
+++ trunk/rkward/rkward/windows/rkmdiwindow.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -17,7 +17,7 @@
#include "rkmdiwindow.h"
-#include "../misc/rkworkplace.h"
+#include "rkworkplace.h"
#include "../debug.h"
Copied: trunk/rkward/rkward/windows/rkworkplace.cpp (from rev 763, trunk/rkward/rkward/misc/rkworkplace.cpp)
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp (rev 0)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2006-09-27 11:16:08 UTC (rev 764)
@@ -0,0 +1,257 @@
+/***************************************************************************
+ rkworkplace - description
+ -------------------
+ begin : Thu Sep 21 2006
+ copyright : (C) 2006 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 "rkworkplace.h"
+
+#include <kparts/partmanager.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kiconloader.h>
+
+#include "detachedwindowcontainer.h"
+#include "rkcommandeditorwindow.h"
+#include "rkhtmlwindow.h"
+#include "rkworkplaceview.h"
+#include "../core/robject.h"
+#include "../core/rcontainerobject.h"
+#include "../core/robjectlist.h"
+#include "../dataeditor/rkeditor.h"
+#include "../dataeditor/rkeditordataframe.h"
+#include "../dataeditor/rkeditordataframepart.h"
+#include "../rkglobals.h"
+#include "../rkward.h"
+
+#include "../debug.h"
+
+// static
+RKWorkplace *RKWorkplace::main_workplace = 0;
+
+RKWorkplace::RKWorkplace (QWidget *parent) : QObject (parent) {
+ RK_TRACE (APP);
+ RK_ASSERT (main_workplace == 0);
+
+ main_workplace = this;
+ wview = new RKWorkplaceView (parent);
+}
+
+RKWorkplace::~RKWorkplace () {
+ RK_TRACE (APP);
+
+// closeAll (); // not needed, as the windows will autodelete themselves using QObject mechanism. Of course, closeAll () should be called *before* quitting.
+}
+
+void RKWorkplace::attachWindow (RKMDIWindow *window) {
+ RK_TRACE (APP);
+ RK_ASSERT (windows.find (window) != windows.end ()); // This should not happen for now.
+
+ window->state = RKMDIWindow::Attached;
+ view ()->addPage (window);
+
+ RK_ASSERT (window->getPart ());
+ RKwardApp::getApp ()->partManager ()->addPart (window->getPart ());
+}
+
+void RKWorkplace::detachWindow (RKMDIWindow *window) {
+ RK_TRACE (APP);
+ RK_ASSERT (windows.find (window) != windows.end ()); // Can't detach a window that is not attached
+
+ window->state = RKMDIWindow::Detached;
+
+ RK_ASSERT (window->getPart ());
+ RKwardApp::getApp ()->partManager ()->removePart (window->getPart ());
+ view ()->removePage (window);
+
+ DetachedWindowContainer *detached = new DetachedWindowContainer (window);
+ detached->show ();
+}
+
+void RKWorkplace::addWindow (RKMDIWindow *window) {
+ RK_TRACE (APP);
+
+ windows.append (window);
+ connect (window, SIGNAL (destroyed (QObject *)), this, SLOT (windowDestroyed (QObject *)));
+ attachWindow (window);
+}
+
+bool RKWorkplace::openScriptEditor (const KURL &url, bool use_r_highlighting, bool read_only, const QString &force_caption) {
+ RK_TRACE (APP);
+
+ RKCommandEditorWindow *editor = new RKCommandEditorWindow (view (), use_r_highlighting);
+
+ if (!url.isEmpty ()) {
+ if (!editor->openURL (url, use_r_highlighting, read_only)) {
+ delete editor;
+ KMessageBox::messageBox (view (), KMessageBox::Error, i18n ("Unable to open \"%1\"").arg (url.prettyURL ()), i18n ("Could not open command file"));
+ return false;
+ }
+ }
+
+ if (!force_caption.isEmpty ()) editor->setCaption (force_caption);
+ addWindow (editor);
+ return true;
+}
+
+void RKWorkplace::openHelpWindow (const KURL &url) {
+ RK_TRACE (APP);
+
+ RKHelpWindow *hw = new RKHelpWindow (view ());
+ if (!url.isEmpty ()) {
+ hw->openURL (url);
+ }
+
+ addWindow (hw);
+}
+
+void RKWorkplace::openOutputWindow (const KURL &url) {
+ RK_TRACE (APP);
+
+ RKOutputWindow::refreshOutput (true, true);
+ if (windows.find (RKOutputWindow::getCurrentOutput ()) == windows.end ()) {
+ addWindow (RKOutputWindow::getCurrentOutput ());
+ }
+}
+
+bool RKWorkplace::canEditObject (RObject *object) {
+ RK_TRACE (APP);
+
+ if (object->isDataFrame ()) {
+ return true;
+ } else if (object->isVariable () && object->getContainer ()->isDataFrame ()) {
+ return true;
+ }
+ return false;
+}
+
+RKEditor *RKWorkplace::editObject (RObject *object, bool initialize_to_empty) {
+ RK_TRACE (APP);
+
+ RObject *iobj = object;
+ RKEditor *ed = 0;
+ RKEditorDataFramePart *part = 0;
+ if (!object->objectOpened ()) {
+ if (object->isDataFrame ()) {
+ part = new RKEditorDataFramePart (0); // TODO: reverse creation logic, just as in the other classes!
+ ed = part->getEditor ();
+ // TODO: add child objects, too?
+ ed->openObject (object, initialize_to_empty);
+ } else if (object->isVariable () && object->getContainer ()->isDataFrame ()) {
+ if (!object->getContainer ()->objectOpened ()) {
+ iobj = object->getContainer ();
+ part = new RKEditorDataFramePart (0);
+ ed = part->getEditor ();
+ // TODO: add child objects, too?
+ ed->openObject (iobj, initialize_to_empty);
+ // ed->focusObject (obj);
+ } else {
+ if (object->getContainer ()->objectOpened ()) {
+ object->getContainer ()->objectOpened ()->show ();
+ object->getContainer ()->objectOpened ()->raise ();
+ }
+ }
+ }
+
+ if (ed) {
+ ed->setCaption (iobj->getShortName ()); // TODO: move to editor
+ ed->setIcon (SmallIcon ("spreadsheet"));
+ addWindow (ed);
+ ed->setFocus (); // somehow we need to call this explicitely
+ }
+ } else {
+ object->objectOpened ()->show ();
+ object->objectOpened ()->raise ();
+ }
+
+ return ed;
+}
+
+void RKWorkplace::flushAllData () {
+ RK_TRACE (APP);
+
+ for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
+ if ((*it)->type == RKMDIWindow::DataEditorWindow) {
+ static_cast<RKEditor *> (*it)->flushChanges ();
+ }
+ }
+}
+
+void RKWorkplace::closeWindow (RKMDIWindow *window) {
+ RK_TRACE (APP);
+ RK_ASSERT (windows.find (window) != windows.end ());
+
+ window->close (true); // all the rest should happen in windowDestroyed ()
+}
+
+void RKWorkplace::closeActiveWindow () {
+ RK_TRACE (APP);
+
+ RKMDIWindow *w = activeAttachedWindow ();
+ if (w) closeWindow (w);
+ else RK_ASSERT (false); // this is benign, and maybe even ok, but I'd like to see when this happens
+}
+
+void RKWorkplace::closeAll (int type, int state) {
+ RK_TRACE (APP);
+
+ RKWorkplaceObjectList list_to_close;
+ for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
+ if (((*it)->type & type) && ((*it)->state & state)) {
+ list_to_close.append ((*it)); // can't inline deletion
+ }
+ }
+
+ for (RKWorkplaceObjectList::const_iterator it = list_to_close.constBegin (); it != list_to_close.constEnd (); ++it) {
+ closeWindow (*it);
+ }
+}
+
+void RKWorkplace::windowDestroyed (QObject *object) {
+ RK_TRACE (APP);
+ RKMDIWindow *window = static_cast<RKMDIWindow *> (object);
+
+ RK_ASSERT (windows.find (window) != windows.end ());
+ view ()->removePage (window, true);
+ windows.remove (window);
+}
+
+RKMDIWindow *RKWorkplace::activeAttachedWindow () {
+ RK_TRACE (APP);
+
+ return (static_cast<RKMDIWindow *> (view ()->activePage ()));
+}
+
+void RKWorkplace::activateWindow (RKMDIWindow *window) {
+ RK_TRACE (APP);
+
+ window->raise (); // Does this do the trick?
+}
+
+void RKWorkplace::saveWorkplace (RCommandChain *chain) {
+ RK_TRACE (APP);
+
+ // TODO
+}
+
+void RKWorkplace::restoreWorkplace (RCommandChain *chain) {
+ RK_TRACE (APP);
+
+ // TODO
+}
+
+void RKWorkplace::rCommandDone (RCommand *command) {
+}
+
+#include "rkworkplace.moc"
Copied: trunk/rkward/rkward/windows/rkworkplace.h (from rev 763, trunk/rkward/rkward/misc/rkworkplace.h)
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h (rev 0)
+++ trunk/rkward/rkward/windows/rkworkplace.h 2006-09-27 11:16:08 UTC (rev 764)
@@ -0,0 +1,92 @@
+/***************************************************************************
+ rkworkplace - description
+ -------------------
+ begin : Thu Sep 21 2006
+ copyright : (C) 2006 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 RKWORKPLACE_H
+#define RKWORKPLACE_H
+
+#include <qvaluelist.h>
+#include <qstring.h>
+#include <qtabwidget.h>
+
+#include <kurl.h>
+
+#include "rkmdiwindow.h"
+#include "../rbackend/rcommandreceiver.h"
+
+class RObject;
+class RCommandChain;
+class RKWorkplaceView;
+class RKEditor;
+
+/** This class (only one instance will probably be around) keeps track of which windows are opened in the
+workplace, which are detached, etc. Will replace RKEditorManager.
+It also provides a QWidget (RKWorkplace::view ()), which actually manages the document windows (only those, so far. I.e. this is a half-replacement for KMdi, which will be gone in KDE 4). Currently layout of the document windows is always tabbed.
+//TODO: move to windows */
+class RKWorkplace : public QObject, public RCommandReceiver {
+ Q_OBJECT
+public:
+/** ctor.
+ at param parent: The parent widget for the workspace view (see view ()) */
+ RKWorkplace (QWidget *parent);
+ ~RKWorkplace ();
+
+ RKWorkplaceView *view () { return wview; };
+
+ typedef QValueList<RKMDIWindow *> RKWorkplaceObjectList;
+ RKWorkplaceObjectList getObjectList () { return windows; };
+
+/** Attach an already created window. */
+ void attachWindow (RKMDIWindow *window);
+ void detachWindow (RKMDIWindow *window);
+ RKMDIWindow *activeAttachedWindow ();
+ void activateWindow (RKMDIWindow *window);
+
+ bool openScriptEditor (const KURL &url=KURL (), bool use_r_highlighting=true, bool read_only=false, const QString &force_caption = QString::null);
+ void openHelpWindow (const KURL &url=KURL ());
+ void openOutputWindow (const KURL &url=KURL ());
+
+ bool canEditObject (RObject *object);
+ RKEditor *editObject (RObject *object, bool initialize_to_empty=false);
+
+/** tell all DataEditorWindow s to syncronize changes to the R backend
+// TODO: add RCommandChain parameter */
+ void flushAllData ();
+ void closeActiveWindow ();
+ void closeWindow (RKMDIWindow *window);
+/** Closes all windows of the given type(s). Default call (no arguments) closes all windows
+ at param type: A bitwise OR of RKWorkplaceObjectType
+ at param state: A bitwise OR of RKWorkplaceObjectState */
+ void closeAll (int type=RKMDIWindow::AnyType, int state=RKMDIWindow::AnyState);
+
+ void saveWorkplace (RCommandChain *chain=0);
+ void restoreWorkplace (RCommandChain *chain=0);
+
+ static RKWorkplace *mainWorkplace () { return main_workplace; };
+signals:
+ void lastWindowClosed (); // TODO: unused so far
+public slots:
+ void windowDestroyed (QObject *window);
+protected:
+ void rCommandDone (RCommand *command);
+private:
+ RKWorkplaceObjectList windows;
+ RKWorkplaceView *wview;
+ void addWindow (RKMDIWindow *window);
+ static RKWorkplace *main_workplace;
+};
+
+#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