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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Oct 9 15:09:02 UTC 2006


Revision: 835
          http://svn.sourceforge.net/rkward/?rev=835&view=rev
Author:   tfry
Date:     2006-10-09 08:08:52 -0700 (Mon, 09 Oct 2006)

Log Message:
-----------
Add per object tooltip information to RKObjectListView

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/core/rfunctionobject.cpp
    trunk/rkward/rkward/core/rfunctionobject.h
    trunk/rkward/rkward/core/robject.cpp
    trunk/rkward/rkward/core/robject.h
    trunk/rkward/rkward/misc/rkobjectlistview.cpp
    trunk/rkward/rkward/misc/rkobjectlistview.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/ChangeLog	2006-10-09 15:08:52 UTC (rev 835)
@@ -1,3 +1,4 @@
+- show tooltip information on objects in object browser
 - do not crash on call to "browser ()"
 - the object browser is updated automatically when needed
 - allow some more configuration in object browser

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/TODO	2006-10-09 15:08:52 UTC (rev 835)
@@ -93,13 +93,14 @@
 				(object list remains the same, watch was not active, but symbol changed)
 				- will need to put an extra notification inside .rk.watch.globalenv ()? Will that get run?
 			- deal with data changes in edited objects
+	- RFunctionObject:
+		- problem with argument values like "" (or text arguments in general). Need to find a better representation. Maybe use formals () directly, and do all work in RFunctionObject::updateArguments ()
 	- RExpressionObject as an abstraction for R-Expressions (i.e. manually edited expressions).
 		- It will be possible to "store" these in the RObjectList and select them just like any other object
 		- RKVarslot will allow editing the selected value by hand (or just typing the name in)
 			- How to do this nicely UI wise?
 	- RKCancelDialog / RKErrorDialog:
 		- remove these classes. Port to use RKProgressControl instead
-	- instead of delete RObject, call RObject::deleteThis () and check for deleted in rCommandDone ()?
 	- use R_DirtyImage to determine, whether workspace needs to be saved
 	- in REmbedInternal, add extractTemporaryStrings (), for strings that do not have to be copied
 	- Object editing / modification tracking:
@@ -160,7 +161,7 @@
 		- stack size (commandline arg --map-ppsize)
 		- disable html help
 	- new dataeditor options:
-		- see below: comments on RKEditorDataFrame
+		- see comments on RKEditorDataFrame
 
 
 ################## Some internal notes below ##############
@@ -221,6 +222,7 @@
 	- seems ok now. But maybe we could still use this to catch immediate warning messages (which go to R_Consolefile)?
 
 - still mysterious in warning-handling: 'help (doesnotexist); print ("stuff");'. Why is the order wrong?!
+	- because first both are evaluated, then the warnings are printed. R_ReplIteration works differently in that it stops at each ";" and "\n"
 
 tryCatch (message ("a"), error=function (x) {print ("e"); x$message}, warning=function (y) {print ("w"); conditionMessage(y)}, message=function (z) {print ("m"); conditionCall (z)})
 withCallingHandlers ({message ("a"); stop ("b");}, error=function (x) {print ("e"); x$message}, warning=function (y) {print ("w"); conditionMessage(y)}, message=function (z) {print ("c"); conditionCall (z)})

Modified: trunk/rkward/rkward/core/rfunctionobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rfunctionobject.cpp	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/rkward/core/rfunctionobject.cpp	2006-10-09 15:08:52 UTC (rev 835)
@@ -35,6 +35,21 @@
 	RK_TRACE (OBJECTS);
 }
 
+QString RFunctionObject::printArgs () {
+	RK_TRACE (OBJECTS);
+
+	QString ret;
+	for (unsigned int i = 0; i < argcount; ++i) {
+		if (i) ret.append (", ");
+		ret.append (argnames[i]);
+		if (!argvalues[i].isEmpty ()) {
+			ret.append ("=");
+			ret.append (argvalues[i]);
+		}
+	}
+	return ret;
+}
+
 bool RFunctionObject::updateStructure (RData *new_data) {
 	RK_TRACE (OBJECTS);
 	RK_ASSERT (new_data->getDataLength () >= 5);

Modified: trunk/rkward/rkward/core/rfunctionobject.h
===================================================================
--- trunk/rkward/rkward/core/rfunctionobject.h	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/rkward/core/rfunctionobject.h	2006-10-09 15:08:52 UTC (rev 835)
@@ -37,6 +37,7 @@
 
 /** reimplemented from RObject to handle function arguments */
 	bool updateStructure (RData *new_data);
+	QString printArgs ();
 protected:
 	unsigned int argcount;
 	QString *argnames;

Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/rkward/core/robject.cpp	2006-10-09 15:08:52 UTC (rev 835)
@@ -16,6 +16,7 @@
  ***************************************************************************/
 
 #include <qregexp.h>
+#include <klocale.h>
 
 #include "robject.h"
 
@@ -23,8 +24,12 @@
 
 #include "../rbackend/rinterface.h"
 #include "../rkglobals.h"
+#include "robjectlist.h"
+#include "rcontainerobject.h"
+#include "rkvariable.h"
+#include "renvironmentobject.h"
+#include "rfunctionobject.h"
 #include "rkmodificationtracker.h"
-#include "robjectlist.h"
 
 #include "../debug.h"
 
@@ -94,6 +99,51 @@
 	return getShortName ();;
 }
 
+QString RObject::getObjectDescription () {
+	RK_TRACE (OBJECTS);
+
+	QString ret;
+	ret.append ("<i>" + getShortName () + "</i>");
+	ret.append ("<br><b>" + i18n ("Full location:") + " </b>" + getFullName ());
+	QString lab = getLabel ();
+	if (!lab.isEmpty ()) ret.append ("<br><b>" + i18n ("Label:") + " </b>" + lab);
+	ret.append ("<br><b>" + i18n ("Type:") + " </b>");
+
+	if (isType (Function)) {
+		ret.append (i18n ("Function"));
+		ret.append ("<br><b>" + i18n ("Usage: ") + " </b>" + getShortName () + "(" + static_cast<RFunctionObject *> (this)->printArgs () + ")");
+	} else if (isType (DataFrame)) {
+		ret.append (i18n ("Data frame"));
+	} else if (isType (Array)) {
+		ret.append (i18n ("Array"));
+	} else if (isType (Matrix)) {
+		ret.append (i18n ("Matrix"));
+	} else if (isType (List)) {
+		ret.append (i18n ("List"));
+	} else if (isType (Variable)) {
+		ret.append (i18n ("Variable"));
+		ret.append ("<br><b>" + i18n ("Data Type:") + " </b>" + static_cast<RKVariable *> (this)->getVarTypeString ());
+	} else if (isType (Environment)) {
+		ret.append (i18n ("Environment"));
+	}
+
+	if (isType (Container | Variable)) {
+		if (num_dimensions == 1) {
+			ret.append ("<br><b>" + i18n ("Length: ") + QString::number (dimensions[0]));
+		} else if (num_dimensions > 1) {
+			ret.append ("<br><b>" + i18n ("Dimensions: "));
+			for (unsigned int i=0; i < num_dimensions; ++i) {
+				if (i) ret.append (", ");
+				ret.append (QString::number (dimensions[i]));
+			}
+		}
+	}
+
+	ret.append ("<br><b>" + i18n ("Class(es):") + " </b>" + makeClassString (","));
+
+	return ret;
+}
+
 void RObject::setLabel (const QString &value, bool sync) {
 	RK_TRACE (OBJECTS);
 	setMetaProperty ("label", value, sync);

Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/rkward/core/robject.h	2006-10-09 15:08:52 UTC (rev 835)
@@ -136,6 +136,8 @@
 	static VarType textToType (const QString &text);
 /** Returns the given string in quotes, taking care of escaping quotation marks inside the string. */
 	static QString rQuote (const QString &string);
+/** Returns a pretty description of the object, and its most important properties. TODO should this be virtual or not? I suppose, it's a close call. For now, we do all work here with casts */
+	QString getObjectDescription ();
 // UNIMPLEMENTED
 /** Returns a canonified name given a non-canoified name. Warning! This is not (necessarily) suitable for submission to
 R, only for internal lookup. For submission to R, always use RObject::getFullName (), as it will apply more complicated (and correct) rules depending on object type */

Modified: trunk/rkward/rkward/misc/rkobjectlistview.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-09 15:08:52 UTC (rev 835)
@@ -28,6 +28,7 @@
 #include "../rkglobals.h"
 #include "../core/robjectlist.h"
 #include "../core/renvironmentobject.h"
+#include "../core/rfunctionobject.h"
 #include "../core/rkvariable.h"
 #include "../core/rkmodificationtracker.h"
 #include "../settings/rksettings.h"
@@ -63,11 +64,16 @@
 	menu->insertItem (i18n ("Configure Defaults"), this, SLOT (popupConfigure ()));
 	connect (this, SIGNAL (contextMenuRequested (QListViewItem *, const QPoint &, int)), this, SLOT (requestedContextMenu (QListViewItem*, const QPoint&, int)));
 
+	setShowToolTips (false);
+	tip = new RKObjectListViewTip (this);
+
 	objectBrowserSettingsChanged ();
 }
 
 RKObjectListView::~RKObjectListView () {
 	RK_TRACE (APP);
+
+	delete tip;
 }
 
 void RKObjectListView::objectBrowserSettingsChanged () {
@@ -475,4 +481,30 @@
 	return true;
 }
 
+
+///////// RKObjectListViewTip ////////////
+RKObjectListViewTip::RKObjectListViewTip (RKObjectListView *parent) : QToolTip (parent->viewport ()) {
+	RK_TRACE (APP);
+
+	view = parent;
+}
+
+RKObjectListViewTip::~RKObjectListViewTip () {
+	RK_TRACE (APP);
+}
+
+void RKObjectListViewTip::maybeTip (const QPoint &pos) {
+	RK_TRACE (APP);
+
+	RKListViewItem *item = static_cast<RKListViewItem *> (view->itemAt (pos));
+	if (!item) return;
+	RObject *object = view->findItemObject (item);
+	if (!object) return;
+
+	// TODO: move all this to RObject::getDescription () or something similar (and complete it)
+	// merge with age-old code in RObjectViewer
+
+	tip (view->itemRect (item), object->getObjectDescription ());
+}
+
 #include "rkobjectlistview.moc"

Modified: trunk/rkward/rkward/misc/rkobjectlistview.h
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-09 11:41:11 UTC (rev 834)
+++ trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-09 15:08:52 UTC (rev 835)
@@ -18,12 +18,14 @@
 #define RKOBJECTLISTVIEW_H
 
 #include <qlistview.h>
+#include <qtooltip.h>
 #include <qmap.h>
 
 class RObject;
 class QPixmap;
 class QPopupMenu;
 class RKListViewItem;
+class RKObjectListViewTip;
 class RKObjectListViewSettings;
 
 /**
@@ -89,6 +91,7 @@
 	RObject *menu_object;
 
 	RKObjectListViewSettings *settings;
+	RKObjectListViewTip *tip;
 
 	static QPixmap *icon_function;
 	static QPixmap *icon_list;
@@ -109,6 +112,16 @@
 	int width (const QFontMetrics &fm, const QListView * lv, int c) const;
 };
 
+class RKObjectListViewTip : public QToolTip {
+protected:
+friend class RKObjectListView;
+	RKObjectListViewTip (RKObjectListView *parent);
+	~RKObjectListViewTip ();
+
+	void maybeTip (const QPoint &pos);
+	RKObjectListView *view;
+};
+
 /** Represents the filter/view settings possible for an RKListView. */
 class RKObjectListViewSettings : public QObject {
 	Q_OBJECT


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