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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 4 21:08:15 UTC 2006


Revision: 806
          http://svn.sourceforge.net/rkward/?rev=806&view=rev
Author:   tfry
Date:     2006-10-04 14:08:04 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
Make object list view settings work, and add global defaults

Modified Paths:
--------------
    trunk/rkward/rkward/misc/rkobjectlistview.cpp
    trunk/rkward/rkward/misc/rkobjectlistview.h
    trunk/rkward/rkward/settings/rksettings.h
    trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.cpp
    trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.h

Modified: trunk/rkward/rkward/misc/rkobjectlistview.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-04 14:59:55 UTC (rev 805)
+++ trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-04 21:08:04 UTC (rev 806)
@@ -71,7 +71,7 @@
 
 void RKObjectListView::objectBrowserSettingsChanged () {
 	setColumnWidthMode (0, QListView::Maximum);
-	if (RKSettingsModuleObjectBrowser::showLabelField ()) {
+	if (settings->settingActive (RKObjectListViewSettings::ShowFieldsLabel)) {
 		if (columnWidth (1) == 0) setColumnWidth (1, 50);
 		setColumnWidthMode (1, QListView::Maximum);
 	} else {
@@ -79,7 +79,7 @@
 		hideColumn (1);
 	}
 
-	if (RKSettingsModuleObjectBrowser::showTypeField ()) {
+	if (settings->settingActive (RKObjectListViewSettings::ShowFieldsType)) {
 		if (columnWidth (2) == 0) setColumnWidth (2, 50);
 		setColumnWidthMode (2, QListView::Maximum);
 	} else {
@@ -87,7 +87,7 @@
 		hideColumn (2);
 	}
 
-	if (RKSettingsModuleObjectBrowser::showClassField ()) {
+	if (settings->settingActive (RKObjectListViewSettings::ShowFieldsClass)) {
 		if (columnWidth (3) == 0) setColumnWidth (3, 50);
 		setColumnWidthMode (3, QListView::Maximum);
 	} else {
@@ -288,13 +288,6 @@
 		item->setOpen (true);
 	}
 
-	if (!RKSettingsModuleObjectBrowser::showHiddenVars ()) {
-		// if the object is hidden, it shouldn't appear
-		if (!object->isType (RObject::GlobalEnv)) {
-			if (object->getShortName ().startsWith (".")) item->setVisible (false);
-		}
-	}
-
 // code below won't work, as objects get added before editor is opened. Need to call from RKEditor(Manager)
 /*	if (object->numChildren () && RKGlobals::editorManager ()->objectOpened (object)) {
 		item->setOpen (true);
@@ -329,6 +322,7 @@
 	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 ()));
 
 	createContextMenus ();
 	globalSettingsChanged ();
@@ -358,6 +352,12 @@
 	return (settings[setting]);
 }
 
+bool RKObjectListViewSettings::settingActive (Settings setting) {
+	RK_TRACE (APP);
+
+	return (settings[setting] >= Yes);
+}
+
 bool RKObjectListViewSettings::shouldShowObject (RObject *object) {
 	RK_TRACE (APP);
 
@@ -421,9 +421,11 @@
 void RKObjectListViewSettings::globalSettingsChanged () {
 	RK_TRACE (APP);
 
-	// TODO: copy global settings
 	for (int i = 0; i < SettingsCount; ++i) {
-		settings[i] = Yes;
+		if (settings_default[i]) {
+			if (RKSettingsModuleObjectBrowser::isSettingActive ((Settings) i)) settings[i] = Yes;
+			else settings[i] = No;
+		}
 	}
 
 	updateSelf ();

Modified: trunk/rkward/rkward/misc/rkobjectlistview.h
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-04 14:59:55 UTC (rev 805)
+++ trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-04 21:08:04 UTC (rev 806)
@@ -136,6 +136,7 @@
 
 	void setSetting (Settings setting, State to);
 	State getSetting (Settings setting);
+	bool settingActive (Settings setting);
 
 	bool shouldShowObject (RObject *object);
 

Modified: trunk/rkward/rkward/settings/rksettings.h
===================================================================
--- trunk/rkward/rkward/settings/rksettings.h	2006-10-04 14:59:55 UTC (rev 805)
+++ trunk/rkward/rkward/settings/rksettings.h	2006-10-04 21:08:04 UTC (rev 806)
@@ -36,7 +36,7 @@
 */
 class RKSettings : public KDialogBase {
 public:
-	enum SettingsPage { NoPage=0, Plugins=1, R=2, RPackages=3, PHP=4, LogFiles=5, Output=6, Watch=7, ObjectBrowser=8, Console=9 };
+	enum SettingsPage { NoPage=0, Plugins=1, R=2, RPackages=3, PHP=4, General=5, Output=6, Watch=7, Console=8, ObjectBrowser=9 };
 
 	static void configureSettings (SettingsPage page=NoPage, QWidget *parent=0, RCommandChain *chain=0);
 

Modified: trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.cpp	2006-10-04 14:59:55 UTC (rev 805)
+++ trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.cpp	2006-10-04 21:08:04 UTC (rev 806)
@@ -29,45 +29,58 @@
 #include "../debug.h"
 
 // static
-int RKSettingsModuleObjectBrowser::options = 0;
+bool RKSettingsModuleObjectBrowser::settings[RKObjectListViewSettings::SettingsCount];
 
 RKSettingsModuleObjectBrowser::RKSettingsModuleObjectBrowser (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
 	RK_TRACE (SETTINGS);
 
+	checkboxes = new QCheckBox*[RKObjectListViewSettings::SettingsCount];
+
 	QVBoxLayout *layout = new QVBoxLayout (this, RKGlobals::marginHint ());
 
-	show_hidden_vars_box = new QCheckBox (i18n ("Show hidden objects"), this);
-	show_hidden_vars_box->setChecked (showHiddenVars ());
-	connect (show_hidden_vars_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
-	layout->addWidget (show_hidden_vars_box);
+	layout->addWidget (new QLabel (i18n ("Which objects should be shown by default?"), this));
 
+	checkboxes[RKObjectListViewSettings::ShowObjectsHidden] = new QCheckBox (i18n ("Show hidden objects"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowObjectsHidden]);
+	checkboxes[RKObjectListViewSettings::ShowObjectsAllEnvironments] = new QCheckBox (i18n ("Show all environments"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowObjectsAllEnvironments]);
 	layout->addSpacing (2*RKGlobals::spacingHint ());
+	checkboxes[RKObjectListViewSettings::ShowObjectsContainer] = new QCheckBox (i18n ("Show objects with children"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowObjectsContainer]);
+	checkboxes[RKObjectListViewSettings::ShowObjectsFunction] = new QCheckBox (i18n ("Show functions"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowObjectsFunction]);
+	checkboxes[RKObjectListViewSettings::ShowObjectsVariable] = new QCheckBox (i18n ("Show variables"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowObjectsVariable]);
 
-	QLabel *label = new QLabel (i18n ("Which columns should be shown?"), this);
-	layout->addWidget (label);
+	layout->addSpacing (2*RKGlobals::spacingHint ());
 
-	show_label_field_box = new QCheckBox (i18n ("Label field"), this);
-	show_label_field_box->setChecked (showLabelField ());
-	connect (show_label_field_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
-	layout->addWidget (show_label_field_box);
+	layout->addWidget (new QLabel (i18n ("Which columns should be shown by default?"), this));
 
-	show_type_field_box = new QCheckBox (i18n ("Type field"), this);
-	show_type_field_box->setChecked (showTypeField ());
-	connect (show_type_field_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
-	layout->addWidget (show_type_field_box);
+	checkboxes[RKObjectListViewSettings::ShowFieldsLabel] = new QCheckBox (i18n ("Label field"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowFieldsLabel]);
+	checkboxes[RKObjectListViewSettings::ShowFieldsType] = new QCheckBox (i18n ("Type field"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowFieldsType]);
+	checkboxes[RKObjectListViewSettings::ShowFieldsClass] = new QCheckBox (i18n ("Class field"), this);
+	layout->addWidget (checkboxes[RKObjectListViewSettings::ShowFieldsClass]);
 
-	show_class_field_box = new QCheckBox (i18n ("Class field"), this);
-	show_class_field_box->setChecked (showClassField ());
-	connect (show_class_field_box, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
-	layout->addWidget (show_class_field_box);
+	layout->addStretch ();
 
-	layout->addStretch ();
+	for (int i = 0; i < RKObjectListViewSettings::SettingsCount; ++i) {
+		checkboxes[i]->setChecked (settings[i]);
+		connect (checkboxes[i], SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
+	}
 }
 
 RKSettingsModuleObjectBrowser::~RKSettingsModuleObjectBrowser () {
 	RK_TRACE (SETTINGS);
 }
 
+//static
+bool RKSettingsModuleObjectBrowser::isSettingActive (RKObjectListViewSettings::Settings setting) {
+	RK_TRACE (SETTINGS);
+	return settings[setting];
+}
+
 bool RKSettingsModuleObjectBrowser::hasChanges () {
 	RK_TRACE (SETTINGS);
 	return changed;
@@ -75,12 +88,11 @@
 
 void RKSettingsModuleObjectBrowser::applyChanges () {
 	RK_TRACE (SETTINGS);
-	options = 0;
-	if (show_hidden_vars_box->isChecked ()) options |= ShowHiddenVars;
-	if (show_label_field_box->isChecked ()) options |= ShowLabelField;
-	if (show_type_field_box->isChecked ()) options |= ShowTypeField;
-	if (show_class_field_box->isChecked ()) options |= ShowClassField;
 
+	for (int i = 0; i < RKObjectListViewSettings::SettingsCount; ++i) {
+		settings[i] = checkboxes[i]->isChecked ();
+	}
+
 	RKSettings::tracker ()->settingsChangedObjectBrowser ();
 }
 
@@ -99,22 +111,29 @@
 	RK_TRACE (SETTINGS);
 
 	config->setGroup ("Object Browser");
-	config->writeEntry ("show hidden vars", showHiddenVars ());
-	config->writeEntry ("show label field", showLabelField ());
-	config->writeEntry ("show type field", showTypeField ());
-	config->writeEntry ("show class field", showClassField ());
+	config->writeEntry ("show hidden vars", settings[RKObjectListViewSettings::ShowObjectsHidden]);
+	config->writeEntry ("show all environments", settings[RKObjectListViewSettings::ShowObjectsAllEnvironments]);
+	config->writeEntry ("show container objects", settings[RKObjectListViewSettings::ShowObjectsContainer]);
+	config->writeEntry ("show function objects", settings[RKObjectListViewSettings::ShowObjectsFunction]);
+	config->writeEntry ("show variable objects", settings[RKObjectListViewSettings::ShowObjectsVariable]);
+	config->writeEntry ("show label field", settings[RKObjectListViewSettings::ShowFieldsLabel]);
+	config->writeEntry ("show type field", settings[RKObjectListViewSettings::ShowFieldsType]);
+	config->writeEntry ("show class field", settings[RKObjectListViewSettings::ShowFieldsClass]);
 }
 
 //static
 void RKSettingsModuleObjectBrowser::loadSettings (KConfig *config) {
 	RK_TRACE (SETTINGS);
 
-	options = 0;
 	config->setGroup ("Object Browser");
-	if (config->readBoolEntry ("show hidden vars", false)) options |= ShowHiddenVars;
-	if (config->readBoolEntry ("show label field", true)) options |= ShowLabelField;
-	if (config->readBoolEntry ("show type field", true)) options |= ShowTypeField;
-	if (config->readBoolEntry ("show class field", true)) options |= ShowClassField;
+	settings[RKObjectListViewSettings::ShowObjectsHidden] = config->readBoolEntry ("show hidden vars", false);
+	settings[RKObjectListViewSettings::ShowObjectsAllEnvironments] = config->readBoolEntry ("show all environments", true);
+	settings[RKObjectListViewSettings::ShowObjectsContainer] = config->readBoolEntry ("show container objects", true);
+	settings[RKObjectListViewSettings::ShowObjectsFunction] = config->readBoolEntry ("show function objects", true);
+	settings[RKObjectListViewSettings::ShowObjectsVariable] = config->readBoolEntry ("show variable objects", true);
+	settings[RKObjectListViewSettings::ShowFieldsLabel] = config->readBoolEntry ("show label field", true);
+	settings[RKObjectListViewSettings::ShowFieldsType] = config->readBoolEntry ("show type field", true);
+	settings[RKObjectListViewSettings::ShowFieldsClass] = config->readBoolEntry ("show class field", true);
 }
 
 void RKSettingsModuleObjectBrowser::boxChanged (int) {

Modified: trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.h	2006-10-04 14:59:55 UTC (rev 805)
+++ trunk/rkward/rkward/settings/rksettingsmoduleobjectbrowser.h	2006-10-04 21:08:04 UTC (rev 806)
@@ -20,6 +20,8 @@
 
 #include "rksettingsmodule.h"
 
+#include "../misc/rkobjectlistview.h"
+
 class QCheckBox;
 
 /** Configuration module for instances of RObjectListView
@@ -47,26 +49,13 @@
 	static void saveSettings (KConfig *config);
 	static void loadSettings (KConfig *config);
 
-/** whether hidden variables should be shown in RObjectListViews by default */
-	static bool showHiddenVars () { return (options & ShowHiddenVars); };
-/** whether the type field should be shown in RObjectListViews by default */
-	static bool showTypeField () { return (options & ShowTypeField); };
-/** whether the class field should be shown in RObjectListViews by default */
-	static bool showClassField () { return (options & ShowClassField); };
-/** whether the label field should be shown in RObjectListViews by default */
-	static bool showLabelField () { return (options & ShowLabelField); };
-	
-	enum ObjectBrowserOptions { ShowHiddenVars=1, ShowTypeField=2, ShowClassField=4, ShowLabelField=8 };
+	static bool isSettingActive (RKObjectListViewSettings::Settings setting);
 public slots:
 /** called when a checkbox has been changed. Signals change to RKSettings dialog to enable apply button */
 	void boxChanged (int);
 private:
-	QCheckBox *show_hidden_vars_box;
-	QCheckBox *show_type_field_box;
-	QCheckBox *show_class_field_box;
-	QCheckBox *show_label_field_box;
-
-	static int options;
+	QCheckBox **checkboxes;
+	static bool settings[RKObjectListViewSettings::SettingsCount];
 };
 
 #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