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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Nov 4 20:20:45 UTC 2007


Revision: 2174
          http://rkward.svn.sourceforge.net/rkward/?rev=2174&view=rev
Author:   tfry
Date:     2007-11-04 12:20:45 -0800 (Sun, 04 Nov 2007)

Log Message:
-----------
More cleanups and Qt3 support code removals

Modified Paths:
--------------
    branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
    branches/KDE4_port/rkward/misc/rkobjectlistview.h
    branches/KDE4_port/rkward/plugin/rkvarselector.cpp
    branches/KDE4_port/rkward/robjectbrowser.cpp
    branches/KDE4_port/rkward/robjectbrowser.h

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-11-04 19:54:57 UTC (rev 2173)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-11-04 20:20:45 UTC (rev 2174)
@@ -18,8 +18,9 @@
 
 #include <klocale.h>
 
-#include <QHelpEvent>
+#include <QContextMenuEvent>
 #include <QMenu>
+#include <QTimer>
 
 #include "../rkglobals.h"
 #include "../core/robjectlist.h"
@@ -61,6 +62,12 @@
 	}
 }
 
+RObject* RKObjectListView::objectAtIndex (const QModelIndex& index) const {
+	RK_TRACE (APP);
+
+	return static_cast<RObject*> (settings->mapToSource (index).internalPointer ());
+}
+
 void RKObjectListView::selectionChanged (const QItemSelection&, const QItemSelection&) {
 	RK_TRACE (APP);
 
@@ -91,9 +98,7 @@
 void RKObjectListView::contextMenuEvent (QContextMenuEvent* event) {
 	RK_TRACE (APP);
 
-	QModelIndex index = settings->mapToSource (indexAt (event->pos ()));
-	menu_object = static_cast<RObject*> (index.internalPointer ());
-
+	menu_object = objectAtIndex (indexAt (event->pos ()));
 	bool suppress = false;
 	emit (aboutToShowContextMenu (menu_object, &suppress));
 
@@ -116,7 +121,6 @@
 	resizeColumnToContents (0);
 
 	connect (RObjectList::getObjectList (), SIGNAL (updateComplete ()), this, SLOT (updateComplete ()));
-	disconnect (RObjectList::getObjectList (), SIGNAL (updateComplete ()), this, SLOT (initialize ()));
 	connect (RObjectList::getObjectList (), SIGNAL (updateStarted ()), this, SLOT (updateStarted ()));
 	connect (selectionModel (), SIGNAL (selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT (selectionChanged(const QItemSelection&, const QItemSelection&)));
 
@@ -140,10 +144,31 @@
 RKObjectListViewSettings::RKObjectListViewSettings (QObject* parent) : QSortFilterProxyModel (parent) {
 	RK_TRACE (APP);
 
-	for (int i = 0; i < SettingsCount; ++i) settings_default[i] = true;
+	update_timer = new QTimer (this);
+	update_timer->setSingleShot (true);
+	connect (update_timer, SIGNAL(timeout()), this, SLOT(updateSelfNow()));
+
 	connect (RKSettings::tracker (), SIGNAL (settingsChanged (RKSettings::SettingsPage)), this, SLOT (globalSettingsChanged (RKSettings::SettingsPage)));
 
+	action_group = new QActionGroup (this);
+	action_group->setExclusive (false);
+	actions[ShowObjectsAllEnvironments] = new QAction (i18n ("All Environments"), action_group);
+	actions[ShowObjectsContainer] = new QAction (i18n ("Objects with children"), action_group);
+	actions[ShowObjectsVariable] = new QAction (i18n ("Variables"), action_group);
+	actions[ShowObjectsFunction] = new QAction (i18n ("Functions"), action_group);
+	actions[ShowObjectsHidden] = new QAction (i18n ("Hidden Objects"), action_group);
+	actions[ShowFieldsType] = new QAction (i18n ("Type"), action_group);
+	actions[ShowFieldsLabel] = new QAction (i18n ("Label"), action_group);
+	actions[ShowFieldsClass] = new QAction (i18n ("Class"), action_group);
+
+	for (int i = 0; i < SettingsCount; ++i) {
+		actions[i]->setCheckable (true);
+		settings_default[i] = true;
+	}
+
 	createContextMenus ();
+
+	// initialize the settings states
 	globalSettingsChanged (RKSettings::PageObjectBrowser);
 }
 
@@ -154,7 +179,7 @@
 	delete show_objects_menu;
 }
 
-void RKObjectListViewSettings::setSetting (Settings setting, State to) {
+void RKObjectListViewSettings::setSetting (Settings setting, bool to) {
 	RK_TRACE (APP);
 
 	settings[setting] = to;
@@ -163,25 +188,13 @@
 	updateSelf ();
 }
 
-RKObjectListViewSettings::State RKObjectListViewSettings::getSetting (Settings setting) {
-	RK_TRACE (APP);
-
-	return (settings[setting]);
-}
-
-bool RKObjectListViewSettings::settingActive (Settings setting) {
-	RK_TRACE (APP);
-
-	return (settings[setting] >= Yes);
-}
-
 bool RKObjectListViewSettings::filterAcceptsColumn (int source_column, const QModelIndex&) const {
 	RK_TRACE (APP);
 
 	if (source_column == RKObjectListModel::NameColumn) return true;
-	if (source_column == RKObjectListModel::LabelColumn) return (settings[ShowFieldsLabel] >= Yes);
-	if (source_column == RKObjectListModel::TypeColumn) return (settings[ShowFieldsType] >= Yes);
-	if (source_column == RKObjectListModel::ClassColumn) return (settings[ShowFieldsClass] >= Yes);
+	if (source_column == RKObjectListModel::LabelColumn) return (settings[ShowFieldsLabel]);
+	if (source_column == RKObjectListModel::TypeColumn) return (settings[ShowFieldsType]);
+	if (source_column == RKObjectListModel::ClassColumn) return (settings[ShowFieldsClass]);
 
 	RK_ASSERT (false);
 	return false;
@@ -201,20 +214,20 @@
 	// always show the global env
 	if (object->isType (RObject::GlobalEnv)) return true;
 
-	if (settings[ShowObjectsHidden] <= No) {
+	if (!settings[ShowObjectsHidden]) {
 		if (object->getShortName ().startsWith ('.')) return false;
 	}
 
 	bool base_filter = QSortFilterProxyModel::filterAcceptsRow (source_row, source_parent);
 
 	if (object->isType (RObject::ToplevelEnv)) {
-		return (base_filter && (settings[ShowObjectsAllEnvironments] >= Yes));
+		return (base_filter && settings[ShowObjectsAllEnvironments]);
 	} else if (object->isType (RObject::Function)) {
-		return (base_filter && (settings[ShowObjectsFunction] >= Yes));
+		return (base_filter && settings[ShowObjectsFunction]);
 	} else if (object->isType (RObject::Container)) {
-		return (base_filter && (settings[ShowObjectsContainer] >= Yes));
+		return (base_filter && settings[ShowObjectsContainer]);
 	} else if (object->isVariable ()) {
-		return (base_filter && (settings[ShowObjectsVariable] >= Yes));
+		return (base_filter && settings[ShowObjectsVariable]);
 	}
 
 	return base_filter;
@@ -243,18 +256,6 @@
 void RKObjectListViewSettings::createContextMenus () {
 	RK_TRACE (APP);
 
-	action_group = new QActionGroup (this);
-	action_group->setExclusive (false);
-	actions[ShowObjectsAllEnvironments] = new QAction (i18n ("All Environments"), action_group);
-	actions[ShowObjectsContainer] = new QAction (i18n ("Objects with children"), action_group);
-	actions[ShowObjectsVariable] = new QAction (i18n ("Variables"), action_group);
-	actions[ShowObjectsFunction] = new QAction (i18n ("Functions"), action_group);
-	actions[ShowObjectsHidden] = new QAction (i18n ("Hidden Objects"), action_group);
-	actions[ShowFieldsType] = new QAction (i18n ("Type"), action_group);
-	actions[ShowFieldsLabel] = new QAction (i18n ("Label"), action_group);
-	actions[ShowFieldsClass] = new QAction (i18n ("Class"), action_group);
-	for (int i = 0; i < SettingsCount; ++i) actions[i]->setCheckable (true);
-
 	show_objects_menu = new QMenu (i18n ("Show Objects"), 0);
 	show_objects_menu->addAction (actions[ShowObjectsAllEnvironments]);
 	show_objects_menu->addAction (actions[ShowObjectsContainer]);
@@ -275,21 +276,16 @@
 void RKObjectListViewSettings::updateSelf () {
 	RK_TRACE (APP);
 
-	for (int i = 0; i < SettingsCount; ++i) {
-		actions[i]->setChecked (settings[(Settings) i] >= Yes);
-		actions[i]->setEnabled (optionConfigurable ((Settings) i));
-	}
-
-	invalidateFilter ();
+	update_timer->start (0);
 	emit (settingsChanged ());
 }
 
-void RKObjectListViewSettings::insertPopupItem (QMenu *menu, Settings setting, const QString &text) {
+void RKObjectListViewSettings::updateSelfNow () {
 	RK_TRACE (APP);
 
-	menu->insertItem (text, setting);
-	menu->setItemParameter (setting, setting);
-	menu->connectItem (setting, this, SLOT (toggleSetting (int)));
+	for (int i = 0; i < SettingsCount; ++i) actions[i]->setChecked (settings[i]);
+
+	invalidateFilter ();
 }
 
 void RKObjectListViewSettings::globalSettingsChanged (RKSettings::SettingsPage page) {
@@ -298,9 +294,8 @@
 	RK_TRACE (APP);
 
 	for (int i = 0; i < SettingsCount; ++i) {
-		if (settings_default[i]) {
-			if (RKSettingsModuleObjectBrowser::isSettingActive ((Settings) i)) settings[i] = Yes;
-			else settings[i] = No;
+		if (settings_default[i]) {	// should only default settings be copied?
+			settings[i] = RKSettingsModuleObjectBrowser::isSettingActive ((Settings) i);
 		}
 	}
 
@@ -322,15 +317,7 @@
 		return;
 	}
 
-	setSetting (static_cast<Settings> (setting), which->isChecked () ? Yes : No);
+	setSetting (static_cast<Settings> (setting), which->isChecked ());
 }
 
-bool RKObjectListViewSettings::optionConfigurable (Settings setting) {
-	RK_TRACE (APP);
-
-	if (settings[setting] == Always) return false;
-	if (settings[setting] == Never) return false;
-	return true;
-}
-
 #include "rkobjectlistview.moc"

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-11-04 19:54:57 UTC (rev 2173)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-11-04 20:20:45 UTC (rev 2174)
@@ -27,6 +27,7 @@
 class RKListViewItem;
 class RKObjectListViewSettings;
 class QActionGroup;
+class QTimer;
 
 /**
 This class provides the common functionality for the tree views in the RObjectBrowser and RKVarselector(s). The caps it (will) provide are: keeping the list up to date and emitting change-signals when appropriate, filtering for certain types of objects, sorting, mapping items to objects. Maybe some GUI-stuff like popup-menus should also be added to this class?
@@ -54,15 +55,16 @@
 	void setObjectCurrent (RObject *object, bool only_if_none_current=false);
 
 	RObject::ObjectList selectedObjects () const;
+
+	RObject* objectAtIndex (const QModelIndex& index) const;
+/** Takes care initializing the RKObjectListView */
+	void initialize ();
 signals:
 	void selectionChanged ();
 /** This signal is emitted just before the context-menu is shown. If you connect to this signal, you can make some adjustments to the context-menu.
 If you set *suppress to true, showing the context menu will be suppressed. */
 	void aboutToShowContextMenu (RObject *object, bool *suppress);
 public slots:
-/** Takes care initializing the RKObjectListView (delayed, as the RObjectList may not have been created, yet) and of getting the current list of objects from the RObjectList */
-	void initialize ();
-
 	void updateComplete ();
 	void updateStarted ();
 	void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
@@ -77,7 +79,7 @@
 	RKObjectListViewSettings *settings;
 };
 
-/** Represents the filter/view settings possible for an RKListView. */
+/** Does filtering for an RKObjectListView. Should probably be renamed to RKObjectListViewFilter */
 class RKObjectListViewSettings : public QSortFilterProxyModel {
 	Q_OBJECT
 public:
@@ -97,44 +99,34 @@
 		SettingsCount=ShowFieldsLabel + 1
 	};
 
-	//KDE 4: TODO: do we really need non-configurable settings? Changing this to only Yes/No would allow
-	// for considerable simplifications
-	enum State {
-		Never,
-		No,
-		Yes,
-		Always
-	};
+	void setSetting (Settings setting, bool to);
+	bool getSetting (Settings setting) const { return settings[setting]; };
 
-	void setSetting (Settings setting, State to);
-	State getSetting (Settings setting);
-	bool settingActive (Settings setting);
-	bool optionConfigurable (Settings setting);
-
-	bool shouldShowObject (RObject *object);
-
-	QMenu *showObjectsMenu () { return show_objects_menu; };
-	QMenu *showFieldsMenu () { return show_fields_menu; };
+	QMenu *showObjectsMenu () const { return show_objects_menu; };
+	QMenu *showFieldsMenu () const { return show_fields_menu; };
 signals:
 	void settingsChanged ();
 public slots:
 	void globalSettingsChanged (RKSettings::SettingsPage);
 	void settingToggled (QAction* which);
+	void updateSelfNow ();
 protected:
 	bool filterAcceptsRow (int source_row, const QModelIndex& source_parent) const;
 	bool filterAcceptsColumn (int source_column, const QModelIndex& source_parent) const;
 	bool lessThan (const QModelIndex& left, const QModelIndex& right) const;
 private:
-	State settings[SettingsCount];
+	bool settings[SettingsCount];
+	bool settings_default[SettingsCount];
 	QAction* actions[SettingsCount];
 	QActionGroup* action_group;
-	bool settings_default[SettingsCount];
-	void insertPopupItem (QMenu *menu, Settings setting, const QString &text);
+
 	void createContextMenus ();
 	void updateSelf ();
 
 	QMenu *show_objects_menu;
 	QMenu *show_fields_menu;
+
+	QTimer *update_timer;
 };
 
 #endif

Modified: branches/KDE4_port/rkward/plugin/rkvarselector.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkvarselector.cpp	2007-11-04 19:54:57 UTC (rev 2173)
+++ branches/KDE4_port/rkward/plugin/rkvarselector.cpp	2007-11-04 20:20:45 UTC (rev 2174)
@@ -44,7 +44,7 @@
 	connect (list_view, SIGNAL (selectionChanged ()), this, SLOT (objectSelectionChanged ()));
 
 	vbox->addWidget (list_view);
-	list_view->getSettings ()->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, RKObjectListViewSettings::No);
+	list_view->getSettings ()->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, false);
 	list_view->initialize ();
 }
 

Modified: branches/KDE4_port/rkward/robjectbrowser.cpp
===================================================================
--- branches/KDE4_port/rkward/robjectbrowser.cpp	2007-11-04 19:54:57 UTC (rev 2173)
+++ branches/KDE4_port/rkward/robjectbrowser.cpp	2007-11-04 20:20:45 UTC (rev 2174)
@@ -17,17 +17,14 @@
 #include "robjectbrowser.h"
 
 #include <qlayout.h>
-#include <q3listview.h>
 #include <qpushbutton.h>
-#include <q3popupmenu.h>
 #include <qcheckbox.h>
 #include <qradiobutton.h>
-#include <q3buttongroup.h>
-#include <q3vbox.h>
-//Added by qt3to4:
-#include <Q3HBoxLayout>
+#include <QHBoxLayout>
 #include <QFocusEvent>
-#include <Q3VBoxLayout>
+#include <QVBoxLayout>
+#include <QMenu>
+#include <QGroupBox>
 
 #include <klocale.h>
 #include <kinputdialog.h>
@@ -108,7 +105,8 @@
 	RK_TRACE (APP);
 	setFocusPolicy (Qt::ClickFocus);
 
-	Q3VBoxLayout *vbox = new Q3VBoxLayout (this);
+	QVBoxLayout *vbox = new QVBoxLayout (this);
+	vbox->setContentsMargins (0, 0, 0, 0);
 
 	list_view = new RKObjectListView (this);
 	vbox->addWidget (new RKObjectListViewSettingsWidget (list_view->getSettings (), this));
@@ -119,15 +117,24 @@
 	
 	setCaption (i18n ("Objects in the R workspace"));
 
-// KDE4: TODO: insertItem is Qt3. Use addAction instead.
-	list_view->contextMenu ()->insertItem (i18n ("Search Help"), this, SLOT (popupHelp ()), 0, Help, 0);
-	list_view->contextMenu ()->insertItem (i18n ("Edit"), this, SLOT (popupEdit ()), 0, Edit, 1);
-	list_view->contextMenu ()->insertItem (i18n ("View"), this, SLOT (popupView ()), 0, View, 2);
-	list_view->contextMenu ()->insertItem (i18n ("Rename"), this, SLOT (popupRename ()), 0, Rename, 3);
-	list_view->contextMenu ()->insertItem (i18n ("Copy to new symbol"), this, SLOT (popupCopy ()), 0, Copy, 4);
-	list_view->contextMenu ()->insertItem (i18n ("Copy to .GlobalEnv"), this, SLOT (popupCopyToGlobalEnv ()), 0, CopyToGlobalEnv, 5);
-	list_view->contextMenu ()->insertItem (i18n ("Delete"), this, SLOT (popupDelete ()), 0, Delete, 6);
-	list_view->contextMenu ()->insertSeparator (7);
+	actions.insert (Help, new QAction (i18n ("Search Help"), this));
+	connect (actions[Help], SIGNAL(triggered(bool)), this, SLOT(popupHelp()));
+	actions.insert (Edit, new QAction (i18n ("Edit"), this));
+	connect (actions[Edit], SIGNAL(triggered(bool)), this, SLOT(popupEdit()));
+	actions.insert (View, new QAction (i18n ("View"), this));
+	connect (actions[View], SIGNAL(triggered(bool)), this, SLOT(popupView()));
+	actions.insert (Rename, new QAction (i18n ("Rename"), this));
+	connect (actions[Rename], SIGNAL(triggered(bool)), this, SLOT(popupRename()));
+	actions.insert (Copy, new QAction (i18n ("Copy to new symbol"), this));
+	connect (actions[Copy], SIGNAL(triggered(bool)), this, SLOT(popupCopy()));
+	actions.insert (CopyToGlobalEnv, new QAction (i18n ("Copy to .GlobalEnv"), this));
+	connect (actions[CopyToGlobalEnv], SIGNAL(triggered(bool)), this, SLOT(popupCopyToGlobalEnv()));
+	actions.insert (Delete, new QAction (i18n ("Delete"), this));
+	connect (actions[Delete], SIGNAL(triggered(bool)), this, SLOT(popupDelete()));
+
+	QAction* sep = list_view->contextMenu ()->insertSeparator (list_view->contextMenu ()->actions ().value (0));
+	list_view->contextMenu ()->insertActions (sep, actions);
+
 	connect (list_view, SIGNAL (aboutToShowContextMenu (RObject *, bool*)), this, SLOT (contextMenuCallback (RObject*, bool*)));
 	
 	connect (list_view, SIGNAL (doubleClicked(const QModelIndex&)), this, SLOT (doubleClicked(const QModelIndex&)));
@@ -219,35 +226,32 @@
 void RObjectBrowserInternal::contextMenuCallback (RObject *, bool *) {
 	RK_TRACE (APP);
 	RObject *object = list_view->menuObject ();
-	QMenu *menu = list_view->contextMenu ();
 
 	if (!object) {
-		menu->setItemVisible (Help, false);
-		menu->setItemVisible (Edit, false);
-		menu->setItemVisible (View, false);
-		menu->setItemVisible (Rename, false);
-		menu->setItemVisible (Copy, false);
-		menu->setItemVisible (CopyToGlobalEnv, false);
-		menu->setItemVisible (Delete, false);
-
+		RK_ASSERT (actions.size () == ActionCount);
+		for (int i = 0; i < ActionCount; ++i) {
+			actions[i]->setVisible (false);
+		}
 		return;
 	}
 
-	menu->setItemVisible (Help, !(object->isType (RObject::ToplevelEnv) || object->isInGlobalEnv ()));
-	menu->setItemVisible (Edit, object->canEdit () && RKWorkplace::mainWorkplace ()->canEditObject (object));
-	menu->setItemVisible (View, object->canRead ());
-	menu->setItemVisible (Rename, object->canRename ());
-	menu->setItemVisible (Copy, object->canRead () && (!object->isType (RObject::ToplevelEnv)));
-	menu->setItemVisible (CopyToGlobalEnv, object->canRead () && (!object->isInGlobalEnv()) && (!object->isType (RObject::ToplevelEnv)));
-	menu->setItemVisible (Delete, object->canRemove ());
+	actions[Help]->setVisible (!(object->isType (RObject::ToplevelEnv) || object->isInGlobalEnv ()));
+	actions[Edit]->setVisible (object->canEdit () && RKWorkplace::mainWorkplace ()->canEditObject (object));
+	actions[View]->setVisible (object->canRead ());
+	actions[Rename]->setVisible (object->canRename ());
+	actions[Copy]->setVisible (object->canRead () && (!object->isType (RObject::ToplevelEnv)));
+	actions[CopyToGlobalEnv]->setVisible (object->canRead () && (!object->isInGlobalEnv()) && (!object->isType (RObject::ToplevelEnv)));
+	actions[Delete]->setVisible (object->canRemove ());
 }
 
 void RObjectBrowserInternal::doubleClicked (const QModelIndex& index) {
 	RK_TRACE (APP);
-	RObject *object = static_cast<RObject*> (index.internalPointer ());
-	
+
+	RObject *object = list_view->objectAtIndex (index);
 	if (!object) return;
 	if (object == RObjectList::getObjectList ()) return;
+
+#warning this will never work, as the object browser is active in this case!
 	QWidget *w = RKWorkplace::mainWorkplace ()->activeWindow (RKMDIWindow::Attached);
 	if (!w) return;
 
@@ -265,24 +269,29 @@
 	RKObjectListViewSettingsWidget::settings = settings;
 	connect (settings, SIGNAL (settingsChanged ()), this, SLOT (settingsChanged ()));
 
-	Q3VBoxLayout *layout = new Q3VBoxLayout (this);
-	group = new Q3ButtonGroup (this);
-	Q3HBoxLayout *grouplayout = new Q3HBoxLayout (group);
+	QVBoxLayout *layout = new QVBoxLayout (this);
+	layout->setContentsMargins (0, 0, 0, 0);
+
+	QGroupBox* group = new QGroupBox (this);
+	QHBoxLayout *grouplayout = new QHBoxLayout (group);
+	grouplayout->setContentsMargins (0, 0, 0, 0);
 	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)));
+	connect (all, SIGNAL(clicked(bool)), this, SLOT(modeChanged(bool)));
+	connect (nonfunctions, SIGNAL(clicked(bool)), this, SLOT(modeChanged(bool)));
+	connect (functions, SIGNAL(clicked(bool)), this, SLOT(modeChanged(bool)));
 	layout->addWidget (group);
 
 	all_envirs = new QCheckBox (i18n ("Show All Environments"), this);
-	connect (all_envirs, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
+	connect (all_envirs, SIGNAL (clicked(bool)), this, SLOT (boxChanged(bool)));
 	layout->addWidget (all_envirs);
 
 	hidden_objects = new QCheckBox (i18n ("Show Hidden Objects"), this);
-	connect (hidden_objects, SIGNAL (stateChanged (int)), this, SLOT (boxChanged (int)));
+	connect (hidden_objects, SIGNAL (clicked(bool)), this, SLOT (boxChanged(bool)));
 	layout->addWidget (hidden_objects);
 
 	settingsChanged ();
@@ -295,24 +304,13 @@
 void RKObjectListViewSettingsWidget::settingsChanged () {
 	RK_TRACE (APP);
 
-	all_envirs->setChecked (settings->settingActive (RKObjectListViewSettings::ShowObjectsAllEnvironments));
-	all_envirs->setEnabled (settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsAllEnvironments));
+	all_envirs->setChecked (settings->getSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments));
+	hidden_objects->setChecked (settings->getSetting (RKObjectListViewSettings::ShowObjectsHidden));
 
-	hidden_objects->setChecked (settings->settingActive (RKObjectListViewSettings::ShowObjectsHidden));
-	hidden_objects->setEnabled (settings->optionConfigurable (RKObjectListViewSettings::ShowObjectsHidden));
+	bool functions_shown = settings->getSetting (RKObjectListViewSettings::ShowObjectsFunction);
+	bool vars_shown = settings->getSetting (RKObjectListViewSettings::ShowObjectsVariable);
+	bool containers_shown = settings->getSetting (RKObjectListViewSettings::ShowObjectsContainer);
 
-	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) {
@@ -326,33 +324,33 @@
 	}
 }
 
-void RKObjectListViewSettingsWidget::modeActivated (int mode) {
+void RKObjectListViewSettingsWidget::modeChanged (bool) {
 	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);
+	if (all->isChecked ()) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsFunction, true);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsVariable, true);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsContainer, true);
+	} else if (functions->isChecked ()) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsFunction, true);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsVariable, false);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsContainer, false);
+	} else if (nonfunctions->isChecked ()) {
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsFunction, false);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsVariable, true);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsContainer, true);
 	} else {
 		RK_ASSERT (false);
 	}
 }
 
-void RKObjectListViewSettingsWidget::boxChanged (int) {
+void RKObjectListViewSettingsWidget::boxChanged (bool) {
 	RK_TRACE (APP);
 
 	if (sender () == all_envirs) {
-		settings->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, all_envirs->isChecked () ? RKObjectListViewSettings::Yes : RKObjectListViewSettings::No);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsAllEnvironments, all_envirs->isChecked ());
 	} else {
-		settings->setSetting (RKObjectListViewSettings::ShowObjectsHidden, hidden_objects->isChecked () ? RKObjectListViewSettings::Yes : RKObjectListViewSettings::No);
+		settings->setSetting (RKObjectListViewSettings::ShowObjectsHidden, hidden_objects->isChecked ());
 	}
 }
 

Modified: branches/KDE4_port/rkward/robjectbrowser.h
===================================================================
--- branches/KDE4_port/rkward/robjectbrowser.h	2007-11-04 19:54:57 UTC (rev 2173)
+++ branches/KDE4_port/rkward/robjectbrowser.h	2007-11-04 20:20:45 UTC (rev 2174)
@@ -21,17 +21,12 @@
 
 #include <QModelIndex>
 #include <QFocusEvent>
-//Added by qt3to4:
-#include <Q3PopupMenu>
 
 class RKObjectListView;
 class RKObjectListViewSettings;
-class Q3ListViewItem;
 class QPushButton;
 class QRadioButton;
-class Q3ButtonGroup;
 class QCheckBox;
-class Q3PopupMenu;
 class RObject;
 class RKCommandEditorWindow;
 class RObjectBrowserInternal;
@@ -72,8 +67,6 @@
 public:
 	RObjectBrowserInternal (QWidget *parent);
 	~RObjectBrowserInternal ();
-
-	enum PopupItems { Help=1, Edit=2, View=3, Rename=4, Copy=5, CopyToGlobalEnv=6, Delete=7 };
 private slots:
 	void updateButtonClicked ();
 	void contextMenuCallback (RObject *object, bool *suppress);
@@ -92,6 +85,18 @@
 /** reimplemnented from QWidget to make show the globalenv object when activated (other than by mouse click) */
 	void focusInEvent (QFocusEvent *e);
 private:
+	enum PopupActions {
+		Help=0,
+		Edit,
+		View,
+		Rename,
+		Copy,
+		CopyToGlobalEnv,
+		Delete,
+		ActionCount
+	};
+	QList<QAction*> actions;
+
 	QPushButton *update_button;
 	RKObjectListView *list_view;
 };
@@ -110,10 +115,9 @@
 	};
 public slots:
 	void settingsChanged ();
-	void modeActivated (int mode);
-	void boxChanged (int);
+	void modeChanged (bool);
+	void boxChanged (bool);
 private:
-	Q3ButtonGroup *group;
 	QRadioButton *all;
 	QRadioButton *nonfunctions;
 	QRadioButton *functions;


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