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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Nov 2 17:09:27 UTC 2007


Revision: 2165
          http://rkward.svn.sourceforge.net/rkward/?rev=2165&view=rev
Author:   tfry
Date:     2007-11-02 10:09:27 -0700 (Fri, 02 Nov 2007)

Log Message:
-----------
Port RKObjectListView to model/view architecture. This needs some more work on the details, but the basics work.

Modified Paths:
--------------
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/core/rkmodificationtracker.cpp
    branches/KDE4_port/rkward/core/rkmodificationtracker.h
    branches/KDE4_port/rkward/core/robject.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/rkformula.cpp
    branches/KDE4_port/rkward/plugin/rkvarselector.cpp
    branches/KDE4_port/rkward/plugin/rkvarslot.cpp
    branches/KDE4_port/rkward/robjectbrowser.cpp
    branches/KDE4_port/rkward/robjectbrowser.h

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/TODO_KDE4	2007-11-02 17:09:27 UTC (rev 2165)
@@ -37,6 +37,7 @@
 			- Can't do any thing about this. It part of the katepart.
 	- placement of menu options?
 	- F9 key seems to be occupied, now (by show/hide folding markers)
+		- perhaps switch to Shift+F7,8,9 for Run line, selection, all (do so globally!)
 
 rkward
 	- does closing windows work
@@ -101,7 +102,7 @@
 
 rkobjectlistview:
 	- do the tool-tips for the objects work?
-		-* not quite: tooltip of (i+1)-th object is shown at i-th position
+	- implement sorting / filtering
 
 rkconsole:
 	- check whether all selection, editing, navigating really works as expected

Modified: branches/KDE4_port/rkward/core/rkmodificationtracker.cpp
===================================================================
--- branches/KDE4_port/rkward/core/rkmodificationtracker.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/core/rkmodificationtracker.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -22,17 +22,18 @@
 #include "../rkglobals.h"
 #include "../dataeditor/rkeditor.h"
 #include "rcontainerobject.h"
+#include "robjectlist.h"
 #include "../windows/rkworkplace.h"
+#include "../misc/rkstandardicons.h"
 
 #include "../debug.h"
 
-RKModificationTracker::RKModificationTracker (QObject *parent) : QObject (parent) {
+RKModificationTracker::RKModificationTracker (QObject *parent) : RKObjectListModel (parent) {
 	RK_TRACE (OBJECTS);
 
 	updates_locked = 0;
 }
 
-
 RKModificationTracker::~RKModificationTracker () {
 	RK_TRACE (OBJECTS);
 }
@@ -73,6 +74,16 @@
 void RKModificationTracker::internalRemoveObject (RObject *object, bool removed_in_workspace, bool delete_obj) {
 	RK_TRACE (OBJECTS);
 
+	RK_ASSERT (object);
+	RK_ASSERT (object->getContainer ());
+
+	if (updates_locked <= 0) {
+		QModelIndex object_index = indexFor (object->getContainer ());
+		int object_row = object->getContainer ()->getIndexOf (object);
+		RK_ASSERT (object_row >= 0);
+		beginRemoveRows (object_index, object_row, object_row);
+	}
+
 // TODO: allow more than one editor per object
 // WARNING: This does not work, if a sub-object is being edited!
 	RKEditor *ed = object->objectOpened ();
@@ -94,6 +105,8 @@
 
 	if (delete_obj) object->remove (removed_in_workspace);
 	else object->getContainer ()->removeChildNoDelete (object);
+
+	if (updates_locked <= 0) endRemoveRows ();
 }
 
 void RKModificationTracker::renameObject (RObject *object, const QString &new_name) {
@@ -106,12 +119,23 @@
 
 // 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) emit (objectPropertiesChanged (object));
+
+	if (updates_locked <= 0) {
+		emit (objectPropertiesChanged (object));
+
+		QModelIndex object_index = indexFor (object);
+		emit (dataChanged (object_index, object_index));
+	}
 }
 
 void RKModificationTracker::addObject (RObject *object, RContainerObject* parent, int position, RKEditor *editor) {
 	RK_TRACE (OBJECTS);
 
+	if (updates_locked <= 0) {
+		QModelIndex parent_index = indexFor (parent);
+		beginInsertRows (parent_index, position, position);
+	}
+
 	parent->insertChild (object, position);
 
 // TODO: allow more than one editor per object
@@ -124,7 +148,11 @@
 			ed->addObject (object);
 		}
 	}
-	if (updates_locked <= 0) emit (objectAdded (object));
+
+	if (updates_locked <= 0) {
+		emit (objectAdded (object));
+		endInsertRows ();
+	}
 }
 
 void RKModificationTracker::objectMetaChanged (RObject *object) {
@@ -135,7 +163,13 @@
 	if (ed) {
 		ed->updateObjectMeta (object);
 	}
-	if (updates_locked <= 0) emit (objectPropertiesChanged (object));
+
+	if (updates_locked <= 0) {
+		emit (objectPropertiesChanged (object));
+
+		QModelIndex object_index = indexFor (object);
+		emit (dataChanged (object_index, object_index));
+	}
 }
 
 void RKModificationTracker::objectDataChanged (RObject *object, RObject::ChangeSet *changes) {
@@ -148,6 +182,133 @@
 	}
 
 	delete changes;
+
+	if (updates_locked <= 0) {
+		QModelIndex object_index = indexFor (object);
+		emit (dataChanged (object_index, object_index));
+	}
 }
 
+
+///////////////// RKObjectListModel ///////////////////////////
+
+#define COL_NAME 0
+#define COL_LABEL 1
+#define COL_TYPE 2
+#define COL_CLASS 3
+#define NUM_COLS (COL_CLASS + 1)
+
+RKObjectListModel::RKObjectListModel (QObject *parent) : QAbstractItemModel (parent) {
+	RK_TRACE (OBJECTS);
+}
+
+RKObjectListModel::~RKObjectListModel () {
+	RK_TRACE (OBJECTS);
+}
+
+QModelIndex RKObjectListModel::index (int row, int column, const QModelIndex& parent) const {
+	RK_TRACE (OBJECTS);
+	if (!parent.isValid ()) {
+		RK_ASSERT (row == 0);
+		// must cast to RObject, here. Else casting to void* and back will confuse the hell out of GCC 4.2
+		return (createIndex (row, column, static_cast<RObject *> (RObjectList::getObjectList ())));
+	}
+	RObject* parent_object = static_cast<RObject*> (parent.internalPointer ());
+
+	RK_ASSERT (parent_object->isContainer ());
+	RContainerObject* container = static_cast<RContainerObject*> (parent_object);
+	RK_ASSERT (row < container->numChildren ());
+
+	return (createIndex (row, column, container->findChildByIndex (row)));
+}
+
+QModelIndex RKObjectListModel::parent (const QModelIndex& index) const {
+	RK_TRACE (OBJECTS);
+
+	if (!index.isValid ()) return QModelIndex ();
+	RObject* child = static_cast<RObject*> (index.internalPointer ());
+	RK_ASSERT (child);
+	return (indexFor (child->getContainer ()));
+}
+
+int RKObjectListModel::rowCount (const QModelIndex& parent) const {
+	RK_TRACE (OBJECTS);
+
+	RObject* parent_object = 0;
+	if (parent.isValid ()) parent_object = static_cast<RObject*> (parent.internalPointer ());
+	else return 1;		// the root item
+
+	if (!(parent_object && parent_object->isContainer ())) return 0;
+
+	return (static_cast<RContainerObject*> (parent_object)->numChildren ());
+}
+
+int RKObjectListModel::columnCount (const QModelIndex&) const {
+	//RK_TRACE (OBJECTS); // no need to trace this
+
+	return NUM_COLS;
+}
+
+QVariant RKObjectListModel::data (const QModelIndex& index, int role) const {
+	RK_TRACE (OBJECTS);
+
+	int col = index.column ();
+	RObject *object = static_cast<RObject*> (index.internalPointer ());
+
+	if ((!object) || (col >= NUM_COLS)) {
+		RK_ASSERT (false);
+		return QVariant ();
+	}
+
+	if (role == Qt::DisplayRole) {
+		if (col == COL_NAME) return object->getShortName ();
+		if (col == COL_LABEL) return object->getLabel ();
+		if (col == COL_TYPE) {
+			if (object->isVariable ()) return RObject::typeToText (object->getDataType ());
+			return QVariant ();
+		}
+		if (col == COL_CLASS) return object->makeClassString ("; ");
+		RK_ASSERT (false);
+	} else if (role == Qt::DecorationRole) {
+		if (col == COL_NAME) return RKStandardIcons::iconForObject (object);
+	} else if (role == Qt::ToolTipRole) {
+		return object->getObjectDescription ();
+	}
+
+	return QVariant ();
+}
+
+QVariant RKObjectListModel::headerData (int section, Qt::Orientation orientation, int role) const {
+	RK_TRACE (OBJECTS);
+
+	if (orientation != Qt::Horizontal) return QVariant ();
+	if (role != Qt::DisplayRole) return QVariant ();
+
+	if (section == COL_NAME) return i18n ("Name");
+	if (section == COL_LABEL) return i18n ("Label");
+	if (section == COL_TYPE) return i18n ("Type");
+	if (section == COL_CLASS) return i18n ("Class");
+
+	RK_ASSERT (false);
+	return QVariant ();
+}
+
+QModelIndex RKObjectListModel::indexFor (RObject *object) const {
+	RK_TRACE (OBJECTS);
+
+	if (!object) return QModelIndex ();
+
+	RContainerObject *parent = object->getContainer ();
+	// must cast to RObject, here. Else casting to void* and back will confuse the hell out of GCC 4.2
+	if (!parent) return createIndex (0, 0, static_cast<RObject*> (RObjectList::getObjectList ()));
+
+	int row = parent->getIndexOf (object);
+	if (row < 0) {
+		RK_ASSERT (false);
+		return QModelIndex ();
+	}
+
+	return (createIndex (row, 0, object));
+}
+
 #include "rkmodificationtracker.moc"

Modified: branches/KDE4_port/rkward/core/rkmodificationtracker.h
===================================================================
--- branches/KDE4_port/rkward/core/rkmodificationtracker.h	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/core/rkmodificationtracker.h	2007-11-02 17:09:27 UTC (rev 2165)
@@ -19,21 +19,46 @@
 
 #include <qobject.h>
 #include <qstring.h>
+#include <QAbstractItemModel>
 
 #include "robject.h"
 
 class RKEditor;
 class RObject;
 
+/** An item model for the RObjectList . Technically this is the base class for RKModificationTracker. The two could be merged, fully, but this way, it's a little easier to see what belongs where, logically. */
+class RKObjectListModel : public QAbstractItemModel {
+protected:
+	RKObjectListModel (QObject *parent);
+	virtual ~RKObjectListModel ();
+public:
+	/** implements QAbstractItemModel::index() */
+	QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex ()) const;
+	/** implements QAbstractItemModel::parent() */
+	QModelIndex parent (const QModelIndex& index) const;
+	/** implements QAbstractItemModel::rowCount() */
+	int rowCount (const QModelIndex& parent = QModelIndex ()) const;
+	/** implements QAbstractItemModel::columnCount(). This is identical for all items */
+	int columnCount (const QModelIndex& parent = QModelIndex ()) const;
+	/** implements QAbstractItemModel::data() */
+	QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
+	/** reimplemented from  QAbstractItemModel::headerData() to provide column names */
+	QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+
+	/** convenience function to create an index for a particular object */
+	QModelIndex indexFor (RObject *object) const;
+};
+
+
 /**
 This class takes care of propagating object-modifications to all editors/variable-browsers etc. that need to know about them. For instance, if an object was removed in the R-workspace, the RObjectList will notify the RKModificationTracker. The modification tracker will then find out, whether there are editor(s) currently editing the removed object. If so, it will prompt the user what to do. Or, if an object is renamed in an editor, the RKModificationTracker will find out, whether the object is opened in further editors (not possible, yet) and tell those to update accordingly. It will further emit signals so the RObjectBrowser and RKVarselector(s) can update their object-lists.
 
 @author Thomas Friedrichsmeier
 */
-class RKModificationTracker : public QObject {
+class RKModificationTracker : public RKObjectListModel {
 Q_OBJECT
 public:
-	RKModificationTracker (QObject *parent = 0);
+	RKModificationTracker (QObject *parent);
 
 	~RKModificationTracker ();
 	

Modified: branches/KDE4_port/rkward/core/robject.h
===================================================================
--- branches/KDE4_port/rkward/core/robject.h	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/core/robject.h	2007-11-02 17:09:27 UTC (rev 2165)
@@ -87,7 +87,7 @@
 	virtual void setLabel (const QString &value, bool sync=true);
 	virtual void setMetaProperty (const QString &id, const QString &value, bool sync=true);
 	
-	bool isContainer () const { return (type & Container); };
+	bool isContainer () const { return (type & (Container | Environment | Workspace)); };
 	bool isDataFrame () const { return (type & DataFrame); };
 	bool isVariable () const { return (type & Variable); };
 	bool isType (int type) const { return (RObject::type & type); };
@@ -123,8 +123,8 @@
 /** short hand for getDimension (0). Meaningful for one-dimensional objects */
 	int getLength () const { return dimensions[0]; };
 
-/** A map of objects accessible by index. Used in RContainerObject. Defined here for technical reasons. */
-	typedef QList<RObject*> RObjectMap;
+/** A QList of RObjects. Internally the same as RObjectMap, but can be considered "public" */
+	typedef QList<RObject*> ObjectList;
 	typedef QMap<QString, RObject*> RObjectSearchMap;
 
 /** A map of values to labels. This is used both in regular objects, in which it just represents a map of named values, if any. The more important use is in factors, where it represents the factor levels. Here, the key is always a string representation of a positive integer. */
@@ -142,6 +142,7 @@
 	virtual RObject **children () const { return 0; };
 
 	RDataType getDataType () const { return (typeToDataType (type)); };
+	int getType () const { return type; };
 	static RDataType typeToDataType (int ftype) { return ((RDataType) ((ftype & DataTypeMask) >> 14)); };
 	void setDataType (RDataType new_type) {
 		int n_type = type - (type & DataTypeMask);
@@ -188,6 +189,9 @@
 	friend class RContainerObject;
 	friend class RObjectList;
 	friend class REnvironmentObject;
+/** A map of objects accessible by index. Used in RContainerObject. Defined here for technical reasons. */
+	typedef QList<RObject*> RObjectMap;
+
 	RContainerObject *parent;
 	QString name;
 	int type;

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.cpp
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -34,26 +34,11 @@
 #include "../misc/rkcommonfunctions.h"
 #include "../debug.h"
 
-// static
-QPixmap *RKObjectListView::icon_function = 0;
-QPixmap *RKObjectListView::icon_list = 0;
-QPixmap *RKObjectListView::package_environment = 0;
-QPixmap *RKObjectListView::environment = 0;
-
-RKObjectListView::RKObjectListView (QWidget *parent) : Q3ListView (parent) {
+RKObjectListView::RKObjectListView (QWidget *parent) : QTreeView (parent) {
 	RK_TRACE (APP);
-	if (icon_function == 0) {
-		icon_function = new QPixmap (QImage (RKCommonFunctions::getRKWardDataDir () + "icons/function.png"));
-		icon_list = new QPixmap (QImage (RKCommonFunctions::getRKWardDataDir () + "icons/list.png"));
-		package_environment = new QPixmap (SmallIcon ("ark", 12));
-		environment = new QPixmap (SmallIcon ("konqueror", 12));
-	}
 
-	setSorting (100);
-	addColumn (i18n("Name"));
-	addColumn (i18n("Label"));
-	addColumn (i18n("Type"));
-	addColumn (i18n("Class"));
+// KDE4: TODO: sorting
+//	setSorting (100);
 	settings = new RKObjectListViewSettings ();
 	connect (settings, SIGNAL (settingsChanged ()), this, SLOT (objectBrowserSettingsChanged ()));
 
@@ -61,10 +46,9 @@
 	menu->insertItem (i18n ("Show Objects"), settings->showObjectsMenu ());
 	menu->insertItem (i18n ("Show Fields"), settings->showFieldsMenu ());
 	menu->insertItem (i18n ("Configure Defaults"), this, SLOT (popupConfigure ()));
-	connect (this, SIGNAL (contextMenuRequested (Q3ListViewItem *, const QPoint &, int)), this, SLOT (requestedContextMenu (Q3ListViewItem*, const QPoint&, int)));
 
 // KDE4: do we need this?
-	setShowToolTips (false);
+//	setShowToolTips (false);
 
 	objectBrowserSettingsChanged ();
 }
@@ -77,17 +61,32 @@
 	RK_TRACE (APP);
 
 	if (!object) return;
-	RKListViewItem *item = findObjectItem (object);
+	if (only_if_none_current && currentIndex ().isValid ()) return;
 
-	if (!item) return;		// this may happen during initialization!
-	if (only_if_none_current && selectedItem ()) return;
+	QModelIndex index = RKGlobals::tracker ()->indexFor (object);
+	if (index.isValid ()) {
+		scrollTo (index);
+		setCurrentIndex (index);
+		resizeColumnToContents (0);
+	}
+}
 
-	ensureItemVisible (item);
-	setCurrentItem (item);
+RObject::ObjectList RKObjectListView::selectedObjects () const {
+	RK_TRACE (APP);
+
+	RObject::ObjectList list;
+	QModelIndexList selected = selectedIndexes ();
+	for (int i = 0; i < selected.size (); ++i) {
+		QModelIndex index = selected[i];
+		if (index.column () != 0) continue;
+		if (!index.isValid ()) continue;
+		list.append (static_cast<RObject*> (index.internalPointer ()));
+	}
+	return list;
 }
 
 void RKObjectListView::objectBrowserSettingsChanged () {
-	setColumnWidthMode (0, Q3ListView::Maximum);
+/*	setColumnWidthMode (0, Q3ListView::Maximum);
 	if (settings->settingActive (RKObjectListViewSettings::ShowFieldsLabel)) {
 		if (columnWidth (1) == 0) setColumnWidth (1, 50);
 		setColumnWidthMode (1, Q3ListView::Maximum);
@@ -119,44 +118,46 @@
 		RK_ASSERT (object);
 
 		it.current ()->setVisible (settings->shouldShowObject (object));
-	}
+	} */
 }
 
+// KDE4 TODO: does this really need to be virtual?
 //virtual 
 void RKObjectListView::popupConfigure () {
+	RK_TRACE (APP);
 	RKSettings::configureSettings (RKSettings::PageObjectBrowser, this);
 }
 
-void RKObjectListView::requestedContextMenu (Q3ListViewItem *item, const QPoint &pos, int) {
-	RObject *object = findItemObject (static_cast<RKListViewItem *> (item));
+void RKObjectListView::contextMenuEvent (QContextMenuEvent* event) {
+	RK_TRACE (APP);
 
-	menu_object = object;
+	QModelIndex index = indexAt (event->pos ());
+	menu_object = static_cast<RObject*> (index.internalPointer ());
 
 	bool suppress = false;
-	emit (aboutToShowContextMenu (static_cast<RKListViewItem *> (item), &suppress));
+	emit (aboutToShowContextMenu (menu_object, &suppress));
 
-	if (!suppress) menu->popup (pos);
+	if (!suppress) menu->popup (event->globalPos ());
 }
 
 void RKObjectListView::initialize () {
 	RK_TRACE (APP);
 
-	setUpdatesEnabled (false);
-	addObject (0, RObjectList::getObjectList (), true);
-	setUpdatesEnabled (true);
-	RKListViewItem *item = findObjectItem (RObjectList::getGlobalEnv ());
-	RK_ASSERT (item);
-	item->setOpen (true);
-	setMinimumHeight (item->height() * 5);
+	setUniformRowHeights (true);		// KDE4: can we do this?
 
-	connect (RKGlobals::tracker (), SIGNAL (objectRemoved (RObject *)), this, SLOT (objectRemoved (RObject*)));
-	connect (RKGlobals::tracker (), SIGNAL (objectPropertiesChanged (RObject *)), this, SLOT (objectPropertiesChanged (RObject*)));
-	connect (RKGlobals::tracker (), SIGNAL (objectAdded (RObject *)), this, SLOT (objectAdded (RObject*)));
+	// KDE4: initialization logic is likely wrong, now.
+	setModel (RKGlobals::tracker ());
 
+	setExpanded (RKGlobals::tracker ()->indexFor (RObjectList::getObjectList ()), true);
+	setExpanded (RKGlobals::tracker ()->indexFor (RObjectList::getGlobalEnv ()), true);
+	setMinimumHeight (rowHeight (RKGlobals::tracker ()->indexFor (RObjectList::getGlobalEnv ())) * 5);
+	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 ()));
 
+// KDE4 TODO: this signal needed?
 	emit (listChanged ());
 	changes = false;
 	updateComplete ();
@@ -165,6 +166,7 @@
 void RKObjectListView::initializeLater () {
 	RK_TRACE (APP);
 
+// KDE4: TODO huh?
 	connect (RObjectList::getObjectList (), SIGNAL (updateComplete ()), this, SLOT (initialize ()));
 	updateStarted ();
 }
@@ -187,178 +189,7 @@
 	update_in_progress = true;
 }
 
-void RKObjectListView::objectAdded (RObject *object) {
-	RK_TRACE (APP);
-
-	RKListViewItem *parent = 0;
-	if (!object->isType (RObject::Workspace)) {
-		parent = findObjectItem (object->getContainer ());
-		RK_ASSERT (parent);
-	}
-	addObject (parent, object, true);
-	
-	if (update_in_progress) {
-		changes = true;
-	} else {
-		emit (listChanged ());
-	}
-}
-
-void RKObjectListView::objectRemoved (RObject *object) {
-	RK_TRACE (APP);
-
-	RKListViewItem *item = findObjectItem (object);
-	RK_ASSERT (item);
-	// also take care of removing the children of the removed item!
-	// this can NOT be done by using QListViewItemIterator (item), as that is NOT constrained to the children!
-	RObject **children = object->children ();
-	for (int i = 0; i < object->numChildren (); ++i) {
-		objectRemoved (children[i]);
-	}
-
-	object_map.remove (item);
-	delete item;
-	
-	if (update_in_progress) {
-		changes = true;
-	} else {
-		emit (listChanged ());
-	}
-}
-
-void RKObjectListView::objectPropertiesChanged (RObject *object) {
-	RK_TRACE (APP);
-
-	RKListViewItem *item = findObjectItem (object);
-	RK_ASSERT (item);
-	updateItem (item, object);
-
-	if (update_in_progress) {
-		changes = true;
-	} else {
-		emit (listChanged ());
-	}
-}
-
-RKListViewItem *RKObjectListView::findObjectItem (RObject *object) {
-	RK_TRACE (APP);
-	for (ObjectMap::const_iterator it = object_map.constBegin (); it != object_map.constEnd (); ++it) {
-		if (it.data () == object) return it.key ();
-	}
-	return 0;
-}
-
-RObject *RKObjectListView::findItemObject (RKListViewItem *item) {
-	RK_TRACE (APP);
-	if (!item) return 0;
-	if (object_map.find (item) == object_map.end ()) {
-		return 0;
-	} else {
-		return object_map[item];
-	}
-}
-
-void RKObjectListView::updateItem (RKListViewItem *item, RObject *object) {
-	RK_TRACE (APP);
-
-	item->setText (0, object->getShortName ());
-	item->setText (1, object->getLabel ());
-	if (object->isVariable ()) {
-		item->setText (2, RObject::typeToText (object->getDataType ()));
-	}
-	item->setText (3, object->makeClassString ("; "));
-
-	if (object->isDataFrame ()) {
-		item->setPixmap (0, SmallIcon("spreadsheet"));
-	} else if (object->isVariable()) {
-		switch(object->getDataType ()) {
-			case RObject::DataNumeric:
-				item->setPixmap (0, SmallIcon("math_paren",12));
-				break;
-			case RObject::DataFactor:
-				item->setPixmap (0, SmallIcon("math_onetwomatrix",12));
-				break;
-			case RObject::DataCharacter:
-				item->setPixmap (0, SmallIcon("text",12));
-				break;
-			case RObject::DataLogical:
-				#warning TODO icon for logical
-			case RObject::DataUnknown:
-				item->setPixmap (0, SmallIcon("help",12));
-				break;
-			default:
-				item->setPixmap (0, SmallIcon("no",12));
-				break;
-		}
-	} else if (object->isType (RObject::List)) {
-		item->setPixmap (0, *icon_list);
-	} else if (object->isType (RObject::Function)) {
-		item->setPixmap (0, *icon_function);
-	} else if (object->isType (RObject::PackageEnv)) {
-		item->setPixmap (0, *package_environment);
-	} else if (object->isType (RObject::Environment)) {
-		item->setPixmap (0, *environment);
-	}
-
-	if (!settings->shouldShowObject (object)) item->setVisible (false);
-}
-
-void RKObjectListView::addObject (RKListViewItem *parent, RObject *object, bool recursive) {
-	RK_TRACE (APP);
-	
-	RKListViewItem *item;
-
-	if (parent) {
-		item = new RKListViewItem (parent);
-	} else {
-		item = new RKListViewItem (this);
-	}
-
-	updateItem (item, object);
-	object_map.insert (item, object);
-
-	if (recursive) {
-		RObject **children = object->children ();
-		for (int i=0; i < object->numChildren (); ++i) {
-			addObject (item, children[i], true);
-		}
-	}
-
-// special treatment for the workspace object
-	if (!parent) {
-		item->setPixmap (0, SmallIcon("view_tree"));
-		item->setText (0, i18n ("[Objects]"));
-		item->setOpen (true);
-	}
-
-// 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);
-		while (item->parent ()) {
-			item = item->parent ();
-			item->setOpen (true);
-		}
-	} */
-}
-
-bool RKObjectListView::event (QEvent *event) {
-	// don't trace here!
-	if (event->type() == QEvent::ToolTip) {
-		RK_TRACE (APP);
-
-		QHelpEvent *help_event = static_cast<QHelpEvent *>(event);
-		RKListViewItem *item = static_cast<RKListViewItem *> (itemAt (help_event->pos ()));
-		if (item) {
-			RObject *object = findItemObject (item);
-			if (object) {
-				QToolTip::showText (help_event->globalPos(), object->getObjectDescription (), this, itemRect (item));
-			}
-		}
-	}
-	return Q3ListView::event(event);
-}
-
-
+/*
 //////////////////// RKListViewItem //////////////////////////
 int RKListViewItem::width (const QFontMetrics &fm, const Q3ListView * lv, int c) const {
 	if (parent ()) {
@@ -370,7 +201,7 @@
 	int ret = Q3ListViewItem::width (fm, lv, c);
 	if (ret > 200) return 200;
 	return ret;
-}
+} */
 
 //////////////////// RKObjectListViewSettings //////////////////////////
 

Modified: branches/KDE4_port/rkward/misc/rkobjectlistview.h
===================================================================
--- branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/misc/rkobjectlistview.h	2007-11-02 17:09:27 UTC (rev 2165)
@@ -17,27 +17,25 @@
 #ifndef RKOBJECTLISTVIEW_H
 #define RKOBJECTLISTVIEW_H
 
-#include <q3listview.h>
+#include <QTreeView>
 #include <qtooltip.h>
 #include <qmap.h>
-//Added by qt3to4:
-#include <QPixmap>
 #include <Q3PopupMenu>
 
 #include "../settings/rksettings.h"
+#include "../core/robject.h"
 
-class RObject;
 class QPixmap;
 class Q3PopupMenu;
 class RKListViewItem;
 class RKObjectListViewSettings;
 
 /**
-This class provides the common functionality for the list-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?
+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?
 
 @author Thomas Friedrichsmeier
 */
-class RKObjectListView : public Q3ListView {
+class RKObjectListView : public QTreeView {
 	Q_OBJECT
 public:
 	explicit RKObjectListView (QWidget *parent);
@@ -45,8 +43,6 @@
 	~RKObjectListView ();
 
 	void initializeLater ();
-/** @returns the RObject corresponding to the given RKListViewItem or 0 if no such item is known. */
-	RObject *findItemObject (RKListViewItem *item);
 
 /** 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
@@ -54,17 +50,19 @@
 	Q3PopupMenu *contextMenu () { return menu; };
 /** This function returns the RObject the context menu has last been invoked on (or 0 if not invoked on an RObject). You can use this in slots called
 from your custom menu items, to figure out, which object you should operate on. */
-	RObject *menuObject () { return menu_object; };
+	RObject *menuObject () const { return menu_object; };
 
 	RKObjectListViewSettings *getSettings () { return settings; };
 
 /** Scrolls so that the item representing object becomes visible, and makes it current */
 	void setObjectCurrent (RObject *object, bool only_if_none_current=false);
+
+	RObject::ObjectList selectedObjects () const;
 signals:
 	void listChanged ();
 /** 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 (RKListViewItem *item, bool *suppress);
+	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 ();
@@ -72,28 +70,12 @@
 	void updateComplete ();
 	void updateStarted ();
 
-	void objectAdded (RObject *object);
-	void objectRemoved (RObject *object);
-	void objectPropertiesChanged (RObject *object);
-
 	void objectBrowserSettingsChanged ();
 
-	void requestedContextMenu (Q3ListViewItem *item, const QPoint &pos, int col);
-	
 	virtual void popupConfigure ();
 protected:
-/** reimplemented for tool tips */
-	bool event (QEvent *event);
+	void contextMenuEvent (QContextMenuEvent* event);
 private:
-// TODO: keep an additional map from RObject to RKListViewItem, in order to make this (often called) more efficient
-	RKListViewItem *findObjectItem (RObject *object);
-	void updateItem (RKListViewItem *item, RObject *object);
-
-	void addObject (RKListViewItem *parent, RObject *object, bool recursive);
-
-	typedef QMap<RKListViewItem *, RObject *> ObjectMap;
-	ObjectMap object_map;
-
 	bool update_in_progress;
 	bool changes;
 
@@ -101,17 +83,13 @@
 	RObject *menu_object;
 
 	RKObjectListViewSettings *settings;
-
-	static QPixmap *icon_function;
-	static QPixmap *icon_list;
-	static QPixmap *package_environment;
-	static QPixmap *environment;
 };
 
 /** 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)
 
 @author Thomas Friedrichsmeier
 */
+/*
 class RKListViewItem : public Q3ListViewItem {
 public:
 	RKListViewItem (Q3ListView *parent) : Q3ListViewItem (parent) {};
@@ -119,7 +97,7 @@
 	~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 {

Modified: branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/plugin/rkcomponentproperties.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -657,9 +657,7 @@
 void RKComponentPropertyRObjects::removeObjectValue (RObject *object) {
 	RK_TRACE (PLUGIN);
 
-	ObjectList::Iterator it = object_list.find (object);
-	if (it != object_list.end ()) {
-		object_list.erase (it);
+	if (object_list.removeAll (object)) {
 		checkListLengthValid ();
 		emit (valueChanged (this));
 	}
@@ -695,32 +693,29 @@
 	return (addObjectValue (object));
 }
 
-void RKComponentPropertyRObjects::setObjectList (const ObjectList &newlist) {
+void RKComponentPropertyRObjects::setObjectList (const RObject::ObjectList &newlist) {
 	RK_TRACE (PLUGIN);
 
 	bool changes = false;
 
 	// remove items from the old list that are not in the new list
-	ObjectList::Iterator it = object_list.begin ();
-	while (it != object_list.end ()) {
-		if (newlist.contains (*it)) {
-			++it;
-		} else {
-			it = object_list.erase (it);		// it now points to the next object in the list
+	for (int i = 0; i < object_list.size (); ++i) {
+		if (!newlist.contains (object_list[i])) {
+			object_list.removeAt (i);
+			--i;
 			changes = true;
 		}
 	}
 
 	// now add items from the new list that are not in the old list
-	ObjectList::const_iterator cit = newlist.begin ();
-	while (cit != newlist.end ()) {
-		if (!object_list.contains (*cit)) {
-			if (isObjectValid (*cit)) {
-				object_list.append (*cit);
+	for (int i = 0; i < newlist.size (); ++i) {
+		RObject *obj = newlist[i];
+		if (!object_list.contains (obj)) {
+			if (isObjectValid (obj)) {
+				object_list.append (obj);
 				changes = true;
 			}
 		}
-		++cit;
 	}
 
 	// emit a signal if there have been any changes
@@ -776,7 +771,7 @@
 	return (object_list.first ());
 }
 
-Q3ValueList<RObject *> RKComponentPropertyRObjects::objectList () {
+RObject::ObjectList RKComponentPropertyRObjects::objectList () {
 	RK_TRACE (PLUGIN);
 
 	return (object_list);
@@ -787,16 +782,16 @@
 
 	QStringList ret;
 	if (modifier.isEmpty ()) {
-		for (ObjectList::const_iterator it = object_list.begin (); it != object_list.end ();++it) {
-			ret.append ((*it)->getFullName ());
+		for (int i = 0; i < object_list.size (); ++i) {
+			ret.append (object_list[i]->getFullName ());
 		}
 	} else if (modifier == "shortname") {
-		for (ObjectList::const_iterator it = object_list.begin (); it != object_list.end ();++it) {
-			ret.append ((*it)->getShortName ());
+		for (int i = 0; i < object_list.size (); ++i) {
+			ret.append (object_list[i]->getShortName ());
 		}
 	} else if (modifier == "label") {
-		for (ObjectList::const_iterator it = object_list.begin (); it != object_list.end ();++it) {
-			ret.append ((*it)->getLabel ());
+		for (int i = 0; i < object_list.size (); ++i) {
+			ret.append (object_list[i]->getLabel ());
 		}
 	} else {
 		warnModifierNotRecognized (modifier);
@@ -943,31 +938,22 @@
 void RKComponentPropertyRObjects::setFromListView (RKObjectListView *list_view, bool selected_only) {
 	RK_TRACE (PLUGIN);
 
-	// first find out the list of objects from the listview
-	ObjectList newlist;
-	Q3ListViewItem *current;
-	current = list_view->firstChild ();
-	while (current->itemBelow ()) {
-		current = current->itemBelow ();
-		if ((!selected_only) || current->isSelected ()) {
-			RObject *obj = list_view->findItemObject (static_cast<RKListViewItem *> (current));
-			RK_ASSERT (obj);
-			newlist.append (static_cast<RKVariable*> (obj));
-		}
-	}
-
+#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 (newlist);
+	setObjectList (list_view->selectedObjects ());
 }
 
 void RKComponentPropertyRObjects::objectPropertiesChanged (RObject *object) {
 	RK_TRACE (PLUGIN);
 
 	// if object list contains this object, check whether it is still valid. Otherwise remove it, revalidize and signal change.
-	ObjectList::Iterator it = object_list.find (object);
-	if (it != object_list.end ()) {
+	int index = object_list.indexOf (object);
+	if (index >= 0) {
 		if (!isObjectValid (object)) {
-			object_list.erase (it);
+			object_list.removeAt (index);
 			checkListLengthValid ();
 			emit (valueChanged (this));
 		}
@@ -979,12 +965,10 @@
 
 	bool changes = false;
 
-	ObjectList::Iterator it = object_list.begin ();
-	while (it != object_list.end ()) {
-		if (isObjectValid (*it)) {
-			++it;
-		} else {
-			it = object_list.erase (it);		// it now points to the next object in the list
+	for (int i = 0; i < object_list.size (); ++i) {
+		if (!isObjectValid (object_list[i])) {
+			object_list.removeAt (i);
+			--i;
 			changes = true;
 		}
 	}
@@ -1107,8 +1091,8 @@
 void RKComponentPropertyConvert::sourcePropertyChanged (RKComponentPropertyBase *) {
 	RK_TRACE (PLUGIN);
 
-	for (Q3ValueList<Source>::const_iterator it = sources.constBegin (); it != sources.constEnd (); ++it) {
-		Source source = *it;		// easier typing
+	for (int i = 0; i < sources.size (); ++i) {
+		Source source = sources[i];		// easier typing
 		switch (_mode) {
 			case Equals: {
 				if (source.property->value (source.modifier) != standard) {

Modified: branches/KDE4_port/rkward/plugin/rkcomponentproperties.h
===================================================================
--- branches/KDE4_port/rkward/plugin/rkcomponentproperties.h	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/plugin/rkcomponentproperties.h	2007-11-02 17:09:27 UTC (rev 2165)
@@ -209,14 +209,12 @@
 };
 
 ///////////////////////////////////////////////// RObjects ////////////////////////////////////////////////////////
-class RObject;
 class RKObjectListView;
 
 #include <qstringlist.h>
-#include <q3valuelist.h>
+#include <qlist.h>
 
-/** for easier typing. A list of RObjects. Should probably be defined somewhere in core-dir instead. */
-typedef Q3ValueList<RObject *> ObjectList;
+#include "../core/robject.h"
 
 /** special type of RKComponentProperty, that prepresents one or more RObject (s) */
 class RKComponentPropertyRObjects : public RKComponentPropertyBase {
@@ -246,7 +244,7 @@
 @returns false if the object does not qualify as a valid selection according to current settings (class/type/dimensions), true otherwise */
 	bool setObjectValue (RObject *object);
 /** set all the objects in the given new list (if valid), and only those. Emit a signal if there was any change */
-	void setObjectList (const ObjectList &newlist);
+	void setObjectList (const RObject::ObjectList &newlist);
 /** Check whether an object is valid for this property.
 @returns false if the object does not qualify as a valid selection according to current settings (class/type/dimensions), true otherwise */
 	bool isObjectValid (RObject *object);
@@ -255,7 +253,7 @@
 	RObject *objectValue ();
 /** Get current list of objects. Do not modify this list! It is the very same list, the property uses internally!
 @returns an empty list if no valid object is selected */
-	ObjectList objectList ();
+	RObject::ObjectList objectList ();
 /** set separator (used to concatenate object names/labels, etc. if more than one object is selected) */
 	void setSeparator (const QString &sep) { separator = sep; emit (valueChanged (this)); };
 /** reimplemented from RKComponentPropertyBase. Modifier "label" returns label. Modifier "shortname" returns short name. Modifier QString::null returns full name. If no object is set, returns an empty string */
@@ -286,7 +284,7 @@
 	void validizeAll (bool silent=false);
 /** simple helper function: Check whether the number of objects currently selected (and only that!), and set the valid state accordingly */
 	void checkListLengthValid ();
-	ObjectList object_list;
+	RObject::ObjectList object_list;
 	int dims;
 	int min_length;
 	int max_length;
@@ -392,7 +390,7 @@
 		RKComponentPropertyBase *property;
 		QString modifier;
 	};
-	Q3ValueList<Source> sources;
+	QList<Source> sources;
 };
 
 #endif

Modified: branches/KDE4_port/rkward/plugin/rkformula.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkformula.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/plugin/rkformula.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -129,8 +129,8 @@
 	} else if (id == (int) Custom) {
 		predictors_view->clear ();
 		item_map.clear ();
-		ObjectList fixed_list = fixed_factors->objectList ();
-		for (ObjectList::const_iterator it = fixed_list.begin (); it != fixed_list.end (); ++it) {
+		RObject::ObjectList fixed_list = fixed_factors->objectList ();
+		for (RObject::ObjectList::const_iterator it = fixed_list.begin (); it != fixed_list.end (); ++it) {
 			Q3ListViewItem *new_item = new Q3ListViewItem (predictors_view, (*it)->getShortName ());
 			item_map.insert (new_item, (*it));
 		}
@@ -154,7 +154,7 @@
 	if (dep_var) {
 		model_ok = true;
 	}
-	ObjectList vlist = fixed_factors->objectList ();
+	RObject::ObjectList vlist = fixed_factors->objectList ();
 	if (vlist.empty ()) {
 		model_ok = false;
 	}
@@ -163,7 +163,7 @@
 	} else if (!vlist.empty ()) {
 		container = vlist.first ()->getContainer ();
 	}
-	for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
+	for (RObject::ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
 		if ((*it)->getContainer () != container) {
 			multitable = true;
 			break;
@@ -172,7 +172,7 @@
 	if (multitable) {
 		table_string = "data.frame (";
 		if (dep_var) table_string.append (mangleName (dep_var) + '=' + dep_var->getFullName ());
-		for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
+		for (RObject::ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
 			table_string.append (", " + mangleName ((*it)) + '=' + (*it)->getFullName ());
 		}
 		table_string.append (")");
@@ -183,12 +183,12 @@
 	// construct model string
 	model_string = mangleName (dep_var) + " ~ ";
 	if (model_type == FullModel) {
-		for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
+		for (RObject::ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
 			if (it != vlist.begin ()) model_string.append (" * ");
 			model_string.append (mangleName (*it));
 		}
 	} else if (model_type == MainEffects) {
-		for (ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
+		for (RObject::ObjectList::const_iterator it = vlist.begin (); it != vlist.end (); ++it) {
 			if (it != vlist.begin ()) model_string.append (" + ");
 			model_string.append (mangleName (*it));
 		}

Modified: branches/KDE4_port/rkward/plugin/rkvarselector.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkvarselector.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/plugin/rkvarselector.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -44,7 +44,7 @@
 	vbox->addWidget (label);
 
 	list_view = new RKObjectListView (this);
-	list_view->setSelectionMode (Q3ListView::Extended);
+	list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
 	connect (list_view, SIGNAL (listChanged ()), this, SLOT (objectListChanged ()));
 	connect (list_view, SIGNAL (selectionChanged ()), this, SLOT (objectSelectionChanged ()));
 

Modified: branches/KDE4_port/rkward/plugin/rkvarslot.cpp
===================================================================
--- branches/KDE4_port/rkward/plugin/rkvarslot.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/plugin/rkvarslot.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -111,7 +111,7 @@
 
 	bool selection = false;
 
-	ObjectList sellist;
+	RObject::ObjectList sellist;
 	Q3ListViewItem *item = list->firstChild ();
 	while (item) {
 		if (item->isSelected ()) {
@@ -135,8 +135,8 @@
 
 	RK_DO (qDebug ("contained in varslot: %s", available->value ().toLatin1 ().data ()), PLUGIN, DL_DEBUG);
 
-	ObjectList objlist = available->objectList ();
-	ObjectList::const_iterator it = objlist.begin ();
+	RObject::ObjectList objlist = available->objectList ();
+	RObject::ObjectList::const_iterator it = objlist.begin ();
 	int i = 1;
 	while (it != objlist.end ()) {
 		Q3ListViewItem *new_item = new Q3ListViewItem (list, QString::number (i++), (*it)->getShortName ());
@@ -176,8 +176,8 @@
 	// first update the properties
 	if (add_mode) {
 		if (multi) {
-			ObjectList objlist = source->objectList ();
-			ObjectList::const_iterator it = objlist.constBegin ();
+			RObject::ObjectList objlist = source->objectList ();
+			RObject::ObjectList::const_iterator it = objlist.constBegin ();
 			while (it != objlist.constEnd ()) {
 				available->addObjectValue (*it);
 				++it;
@@ -186,14 +186,14 @@
 			if (source->objectValue ()) available->setObjectValue (source->objectValue ());
 		}
 	} else {		// remove-mode
-		ObjectList objlist;
+		RObject::ObjectList objlist;
 		if (multi) {
 			objlist = selected->objectList ();
 		} else {
 			objlist = available->objectList ();
 		}
 
-		ObjectList::const_iterator it = objlist.begin ();
+		RObject::ObjectList::const_iterator it = objlist.begin ();
 		while (it != objlist.end ()) {
 			available->removeObjectValue (*it);
 			selected->removeObjectValue (*it);

Modified: branches/KDE4_port/rkward/robjectbrowser.cpp
===================================================================
--- branches/KDE4_port/rkward/robjectbrowser.cpp	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/robjectbrowser.cpp	2007-11-02 17:09:27 UTC (rev 2165)
@@ -127,9 +127,9 @@
 	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);
-	connect (list_view, SIGNAL (aboutToShowContextMenu (RKListViewItem*, bool*)), this, SLOT (contextMenuCallback (RKListViewItem*, bool*)));
+	connect (list_view, SIGNAL (aboutToShowContextMenu (RObject *, bool*)), this, SLOT (contextMenuCallback (RObject*, bool*)));
 	
-	connect (list_view, SIGNAL (doubleClicked (Q3ListViewItem *, const QPoint &, int )), this, SLOT (slotListDoubleClicked (Q3ListViewItem *, const QPoint &, int)));
+	connect (list_view, SIGNAL (doubleClicked(const QModelIndex&)), this, SLOT (doubleClicked(const QModelIndex&)));
 	
 	resize (minimumSizeHint ().expandedTo (QSize (400, 480)));
 
@@ -215,7 +215,7 @@
 	}
 }
 
-void RObjectBrowserInternal::contextMenuCallback (RKListViewItem *, bool *) {
+void RObjectBrowserInternal::contextMenuCallback (RObject *, bool *) {
 	RK_TRACE (APP);
 	RObject *object = list_view->menuObject ();
 	Q3PopupMenu *menu = list_view->contextMenu ();
@@ -241,17 +241,18 @@
 	menu->setItemVisible (Delete, object->canRemove ());
 }
 
-void RObjectBrowserInternal::slotListDoubleClicked (Q3ListViewItem *item, const QPoint &, int) {
+void RObjectBrowserInternal::doubleClicked (const QModelIndex& index) {
 	RK_TRACE (APP);
-	RObject *object = list_view->findItemObject (static_cast<RKListViewItem*> (item));
+	RObject *object = static_cast<RObject*> (index.internalPointer ());
 	
 	if (!object) return;
 	if (object == RObjectList::getObjectList ()) return;
 	QWidget *w = RKWorkplace::mainWorkplace ()->activeWindow (RKMDIWindow::Attached);
 	if (!w) return;
-	
-	if (w->inherits ("RKCommandEditorWindow")) {
-		static_cast<RKCommandEditorWindow*> (w)->insertText (object->getFullName ());
+
+	RKCommandEditorWindow *cw = qobject_cast<RKCommandEditorWindow*> (w);
+	if (cw) {
+		cw->insertText (object->getFullName ());
 	}
 }
 

Modified: branches/KDE4_port/rkward/robjectbrowser.h
===================================================================
--- branches/KDE4_port/rkward/robjectbrowser.h	2007-11-02 12:50:18 UTC (rev 2164)
+++ branches/KDE4_port/rkward/robjectbrowser.h	2007-11-02 17:09:27 UTC (rev 2165)
@@ -18,13 +18,14 @@
 #define ROBJECTBROWSER_H
 
 #include "windows/rkmdiwindow.h"
+
+#include <QModelIndex>
+#include <QFocusEvent>
 //Added by qt3to4:
 #include <Q3PopupMenu>
-#include <QFocusEvent>
 
 class RKObjectListView;
 class RKObjectListViewSettings;
-class RKListViewItem;
 class Q3ListViewItem;
 class QPushButton;
 class QRadioButton;
@@ -75,7 +76,7 @@
 	enum PopupItems { Help=1, Edit=2, View=3, Rename=4, Copy=5, CopyToGlobalEnv=6, Delete=7 };
 private slots:
 	void updateButtonClicked ();
-	void contextMenuCallback (RKListViewItem *item, bool *suppress);
+	void contextMenuCallback (RObject *object, bool *suppress);
 	
 	void popupHelp ();
 	void popupEdit ();
@@ -86,7 +87,7 @@
 	void popupDelete ();
 	void popupRename ();
 /** when an object in the list is double clicked, insert its name in the current RKCommandEditor window */
-	void slotListDoubleClicked (Q3ListViewItem *item, const QPoint &pos, int);
+	void doubleClicked (const QModelIndex &index);
 protected:
 /** reimplemnented from QWidget to make show the globalenv object when activated (other than by mouse click) */
 	void focusInEvent (QFocusEvent *e);


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