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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Apr 18 10:37:05 UTC 2011


Revision: 3512
          http://rkward.svn.sourceforge.net/rkward/?rev=3512&view=rev
Author:   tfry
Date:     2011-04-18 10:37:05 +0000 (Mon, 18 Apr 2011)

Log Message:
-----------
Support removing tool windows from all sidebars. Pending jobs view is now removed by default.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/misc/rkstandardicons.cpp
    trunk/rkward/rkward/misc/rkstandardicons.h
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/windows/CMakeLists.txt
    trunk/rkward/rkward/windows/rkmdiwindow.cpp
    trunk/rkward/rkward/windows/rktoolwindowbar.cpp
    trunk/rkward/rkward/windows/rktoolwindowbar.h
    trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp
    trunk/rkward/rkward/windows/rkworkplace.cpp
    trunk/rkward/rkward/windows/rkworkplace.h
    trunk/rkward/rkward/windows/robjectbrowser.cpp

Added Paths:
-----------
    trunk/rkward/rkward/windows/rktoolwindowlist.cpp
    trunk/rkward/rkward/windows/rktoolwindowlist.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/ChangeLog	2011-04-18 10:37:05 UTC (rev 3512)
@@ -1,3 +1,5 @@
+- "Pending jobs" tool window is not longer shown in the bottom sidebar by default
+- Support removing individual tool windows from the sidebars, completely
 - Add an action to interrupt all (current and pending) commands
 - Fixed: When saving the workplace while closing the session, the workplace layout would not always be saved correctly
 - File browser context menu gains many more KDE standard actions (KDE 4.3 and above, only)

Modified: trunk/rkward/rkward/misc/rkstandardicons.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkstandardicons.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/misc/rkstandardicons.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -52,6 +52,7 @@
 	icons[ActionPasteInsideTable] = QIcon (rkward_icon_base + "paste_inside_table.png");
 	icons[ActionPasteInsideSelection] = QIcon (rkward_icon_base + "paste_inside_selection.png");
 
+	icons[ActionDelete] = icons[ActionDeleteRow];
 	icons[ActionAddRight] = KIcon ("arrow-right");
 	icons[ActionRemoveLeft] = KIcon ("arrow-left");
 

Modified: trunk/rkward/rkward/misc/rkstandardicons.h
===================================================================
--- trunk/rkward/rkward/misc/rkstandardicons.h	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/misc/rkstandardicons.h	2011-04-18 10:37:05 UTC (rev 3512)
@@ -52,6 +52,7 @@
 		ActionPasteInsideTable,
 		ActionPasteInsideSelection,
 
+		ActionDelete,
 		ActionAddRight,
 		ActionRemoveLeft,
 

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/rkward.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -80,6 +80,7 @@
 #include "windows/rkhelpsearchwindow.h"
 #include "windows/rktoplevelwindowgui.h"
 #include "windows/rkfilebrowser.h"
+#include "windows/rktoolwindowlist.h"
 #include "rkconsole.h"
 #include "debug.h"
 #include "version.h"
@@ -198,12 +199,12 @@
 	setUpdatesEnabled (false);
 
 	readOptions();
-	//It's necessary to give a different name to all tool windows, or they won't be properly displayed
-	RObjectBrowser::object_browser = new RObjectBrowser (0, true, "workspace");
+	RObjectBrowser::object_browser = new RObjectBrowser (0, true);
+	RObjectBrowser::mainBrowser ()->setCaption (i18n ("Workspace"));
+	RKToolWindowList::registerToolWindow (RObjectBrowser::mainBrowser (), "workspace", RKToolWindowList::Left);
 
-	RKCommandLog *log = new RKCommandLog (0, true, "Command log");
-	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (log, KMultiTabBar::Bottom);
-	RKCommandLog::rkcommand_log = log;
+	RKCommandLog::rkcommand_log = new RKCommandLog (0, true);
+	RKToolWindowList::registerToolWindow (RKCommandLog::rkcommand_log, "commandlog", RKToolWindowList::Bottom);
 
 	// startup options will be deleted from the R thread (TODO correct this!), so we need to copy the initial_url here, or run into race conditions
 	KUrl open_url = startup_options->initial_url;
@@ -214,25 +215,24 @@
 	
 	initPlugins ();
 
-	RObjectBrowser::mainBrowser ()->setCaption (i18n ("Workspace"));
-	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (RObjectBrowser::mainBrowser (), KMultiTabBar::Left);
-
-	RKFileBrowser::main_browser = new RKFileBrowser (0, true, "file_browser");
+	RKFileBrowser::main_browser = new RKFileBrowser (0, true);
 	RKFileBrowser::main_browser->setCaption (i18n ("Files"));
-	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (RKFileBrowser::main_browser, KMultiTabBar::Left);
+	RKToolWindowList::registerToolWindow (RKFileBrowser::main_browser, "filebrowser", RKToolWindowList::Left);
 
-	RControlWindow::control_window = new RControlWindow (0, true, "rcontrol");
+	RControlWindow::control_window = new RControlWindow (0, true);
 	RControlWindow::getControl ()->setCaption (i18n ("Pending Jobs"));
-	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (RControlWindow::getControl (), KMultiTabBar::Bottom);
+	RKToolWindowList::registerToolWindow (RControlWindow::getControl (), "pendingjobs", RKToolWindowList::Nowhere);
 
-	RKConsole *console = new RKConsole (0, true, "r_console");
+	RKConsole *console = new RKConsole (0, true);
 	RKConsole::setMainConsole (console);
-	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (console, KMultiTabBar::Bottom);
+	RKToolWindowList::registerToolWindow (console, "console", RKToolWindowList::Bottom);
 
-	RKHelpSearchWindow *help_search = new RKHelpSearchWindow (0, true, "r_help");
+	RKHelpSearchWindow *help_search = new RKHelpSearchWindow (0, true);
 	RKHelpSearchWindow::main_help_search = help_search;
-	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (help_search, KMultiTabBar::Bottom);
+	RKToolWindowList::registerToolWindow (help_search, "helpsearch", RKToolWindowList::Bottom);
 
+	RKWorkplace::mainWorkplace ()->placeToolWindows ();
+
 	setUpdatesEnabled (true);
 	show ();
 

Modified: trunk/rkward/rkward/windows/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/windows/CMakeLists.txt	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/CMakeLists.txt	2011-04-18 10:37:05 UTC (rev 3512)
@@ -16,6 +16,7 @@
 	rktoplevelwindowgui.cpp
 	rkfilebrowser.cpp
 	rktoolwindowbar.cpp
+	rktoolwindowlist.cpp
 	robjectbrowser.cpp
 )
 

Modified: trunk/rkward/rkward/windows/rkmdiwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/rkmdiwindow.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -2,7 +2,7 @@
                           rkmdiwindow  -  description
                              -------------------
     begin                : Tue Sep 26 2006
-    copyright            : (C) 2006, 2007, 2008, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2006, 2007, 2008, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -32,6 +32,7 @@
 #include "rkworkplace.h"
 #include "rkworkplaceview.h"
 #include "rktoolwindowbar.h"
+#include "rktoolwindowlist.h"
 #include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkstandardicons.h"
 #include "../misc/rkxmlguisyncer.h"
@@ -72,6 +73,7 @@
 RKMDIWindow::~RKMDIWindow () {
 	RK_TRACE (APP);
 
+	if (isToolWindow ()) RKToolWindowList::unregisterToolWindow (this);
 	delete standard_client;
 }
 
@@ -116,8 +118,8 @@
 	QWidget *old_focus = qApp->focusWidget ();
 
 	if (isToolWindow ()) {
-		RK_ASSERT (tool_window_bar);
-		tool_window_bar->showWidget (this);
+		if (tool_window_bar) tool_window_bar->showWidget (this);
+		else RKWorkplace::mainWorkplace ()->detachWindow (this, true);
 	} else {
 		if (isAttached ()) RKWorkplace::mainWorkplace ()->view ()->setActivePage (this);
 		else {
@@ -148,8 +150,8 @@
 			RKWorkplace::mainWorkplace ()->attachWindow (this);
 		}
 
-		RK_ASSERT (tool_window_bar);
-		tool_window_bar->hideWidget (this);
+		if (tool_window_bar) tool_window_bar->hideWidget (this);
+		else hide ();
 		return true;
 	}
 
@@ -181,8 +183,7 @@
 	RK_TRACE (APP);
 
 	if (isToolWindow ()) {
-		RK_ASSERT (tool_window_bar);
-		tool_window_bar->hideWidget (this);
+		if (tool_window_bar) tool_window_bar->hideWidget (this);
 	}
 }
 

Modified: trunk/rkward/rkward/windows/rktoolwindowbar.cpp
===================================================================
--- trunk/rkward/rkward/windows/rktoolwindowbar.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/rktoolwindowbar.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -2,7 +2,7 @@
                           rktoolwindowbar  -  description
                              -------------------
     begin                : Fri Oct 12 2007
-    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -23,6 +23,7 @@
 #include <kmenu.h>
 #include <klocale.h>
 #include <kparts/partmanager.h>
+#include <kselectaction.h>
 
 #include <QSplitter>
 #include <QContextMenuEvent>
@@ -35,7 +36,6 @@
 
 #include "../debug.h"
 
-#define CHANGE_ATTACHMENT_ACTION_ID 10
 #define DEFAULT_SPLITTER_SIZE 200
 #define SPLITTER_MIN_SIZE 30
 
@@ -267,49 +267,79 @@
 			RKMDIWindow *widget = idToWidget (id_of_popup);
 			RK_ASSERT (widget);
 			if (widget) {
-				KMenu *p = new KMenu (this);
+				KMenu menu (this);
 
-				p->addTitle (i18n("Attachment"));
-				
-				p->addAction (RKStandardIcons::getIcon (widget->isAttached () ? RKStandardIcons::ActionDetachWindow : RKStandardIcons::ActionAttachWindow), widget->isAttached () ? i18n("Detach") : i18n("Attach"))->setData (CHANGE_ATTACHMENT_ACTION_ID);
+				QAction *a = menu.addAction (RKStandardIcons::getIcon (widget->isAttached () ? RKStandardIcons::ActionDetachWindow : RKStandardIcons::ActionAttachWindow), widget->isAttached () ? i18n("Detach") : i18n("Attach"));
+				connect (a, SIGNAL (triggered(bool)), this, SLOT (changeAttachment()));
 
-				p->addTitle (i18n("Move To"));
+				KSelectAction *sel = new KSelectAction (i18n ("Position"), &menu);
+				if (position () != KMultiTabBar::Left) sel->addAction (KIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveLeft)), i18n ("Left Sidebar"));
+				if (position () != KMultiTabBar::Right) sel->addAction (KIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveRight)), i18n ("Right Sidebar"));
+				if (position () != KMultiTabBar::Top) sel->addAction (KIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveUp)), i18n ("Top Sidebar"));
+				if (position () != KMultiTabBar::Bottom) sel->addAction (KIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveDown)), i18n ("Bottom Sidebar"));
+				sel->addAction (KIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionDelete)), i18n ("Not shown in sidebar"));
+				connect (sel, SIGNAL (triggered(int)), this, SLOT (moveToolWindow(int)));
+				menu.addAction (sel);
 	
-				if (position () != KMultiTabBar::Left) p->addAction(RKStandardIcons::getIcon (RKStandardIcons::ActionMoveLeft), i18n("Left Sidebar"))->setData(KMultiTabBar::Left);
-				if (position () != KMultiTabBar::Right) p->addAction(RKStandardIcons::getIcon (RKStandardIcons::ActionMoveRight), i18n("Right Sidebar"))->setData(KMultiTabBar::Right);
-				if (position () != KMultiTabBar::Top) p->addAction(RKStandardIcons::getIcon (RKStandardIcons::ActionMoveUp), i18n("Top Sidebar"))->setData(KMultiTabBar::Top);
-				if (position () != KMultiTabBar::Bottom) p->addAction(RKStandardIcons::getIcon (RKStandardIcons::ActionMoveDown), i18n("Bottom Sidebar"))->setData(KMultiTabBar::Bottom);
-	
-				connect (p, SIGNAL (triggered(QAction *)), this, SLOT (buttonPopupActivate(QAction *)));
-				p->exec (e->globalPos());
-				delete p;
-	
+				menu.exec (e->globalPos());
+
 				return true;
 			}
 		}
 	}
-	
+
 	return false;
 }
 
-void RKToolWindowBar::buttonPopupActivate (QAction *a) {
+void RKToolWindowBar::contextMenuEvent (QContextMenuEvent* event) {
 	RK_TRACE (APP);
 
-	int action = a->data().toInt();
+	KMenu menu (this);
+	foreach (RKToolWindowList::ToolWindowRepresentation rep, RKToolWindowList::registeredToolWindows ()) {
+		QAction *a = menu.addAction (rep.window->windowIcon (), rep.window->shortCaption ());
+		a->setCheckable (true);
+		a->setChecked (rep.window->tool_window_bar == this);
+		a->setData (rep.id);
+	}
+	connect (&menu, SIGNAL (triggered(QAction*)), this, SLOT (addRemoveToolWindow(QAction*)));
+	menu.exec (event->globalPos ());
+
+	event->accept ();
+}
+
+void RKToolWindowBar::changeAttachment () {
+	RK_TRACE (APP);
+
 	RKMDIWindow *window = idToWidget (id_of_popup);
 	RK_ASSERT (window);
 
-	// move to another bar
-	if (action < 4) {
-		// move + show ;)
-		RKWorkplace::mainWorkplace ()->placeInToolWindowBar (window, (KMultiTabBar::KMultiTabBarPosition) action);
-		window->activate ();
-	}
+	// toggle attachment
+	if (window->isAttached ()) RKWorkplace::mainWorkplace ()->detachWindow (window);
+	else RKWorkplace::mainWorkplace ()->attachWindow (window);
+}
 
-	// toggle attachment
-	if (action == CHANGE_ATTACHMENT_ACTION_ID) {
-		if (window->isAttached ()) RKWorkplace::mainWorkplace ()->detachWindow (window);
-		else RKWorkplace::mainWorkplace ()->attachWindow (window);
+void RKToolWindowBar::moveToolWindow(int target) {
+	RK_TRACE (APP);
+
+	RK_ASSERT (target >= RKToolWindowList::Left);
+	RK_ASSERT (target <= RKToolWindowList::Bottom);
+	RKMDIWindow *window = idToWidget (id_of_popup);
+	RK_ASSERT (window);
+
+	RKWorkplace::mainWorkplace ()->placeInToolWindowBar (window, (RKToolWindowList::Placement) target);
+}
+
+
+void RKToolWindowBar::addRemoveToolWindow (QAction *action) {
+	RK_TRACE (APP);
+	RK_ASSERT (action);
+
+	RKMDIWindow *win = RKToolWindowList::findToolWindowById (action->data ().toString ());
+	if (action->isChecked ()) {
+		addWidget (win);
+	} else {
+		RK_ASSERT (win->tool_window_bar == this);
+		removeWidget (win);
 	}
 }
 

Modified: trunk/rkward/rkward/windows/rktoolwindowbar.h
===================================================================
--- trunk/rkward/rkward/windows/rktoolwindowbar.h	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/rktoolwindowbar.h	2011-04-18 10:37:05 UTC (rev 3512)
@@ -2,7 +2,7 @@
                           rktoolwindowbar  -  description
                              -------------------
     begin                : Fri Oct 12 2007
-    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -52,10 +52,15 @@
 	void saveSize (KConfigGroup &cg) const;
 private slots:
 	void tabClicked (int id);
-	void buttonPopupActivate (QAction *a);
+	void changeAttachment ();
+	void moveToolWindow (int target);
+	void addRemoveToolWindow (QAction* action);
 	void splitterMoved (int, int);
 protected:
+	/** handle RMB clicks on individual buttons */
 	bool eventFilter (QObject *obj, QEvent *ev);
+	/** handle RMB clicks on the bar itself */
+	void contextMenuEvent (QContextMenuEvent *event);
 private:
 friend class RKWorkplace;
 	void reclaimDetached (RKMDIWindow *window);

Added: trunk/rkward/rkward/windows/rktoolwindowlist.cpp
===================================================================
--- trunk/rkward/rkward/windows/rktoolwindowlist.cpp	                        (rev 0)
+++ trunk/rkward/rkward/windows/rktoolwindowlist.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -0,0 +1,62 @@
+/***************************************************************************
+                          rktoolwindowlist  -  description
+                             -------------------
+    begin                : Thu Apr 07 2011
+    copyright            : (C) 2011 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 "rktoolwindowlist.h"
+
+#include "../debug.h"
+
+namespace RKToolWindowListPrivate {
+	QList<RKToolWindowList::ToolWindowRepresentation> registered_tool_windows;
+};
+
+QList<RKToolWindowList::ToolWindowRepresentation>& RKToolWindowList::registeredToolWindows () {
+	return RKToolWindowListPrivate::registered_tool_windows;
+}
+
+void RKToolWindowList::registerToolWindow (RKMDIWindow *window, const QString &id, Placement default_placement) {
+	RK_TRACE (APP);
+
+	ToolWindowRepresentation tr;
+	tr.window = window;
+	tr.id = id;
+	tr.default_placement = default_placement;
+
+	RKToolWindowListPrivate::registered_tool_windows.append (tr);
+}
+
+RKMDIWindow* RKToolWindowList::findToolWindowById (const QString &id) {
+	RK_TRACE (APP);
+
+	for (int i = 0; i < RKToolWindowListPrivate::registered_tool_windows.size (); ++i) {
+		if (RKToolWindowListPrivate::registered_tool_windows[i].id == id) return RKToolWindowListPrivate::registered_tool_windows[i].window;
+	}
+
+	return 0;
+}
+
+void RKToolWindowList::unregisterToolWindow (RKMDIWindow *window) {
+	RK_TRACE (APP);
+
+	for (int i = 0; i < RKToolWindowListPrivate::registered_tool_windows.size (); ++i) {
+		if (RKToolWindowListPrivate::registered_tool_windows[i].window == window) {
+			RKToolWindowListPrivate::registered_tool_windows.removeAt (i);
+			return;
+		}
+	}
+
+	RK_ASSERT (false);
+}

Added: trunk/rkward/rkward/windows/rktoolwindowlist.h
===================================================================
--- trunk/rkward/rkward/windows/rktoolwindowlist.h	                        (rev 0)
+++ trunk/rkward/rkward/windows/rktoolwindowlist.h	2011-04-18 10:37:05 UTC (rev 3512)
@@ -0,0 +1,48 @@
+/***************************************************************************
+                          rktoolwindowlist  -  description
+                             -------------------
+    begin                : Thu Apr 07 2011
+    copyright            : (C) 2011 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 RKTOOLWINDOWLIST_H
+#define RKTOOLWINDOWLIST_H
+
+#include <QList>
+#include <QString>
+
+class RKMDIWindow;
+
+/** Simple helper functions to keep track of available tool windows. */
+namespace RKToolWindowList {
+	enum Placement {
+		Left=0,
+		Right=1,
+		Top=2,
+		Bottom=3,
+		Nowhere=4
+	};
+
+	struct ToolWindowRepresentation {
+		RKMDIWindow *window;
+		QString id;
+		Placement default_placement;
+	};
+
+	void registerToolWindow (RKMDIWindow *window, const QString &id, Placement default_placement);
+	void unregisterToolWindow (RKMDIWindow *window);
+	RKMDIWindow* findToolWindowById (const QString &id);
+	QList<ToolWindowRepresentation>& registeredToolWindows ();
+};
+
+#endif

Modified: trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp
===================================================================
--- trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -70,6 +70,7 @@
 
 	// window menu
 	KAction *action;
+	// NOTE: Why don't we just iterate over RKToolWindowList::registeredToolWindows ()? Because that is not yet filled at the time that the RKToplevelWindowGUI for the main window is constructed! What a pity...
 	action = actionCollection ()->addAction ("window_show_workspace", this, SLOT(toggleWorkspace()));
 	action->setText (i18n ("Show/Hide Workspace Browser"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowWorkspaceBrowser));

Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -35,6 +35,7 @@
 #include "rkhtmlwindow.h"
 #include "rkworkplaceview.h"
 #include "rktoolwindowbar.h"
+#include "rktoolwindowlist.h"
 #include "../core/robject.h"
 #include "../core/rcontainerobject.h"
 #include "../core/robjectlist.h"
@@ -63,35 +64,32 @@
 	/* Splitter setup contains heavy copying from Kate's katemdi! */
 	KVBox *vbox = new KVBox (this);
 
-	tool_window_bars[KMultiTabBar::Top] = new RKToolWindowBar (KMultiTabBar::Top, vbox);
+	tool_window_bars[RKToolWindowList::Top] = new RKToolWindowBar (KMultiTabBar::Top, vbox);
 	vert_splitter = new QSplitter (Qt::Vertical, vbox);
 	vert_splitter->setOpaqueResize (KGlobalSettings::opaqueResize ());
-	tool_window_bars[KMultiTabBar::Top]->setSplitter (vert_splitter);
+	tool_window_bars[RKToolWindowList::Top]->setSplitter (vert_splitter);
 
 	KHBox *hbox = new KHBox (vert_splitter);
 	vert_splitter->setCollapsible (vert_splitter->indexOf (hbox), false);
 	vert_splitter->setStretchFactor (vert_splitter->indexOf (hbox), 1);
 
-	tool_window_bars[KMultiTabBar::Left] = new RKToolWindowBar (KMultiTabBar::Left, hbox);
+	tool_window_bars[RKToolWindowList::Left] = new RKToolWindowBar (KMultiTabBar::Left, hbox);
 	horiz_splitter = new QSplitter (Qt::Horizontal, hbox);
 	horiz_splitter->setOpaqueResize (KGlobalSettings::opaqueResize ());
-	tool_window_bars[KMultiTabBar::Left]->setSplitter (horiz_splitter);
+	tool_window_bars[RKToolWindowList::Left]->setSplitter (horiz_splitter);
 
 	wview = new RKWorkplaceView (horiz_splitter);
 	horiz_splitter->setCollapsible (horiz_splitter->indexOf (wview), false);
 	horiz_splitter->setStretchFactor(horiz_splitter->indexOf (wview), 1);
 
-	tool_window_bars[KMultiTabBar::Bottom] = new RKToolWindowBar (KMultiTabBar::Bottom, vbox);
-	tool_window_bars[KMultiTabBar::Bottom]->setSplitter (vert_splitter);
+	tool_window_bars[RKToolWindowList::Bottom] = new RKToolWindowBar (KMultiTabBar::Bottom, vbox);
+	tool_window_bars[RKToolWindowList::Bottom]->setSplitter (vert_splitter);
 
-	tool_window_bars[KMultiTabBar::Right] = new RKToolWindowBar (KMultiTabBar::Right, hbox);
-	tool_window_bars[KMultiTabBar::Right]->setSplitter (horiz_splitter);
+	tool_window_bars[RKToolWindowList::Right] = new RKToolWindowBar (KMultiTabBar::Right, hbox);
+	tool_window_bars[RKToolWindowList::Right]->setSplitter (horiz_splitter);
 
 	KConfigGroup toolbar_config = KGlobal::config ()->group ("ToolwindowBars");
-	tool_window_bars[KMultiTabBar::Top]->restoreSize (toolbar_config);
-	tool_window_bars[KMultiTabBar::Left]->restoreSize (toolbar_config);
-	tool_window_bars[KMultiTabBar::Bottom]->restoreSize (toolbar_config);
-	tool_window_bars[KMultiTabBar::Right]->restoreSize (toolbar_config);
+	for (int i = 0; i < TOOL_WINDOW_BAR_COUNT; ++i) tool_window_bars[i]->restoreSize (toolbar_config);
 
 	// now add it all to this widget
 	QVBoxLayout *box = new QVBoxLayout (this);
@@ -113,10 +111,7 @@
 	RK_TRACE (APP);
 
 	KConfigGroup toolbar_config = KGlobal::config ()->group ("ToolwindowBars");
-	tool_window_bars[KMultiTabBar::Top]->saveSize (toolbar_config);
-	tool_window_bars[KMultiTabBar::Left]->saveSize (toolbar_config);
-	tool_window_bars[KMultiTabBar::Bottom]->saveSize (toolbar_config);
-	tool_window_bars[KMultiTabBar::Right]->saveSize (toolbar_config);
+	for (int i = 0; i < TOOL_WINDOW_BAR_COUNT; ++i) tool_window_bars[i]->saveSize (toolbar_config);
 }
 
 void RKWorkplace::initActions (KActionCollection *ac, const char *prev_id, const char *next_id, const char *left_id, const char *right_id) {
@@ -141,7 +136,8 @@
 	// all the rest is done, even if the window was previously "Attached", as this may also mean it was freshly created
 	window->state = RKMDIWindow::Attached;
 	if (window->isToolWindow ()) {
-		window->tool_window_bar->reclaimDetached (window);
+		if (!window->tool_window_bar) placeInToolWindowBar (window, RKToolWindowList::Bottom);
+		else window->tool_window_bar->reclaimDetached (window);
 	} else {
 		view ()->addWindow (window);
 		view ()->topLevelWidget ()->raise ();
@@ -174,18 +170,32 @@
 	RK_TRACE (APP);
 
 	windows.append (window);
-	connect (window, SIGNAL (destroyed (QObject *)), this, SLOT (windowDestroyed (QObject *)));
+	connect (window, SIGNAL (destroyed (QObject *)), this, SLOT (removeWindow (QObject *)));
 	connect (window, SIGNAL (windowActivated(RKMDIWindow*)), history, SLOT (windowActivated(RKMDIWindow*)));
 	if (attached) attachWindow (window);
 	else detachWindow (window, false);
 }
 
-void RKWorkplace::placeInToolWindowBar (RKMDIWindow *window, KMultiTabBar::KMultiTabBarPosition position) {
+void RKWorkplace::placeToolWindows() {
 	RK_TRACE (APP);
 
+	foreach (const RKToolWindowList::ToolWindowRepresentation rep, RKToolWindowList::registeredToolWindows ()) {
+		placeInToolWindowBar (rep.window, rep.default_placement);
+	}
+}
+
+void RKWorkplace::placeInToolWindowBar (RKMDIWindow *window, RKToolWindowList::Placement position) {
+	RK_TRACE (APP);
+
 	RK_ASSERT (window->isToolWindow ());
-	tool_window_bars[position]->addWidget (window);
-	if (!windows.contains (window)) {	// must be new
+	if (position == RKToolWindowList::Nowhere) {
+		if (window->tool_window_bar) window->tool_window_bar->removeWidget (window);
+		return;
+	} else {
+		tool_window_bars[position]->addWidget (window);
+	}
+
+	if (!windows.contains (window)) {	// first time, we see this window?
 		addWindow (window, true);
 		RKWardMainWindow::getMain ()->partManager ()->addPart (window->getPart ());
 	}
@@ -378,9 +388,9 @@
 	RK_ASSERT (windows.contains (window));
 
 	bool tool_window = window->isToolWindow ();
-	window->close (true);		// all the rest should happen in windowDestroyed ()
+	window->close (true);		// all the rest should happen in removeWindow ()
 	
-	if (tool_window) windowRemoved ();	// for regular windows, this happens in windowDestroyed(), already
+	if (tool_window) windowRemoved ();	// for regular windows, this happens in removeWindow(), already
 }
 
 void RKWorkplace::closeActiveWindow () {
@@ -411,12 +421,12 @@
 	}
 }
 
-void RKWorkplace::windowDestroyed (QObject *object) {
+void RKWorkplace::removeWindow (QObject *object) {
 	RK_TRACE (APP);
 	RKMDIWindow *window = static_cast<RKMDIWindow *> (object);
 
 	// remove from history first (otherwise, we might find it there, when trying to activate a new window)
-	history->windowDestroyed (window);
+	history->removeWindow (window);
 
 	// WARNING: the window is dead. Don't call any functions on it.
 
@@ -723,7 +733,7 @@
 	}
 }
 
-void RKMDIWindowHistory::windowDestroyed (QObject *window) {
+void RKMDIWindowHistory::removeWindow (QObject *window) {
 	RK_TRACE (APP);
 
 	back_list.removeAll (static_cast<RKMDIWindow *> (window));

Modified: trunk/rkward/rkward/windows/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/rkworkplace.h	2011-04-18 10:37:05 UTC (rev 3512)
@@ -24,9 +24,9 @@
 #include <QSplitter>
 
 #include <kurl.h>
-#include <kmultitabbar.h>
 
 #include "rkmdiwindow.h"
+#include "rktoolwindowlist.h"
 
 class RObject;
 class RCommandChain;
@@ -36,6 +36,8 @@
 class KAction;
 class RKToolWindowBar;
 
+#define TOOL_WINDOW_BAR_COUNT 4
+
 /** Simple class to store the history of recently used RKMDIWindow */
 class RKMDIWindowHistory : public QObject {
 	Q_OBJECT
@@ -46,7 +48,7 @@
 	void initActions (KActionCollection *ac, const char *prev_id, const char *next_id);
 	bool haveNext ();
 	bool havePrev ();
-	void windowDestroyed (QObject *window);
+	void removeWindow (QObject *window);
 public slots:
 	void next ();
 	void prev ();
@@ -151,13 +153,13 @@
 /** 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; };
-	void placeInToolWindowBar (RKMDIWindow *window, KMultiTabBar::KMultiTabBarPosition position);
+	void placeToolWindows ();
 signals:
 /** TODO: For future expansion. This signal is neither emitted nor used so far. It could be used to deactivate some options in the "Window" menu. Or maybe it can be removed? */
 	void lastWindowClosed ();
 public slots:
 /** When windows are attached to the workplace, their QObject::destroyed () signal is connected to this slot. Thereby deleted objects are removed from the workplace automatically */
-	void windowDestroyed (QObject *window);
+	void removeWindow (QObject *window);
 	void saveSettings ();
 private:
 /** current list of windows. @See getObjectList () */ 
@@ -176,7 +178,9 @@
 	QSplitter *horiz_splitter;
 	QSplitter *vert_splitter;
 
-	RKToolWindowBar* tool_window_bars[4];
+	RKToolWindowBar* tool_window_bars[TOOL_WINDOW_BAR_COUNT];
+friend class RKToolWindowBar;
+	void placeInToolWindowBar (RKMDIWindow *window, RKToolWindowList::Placement position);
 };
 
 #endif

Modified: trunk/rkward/rkward/windows/robjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/windows/robjectbrowser.cpp	2011-04-09 09:07:20 UTC (rev 3511)
+++ trunk/rkward/rkward/windows/robjectbrowser.cpp	2011-04-18 10:37:05 UTC (rev 3512)
@@ -2,7 +2,7 @@
                           robjectbrowser  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007, 2008, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2008, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -65,7 +65,7 @@
 	setMetaInfo (i18n ("R workspace browser"), "rkward://page/rkward_workspace_browser", RKSettings::PageObjectBrowser);
 	initializeActivationSignals ();
 
-	setCaption (i18n ("Objects in the R workspace"));
+	setCaption (i18n ("R Workspace"));
 }
 
 RObjectBrowser::~RObjectBrowser () {


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