[rkward-cvs] SF.net SVN: rkward: [762] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Sep 25 17:57:24 UTC 2006


Revision: 762
          http://svn.sourceforge.net/rkward/?rev=762&view=rev
Author:   tfry
Date:     2006-09-25 10:57:13 -0700 (Mon, 25 Sep 2006)

Log Message:
-----------
Slightly less buggy version of the new MDI. Left TODO (among others):
Part activation / focus not always working
Caption initialization for RKCommandEditorWindow
Hide TabBar when only one window
Hide TabWidget drop shadow
update main window caption

Modified Paths:
--------------
    trunk/rkward/rkward/dataeditor/rkeditor.cpp
    trunk/rkward/rkward/dataeditor/rkeditor.h
    trunk/rkward/rkward/misc/rkworkplace.cpp
    trunk/rkward/rkward/misc/rkworkplace.h
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
    trunk/rkward/rkward/windows/detachedwindowcontainer.h
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.h

Modified: trunk/rkward/rkward/dataeditor/rkeditor.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.cpp	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/dataeditor/rkeditor.cpp	2006-09-25 17:57:13 UTC (rev 762)
@@ -16,7 +16,7 @@
  ***************************************************************************/
 #include "rkeditor.h"
 
-RKEditor::RKEditor (QWidget *parent) : KMdiChildView (parent) {
+RKEditor::RKEditor (QWidget *parent) : RKMDIWindow (parent, RKWorkplace::DataEditorWindow) {
 }
 
 

Modified: trunk/rkward/rkward/dataeditor/rkeditor.h
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.h	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/dataeditor/rkeditor.h	2006-09-25 17:57:13 UTC (rev 762)
@@ -24,6 +24,8 @@
 #include <kparts/part.h>
 #include <kmdichildview.h>
 
+#include "../misc/rkworkplace.h"
+
 class RCommandChain;
 class RKDrag;
 
@@ -32,8 +34,8 @@
 
 @author Thomas Friedrichsmeier
 */
-class RKEditor : public KMdiChildView {
-Q_OBJECT
+class RKEditor : public RKMDIWindow {
+	Q_OBJECT
 protected:
     RKEditor (QWidget *parent);
 
@@ -64,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;
 
+	bool isModified () { return false; };
 	KParts::Part *getPart () { return part; };
 protected:
 friend class RKWorkplace;

Modified: trunk/rkward/rkward/misc/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkworkplace.cpp	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/misc/rkworkplace.cpp	2006-09-25 17:57:13 UTC (rev 762)
@@ -31,6 +31,8 @@
 #include "../dataeditor/rkeditor.h"
 #include "../dataeditor/rkeditordataframe.h"
 #include "../dataeditor/rkeditordataframepart.h"
+#include "../rkglobals.h"
+#include "../rkward.h"
 
 #include "../debug.h"
 
@@ -44,7 +46,7 @@
 	main_workplace = this;
 	wview = new RKWorkplaceView (parent);
 	connect (wview, SIGNAL (currentChanged (QWidget *)), this, SLOT (activeAttachedChanged (QWidget *)));
-	part_manager = new KParts::PartManager (view ());
+	part_manager = new KParts::PartManager (RKGlobals::rkApp ());
 }
 
 RKWorkplace::~RKWorkplace () {
@@ -53,58 +55,47 @@
 	closeAll ();
 }
 
-void RKWorkplace::attachWindow (QWidget *window) {
+void RKWorkplace::attachWindow (RKMDIWindow *window) {
 	RK_TRACE (APP);
 	RK_ASSERT (windows.find (window) != windows.end ());		// This should not happen for now.
 
-	RKWorkplaceObjectInfo *info = windows[window];
-	info->state = Attached;
+	connect (window, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (updateWindowCaption (RKMDIWindow *)));
+	window->state = Attached;
 
 	window->reparent (view (), QPoint (0, 0));
-	view ()->addTab (window, window->caption ());
-	RK_ASSERT (info->part);
-	part_manager->addPart (info->part);
+	view ()->addTab (window, *(window->icon ()), window->shortCaption ());
+	window->show ();
+	view ()->setCurrentPage (view ()->indexOf (window));
+	window->setFocus ();
+
+	RK_ASSERT (window->getPart ());
+	part_manager->addPart (window->getPart ());
 }
 
-void RKWorkplace::detachWindow (QWidget *window) {
+void RKWorkplace::detachWindow (RKMDIWindow *window) {
 	RK_TRACE (APP);
 	RK_ASSERT (windows.find (window) != windows.end ());		// Can't detach a window that is not attached
 
-	RKWorkplaceObjectInfo *info = windows[window];
-	info->state = Detached;
+	disconnect (window, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (updateWindowCaption (RKMDIWindow *)));
+	window->state = Detached;
 
-	RK_ASSERT (info->part);
-	part_manager->removePart (info->part);
+	RK_ASSERT (window->getPart ());
+	part_manager->removePart (window->getPart ());
 	view ()->removePage (window);
 
-	DetachedWindowContainer *detached = new DetachedWindowContainer (info->part, window);
+	DetachedWindowContainer *detached = new DetachedWindowContainer (window);
 	detached->show ();
 }
 
-void RKWorkplace::addWindow (QWidget *window, RKWorkplaceObjectType type) {
+void RKWorkplace::addWindow (RKMDIWindow *window) {
 	RK_TRACE (APP);
 
 	connect (window, SIGNAL (destroyed (QObject *)), this, SLOT (windowDestroyed (QObject *)));
 
-	RKWorkplaceObjectInfo *info = new RKWorkplaceObjectInfo;
-	info->part = 0;
-	info->state = Attached;
-	info->type = type;
-	windows.insert (window, info);
-
-	window->show ();
-	view ()->addTab (window, window->caption ());
-	view ()->setCurrentPage (view ()->indexOf (window));
-	window->setFocus ();
+	windows.append (window);
+	attachWindow (window);
 }
 
-void RKWorkplace::registerPart (QWidget *window, KParts::Part *part) {
-	RK_TRACE (APP);
-	RK_ASSERT (windows.find (window) != windows.end ());
-
-	windows[window]->part = part;
-}
-
 bool RKWorkplace::openScriptEditor (const KURL &url, bool use_r_highlighting, bool read_only, const QString &force_caption) {
 	RK_TRACE (APP);
 
@@ -119,8 +110,7 @@
 	}
 
 	if (!force_caption.isEmpty ()) editor->setCaption (force_caption);
-	addWindow (editor, CommandEditorWindow);
-	registerPart (editor, editor->getPart ());
+	addWindow (editor);
 	return true;
 }
 
@@ -132,7 +122,7 @@
 		hw->openURL (url);
 	}
 
-	addWindow (hw, HelpWindow);
+	addWindow (hw);
 }
 
 void RKWorkplace::openOutputWindow (const KURL &url) {
@@ -140,7 +130,7 @@
 
 	RKOutputWindow::refreshOutput (true, true);
 	if (windows.find (RKOutputWindow::getCurrentOutput ()) == windows.end ()) {
-		addWindow (RKOutputWindow::getCurrentOutput (), OutputWindow);
+		addWindow (RKOutputWindow::getCurrentOutput ());
 	}
 }
 
@@ -185,10 +175,9 @@
 
 		if (ed) {
 			ed->setCaption (iobj->getShortName ());		// TODO: move to editor
-			addWindow (ed, DataEditorWindow);
 			ed->setIcon (SmallIcon ("spreadsheet"));
+			addWindow (ed);
 			ed->setFocus ();		// somehow we need to call this explicitely
-			registerPart (ed, part);
 		}
 	} else {
 		object->objectOpened ()->show ();
@@ -201,14 +190,14 @@
 void RKWorkplace::flushAllData () {
 	RK_TRACE (APP);
 
-	for (RKWorkplaceObjectMap::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
-		if (it.data ()->type == DataEditorWindow) {
-			static_cast<RKEditor *> (it.key ())->flushChanges ();
+	for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
+		if ((*it)->type == DataEditorWindow) {
+			static_cast<RKEditor *> (*it)->flushChanges ();
 		}
 	}
 }
 
-void RKWorkplace::closeWindow (QWidget *window) {
+void RKWorkplace::closeWindow (RKMDIWindow *window) {
 	RK_TRACE (APP);
 	RK_ASSERT (windows.find (window) != windows.end ());
 
@@ -218,7 +207,7 @@
 void RKWorkplace::closeActiveWindow () {
 	RK_TRACE (APP);
 
-	QWidget *w = activeAttachedWindow ();
+	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
 }
@@ -226,52 +215,50 @@
 void RKWorkplace::closeAll (int type, int state) {
 	RK_TRACE (APP);
 
-	QValueList<QWidget *> list_to_close;
-	for (RKWorkplaceObjectMap::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
-		if ((it.data ()->type & type) && (it.data ()->state & state)) {
-			list_to_close.append (it.key ());		// can't inline deletion
+	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 (QValueList<QWidget *>::const_iterator it = list_to_close.constBegin (); it != list_to_close.constEnd (); ++it) {
+	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);
-	QWidget *window = static_cast<QWidget *> (object);
+	RKMDIWindow *window = static_cast<RKMDIWindow *> (object);
 
 	RK_ASSERT (windows.find (window) != windows.end ());
-	delete windows[window];
 	windows.remove (window);
 }
 
-void RKWorkplace::updateWindowCaption (QWidget *window) {
+void RKWorkplace::updateWindowCaption (RKMDIWindow *window) {
 	RK_TRACE (APP);
 
 	RK_ASSERT (windows.find (window) != windows.end ());
-	view ()->changeTab (window, window->caption ());
+	view ()->changeTab (window, window->shortCaption ());
 	if (window == activeAttachedWindow ()) emit (changeCaption ());
 }
 
 void RKWorkplace::activeAttachedChanged (QWidget *window) {
 	RK_TRACE (APP);
-	RK_ASSERT (windows.find (window) != windows.end ());
+	RKMDIWindow *w = static_cast<RKMDIWindow *>(window);
+	RK_ASSERT (windows.find (w) != windows.end ());
 	RK_ASSERT (window);
 
 	emit (changeCaption ());
-	// do we need to force an update of the active Part?
-	emit (changeGUI (windows[window]->part));
 }
 
-QWidget *RKWorkplace::activeAttachedWindow () {
+RKMDIWindow *RKWorkplace::activeAttachedWindow () {
 	RK_TRACE (APP);
 
-	return (view ()->currentPage ());
+	return (static_cast<RKMDIWindow *> (view ()->currentPage ()));
 }
 
-void RKWorkplace::activateWindow (QWidget *window) {
+void RKWorkplace::activateWindow (RKMDIWindow *window) {
 	RK_TRACE (APP);
 
 	window->raise ();		// Does this do the trick?

Modified: trunk/rkward/rkward/misc/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/misc/rkworkplace.h	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/misc/rkworkplace.h	2006-09-25 17:57:13 UTC (rev 762)
@@ -32,6 +32,7 @@
 class RKWorkplaceView;
 class KParts::PartManager;
 class RKEditor;
+class RKMDIWindow;
 
 /** 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.
@@ -45,37 +46,30 @@
 	RKWorkplace (QWidget *parent);
 	~RKWorkplace ();
 
-	enum RKWorkplaceObjectType {
+	enum ObjectType {
 		DataEditorWindow=1,
 		CommandEditorWindow=2,
 		OutputWindow=4,
 		HelpWindow=8,
 		AnyType=DataEditorWindow | CommandEditorWindow | OutputWindow | HelpWindow
 	};
-
-	enum RKWorkplaceObjectState {
+	
+	enum ObjectState {
 		Attached=1,
 		Detached=2,
 		AnyState=Attached | Detached
 	};
 
-	struct RKWorkplaceObjectInfo {
-		RKWorkplaceObjectType type;
-		KParts::Part *part;
-		RKWorkplaceObjectState state;
-	};
-
-	typedef QMap<QWidget *, RKWorkplaceObjectInfo *> RKWorkplaceObjectMap;
-
 	RKWorkplaceView *view () { return wview; };
 
-	RKWorkplaceObjectMap getObjectList () { return windows; };
+	typedef QValueList<RKMDIWindow *> RKWorkplaceObjectList;
+	RKWorkplaceObjectList getObjectList () { return windows; };
 
 /** Attach an already created window. */
-	void attachWindow (QWidget *window);
-	void detachWindow (QWidget *window);
-	QWidget *activeAttachedWindow ();
-	void activateWindow (QWidget *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 ());
@@ -88,7 +82,7 @@
 // TODO: add RCommandChain parameter */
 	void flushAllData ();
 	void closeActiveWindow ();
-	void closeWindow (QWidget *window);
+	void closeWindow (RKMDIWindow *window);
 /** Closes all windows of the given type(s). Default call (no arguments) closes all windows
 @param type: A bitwise OR of RKWorkplaceObjectType
 @param state: A bitwise OR of RKWorkplaceObjectState */
@@ -100,20 +94,17 @@
 	static RKWorkplace *mainWorkplace () { return main_workplace; };
 signals:
 	void lastWindowClosed ();
-	void changeGUI (KParts::Part *active_part);
 	void changeCaption ();
 public slots:
 	void windowDestroyed (QObject *window);
-	void updateWindowCaption (QWidget *window);
+	void updateWindowCaption (RKMDIWindow *window);
 	void activeAttachedChanged (QWidget *window);
-
-	void registerPart (QWidget *window, KParts::Part *part);
 protected:
 	void rCommandDone (RCommand *command);
 private:
-	RKWorkplaceObjectMap windows;
+	RKWorkplaceObjectList windows;
 	RKWorkplaceView *wview;
-	void addWindow (QWidget *window, RKWorkplaceObjectType type);
+	void addWindow (RKMDIWindow *window);
 	static RKWorkplace *main_workplace;
 friend class RKwardApp;
 	KParts::PartManager *part_manager;
@@ -126,4 +117,25 @@
 	~RKWorkplaceView () {};
 };
 
+class RKMDIWindow : public QWidget {
+	Q_OBJECT
+protected:
+	RKMDIWindow (QWidget *parent, RKWorkplace::ObjectType type) : QWidget (parent) { RKMDIWindow::type=type; state=RKWorkplace::Attached; };
+	~RKMDIWindow () {};
+public:
+	virtual bool isModified () = 0;
+	virtual QString fullCaption () { return shortCaption (); };
+	virtual QString shortCaption () { return caption (); };
+	virtual KParts::Part *getPart () = 0;
+	void setCaption (const QString &caption) { QWidget::setCaption (caption); emit (captionChanged (this)); };
+	virtual QWidget *getWindow () { return getPart ()->widget (); };
+signals:
+	void captionChanged (RKMDIWindow *);
+protected:
+friend class RKWorkplace;
+	RKWorkplace::ObjectType type;
+private:
+	RKWorkplace::ObjectState state;
+};
+
 #endif

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/rkward.cpp	2006-09-25 17:57:13 UTC (rev 762)
@@ -82,7 +82,7 @@
 	ShowEditTextFileAgent::showEditFiles (0);		// TODO: AAAAAAAARGGGH!!!! It won't link without this bogus line!!!
 	RKReadLineDialog::readLine (0, QString(), QString(), 0, 0);	// TODO: see above
 	new RKEditorDataFramePart (0);
-	DetachedWindowContainer (0, 0);
+	DetachedWindowContainer (0);
 }
 
 RKwardApp::RKwardApp (KURL *load_url) : DCOPObject ("rkwardapp"), KMdiMainFrm (0, 0, KMdi::IDEAlMode) {
@@ -127,7 +127,7 @@
 	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 (), SIGNAL (changeGUI (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
+	connect (RKWorkplace::mainWorkplace ()->part_manager, SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (createGUI (KParts::Part *)));
 	connect (RKWorkplace::mainWorkplace (), SIGNAL (changeCaption (const QString &)), this, SLOT (setCaption (const QString &)));
 	
 
@@ -477,9 +477,9 @@
 		}
 	}
 
-	RKWorkplace::RKWorkplaceObjectMap map = RKWorkplace::mainWorkplace ()->getObjectList ();
-	for (RKWorkplace::RKWorkplaceObjectMap::const_iterator it = map.constBegin (); it != map.constEnd (); ++it){
-		if (!it.key ()->close ()) {
+	RKWorkplace::RKWorkplaceObjectList map = RKWorkplace::mainWorkplace ()->getObjectList ();
+	for (RKWorkplace::RKWorkplaceObjectList::const_iterator it = map.constBegin (); it != map.constEnd (); ++it){
+		if (!(*it)->close ()) {
 			// If a child refuses to close, we return false.
 			slotSetStatusReady ();
 			return false;

Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.cpp	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.cpp	2006-09-25 17:57:13 UTC (rev 762)
@@ -28,7 +28,7 @@
 #include "../rkglobals.h"
 #include "../debug.h"
 
-DetachedWindowContainer::DetachedWindowContainer (KParts::Part *part_to_capture, QWidget *widget_to_capture) : KParts::MainWindow  (RKGlobals::rkApp ()) {
+DetachedWindowContainer::DetachedWindowContainer (RKMDIWindow *widget_to_capture) : KParts::MainWindow  (RKGlobals::rkApp ()) {
 	RK_TRACE (APP);
 
 // create own GUI
@@ -38,15 +38,14 @@
 	createShellGUI ();
 
 // capture widget
-	part = part_to_capture;
 	widget_to_capture->reparent (this, QPoint (0, 0));
 	setCentralWidget (widget_to_capture);
-	createGUI (part_to_capture);
+	createGUI (widget_to_capture->getPart ());
 
 // should self-destruct, when child widget is destroyed
 	connect (widget_to_capture, SIGNAL (destroyed (QObject *)), this, SLOT (viewDestroyed (QObject *)));
-	connect (widget_to_capture, SIGNAL (captionChanged (QWidget *)), this, SLOT (updateCaption (QWidget *)));
-	setCaption (widget_to_capture->caption ());	// has to come after createGUI!
+	connect (widget_to_capture, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (updateCaption (RKMDIWindow *)));
+	setCaption (widget_to_capture->fullCaption ());	// has to come after createGUI!
 }
 
 DetachedWindowContainer::~DetachedWindowContainer () {
@@ -59,17 +58,17 @@
 	delete this;
 }
 
-void DetachedWindowContainer::updateCaption (QWidget *widget) {
+void DetachedWindowContainer::updateCaption (RKMDIWindow *widget) {
 	RK_TRACE (APP);
-	RK_ASSERT (widget = centralWidget ());
+	RK_ASSERT (widget == centralWidget ());
 
-	setCaption (widget->caption ());
+	setCaption (widget->fullCaption ());
 }
 
 void DetachedWindowContainer::slotReattach () {
 	RK_TRACE (APP);
 
-	QWidget *window = centralWidget ();
+	RKMDIWindow *window = static_cast<RKMDIWindow *> (centralWidget ());
 	window->reparent (0, QPoint (0, 0));
 	RKWorkplace::mainWorkplace ()->attachWindow (window);
 

Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.h
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.h	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.h	2006-09-25 17:57:13 UTC (rev 762)
@@ -21,7 +21,7 @@
 #include <kparts/part.h>
 #include <kparts/mainwindow.h>
 
-class QWidget;
+class RKMDIWindow;
 
 /** This class can be used host a (part) window detached from the main window. @see RKwardApp::slotDetachWindow ().
 
@@ -33,7 +33,7 @@
 /** constructor.
 @param part_to_capture The part to use to create the GUI in the detached window
 @param widget_to_capture The view to reparent into the detached window */
-	DetachedWindowContainer (KParts::Part *part_to_capture, QWidget *widget_to_capture);
+	DetachedWindowContainer (RKMDIWindow *widget_to_capture);
 /** destructor. Usually you don't call this explicitely, but rather delete/close the child view. The DetachedWindowContainer will then self destruct */
 	~DetachedWindowContainer ();
 
@@ -42,7 +42,7 @@
 	void viewDestroyed (QObject *view);
 /** re-attach to the main window */
 	void slotReattach ();
-	void updateCaption (QWidget *);
+	void updateCaption (RKMDIWindow *);
 private:
 	KParts::Part *part;
 };

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2006-09-25 17:57:13 UTC (rev 762)
@@ -47,7 +47,6 @@
 
 #include "../rkeditormanager.h"
 #include "../misc/rkcommonfunctions.h"
-#include "../misc/rkworkplace.h"
 #include "../rkglobals.h"
 #include "../rkward.h"
 #include "../khelpdlg.h"
@@ -57,7 +56,7 @@
 
 #define GET_HELP_URL 1
 
-RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, bool use_r_highlighting) : QWidget (parent) {
+RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, bool use_r_highlighting) : RKMDIWindow (parent, RKWorkplace::CommandEditorWindow) {
 	RK_TRACE (COMMANDEDITOR);
 
 	KLibFactory *factory = KLibLoader::self()->factory( "libkatepart" );
@@ -178,7 +177,7 @@
 	if (isModified ()) name.append (i18n (" [modified]"));
 
 	setCaption (name);
-	RKWorkplace::mainWorkplace ()->updateWindowCaption (this);
+	emit (captionChanged (this));
 }
 
 void RKCommandEditorWindow::showHelp () {

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2006-09-25 17:57:13 UTC (rev 762)
@@ -24,6 +24,8 @@
 #include <kate/document.h>
 #include <kurl.h>
 
+#include "../misc/rkworkplace.h"
+
 /**
 	\brief Provides an editor window for R-commands, as well as a text-editor window in general.
 
@@ -31,7 +33,7 @@
 
 @author Pierre Ecochard
 */
-class RKCommandEditorWindow : public QWidget {
+class RKCommandEditorWindow : public RKMDIWindow {
 // we need the Q_OBJECT thing for some inherits ("RKCommandEditorWindow")-calls in rkward.cpp.
 	Q_OBJECT
 public:

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2006-09-25 17:57:13 UTC (rev 762)
@@ -34,10 +34,9 @@
 #include "../rkward.h"
 #include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkcommonfunctions.h"
-#include "../misc/rkworkplace.h"
 #include "../debug.h"
 
-RKHTMLWindow::RKHTMLWindow (QWidget *parent) : KMdiChildView (parent) {
+RKHTMLWindow::RKHTMLWindow (QWidget *parent) : RKMDIWindow (parent, RKWorkplace::HelpWindow) {
 	RK_TRACE (APP);
 	scroll_position=0;
 	
@@ -60,6 +59,16 @@
 	RK_TRACE (APP);
 }
 
+bool RKHTMLWindow::isModified () {
+	RK_TRACE (APP);
+	return false;
+}
+
+KParts::Part *RKHTMLWindow::getPart () {
+	RK_TRACE (APP);
+	return khtmlpart;
+}
+
 void RKHTMLWindow::addCommonActions (KActionCollection *action_collection) {
 	RK_TRACE (APP);
 
@@ -129,7 +138,7 @@
 
 void RKHTMLWindow::updateCaption (const KURL &url) {
 	RK_TRACE (APP);
-	setMDICaption (url.filename ());
+	setCaption (url.filename ());
 }
 
 void RKHTMLWindow::slotOpenURLRequest(const KURL &url, const KParts::URLArgs & ) {
@@ -155,6 +164,7 @@
 RKOutputWindow::RKOutputWindow (QWidget *parent) : RKHTMLWindow (parent), KXMLGUIClient () {
 	RK_TRACE (APP);
 
+	type = RKWorkplace::OutputWindow;
 	// strip down the khtmlpart's GUI. remove some stuff we definitely don't need.
 	RKCommonFunctions::removeContainers (khtmlpart, QStringList::split (',', "tools,security,extraToolBar,saveBackground,saveFrame,printFrame,kget_menu"), true);
 
@@ -165,8 +175,7 @@
 	khtmlpart->insertChildClient (this);
 
 	setIcon (SmallIcon ("text_block"));
-	setMDICaption (i18n ("Output"));
-	RKGlobals::rkApp ()->addWindow (this);
+	setCaption (i18n ("Output"));
 
 	outputFlush = new KAction (i18n ("&Flush"), 0, 0, this, SLOT (flushOutput ()), actionCollection (), "output_flush");
 	outputRefresh = new KAction (i18n ("&Refresh"), 0, 0, this, SLOT (refreshOutput ()), actionCollection (), "output_refresh");
@@ -174,8 +183,6 @@
 	print->setText (i18n ("Print Output"));
 	addCommonActions (actionCollection ());
 
-	emit (partCreated (this, khtmlpart));
-
 	KAction *action = khtmlpart->action ("saveDocument");
 	if (action) action->setText (i18n ("Save Output as HTML"));
 }
@@ -216,7 +223,7 @@
 
 	if (current_output) {
 		if (raise) {
-			current_output->activate ();
+			RKWorkplace::mainWorkplace ()->activateWindow (current_output);
 		}
 		current_output->refresh ();
 	} else {
@@ -233,7 +240,6 @@
 	
 	if (!current_output) {
 		current_output = new RKOutputWindow (RKWorkplace::mainWorkplace ()->view ());
-#warning need to register the window!
 
 		KURL url (RKSettingsModuleGeneral::filesPath () + "/rk_out.html");
 		current_output->openURL (url);
@@ -289,10 +295,7 @@
 	khtmlpart->insertChildClient (this);
 
 	setIcon (SmallIcon ("help"));
-	setMDICaption (i18n ("R Help"));
-	RKGlobals::rkApp ()->addWindow (this);
-
-	emit (partCreated (this, khtmlpart));
+	setCaption (i18n ("R Help"));
 }
 
 RKHelpWindow::~RKHelpWindow () {

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h	2006-09-25 15:15:42 UTC (rev 761)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h	2006-09-25 17:57:13 UTC (rev 762)
@@ -25,6 +25,8 @@
 
 #include <qptrlist.h>
 
+#include "../misc/rkworkplace.h"
+
 class KHTMLPart;
 class KActionCollection;
 
@@ -37,7 +39,7 @@
 
 @author Pierre Ecochard
 */
-class RKHTMLWindow : public KMdiChildView {
+class RKHTMLWindow : public RKMDIWindow {
 	Q_OBJECT
 protected:
 /** constructor. Protected. Use derived classes instead, or derive your own class.
@@ -53,8 +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);
-signals:
-	void partCreated (QWidget *widget, KParts::Part *part);
+	bool isModified ();
+	KParts::Part *getPart ();
 public slots:
 /** this is used for browsing only. Use openURL instead, when calling from outside. */
 	void slotOpenURLRequest (const KURL &url, const KParts::URLArgs &);


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