[rkward-cvs] SF.net SVN: rkward: [2093] branches/KDE4_port/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Oct 18 16:33:59 UTC 2007


Revision: 2093
          http://rkward.svn.sourceforge.net/rkward/?rev=2093&view=rev
Author:   tfry
Date:     2007-10-18 09:33:59 -0700 (Thu, 18 Oct 2007)

Log Message:
-----------
Clean up settings change notification logic

Modified Paths:
--------------
    branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp
    branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
    branches/KDE4_port/rkward/misc/rkobjectlistview.h
    branches/KDE4_port/rkward/rkconsole.cpp
    branches/KDE4_port/rkward/settings/rksettings.cpp
    branches/KDE4_port/rkward/settings/rksettings.h
    branches/KDE4_port/rkward/settings/rksettingsmoduleobjectbrowser.cpp
    branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp
    branches/KDE4_port/rkward/windows/rcontrolwindow.cpp
    branches/KDE4_port/rkward/windows/rkcommandlog.cpp
    branches/KDE4_port/rkward/windows/rkcommandlog.h

Modified: branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp
===================================================================
--- branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/dialogs/rkloadlibsdialog.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -146,7 +146,7 @@
 		emit (applyClicked ());
 		break;
 	case KDialog::User1:
-		RKSettings::configureSettings (RKSettings::RPackages, this, chain);
+		RKSettings::configureSettings (RKSettings::PageRPackages, this, chain);
 		break;
 	}
 }

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -30,7 +30,6 @@
 #include "../core/rfunctionobject.h"
 #include "../core/rkvariable.h"
 #include "../core/rkmodificationtracker.h"
-#include "../settings/rksettings.h"
 #include "../settings/rksettingsmoduleobjectbrowser.h"
 #include "../misc/rkcommonfunctions.h"
 #include "../debug.h"
@@ -125,7 +124,7 @@
 
 //virtual 
 void RKObjectListView::popupConfigure () {
-	RKSettings::configureSettings (RKSettings::ObjectBrowser, this);
+	RKSettings::configureSettings (RKSettings::PageObjectBrowser, this);
 }
 
 void RKObjectListView::requestedContextMenu (Q3ListViewItem *item, const QPoint &pos, int) {
@@ -381,10 +380,10 @@
 	settings = new State[SettingsCount];
 	settings_default = new bool[SettingsCount];
 	for (int i = 0; i < SettingsCount; ++i) settings_default[i] = true;
-	connect (RKSettings::tracker (), SIGNAL (objectBrowserSettingsChanged ()), this, SLOT (globalSettingsChanged ()));
+	connect (RKSettings::tracker (), SIGNAL (settingsChanged (RKSettings::SettingsPage)), this, SLOT (globalSettingsChanged (RKSettings::SettingsPage)));
 
 	createContextMenus ();
-	globalSettingsChanged ();
+	globalSettingsChanged (RKSettings::PageObjectBrowser);
 }
 
 RKObjectListViewSettings::~RKObjectListViewSettings () {
@@ -477,7 +476,9 @@
 	menu->connectItem (setting, this, SLOT (toggleSetting (int)));
 }
 
-void RKObjectListViewSettings::globalSettingsChanged () {
+void RKObjectListViewSettings::globalSettingsChanged (RKSettings::SettingsPage page) {
+	if (page != RKSettings::PageObjectBrowser) return;
+
 	RK_TRACE (APP);
 
 	for (int i = 0; i < SettingsCount; ++i) {

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-10-18 16:33:59 UTC (rev 2093)
@@ -24,6 +24,8 @@
 #include <QPixmap>
 #include <Q3PopupMenu>
 
+#include "../settings/rksettings.h"
+
 class RObject;
 class QPixmap;
 class Q3PopupMenu;
@@ -158,7 +160,7 @@
 signals:
 	void settingsChanged ();
 public slots:
-	void globalSettingsChanged ();
+	void globalSettingsChanged (RKSettings::SettingsPage);
 	void toggleSetting (int which);
 private:
 	State *settings;

Modified: branches/KDE4_port/rkward/rkconsole.cpp
===================================================================
--- branches/KDE4_port/rkward/rkconsole.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/rkconsole.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -752,7 +752,7 @@
 
 void RKConsole::configure () {
 	RK_TRACE (APP);
-	RKSettings::configureSettings (RKSettings::Console, this);
+	RKSettings::configureSettings (RKSettings::PageConsole, this);
 }
 
 void RKConsole::slotInterruptCommand () {

Modified: branches/KDE4_port/rkward/settings/rksettings.cpp
===================================================================
--- branches/KDE4_port/rkward/settings/rksettings.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/settings/rksettings.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -95,23 +95,21 @@
 void RKSettings::initModules () {
 	RK_TRACE (SETTINGS);
 
-	modules.append (new RKSettingsModulePlugins (this, this));
-	modules.append (new RKSettingsModuleR (this, this));
-	modules.append (new RKSettingsModuleRPackages (this, this));
-	modules.append (new RKSettingsModulePHP (this, this));
-	modules.append (new RKSettingsModuleGeneral (this, this));
-	modules.append (new RKSettingsModuleOutput (this, this));
-	modules.append (new RKSettingsModuleWatch (this, this));
-	modules.append (new RKSettingsModuleConsole (this, this));
-	modules.append (new RKSettingsModuleObjectBrowser (this, this));
-	
+	modules.insert (PagePlugins, new RKSettingsModulePlugins (this, this));
+	modules.insert (PageR, new RKSettingsModuleR (this, this));
+	modules.insert (PageRPackages, new RKSettingsModuleRPackages (this, this));
+	modules.insert (PagePHP, new RKSettingsModulePHP (this, this));
+	modules.insert (PageGeneral, new RKSettingsModuleGeneral (this, this));
+	modules.insert (PageOutput, new RKSettingsModuleOutput (this, this));
+	modules.insert (PageWatch, new RKSettingsModuleWatch (this, this));
+	modules.insert (PageConsole, new RKSettingsModuleConsole (this, this));
+	modules.insert (PageObjectBrowser, new RKSettingsModuleObjectBrowser (this, this));
+
 	ModuleList::const_iterator it;
-	int i=0;
 	for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
-		pages[i++] = addPage (*it, (*it)->caption ());
-		(*it)->show ();
+		pages[it.key ()] = addPage (it.value (), it.value ()->caption ());
+		it.value ()->show ();
 	}
-	RK_ASSERT (i == (NumPages - 1));
 }
 
 void RKSettings::raisePage (SettingsPage page) {
@@ -128,15 +126,10 @@
 	// which module is it?
 	RKSettingsModule *new_module = 0;
 	for (ModuleList::const_iterator it = modules.constBegin (); it != modules.constEnd (); ++it) {
-		QWidget *pwidget = *it;
-		while (pwidget) {
-			if (pwidget == page) {
-				new_module = *it;
-				break;
-			}
-			pwidget = pwidget->parentWidget ();
+		if (it.value () == page) {
+			new_module = it.value ();
+			break;
 		}
-		if (new_module) break;
 	}
 
 	bool has_help;
@@ -165,7 +158,7 @@
 		for (i = 0; i < NumPages; ++i) {
 			if (currentPage () == pages[i]) break;
 		}
-		RKSettingsModule *current_module = modules[i];
+		RKSettingsModule *current_module = modules[static_cast<SettingsPage> (i)];
 		RK_ASSERT (current_module);
 	
 		RKWorkplace::mainWorkplace ()->openHelpWindow (current_module->helpURL ());
@@ -179,9 +172,10 @@
 
 	ModuleList::const_iterator it;
 	for (it = modules.constBegin (); it != modules.constEnd (); ++it) {
-		if ((*it)->hasChanges ()) {
-			(*it)->applyChanges ();
-			(*it)->save (KGlobal::config ().data ());
+		if (it.value ()->hasChanges ()) {
+			it.value ()->applyChanges ();
+			it.value ()->save (KGlobal::config ().data ());
+			tracker ()->signalSettingsChange (it.key ());
 		}
 	}
 	enableButtonApply (false);
@@ -231,9 +225,9 @@
 	RK_TRACE (SETTINGS);
 }
 
-void RKSettingsTracker::settingsChangedObjectBrowser () {
+void RKSettingsTracker::signalSettingsChange (RKSettings::SettingsPage page) {
 	RK_TRACE (SETTINGS);
-	emit (objectBrowserSettingsChanged ());
+	emit (settingsChanged (page));
 }
 
 #include "rksettings.moc"

Modified: branches/KDE4_port/rkward/settings/rksettings.h
===================================================================
--- branches/KDE4_port/rkward/settings/rksettings.h	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/settings/rksettings.h	2007-10-18 16:33:59 UTC (rev 2093)
@@ -19,7 +19,7 @@
 
 #include <kpagedialog.h>
 
-#include <q3valuelist.h>
+#include <qmap.h>
 
 class RKSettingsModule;
 class KConfig;
@@ -37,16 +37,16 @@
 public:
 	enum SettingsPage {
 		NoPage=0,
-		Plugins=1,
-		R=2,
-		RPackages=3,
-		PHP=4,
-		General=5,
-		Output=6,
-		Watch=7,
-		Console=8,
-		ObjectBrowser=9,
-		NumPages = ObjectBrowser + 1
+		PagePlugins=1,
+		PageR=2,
+		PageRPackages=3,
+		PagePHP=4,
+		PageGeneral=5,
+		PageOutput=6,
+		PageWatch=7,
+		PageConsole=8,
+		PageObjectBrowser=9,
+		NumPages = PageObjectBrowser + 1
 	};
 
 	static void configureSettings (SettingsPage page=NoPage, QWidget *parent=0, RCommandChain *chain=0);
@@ -70,7 +70,7 @@
 	void raisePage (SettingsPage page);
 	static void dialogClosed ();
 
-	typedef Q3ValueList<RKSettingsModule *> ModuleList;
+	typedef QMap<SettingsPage, RKSettingsModule *> ModuleList;
 	ModuleList modules;
 	KPageWidgetItem *pages[NumPages];
 
@@ -87,11 +87,9 @@
 	RKSettingsTracker (QObject *parent);
 	~RKSettingsTracker ();
 
-	void settingsChangedObjectBrowser ();
-	void settingsChangedMaxCommandLogLines () { maxCommandLogLinesChanged (); };
+	void signalSettingsChange (RKSettings::SettingsPage page);
 signals:
-	void objectBrowserSettingsChanged ();
-	void maxCommandLogLinesChanged ();
+	void settingsChanged (RKSettings::SettingsPage);
 };
 
 #endif

Modified: branches/KDE4_port/rkward/settings/rksettingsmoduleobjectbrowser.cpp
===================================================================
--- branches/KDE4_port/rkward/settings/rksettingsmoduleobjectbrowser.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/settings/rksettingsmoduleobjectbrowser.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -117,8 +117,6 @@
 		settings[i] = checkboxes[i]->isChecked ();
 	}
 	getstructure_blacklist = blacklist_choser->getValues();
-
-	RKSettings::tracker ()->settingsChangedObjectBrowser ();
 }
 
 void RKSettingsModuleObjectBrowser::save (KConfig *config) {

Modified: branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp
===================================================================
--- branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -267,9 +267,7 @@
 	app_filter = getFilterSettings (app_filter_boxes);
 	sync_filter = getFilterSettings (sync_filter_boxes);
 
-	unsigned int max_log_lines_new = max_log_lines_spinner->value ();
-	if (max_log_lines_new != max_log_lines) RKSettings::tracker ()->settingsChangedMaxCommandLogLines ();
-	max_log_lines = max_log_lines_new;
+	max_log_lines = max_log_lines_spinner->value ();
 }
 
 void RKSettingsModuleWatch::save (KConfig *config) {

Modified: branches/KDE4_port/rkward/windows/rcontrolwindow.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rcontrolwindow.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/windows/rcontrolwindow.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -326,7 +326,7 @@
 void RControlWindow::configureButtonClicked () {
 	RK_TRACE (APP);
 
-	RKSettings::configureSettings (RKSettings::R, this);
+	RKSettings::configureSettings (RKSettings::PageR, this);
 }
 
 //############# END RContolWindow #######################

Modified: branches/KDE4_port/rkward/windows/rkcommandlog.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandlog.cpp	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/windows/rkcommandlog.cpp	2007-10-18 16:33:59 UTC (rev 2093)
@@ -21,7 +21,6 @@
 #include "../rkglobals.h"
 #include "../rkconsole.h"
 #include "../settings/rksettingsmodulewatch.h"
-#include "../settings/rksettings.h"
 #include "../misc/rkcommonfunctions.h"
 #include "rkcommandeditorwindow.h"
 
@@ -63,8 +62,8 @@
 	initializeActivationSignals ();
 	setFocusPolicy (Qt::ClickFocus);
 
-	connect (RKSettings::tracker (), SIGNAL (maxCommandLogLinesChanged()), this, SLOT (maxCommandLogLinesChanged()));
-	maxCommandLogLinesChanged ();
+	connect (RKSettings::tracker (), SIGNAL (settingsChanged(RKSettings::SettingsPage)), this, SLOT (settingsChanged(RKSettings::SettingsPage)));
+	settingsChanged (RKSettings::PageWatch);
 }
 
 RKCommandLog::~RKCommandLog(){
@@ -192,7 +191,9 @@
 	if (RKSettingsModuleWatch::shouldShowOutput (command)) log_view->insert ("\n");
 }
 
-void RKCommandLog::maxCommandLogLinesChanged () {
+void RKCommandLog::settingsChanged (RKSettings::SettingsPage page) {
+	if (page != RKSettings::PageWatch) return;
+
 	RK_TRACE (APP);
 
 	log_view->document ()->setMaximumBlockCount (RKSettingsModuleWatch::maxLogLines ());
@@ -208,7 +209,7 @@
 
 void RKCommandLog::configureLog () {
 	RK_TRACE (APP);
-	RKSettings::configureSettings (RKSettings::Watch, this);
+	RKSettings::configureSettings (RKSettings::PageWatch, this);
 }
 
 void RKCommandLog::clearLog () {

Modified: branches/KDE4_port/rkward/windows/rkcommandlog.h
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandlog.h	2007-10-18 16:03:21 UTC (rev 2092)
+++ branches/KDE4_port/rkward/windows/rkcommandlog.h	2007-10-18 16:33:59 UTC (rev 2093)
@@ -22,6 +22,7 @@
 #include <qtextedit.h>
 
 #include "rkmdiwindow.h"
+#include "../settings/rksettings.h"
 #include "../rbackend/rcommandreceiver.h"
 
 class RCommand;
@@ -57,7 +58,7 @@
 /** clears the log_view-window */
 	void clearLog ();
 	void runSelection ();
-	void maxCommandLogLinesChanged ();
+	void settingsChanged (RKSettings::SettingsPage page);
 private:
 	void addInputNoCheck (RCommand *command);
 	void addOutputNoCheck (RCommand *command, ROutput *output);


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