[rkward/work/workspace_browser_redesign] rkward: Finish first version of workspace browser filter settings UI.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Nov 12 19:51:08 UTC 2015


Git commit cb61ce940153fe416a573e7ae54cd65ec441edae by Thomas Friedrichsmeier.
Committed on 12/11/2015 at 19:48.
Pushed by tfry into branch 'work/workspace_browser_redesign'.

Finish first version of workspace browser filter settings UI.
 - Those settings that _are_ stored, are stored implicitly, rather than on a settings page.
 - Separate settings for worksapce browser tool window and varselectors.
 - For varselectors, filter widget is available from the context menu.

M  +42   -101  rkward/misc/rkobjectlistview.cpp
M  +9    -28   rkward/misc/rkobjectlistview.h
M  +1    -2    rkward/misc/rksaveobjectchooser.cpp
M  +1    -0    rkward/misc/rkstandardicons.cpp
M  +1    -0    rkward/misc/rkstandardicons.h
M  +42   -6    rkward/plugin/rkvarselector.cpp
M  +8    -1    rkward/plugin/rkvarselector.h
M  +33   -45   rkward/settings/rksettingsmoduleobjectbrowser.cpp
M  +7    -4    rkward/settings/rksettingsmoduleobjectbrowser.h
M  +1    -1    rkward/windows/robjectbrowser.cpp

http://commits.kde.org/rkward/cb61ce940153fe416a573e7ae54cd65ec441edae

diff --git a/rkward/misc/rkobjectlistview.cpp b/rkward/misc/rkobjectlistview.cpp
index a721fa6..c19162e 100644
--- a/rkward/misc/rkobjectlistview.cpp
+++ b/rkward/misc/rkobjectlistview.cpp
@@ -76,19 +76,17 @@ public:
 	QIcon collapsed;
 };
 
-RKObjectListView::RKObjectListView (QWidget *parent) : QTreeView (parent) {
+RKObjectListView::RKObjectListView (bool toolwindow, QWidget *parent) : QTreeView (parent) {
 	RK_TRACE (APP);
 
 	root_object = 0;
 	rkdelegate = new RKObjectListViewRootDelegate (this);
-	settings = new RKObjectListViewSettings (this);
+	settings = new RKObjectListViewSettings (toolwindow, this);
 	setSortingEnabled (true);
 	sortByColumn (0, Qt::AscendingOrder);
 
 	menu = new QMenu (this);
-	menu->addMenu (settings->showObjectsMenu ());
-	menu->addMenu (settings->showFieldsMenu ());
-	menu->addAction (i18n ("Configure Defaults"), this, SLOT (popupConfigure()));
+	settings->addSettingsToMenu (menu, 0);
 
 	connect (this, SIGNAL(clicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
 }
@@ -130,7 +128,6 @@ void RKObjectListView::setRootObject (RObject *root) {
 	RK_TRACE (APP);
 
 	root_object = root;
-	if (!root && !settings->getSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments)) root = RObjectList::getGlobalEnv ();
 	QModelIndex index = settings->mapFromSource (RKGlobals::tracker ()->indexFor (root));
 	if (index != rootIndex ()) {
 		setRootIndex (index);
@@ -165,11 +162,6 @@ RObject::ObjectList RKObjectListView::selectedObjects () const {
 	return list;
 }
 
-void RKObjectListView::popupConfigure () {
-	RK_TRACE (APP);
-	RKSettings::configureSettings (RKSettings::PageObjectBrowser, this);
-}
-
 void RKObjectListView::contextMenuEvent (QContextMenuEvent* event) {
 	RK_TRACE (APP);
 
@@ -228,9 +220,11 @@ void RKObjectListView::settingsChanged () {
 
 //////////////////// RKObjectListViewSettings //////////////////////////
 
-RKObjectListViewSettings::RKObjectListViewSettings (QObject* parent) : QSortFilterProxyModel (parent) {
+RKObjectListViewSettings::RKObjectListViewSettings (bool tool_window, QObject* parent) : QSortFilterProxyModel (parent) {
 	RK_TRACE (APP);
 
+	is_tool_window = tool_window;
+
 	update_timer = new QTimer (this);
 	update_timer->setSingleShot (true);
 	connect (update_timer, SIGNAL(timeout()), this, SLOT(updateSelfNow()));
@@ -239,33 +233,23 @@ RKObjectListViewSettings::RKObjectListViewSettings (QObject* parent) : QSortFilt
 	hide_functions = hide_non_functions = false;
 	filter_on_class = filter_on_label = filter_on_name = true;
 	depth_limit = 1;
-	show_hidden_objects = RKSettingsModuleObjectBrowser::isSettingActive (ShowObjectsHidden);
-
-	connect (RKSettings::tracker (), SIGNAL (settingsChanged(RKSettings::SettingsPage)), this, SLOT (globalSettingsChanged(RKSettings::SettingsPage)));
 
-	action_group = new QActionGroup (this);
-	action_group->setExclusive (false);
-	settings[ShowObjectsAllEnvironments].action = new QAction (i18n ("All Environments"), action_group);
-	settings[ShowObjectsHidden].action = new QAction (i18n ("Hidden Objects"), action_group);
-	settings[ShowFieldsType].action = new QAction (i18n ("Type"), action_group);
-	settings[ShowFieldsLabel].action = new QAction (i18n ("Label"), action_group);
-	settings[ShowFieldsClass].action = new QAction (i18n ("Class"), action_group);
+	persistent_settings_actions[ShowObjectsHidden] = new QAction (i18n ("Show Hidden Objects"), this);
+	persistent_settings_actions[ShowFieldsType] = new QAction (i18n ("Type"), this);
+	persistent_settings_actions[ShowFieldsLabel] = new QAction (i18n ("Label"), this);
+	persistent_settings_actions[ShowFieldsClass] = new QAction (i18n ("Class"), this);
 
 	for (int i = 0; i < SettingsCount; ++i) {
-		settings[i].action->setCheckable (true);
+		if (is_tool_window) persistent_settings[i] = RKSettingsModuleObjectBrowser::isDefaultForWorkspace ((PersistentSettings) i);
+		else persistent_settings[i] = RKSettingsModuleObjectBrowser::isDefaultForVarselector ((PersistentSettings) i);
+		persistent_settings_actions[i]->setCheckable (true);
+		persistent_settings_actions[i]->setChecked (persistent_settings[i]);
+		connect (persistent_settings_actions[i], SIGNAL (toggled(bool)), this, SLOT(filterSettingsChanged ()));
 	}
-
-	createContextMenus ();
-
-	// initialize the settings states
-	globalSettingsChanged (RKSettings::PageObjectBrowser);
 }
 
 RKObjectListViewSettings::~RKObjectListViewSettings () {
 	RK_TRACE (APP);
-
-	delete show_fields_menu;
-	delete show_objects_menu;
 }
 
 QWidget* RKObjectListViewSettings::filterWidget (QWidget *parent) {
@@ -339,9 +323,10 @@ QWidget* RKObjectListViewSettings::filterWidget (QWidget *parent) {
 	else type_box->setCurrentIndex (0);
 	connect (type_box, SIGNAL (currentIndexChanged(QString)), this, SLOT (filterSettingsChanged()));
 
-	hidden_objects_box = new QCheckBox (i18n ("Show Hidden Objects"));
-	hidden_objects_box->setChecked (show_hidden_objects);
-	connect (hidden_objects_box, SIGNAL (clicked(bool)), this, SLOT (filterSettingsChanged()));
+	QCheckBox* hidden_objects_box = new QCheckBox (i18n ("Show Hidden Objects"));
+	hidden_objects_box->setChecked (persistent_settings[ShowObjectsHidden]);
+	connect (hidden_objects_box, SIGNAL (clicked(bool)), persistent_settings_actions[ShowObjectsHidden], SLOT (setChecked(bool)));
+	connect (persistent_settings_actions[ShowObjectsHidden], SIGNAL (triggered(bool)), hidden_objects_box, SLOT (setChecked(bool)));
 	layout->addWidget (hidden_objects_box);
 
 	return filter_widget;
@@ -350,27 +335,20 @@ QWidget* RKObjectListViewSettings::filterWidget (QWidget *parent) {
 void RKObjectListViewSettings::filterSettingsChanged () {
 	RK_TRACE (APP);
 
-	if (!filter_widget) {
-		RK_ASSERT (filter_widget);
-		return;
+	if (filter_widget) {
+		filter_on_name = filter_on_name_box->isChecked ();
+		filter_on_label = filter_on_label_box->isChecked ();
+		filter_on_class = filter_on_class_box->isChecked ();
+		depth_limit = depth_box->currentIndex ();
+		hide_functions = type_box->currentIndex () == 2;
+		hide_non_functions = type_box->currentIndex () == 1;
 	}
 
-	filter_on_name = filter_on_name_box->isChecked ();
-	filter_on_label = filter_on_label_box->isChecked ();
-	filter_on_class = filter_on_class_box->isChecked ();
-	depth_limit = depth_box->currentIndex ();
-	hide_functions = type_box->currentIndex () == 2;
-	hide_non_functions = type_box->currentIndex () == 1;
-	show_hidden_objects = hidden_objects_box->isChecked ();
-#warning TODO: It is also a QAction, currently.
-	updateSelf ();
-}
-
-void RKObjectListViewSettings::setSetting (Settings setting, bool to) {
-	RK_TRACE (APP);
-
-	settings[setting].state = to;
-	settings[setting].is_at_default = false;
+	for (int i = 0; i < SettingsCount; ++i) {
+		persistent_settings[i] = persistent_settings_actions[i]->isChecked ();
+		if (is_tool_window) RKSettingsModuleObjectBrowser::setDefaultForWorkspace ((PersistentSettings) i, persistent_settings[i]);
+		else RKSettingsModuleObjectBrowser::setDefaultForVarselector ((PersistentSettings) i, persistent_settings[i]);
+	}
 
 	updateSelf ();
 }
@@ -379,9 +357,9 @@ bool RKObjectListViewSettings::filterAcceptsColumn (int source_column, const QMo
 	RK_TRACE (APP);
 
 	if (source_column == RKObjectListModel::NameColumn) return true;
-	if (source_column == RKObjectListModel::LabelColumn) return (settings[ShowFieldsLabel].state);
-	if (source_column == RKObjectListModel::TypeColumn) return (settings[ShowFieldsType].state);
-	if (source_column == RKObjectListModel::ClassColumn) return (settings[ShowFieldsClass].state);
+	if (source_column == RKObjectListModel::LabelColumn) return (persistent_settings[ShowFieldsLabel]);
+	if (source_column == RKObjectListModel::TypeColumn) return (persistent_settings[ShowFieldsType]);
+	if (source_column == RKObjectListModel::ClassColumn) return (persistent_settings[ShowFieldsClass]);
 
 	RK_ASSERT (false);
 	return false;
@@ -433,7 +411,7 @@ bool RKObjectListViewSettings::acceptRow (int source_row, const QModelIndex& sou
 	object = object->findChildByObjectModelIndex (source_row);
 	RK_ASSERT (object);
 
-	if (!show_hidden_objects) {
+	if (!persistent_settings[ShowObjectsHidden]) {
 		if (object->getShortName ().startsWith ('.')) return false;
 		if (object == reinterpret_cast<RObject*> (RObjectList::getObjectList ()->orphanNamespacesObject ())) return false;
 	}
@@ -479,20 +457,17 @@ bool RKObjectListViewSettings::lessThan (const QModelIndex& left, const QModelIn
 	return (QSortFilterProxyModel::lessThan (left, right));
 }
 
-void RKObjectListViewSettings::createContextMenus () {
+void RKObjectListViewSettings::addSettingsToMenu (QMenu* menu, QAction* before) {
 	RK_TRACE (APP);
 
-	show_objects_menu = new QMenu (i18n ("Show Objects"), 0);
-	show_objects_menu->addAction (settings[ShowObjectsAllEnvironments].action);
-	show_objects_menu->addSeparator ();
-	show_objects_menu->addAction (settings[ShowObjectsHidden].action);
+	menu->insertAction (before, persistent_settings_actions[ShowObjectsHidden]);
 
-	show_fields_menu = new QMenu (i18n ("Show Fields"), 0);
-	show_fields_menu->addAction (settings[ShowFieldsType].action);
-	show_fields_menu->addAction (settings[ShowFieldsLabel].action);
-	show_fields_menu->addAction (settings[ShowFieldsClass].action);
+	QMenu *show_fields_menu = new QMenu (i18n ("Show Fields"), menu);
+	show_fields_menu->addAction (persistent_settings_actions[ShowFieldsType]);
+	show_fields_menu->addAction (persistent_settings_actions[ShowFieldsLabel]);
+	show_fields_menu->addAction (persistent_settings_actions[ShowFieldsClass]);
+	menu->insertMenu (before, show_fields_menu);
 
-	connect (action_group, SIGNAL (triggered(QAction*)), this, SLOT(settingToggled(QAction*)));
 	updateSelf ();
 }
 
@@ -505,43 +480,9 @@ void RKObjectListViewSettings::updateSelf () {
 void RKObjectListViewSettings::updateSelfNow () {
 	RK_TRACE (APP);
 
-	for (int i = 0; i < SettingsCount; ++i) settings[i].action->setChecked (settings[i].state);
-
 	invalidateFilter ();
 
 	emit (settingsChanged ());
 }
 
-void RKObjectListViewSettings::globalSettingsChanged (RKSettings::SettingsPage page) {
-	if (page != RKSettings::PageObjectBrowser) return;
-
-	RK_TRACE (APP);
-
-	for (int i = 0; i < SettingsCount; ++i) {
-		if (settings[i].is_at_default) {     // Only settings that have been left at their default are copied
-			settings[i].state = RKSettingsModuleObjectBrowser::isSettingActive ((Settings) i);
-		}
-	}
-
-	updateSelf ();
-}
-
-void RKObjectListViewSettings::settingToggled (QAction* which) {
-	RK_TRACE (APP);
-
-	int setting = -1;
-	for (int i = 0; i < SettingsCount; ++i) {
-		if (settings[i].action == which) {
-			setting = i;
-			break;
-		}
-	}
-	if (setting < 0) {
-		RK_ASSERT (false);
-		return;
-	}
-
-	setSetting (static_cast<Settings> (setting), which->isChecked ());
-}
-
 #include "rkobjectlistview.moc"
diff --git a/rkward/misc/rkobjectlistview.h b/rkward/misc/rkobjectlistview.h
index 130eb98..af64bbd 100644
--- a/rkward/misc/rkobjectlistview.h
+++ b/rkward/misc/rkobjectlistview.h
@@ -26,7 +26,6 @@
 class QMenu;
 class RKListViewItem;
 class RKObjectListViewSettings;
-class QActionGroup;
 class QTimer;
 class QCheckBox;
 class QComboBox;
@@ -39,8 +38,7 @@ This class provides the common functionality for the tree views in the RObjectBr
 class RKObjectListView : public QTreeView {
 	Q_OBJECT
 public:
-	explicit RKObjectListView (QWidget *parent);
-	
+	explicit RKObjectListView (bool toolwindow, QWidget *parent);
 	~RKObjectListView ();
 
 /** This function returns a pointer to the context menu of the RKObjectListView. It is provided so you can add your own items.
@@ -72,7 +70,6 @@ public slots:
 	void updateStarted ();
 	void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
 	void settingsChanged ();
-	void popupConfigure ();
 	void itemClicked (const QModelIndex& index);
 protected:
 	void contextMenuEvent (QContextMenuEvent* event);
@@ -90,11 +87,11 @@ class RKObjectListViewSettings : public QSortFilterProxyModel {
 	Q_OBJECT
 public:
 /** ctor. copies the default settings from RKSettingsModuleObjectBrowser */ 
-	explicit RKObjectListViewSettings (QObject* parent=0);
+	explicit RKObjectListViewSettings (bool toolwindow, QObject* parent=0);
 	~RKObjectListViewSettings ();
 
-	enum Settings {
-		ShowObjectsAllEnvironments,
+/** enum of @em persistent settings. There are more settings than these, but those will not be stored */
+	enum PersistentSettings {
 		ShowObjectsHidden,
 		ShowFieldsType,
 		ShowFieldsClass,
@@ -102,19 +99,13 @@ public:
 		SettingsCount
 	};
 
-	void setSetting (Settings setting, bool to);
-	bool getSetting (Settings setting) const { return settings[setting].state; };
-
-	QMenu *showObjectsMenu () const { return show_objects_menu; };
-	QMenu *showFieldsMenu () const { return show_fields_menu; };
+	void addSettingsToMenu (QMenu* menu, QAction* before);
 
 	QWidget* filterWidget (QWidget *parent);
 signals:
 	void settingsChanged ();
 public slots:
-	void globalSettingsChanged (RKSettings::SettingsPage);
 	void filterSettingsChanged ();
-	void settingToggled (QAction* which);
 	void updateSelfNow ();
 protected:
 	bool filterAcceptsRow (int source_row, const QModelIndex& source_parent) const;
@@ -122,21 +113,11 @@ protected:
 	bool filterAcceptsColumn (int source_column, const QModelIndex& source_parent) const;
 	bool lessThan (const QModelIndex& left, const QModelIndex& right) const;
 private:
-	struct Setting {
-		Setting () : is_at_default (true) {};
-		QAction *action;
-		bool is_at_default;
-		bool state;
-	};
-	Setting settings[SettingsCount];
-	QActionGroup* action_group;
+	QAction* persistent_settings_actions[SettingsCount];
+	bool persistent_settings[SettingsCount];
 
-	void createContextMenus ();
 	void updateSelf ();
 
-	QMenu *show_objects_menu;
-	QMenu *show_fields_menu;
-
 	QWidget *filter_widget;
 	QWidget *filter_widget_expansion;
 	QCheckBox* filter_on_name_box;
@@ -150,8 +131,8 @@ private:
 	QComboBox* type_box;
 	bool hide_functions;
 	bool hide_non_functions;
-	QCheckBox* hidden_objects_box;
-	bool show_hidden_objects;
+
+	bool is_tool_window;
 
 	QTimer *update_timer;
 };
diff --git a/rkward/misc/rksaveobjectchooser.cpp b/rkward/misc/rksaveobjectchooser.cpp
index 1adc5d4..5a2541f 100644
--- a/rkward/misc/rksaveobjectchooser.cpp
+++ b/rkward/misc/rksaveobjectchooser.cpp
@@ -105,9 +105,8 @@ void RKSaveObjectChooser::selectRootObject () {
 	KVBox *page = new KVBox (dialog);
 	dialog->setMainWidget (page);
 
-	RKObjectListView* list_view = new RKObjectListView (page);
+	RKObjectListView* list_view = new RKObjectListView (false, page);
 	list_view->setSelectionMode (QAbstractItemView::SingleSelection);
-	list_view->getSettings ()->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, false);
 	list_view->initialize ();
 	list_view->setObjectCurrent (root_object);
 	connect (list_view, SIGNAL (doubleClicked(QModelIndex)), dialog, SLOT (accept()));
diff --git a/rkward/misc/rkstandardicons.cpp b/rkward/misc/rkstandardicons.cpp
index 6234330..6a2c53a 100644
--- a/rkward/misc/rkstandardicons.cpp
+++ b/rkward/misc/rkstandardicons.cpp
@@ -44,6 +44,7 @@ void RKStandardIcons::initIcons () {
 	icons[ActionCDToScript] = KIcon ("folder-txt");
 
 	icons[ActionConfigurePackages] = KIcon ("utilities-file-archiver");
+	icons[ActionSearch] = KIcon ("edit-find");
 
 	icons[ActionDeleteRow] = KIcon ("edit-delete");
 	icons[ActionInsertRow] = KIcon ("list-add");
diff --git a/rkward/misc/rkstandardicons.h b/rkward/misc/rkstandardicons.h
index 644b07b..cb9ee70 100644
--- a/rkward/misc/rkstandardicons.h
+++ b/rkward/misc/rkstandardicons.h
@@ -44,6 +44,7 @@ public:
 		ActionCDToScript,
 
 		ActionConfigurePackages,
+		ActionSearch,
 
 		ActionDeleteRow,
 		ActionInsertRow,
diff --git a/rkward/plugin/rkvarselector.cpp b/rkward/plugin/rkvarselector.cpp
index 9ea7c1e..c69eab0 100644
--- a/rkward/plugin/rkvarselector.cpp
+++ b/rkward/plugin/rkvarselector.cpp
@@ -2,7 +2,7 @@
                           rkvarselector.cpp  -  description
                              -------------------
     begin                : Thu Nov 7 2002
-    copyright            : (C) 2002, 2006, 2009, 2010, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2002-2015 by Thomas Friedrichsmeier
     email                : thomas.friedrichsmeier at kdemail.net
  ***************************************************************************/
 
@@ -18,14 +18,18 @@
 #include "rkvarselector.h"
 
 #include <QVBoxLayout>
-#include <qlabel.h>
+#include <QLabel>
+#include <QAction>
+#include <QMenu>
 
 #include <klocale.h>
 
 #include "../misc/xmlhelper.h"
 #include "../rkglobals.h"
 #include "../misc/rkobjectlistview.h"
+#include "../misc/rkstandardicons.h"
 #include "../core/robjectlist.h"
+#include "../core/renvironmentobject.h"
 
 #include "../debug.h"
 
@@ -45,13 +49,32 @@ RKVarSelector::RKVarSelector (const QDomElement &element, RKComponent *parent_co
 	QLabel *label = new QLabel (element.attribute ("label", i18n ("Select Variable(s)")), this);
 	vbox->addWidget (label);
 
-	list_view = new RKObjectListView (this);
+	// TODO: Or should these actions be moved to RKObjectListView, non-tool-window-mode?
+	show_all_envs_action = new QAction (i18n ("Show all environments"), this);
+	show_all_envs_action->setCheckable (true);
+	show_all_envs_action->setToolTip (i18n ("Show objects in all environments on the <i>search()</i> path, instead of just those in <i>.GlobalEnv</i>. Check this, if you want to select objects from a loaded package."));
+	connect (show_all_envs_action, SIGNAL (toggled(bool)), this, SLOT (rootChanged()));
+
+	filter_widget = 0;
+	filter_widget_placeholder = new QVBoxLayout (this);
+	filter_widget_placeholder->setContentsMargins (0, 0, 0, 0);
+	vbox->addLayout (filter_widget_placeholder);
+	show_filter_action = new QAction (i18n ("Show filter options"), this);
+	show_filter_action->setCheckable (true);
+	show_filter_action->setShortcut (QKeySequence ("Ctrl+F"));
+	show_filter_action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionSearch));
+	connect (show_filter_action, SIGNAL (toggled(bool)), this, SLOT(showFilterWidget()));
+
+	list_view = new RKObjectListView (false, this);
 	list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
+	list_view->initialize ();
+	vbox->addWidget (list_view);
 	connect (list_view, SIGNAL (selectionChanged()), this, SLOT (objectSelectionChanged()));
 
-	vbox->addWidget (list_view);
-	list_view->getSettings ()->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, false);
-	list_view->initialize ();
+	QAction* sep = list_view->contextMenu ()->insertSeparator (list_view->contextMenu ()->actions ().value (0));
+	list_view->contextMenu ()->insertAction (sep, show_filter_action);
+	list_view->contextMenu ()->insertAction (sep, show_all_envs_action);
+
 	rootChanged ();
 }
 
@@ -59,10 +82,23 @@ RKVarSelector::~RKVarSelector () {
 	RK_TRACE (PLUGIN);
 }
 
+void RKVarSelector::showFilterWidget () {
+	RK_TRACE (PLUGIN);
+
+	if (!filter_widget) {
+		filter_widget = list_view->getSettings ()->filterWidget (this);
+		filter_widget_placeholder->addWidget (filter_widget);
+	}
+	filter_widget->setShown (show_filter_action->isChecked ());
+}
+
 void RKVarSelector::rootChanged () {
 	RK_TRACE (PLUGIN);
 
 	RObject* object = root->objectValue ();
+	if (!object) {
+		if (!show_all_envs_action->isChecked ()) object = RObjectList::getGlobalEnv ();
+	}
 	list_view->setRootObject (object);
 }
 
diff --git a/rkward/plugin/rkvarselector.h b/rkward/plugin/rkvarselector.h
index 221d0e5..fdb9675 100644
--- a/rkward/plugin/rkvarselector.h
+++ b/rkward/plugin/rkvarselector.h
@@ -2,7 +2,7 @@
                           rkvarselector.h  -  description
                              -------------------
     begin                : Thu Nov 7 2002
-    copyright            : (C) 2002, 2006, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2002-2015 by Thomas Friedrichsmeier
     email                : thomas.friedrichsmeier at kdemail.net
  ***************************************************************************/
 
@@ -23,6 +23,8 @@
 
 class RKObjectListView;
 class QDomElement;
+class QAction;
+class QVBoxLayout;
 
 /** This is an especially important RK-plugin-widget. It provides a list of variables, that
 can be selected for statistical analysis.
@@ -41,10 +43,15 @@ public:
 private slots:
 	void objectSelectionChanged ();
 	void rootChanged ();
+	void showFilterWidget ();
 private:
 	RKObjectListView *list_view;
 	RKComponentPropertyRObjects *selected;
 	RKComponentPropertyRObjects *root;
+	QAction *show_filter_action;
+	QAction *show_all_envs_action;
+	QWidget *filter_widget;
+	QVBoxLayout *filter_widget_placeholder;
 };
 
 #endif
diff --git a/rkward/settings/rksettingsmoduleobjectbrowser.cpp b/rkward/settings/rksettingsmoduleobjectbrowser.cpp
index 22215e6..e5c1679 100644
--- a/rkward/settings/rksettingsmoduleobjectbrowser.cpp
+++ b/rkward/settings/rksettingsmoduleobjectbrowser.cpp
@@ -34,41 +34,18 @@
 #include "../debug.h"
 
 // static
-bool RKSettingsModuleObjectBrowser::settings[RKObjectListViewSettings::SettingsCount];
+bool RKSettingsModuleObjectBrowser::workspace_settings[RKObjectListViewSettings::SettingsCount];
+bool RKSettingsModuleObjectBrowser::varselector_settings[RKObjectListViewSettings::SettingsCount];
 QStringList RKSettingsModuleObjectBrowser::getstructure_blacklist;
 
 RKSettingsModuleObjectBrowser::RKSettingsModuleObjectBrowser (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
 	RK_TRACE (SETTINGS);
 
-	for (int i = 0; i < RKObjectListViewSettings::SettingsCount; ++i) {
-		checkboxes[i] = 0;
-	}
-
 	QVBoxLayout *layout = new QVBoxLayout (this);
 
-	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]);
-
-	layout->addSpacing (2*RKGlobals::spacingHint ());
-
-	layout->addWidget (new QLabel (i18n ("Which columns should be shown by default?"), this));
-
-	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]);
-
-	layout->addStretch ();
-
-	for (int i = 0; i < RKObjectListViewSettings::SettingsCount; ++i) {
-		if (!checkboxes[i]) continue;   // We don't provide checkboxes for all settings in this list
-		checkboxes[i]->setChecked (settings[i]);
-		connect (checkboxes[i], SIGNAL (stateChanged(int)), this, SLOT (boxChanged(int)));
-	}
+	// Note: Up to RKWard 0.6.3, this settings module had a lot of additional checkboxes. Since 0.6.4, most settings are stored, implictily,
+	//       i.e. the Workspace Browser tool window "remembers" its latest settings (and so does the Varselector, separately). This modules
+	//       is still responsible to storing / loading settings.
 
 	blacklist_choser = new MultiStringSelector (i18n ("Never fetch the structure of these packages:"), this);
 	blacklist_choser->setValues (getstructure_blacklist);
@@ -82,9 +59,15 @@ RKSettingsModuleObjectBrowser::~RKSettingsModuleObjectBrowser () {
 }
 
 //static
-bool RKSettingsModuleObjectBrowser::isSettingActive (RKObjectListViewSettings::Settings setting) {
+void RKSettingsModuleObjectBrowser::setDefaultForWorkspace (RKObjectListViewSettings::PersistentSettings setting, bool state) {
+	RK_TRACE (SETTINGS);
+	workspace_settings[setting] = state;
+}
+
+//static
+void RKSettingsModuleObjectBrowser::setDefaultForVarselector (RKObjectListViewSettings::PersistentSettings setting, bool state) {
 	RK_TRACE (SETTINGS);
-	return settings[setting];
+	varselector_settings[setting] = state;
 }
 
 //static
@@ -102,9 +85,6 @@ void RKSettingsModuleObjectBrowser::addBlackList (QStringList *string_list) {
 void RKSettingsModuleObjectBrowser::applyChanges () {
 	RK_TRACE (SETTINGS);
 
-	for (int i = 0; i < RKObjectListViewSettings::SettingsCount; ++i) {
-		if (checkboxes[i]) settings[i] = checkboxes[i]->isChecked ();
-	}
 	getstructure_blacklist = blacklist_choser->getValues();
 }
 
@@ -118,34 +98,42 @@ QString RKSettingsModuleObjectBrowser::caption () {
 	return (i18n ("Workspace"));
 }
 
-//static
-void RKSettingsModuleObjectBrowser::saveSettings (KConfig *config) {
-	RK_TRACE (SETTINGS);
-
-	KConfigGroup cg = config->group ("Object Browser");
+void writeSettings (KConfigGroup &cg, bool *settings) {
 	cg.writeEntry ("show hidden vars", settings[RKObjectListViewSettings::ShowObjectsHidden]);
 	cg.writeEntry ("show label field", settings[RKObjectListViewSettings::ShowFieldsLabel]);
 	cg.writeEntry ("show type field", settings[RKObjectListViewSettings::ShowFieldsType]);
 	cg.writeEntry ("show class field", settings[RKObjectListViewSettings::ShowFieldsClass]);
-
-	cg.writeEntry ("package blacklist", getstructure_blacklist);
 }
 
 //static
-void RKSettingsModuleObjectBrowser::loadSettings (KConfig *config) {
+void RKSettingsModuleObjectBrowser::saveSettings (KConfig *config) {
 	RK_TRACE (SETTINGS);
 
 	KConfigGroup cg = config->group ("Object Browser");
-	// The following are _not_ actually configurable defaults in RKWard 0.6.4. These settings here simply serve to define the static default.
-	// TODO: That is just plain wrong. Move them to RObjectListViewSettings, exclusively.
-	settings[RKObjectListViewSettings::ShowObjectsAllEnvironments] = true;
-	// These defaults _are_ configurable
+	cg.writeEntry ("package blacklist", getstructure_blacklist);
+
+	KConfigGroup toolgroup = cg.group ("Tool window");
+	writeSettings (toolgroup, workspace_settings);
+	KConfigGroup varselgroup = cg.group ("Varselector");
+	writeSettings (varselgroup, varselector_settings);
+}
+
+void readSettings (const KConfigGroup &cg, bool *settings) {
 	settings[RKObjectListViewSettings::ShowObjectsHidden] = cg.readEntry ("show hidden vars", false);
 	settings[RKObjectListViewSettings::ShowFieldsLabel] = cg.readEntry ("show label field", true);
 	settings[RKObjectListViewSettings::ShowFieldsType] = cg.readEntry ("show type field", true);
 	settings[RKObjectListViewSettings::ShowFieldsClass] = cg.readEntry ("show class field", true);
+}
 
+//static
+void RKSettingsModuleObjectBrowser::loadSettings (KConfig *config) {
+	RK_TRACE (SETTINGS);
+
+	KConfigGroup cg = config->group ("Object Browser");
 	getstructure_blacklist = cg.readEntry ("package blacklist", QStringList ("GO"));
+
+	readSettings (cg.group ("Tool window"), workspace_settings);
+	readSettings (cg.group ("Varselector"), varselector_settings);
 }
 
 void RKSettingsModuleObjectBrowser::boxChanged (int) {
diff --git a/rkward/settings/rksettingsmoduleobjectbrowser.h b/rkward/settings/rksettingsmoduleobjectbrowser.h
index 002e64c..6e6b9ef 100644
--- a/rkward/settings/rksettingsmoduleobjectbrowser.h
+++ b/rkward/settings/rksettingsmoduleobjectbrowser.h
@@ -2,7 +2,7 @@
                           rksettingsmodule  -  description
                              -------------------
     begin                : Fri Apr 22 2005
-    copyright            : (C) 2005 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2015 by Thomas Friedrichsmeier
     email                : thomas.friedrichsmeier at kdemail.net
  ***************************************************************************/
 
@@ -48,7 +48,10 @@ public:
 	static void saveSettings (KConfig *config);
 	static void loadSettings (KConfig *config);
 
-	static bool isSettingActive (RKObjectListViewSettings::Settings setting);
+	static bool isDefaultForWorkspace (RKObjectListViewSettings::PersistentSettings setting) { return workspace_settings[setting]; };
+	static bool isDefaultForVarselector (RKObjectListViewSettings::PersistentSettings setting) { return varselector_settings[setting]; };
+	static void setDefaultForWorkspace (RKObjectListViewSettings::PersistentSettings setting, bool state);
+	static void setDefaultForVarselector (RKObjectListViewSettings::PersistentSettings setting, bool state);
 
 	static bool isPackageBlacklisted (const QString &package_name);
 
@@ -62,8 +65,8 @@ private:
 	MultiStringSelector *blacklist_choser;
 	static QStringList getstructure_blacklist;
 
-	QCheckBox *checkboxes[RKObjectListViewSettings::SettingsCount];
-	static bool settings[RKObjectListViewSettings::SettingsCount];
+	static bool workspace_settings[RKObjectListViewSettings::SettingsCount];
+	static bool varselector_settings[RKObjectListViewSettings::SettingsCount];
 };
 
 #endif
diff --git a/rkward/windows/robjectbrowser.cpp b/rkward/windows/robjectbrowser.cpp
index 0041a48..b4353ed 100644
--- a/rkward/windows/robjectbrowser.cpp
+++ b/rkward/windows/robjectbrowser.cpp
@@ -107,7 +107,7 @@ RObjectBrowserInternal::RObjectBrowserInternal (QWidget *parent) : QWidget (pare
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	list_view = new RKObjectListView (this);
+	list_view = new RKObjectListView (true, this);
 	vbox->addWidget (list_view->getSettings ()->filterWidget (this));
 	vbox->addWidget (list_view);
 



More information about the rkward-tracker mailing list