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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Nov 4 16:02:14 UTC 2007


Revision: 2167
          http://rkward.svn.sourceforge.net/rkward/?rev=2167&view=rev
Author:   tfry
Date:     2007-11-04 08:02:13 -0800 (Sun, 04 Nov 2007)

Log Message:
-----------
Objectlist view cleanups

Modified Paths:
--------------
    branches/KDE4_port/rkward/core/rkmodificationtracker.cpp
    branches/KDE4_port/rkward/core/rkmodificationtracker.h
    branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
    branches/KDE4_port/rkward/misc/rkobjectlistview.h
    branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp
    branches/KDE4_port/rkward/plugin/rkcomponentproperties.h
    branches/KDE4_port/rkward/plugin/rkvarselector.cpp
    branches/KDE4_port/rkward/plugin/rkvarselector.h

Modified: branches/KDE4_port/rkward/core/rkmodificationtracker.cpp
===================================================================
--- branches/KDE4_port/rkward/core/rkmodificationtracker.cpp	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/core/rkmodificationtracker.cpp	2007-11-04 16:02:13 UTC (rev 2167)
@@ -38,6 +38,16 @@
 	RK_TRACE (OBJECTS);
 }
 
+void RKModificationTracker::lockUpdates (bool lock) {
+	RK_TRACE (OBJECTS);
+
+	if (lock) ++updates_locked;
+	else {
+		--updates_locked;
+		RK_ASSERT (updates_locked >= 0);
+	}
+}
+
 bool RKModificationTracker::removeObject (RObject *object, RKEditor *editor, bool removed_in_workspace) {
 	RK_TRACE (OBJECTS);
 // TODO: allow more than one editor per object
@@ -77,7 +87,7 @@
 	RK_ASSERT (object);
 	RK_ASSERT (object->getContainer ());
 
-	if (updates_locked <= 0) {
+	if (!updates_locked) {
 		QModelIndex object_index = indexFor (object->getContainer ());
 		int object_row = object->getContainer ()->getIndexOf (object);
 		RK_ASSERT (object_row >= 0);
@@ -101,12 +111,12 @@
 		}
 	}
 
-	if (updates_locked <= 0) emit (objectRemoved (object));
+	if (!updates_locked) emit (objectRemoved (object));
 
 	if (delete_obj) object->remove (removed_in_workspace);
 	else object->getContainer ()->removeChildNoDelete (object);
 
-	if (updates_locked <= 0) endRemoveRows ();
+	if (!updates_locked) endRemoveRows ();
 }
 
 void RKModificationTracker::renameObject (RObject *object, const QString &new_name) {
@@ -120,7 +130,7 @@
 // since we may end up with a different name that originally requested, we propagate the change also to the original editor
 	if (ed) ed->renameObject (object);
 
-	if (updates_locked <= 0) {
+	if (!updates_locked) {
 		emit (objectPropertiesChanged (object));
 
 		QModelIndex object_index = indexFor (object);
@@ -131,7 +141,7 @@
 void RKModificationTracker::addObject (RObject *object, RContainerObject* parent, int position, RKEditor *editor) {
 	RK_TRACE (OBJECTS);
 
-	if (updates_locked <= 0) {
+	if (!updates_locked) {
 		QModelIndex parent_index = indexFor (parent);
 		beginInsertRows (parent_index, position, position);
 	}
@@ -149,7 +159,7 @@
 		}
 	}
 
-	if (updates_locked <= 0) {
+	if (!updates_locked) {
 		emit (objectAdded (object));
 		endInsertRows ();
 	}
@@ -164,7 +174,7 @@
 		ed->updateObjectMeta (object);
 	}
 
-	if (updates_locked <= 0) {
+	if (!updates_locked) {
 		emit (objectPropertiesChanged (object));
 
 		QModelIndex object_index = indexFor (object);
@@ -183,7 +193,7 @@
 
 	delete changes;
 
-	if (updates_locked <= 0) {
+	if (!updates_locked) {
 		QModelIndex object_index = indexFor (object);
 		emit (dataChanged (object_index, object_index));
 	}

Modified: branches/KDE4_port/rkward/core/rkmodificationtracker.h
===================================================================
--- branches/KDE4_port/rkward/core/rkmodificationtracker.h	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/core/rkmodificationtracker.h	2007-11-04 16:02:13 UTC (rev 2167)
@@ -73,7 +73,7 @@
 /** the object's data was modified. Tells all editors and lists containing the object to update accordingly. The ChangeSet given tells which parts of the data have to be updated. The ChangeSet will get deleted by the RKModificationTracker, when done. */
 	void objectDataChanged (RObject *object, RObject::ChangeSet *changes);
 /** recursive! */
-	void lockUpdates (bool lock) { if (lock) ++updates_locked; else --updates_locked; };
+	void lockUpdates (bool lock);
 signals:
 /** classes which are not RKEditor(s) but need to know, when an object was removed, should connect to this signal */
 	void objectRemoved (RObject *object);

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-11-04 16:02:13 UTC (rev 2167)
@@ -47,9 +47,6 @@
 	menu->insertItem (i18n ("Show Fields"), settings->showFieldsMenu ());
 	menu->insertItem (i18n ("Configure Defaults"), this, SLOT (popupConfigure ()));
 
-// KDE4: do we need this?
-//	setShowToolTips (false);
-
 	objectBrowserSettingsChanged ();
 }
 
@@ -71,6 +68,12 @@
 	}
 }
 
+void RKObjectListView::selectionChanged (const QItemSelection&, const QItemSelection&) {
+	RK_TRACE (APP);
+
+	emit (selectionChanged ());
+}
+
 RObject::ObjectList RKObjectListView::selectedObjects () const {
 	RK_TRACE (APP);
 
@@ -156,30 +159,16 @@
 	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&)));
 
-// KDE4 TODO: this signal needed?
-	emit (listChanged ());
-	changes = false;
 	updateComplete ();
 }
 
-void RKObjectListView::initializeLater () {
-	RK_TRACE (APP);
-
-// KDE4: TODO huh?
-	connect (RObjectList::getObjectList (), SIGNAL (updateComplete ()), this, SLOT (initialize ()));
-	updateStarted ();
-}
-
 void RKObjectListView::updateComplete () {
 	RK_TRACE (APP);
 
 	setEnabled (true);
 	update_in_progress = false;
-	if (changes) {
-		emit (listChanged ());
-		changes = false;
-	}
 }
 
 void RKObjectListView::updateStarted () {
@@ -189,20 +178,6 @@
 	update_in_progress = true;
 }
 
-/*
-//////////////////// RKListViewItem //////////////////////////
-int RKListViewItem::width (const QFontMetrics &fm, const Q3ListView * lv, int c) const {
-	if (parent ()) {
-		if (!parent ()->isOpen ()) {
-			return 0;
-		}
-	}
-
-	int ret = Q3ListViewItem::width (fm, lv, c);
-	if (ret > 200) return 200;
-	return ret;
-} */
-
 //////////////////// RKObjectListViewSettings //////////////////////////
 
 RKObjectListViewSettings::RKObjectListViewSettings () {

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-11-04 16:02:13 UTC (rev 2167)
@@ -42,8 +42,6 @@
 	
 	~RKObjectListView ();
 
-	void initializeLater ();
-
 /** This function returns a pointer to the context menu of the RKObjectListView. It is provided so you can add your own items.
 @returns a pointer to the context menu
 @see aboutToShowContextMenu */
@@ -59,7 +57,7 @@
 
 	RObject::ObjectList selectedObjects () const;
 signals:
-	void listChanged ();
+	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);
@@ -69,6 +67,7 @@
 
 	void updateComplete ();
 	void updateStarted ();
+	void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected);
 
 	void objectBrowserSettingsChanged ();
 
@@ -85,20 +84,6 @@
 	RKObjectListViewSettings *settings;
 };
 
-/** This subclass of RKListViewItem reimplements the width ()-function to return 0 if the item is not currently visible. This is needed to get a sane column width in the listview. Also limit maximum default width to 200 px (TODO: make this configurable)
-
- at author Thomas Friedrichsmeier
-*/
-/*
-class RKListViewItem : public Q3ListViewItem {
-public:
-	RKListViewItem (Q3ListView *parent) : Q3ListViewItem (parent) {};
-	RKListViewItem (Q3ListViewItem *parent) : Q3ListViewItem (parent) {};
-	~RKListViewItem () {};
-
-	int width (const QFontMetrics &fm, const Q3ListView * lv, int c) const;
-}; */
-
 /** Represents the filter/view settings possible for an RKListView. */
 class RKObjectListViewSettings : public QObject {
 	Q_OBJECT

Modified: branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp	2007-11-04 16:02:13 UTC (rev 2167)
@@ -935,17 +935,6 @@
 	}
 }
 
-void RKComponentPropertyRObjects::setFromListView (RKObjectListView *list_view, bool selected_only) {
-	RK_TRACE (PLUGIN);
-
-#warning KDE4 implement for selected_only==false
-//KDE4: TODO !selected_only
-// Or perhaps remove this parameter altogether? Looks like it is only needed for RKVarselector, and probably it
-// does not do much good, there.
-	// invalid objects will be ignored in setObjectList
-	setObjectList (list_view->selectedObjects ());
-}
-
 void RKComponentPropertyRObjects::objectPropertiesChanged (RObject *object) {
 	RK_TRACE (PLUGIN);
 

Modified: branches/KDE4_port/rkward/plugin/rkcomponentproperties.h
===================================================================
--- branches/KDE4_port/rkward/plugin/rkcomponentproperties.h	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/plugin/rkcomponentproperties.h	2007-11-04 16:02:13 UTC (rev 2167)
@@ -269,9 +269,6 @@
 	void connectToGovernor (RKComponentPropertyBase *governor, const QString &modifier=QString::null, bool reconcile_requirements=true);
 /** reimplemented from RKComponentPropertyBase to use special handling for object properties */
 	void governorValueChanged (RKComponentPropertyBase *property);
-/** fill this property with all objects shown in the given RKObjectListView. Emit a signal, if there was a change. Only valid objects are added!
- at param selected_only if true, only the currently selected objects are filled into this property */
-	void setFromListView (RKObjectListView *list_view, bool selected_only=false);
 /** @returns true, if the property holds the maximum number of items (or more) */
 	bool atMaxLength ();
 public slots:

Modified: branches/KDE4_port/rkward/plugin/rkvarselector.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkvarselector.cpp	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/plugin/rkvarselector.cpp	2007-11-04 16:02:13 UTC (rev 2167)
@@ -17,14 +17,10 @@
 
 #include "rkvarselector.h"
 
-#include <qlayout.h>
+#include <QVBoxLayout>
 #include <qlabel.h>
-//Added by qt3to4:
-#include <Q3VBoxLayout>
 
 #include "../misc/xmlhelper.h"
-#include "../core/rcontainerobject.h"
-#include "../core/rkvariable.h"
 #include "../rkglobals.h"
 #include "../misc/rkobjectlistview.h"
 #include "../core/robjectlist.h"
@@ -35,17 +31,16 @@
 	RK_TRACE (PLUGIN);
 
 // TODO: read filter settings
-	addChild ("available", available = new RKComponentPropertyRObjects (this, false));
 	addChild ("selected", selected = new RKComponentPropertyRObjects (this, false));
 
-	Q3VBoxLayout  *vbox = new Q3VBoxLayout (this, RKGlobals::spacingHint ());
+	QVBoxLayout *vbox = new QVBoxLayout (this);
+	vbox->setContentsMargins (0, 0, 0, 0);
 	
 	QLabel *label = new QLabel (element.attribute ("label", "Select Variable(s)"), this);
 	vbox->addWidget (label);
 
 	list_view = new RKObjectListView (this);
 	list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
-	connect (list_view, SIGNAL (listChanged ()), this, SLOT (objectListChanged ()));
 	connect (list_view, SIGNAL (selectionChanged ()), this, SLOT (objectSelectionChanged ()));
 
 	vbox->addWidget (list_view);
@@ -57,17 +52,10 @@
 	RK_TRACE (PLUGIN);
 }
 
-void RKVarSelector::objectListChanged () {
-	RK_TRACE (PLUGIN);
-
-	available->setFromListView (list_view);
-	selected->setFromListView (list_view, true);
-}
-
 void RKVarSelector::objectSelectionChanged () {
 	RK_TRACE (PLUGIN);
 
-	selected->setFromListView (list_view, true);
+	selected->setObjectList (list_view->selectedObjects ());
 	RK_DO (qDebug ("selected in varselector: %s", selected->value ().toLatin1 ().data ()), PLUGIN, DL_DEBUG);
 }
 

Modified: branches/KDE4_port/rkward/plugin/rkvarselector.h
===================================================================
--- branches/KDE4_port/rkward/plugin/rkvarselector.h	2007-11-03 17:50:18 UTC (rev 2166)
+++ branches/KDE4_port/rkward/plugin/rkvarselector.h	2007-11-04 16:02:13 UTC (rev 2167)
@@ -35,18 +35,16 @@
 
 
 class RKVarSelector : public RKComponent {
-   Q_OBJECT
+	Q_OBJECT
 public: 
 	RKVarSelector (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKVarSelector ();
 	int type () { return ComponentVarSelector; };
 public slots:
-	void objectListChanged ();
 	void objectSelectionChanged ();
 private:
 	RKObjectListView *list_view;
 	RKComponentPropertyRObjects *selected;
-	RKComponentPropertyRObjects *available;
 };
 
 #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