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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 4 22:48:07 UTC 2006


Revision: 807
          http://svn.sourceforge.net/rkward/?rev=807&view=rev
Author:   tfry
Date:     2006-10-04 15:48:01 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
Add alternative way of specifying object filter, and fix problem with hidden vars filter

Modified Paths:
--------------
    trunk/rkward/rkward/misc/rkobjectlistview.cpp
    trunk/rkward/rkward/misc/rkobjectlistview.h
    trunk/rkward/rkward/robjectbrowser.cpp
    trunk/rkward/rkward/robjectbrowser.h

Modified: trunk/rkward/rkward/misc/rkobjectlistview.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-04 21:08:04 UTC (rev 806)
+++ trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-04 22:48:01 UTC (rev 807)
@@ -362,10 +362,10 @@
 	RK_TRACE (APP);
 
 	if (object->getShortName ().startsWith (".")) {
+		if ((!object->isType (RObject::GlobalEnv)) && (settings[ShowObjectsHidden] <= No)) return false;
+	}
+	if (object->isType (RObject::ToplevelEnv)) {
 		if (object->isType (RObject::GlobalEnv)) return true;
-		return (settings[ShowObjectsHidden] >= Yes);
-	} else if (object->isType (RObject::ToplevelEnv)) {
-		if (object->isType (RObject::GlobalEnv)) return true;
 		return (settings[ShowObjectsAllEnvironments] >= Yes);
 	} else if (object->isType (RObject::Function)) {
 		return (settings[ShowObjectsFunction] >= Yes);
@@ -455,18 +455,4 @@
 	return true;
 }
 
-//////////////////// RKObjectListViewSettingsWidget //////////////////////////
-RKObjectListViewSettingsWidget::RKObjectListViewSettingsWidget (RKObjectListViewSettings *settings, QWidget *parent) : QWidget (parent) {
-	RK_TRACE (APP);
-}
-
-RKObjectListViewSettingsWidget::~RKObjectListViewSettingsWidget () {
-	RK_TRACE (APP);
-}
-
-void RKObjectListViewSettingsWidget::settingsChanged () {
-	RK_TRACE (APP);
-}
-
-
 #include "rkobjectlistview.moc"

Modified: trunk/rkward/rkward/misc/rkobjectlistview.h
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-04 21:08:04 UTC (rev 806)
+++ trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-04 22:48:01 UTC (rev 807)
@@ -137,6 +137,7 @@
 	void setSetting (Settings setting, State to);
 	State getSetting (Settings setting);
 	bool settingActive (Settings setting);
+	bool optionConfigurable (Settings setting);
 
 	bool shouldShowObject (RObject *object);
 
@@ -150,7 +151,6 @@
 private:
 	State *settings;
 	bool *settings_default;
-	bool optionConfigurable (Settings setting);
 	void insertPopupItem (QPopupMenu *menu, Settings setting, const QString &text);
 	void createContextMenus ();
 	void updateSelf ();
@@ -159,15 +159,4 @@
 	QPopupMenu *show_fields_menu;
 };
 
-class RKObjectListViewSettingsWidget : public QWidget {
-	Q_OBJECT
-public:
-	RKObjectListViewSettingsWidget (RKObjectListViewSettings *settings, QWidget *parent);
-	~RKObjectListViewSettingsWidget ();
-public slots:
-	void settingsChanged ();
-private:
-	RKObjectListViewSettings *settings;
-};
-
 #endif

Modified: trunk/rkward/rkward/robjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/robjectbrowser.cpp	2006-10-04 21:08:04 UTC (rev 806)
+++ trunk/rkward/rkward/robjectbrowser.cpp	2006-10-04 22:48:01 UTC (rev 807)
@@ -20,6 +20,9 @@
 #include <qlistview.h>
 #include <qpushbutton.h>
 #include <qpopupmenu.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
 
 #include <klocale.h>
 #include <kinputdialog.h>
@@ -42,11 +45,10 @@
 RObjectBrowser::RObjectBrowser () : QWidget () {
 	RK_TRACE (APP);
 
-	QGridLayout *grid = new QGridLayout (this, 1, 1);
-	QVBoxLayout *vbox = new QVBoxLayout ();
-	grid->addLayout (vbox, 0, 0);
-	
+	QVBoxLayout *vbox = new QVBoxLayout (this);
+
 	list_view = new RKObjectListView (this);
+	vbox->addWidget (new RKObjectListViewSettingsWidget (list_view->getSettings (), this));
 	vbox->addWidget (list_view);
 
 	update_button = new QPushButton (i18n ("Update"), this);
@@ -181,4 +183,103 @@
 	}
 }
 
+
+//////////////////// RKObjectListViewSettingsWidget //////////////////////////
+RKObjectListViewSettingsWidget::RKObjectListViewSettingsWidget (RKObjectListViewSettings *settings, QWidget *parent) : QWidget (parent) {
+	RK_TRACE (APP);
+
+	RKObjectListViewSettingsWidget::settings = settings;
+	connect (settings, SIGNAL (settingsChanged ()), this, SLOT (settingsChanged ()));
+
+	QVBoxLayout *layout = new QVBoxLayout (this);
+	group = new QButtonGroup (this);
+	QHBoxLayout *grouplayout = new QHBoxLayout (group);
+	all = new QRadioButton (i18n ("All"), group);
+	nonfunctions = new QRadioButton (i18n ("Non-Functions"), group);
+	functions = new QRadioButton (i18n ("Functions"), group);
+	grouplayout->addWidget (all);
+	grouplayout->addWidget (nonfunctions);
+	grouplayout->addWidget (functions);
+	connect (group, SIGNAL (clicked (int)), this, SLOT (modeActivated (int)));
+	layout->addWidget (group);
+
+	all_envirs = new QCheckBox (i18n ("Show All Environments"), this);
+	connect (all_envirs, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
+	layout->addWidget (all_envirs);
+
+	hidden_objects = new QCheckBox (i18n ("Show Hidden Objects"), this);
+	connect (hidden_objects, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
+	layout->addWidget (hidden_objects);
+
+	settingsChanged ();
+}
+
+RKObjectListViewSettingsWidget::~RKObjectListViewSettingsWidget () {
+	RK_TRACE (APP);
+}
+
+void RKObjectListViewSettingsWidget::settingsChanged () {
+	RK_TRACE (APP);
+
+	all_envirs->setChecked (settings->settingActive (RKObjectListViewSettings::ShowObjectsAllEnvironments));
+	all_envirs->setEnabled (settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsAllEnvironments));
+
+	hidden_objects->setChecked (settings->settingActive (RKObjectListViewSettings::ShowObjectsHidden));
+	hidden_objects->setEnabled (settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsHidden));
+
+	bool functions_shown = settings->settingActive (RKObjectListViewSettings::ShowObjectsFunction);
+	bool functions_configurable = settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsFunction);
+
+	bool vars_shown = settings->settingActive (RKObjectListViewSettings::ShowObjectsVariable);
+	bool vars_configurable = settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsVariable);
+
+	bool containers_shown = settings->settingActive (RKObjectListViewSettings::ShowObjectsContainer);
+	bool containers_configurable = settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsContainer);
+
+	if (functions_configurable && (vars_configurable || containers_configurable)) group->show ();
+	else group->hide ();
+
+	if (functions_shown && vars_shown && containers_shown) {
+		all->setChecked (true);
+	} else if (vars_shown && containers_shown) {
+		nonfunctions->setChecked (true);
+	} else if (functions_shown && (!(vars_shown || containers_shown))) {
+		functions->setChecked (true);
+	} else {
+		all->setChecked (false);
+		nonfunctions->setChecked (false);
+		functions->setChecked (false);
+	}
+}
+
+void RKObjectListViewSettingsWidget::modeActivated (int mode) {
+	RK_TRACE (APP);
+
+	if (mode == All) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsFunction, RKObjectListViewSettings::Yes);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsVariable, RKObjectListViewSettings::Yes);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsContainer, RKObjectListViewSettings::Yes);
+	} else if (mode == Functions) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsFunction, RKObjectListViewSettings::Yes);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsVariable, RKObjectListViewSettings::No);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsContainer, RKObjectListViewSettings::No);
+	} else if (mode == NonFunctions) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsFunction, RKObjectListViewSettings::No);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsVariable, RKObjectListViewSettings::Yes);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsContainer, RKObjectListViewSettings::Yes);
+	} else {
+		RK_ASSERT (false);
+	}
+}
+
+void RKObjectListViewSettingsWidget::boxChanged (int) {
+	RK_TRACE (APP);
+
+	if (sender () == all_envirs) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, all_envirs->isChecked () ? RKObjectListViewSettings::Yes : RKObjectListViewSettings::No);
+	} else {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsHidden, hidden_objects->isChecked () ? RKObjectListViewSettings::Yes : RKObjectListViewSettings::No);
+	}
+}
+
 #include "robjectbrowser.moc"

Modified: trunk/rkward/rkward/robjectbrowser.h
===================================================================
--- trunk/rkward/rkward/robjectbrowser.h	2006-10-04 21:08:04 UTC (rev 806)
+++ trunk/rkward/rkward/robjectbrowser.h	2006-10-04 22:48:01 UTC (rev 807)
@@ -20,9 +20,13 @@
 #include <qwidget.h>
 
 class RKObjectListView;
+class RKObjectListViewSettings;
 class RKListViewItem;
 class QListViewItem;
 class QPushButton;
+class QRadioButton;
+class QButtonGroup;
+class QCheckBox;
 class QPopupMenu;
 class RObject;
 class RKCommandEditorWindow;
@@ -63,4 +67,30 @@
 	RKObjectListView *list_view;	
 };
 
+/** This class provides a widget to switch quickly between the most important RKObjectListViewSettings */
+class RKObjectListViewSettingsWidget : public QWidget {
+	Q_OBJECT
+public:
+	RKObjectListViewSettingsWidget (RKObjectListViewSettings *settings, QWidget *parent);
+	~RKObjectListViewSettingsWidget ();
+
+	enum Modes {
+		All = 0,
+		NonFunctions = 1,
+		Functions = 2
+	};
+public slots:
+	void settingsChanged ();
+	void modeActivated (int mode);
+	void boxChanged (int);
+private:
+	QButtonGroup *group;
+	QRadioButton *all;
+	QRadioButton *nonfunctions;
+	QRadioButton *functions;
+	QCheckBox *all_envirs;
+	QCheckBox *hidden_objects;
+	RKObjectListViewSettings *settings;
+};
+
 #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