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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Jul 31 14:21:39 UTC 2011


Revision: 3704
          http://rkward.svn.sourceforge.net/rkward/?rev=3704&view=rev
Author:   tfry
Date:     2011-07-31 14:21:39 +0000 (Sun, 31 Jul 2011)

Log Message:
-----------
Add support for the new results of help.search() (see https://stat.ethz.ch/pipermail/r-devel/2011-July/061659.html), and a few related additions. Needs testing.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/agents/showedittextfileagent.cpp
    trunk/rkward/rkward/rbackend/rkrbackend.cpp
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
    trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.edit.Rd
    trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
    trunk/rkward/rkward/windows/rkhelpsearchwindow.h

Added Paths:
-----------
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R
    trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.demo.Rd

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/ChangeLog	2011-07-31 14:21:39 UTC (rev 3704)
@@ -1,6 +1,9 @@
+- Support the results list new help.search() in R 2.14.x, which includes vignettes and demos		# TODO: actually test this with R 2.14!
+- rk.edit.files() and rk.show.files() gain parameter "prompt", which can be used to suppress user prompt
+- Added function rk.demo(), which is similar to demo(), but opens the example script in a script editor window
 - Fixed: Some plugin dialogs would not become visible, or be shown in very small size, with some window managers
 - Fixed: Potential crash when using context menus with "focus follows mouse" window activation policy
-- Add shortcut Ctrl+Enter to insert a linebreak and submit from a script editor
+- Added shortcut Ctrl+Enter to insert a linebreak and submit from a script editor
 - Reduce CPU usage while idle
 - Pareto-plot plugin gains more tabulation options				TODO: also use in piechart, barplot
 - rk.results() now prints rownames, where appropriate			TODO: test

Modified: trunk/rkward/rkward/agents/showedittextfileagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/showedittextfileagent.cpp	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/agents/showedittextfileagent.cpp	2011-07-31 14:21:39 UTC (rev 3704)
@@ -2,7 +2,7 @@
                           showedittextfileagent  -  description
                              -------------------
     begin                : Tue Sep 13 2005
-    copyright            : (C) 2005, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -79,6 +79,7 @@
 	QStringList files = request->params["files"].toStringList ();
 	QStringList titles = request->params["titles"].toStringList ();
 	QString wtitle = request->params["wtitle"].toString ();
+	bool prompt = request->params["prompt"].toBool ();
 	int count = files.count ();
 	RK_ASSERT (titles.count () == count);
 
@@ -100,12 +101,16 @@
 	if (request->type == RBackendRequest::ShowFiles) {
 		RK_ASSERT (!request->synchronous);
 
-		KMessageBox::informationList (RKWardMainWindow::getMain (), i18n ("A command running in the R-engine wants you to see the following file(s):\n"), display_titles, i18n ("Showing file(s)"), "show_files");
+		if (prompt) KMessageBox::informationList (RKWardMainWindow::getMain (), i18n ("A command running in the R-engine wants you to see the following file(s):\n"), display_titles, i18n ("Showing file(s)"), "show_files");
 
 		delete_files = request->params["delete"].toBool ();
 		RKRBackendProtocolFrontend::setRequestCompleted (request);
 	} else if (request->type == RBackendRequest::EditFiles) {
-		new ShowEditTextFileAgent (request, i18n ("A command running in the R-engine wants you to edit one or more file(s). Please look at these files, edit them as appriopriate, and save them. When done, press the \"Done\"-button, or close this dialog to resume.\n\n") + display_titles.join ("\n"), i18n ("Edit file(s)"));
+		if (prompt) {
+			new ShowEditTextFileAgent (request, i18n ("A command running in the R-engine wants you to edit one or more file(s). Please look at these files, edit them as appriopriate, and save them. When done, press the \"Done\"-button, or close this dialog to resume.\n\n") + display_titles.join ("\n"), i18n ("Edit file(s)"));
+		} else {
+			RKRBackendProtocolFrontend::setRequestCompleted (request);
+		}
 
 		r_highlighting = true;
 		read_only = false;

Modified: trunk/rkward/rkward/rbackend/rkrbackend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.cpp	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/rbackend/rkrbackend.cpp	2011-07-31 14:21:39 UTC (rev 3704)
@@ -554,7 +554,7 @@
 /* There are about one million possible entry points to editing / showing files. We try to cover them all, using the
 following bunch of functions (REditFilesHelper() and doShowEditFiles() are helpers, only) */
 
-void REditFilesHelper (QStringList files, QStringList titles, QString wtitle, RBackendRequest::RCallbackType edit, bool delete_files) {
+void REditFilesHelper (QStringList files, QStringList titles, QString wtitle, RBackendRequest::RCallbackType edit, bool delete_files, bool prompt) {
 	RK_TRACE (RBACKEND);
 
 	RK_ASSERT ((edit == RBackendRequest::ShowFiles) || (edit == RBackendRequest::EditFiles));
@@ -567,6 +567,7 @@
 	request.params["files"] = QVariant (files);
 	request.params["titles"] = QVariant (titles);
 	request.params["wtitle"] = QVariant (wtitle);
+	request.params["prompt"] = QVariant (prompt);
 
 	RKRBackend::this_pointer->handleRequest (&request);
 }
@@ -574,30 +575,31 @@
 int REditFiles (int nfile, const char **file, const char **title, const char *wtitle) {
 	RK_TRACE (RBACKEND);
 
-	REditFilesHelper (charPArrayToQStringList (file, nfile), charPArrayToQStringList (title, nfile), wtitle, RBackendRequest::EditFiles, false);
+	REditFilesHelper (charPArrayToQStringList (file, nfile), charPArrayToQStringList (title, nfile), wtitle, RBackendRequest::EditFiles, false, true);
 
 // default implementation seems to return 1 if nfile <= 0, else 1. No idea, what for. see unix/std-sys.c
 	return (nfile <= 0);
 }
 
-SEXP doShowEditFiles (SEXP files, SEXP titles, SEXP wtitle, SEXP del, RBackendRequest::RCallbackType edit) {
+SEXP doShowEditFiles (SEXP files, SEXP titles, SEXP wtitle, SEXP del, SEXP prompt, RBackendRequest::RCallbackType edit) {
 	RK_TRACE (RBACKEND);
 
 	QStringList file_strings = RKRSupport::SEXPToStringList (files);
 	QStringList title_strings = RKRSupport::SEXPToStringList (titles);
 	QString wtitle_string = RKRSupport::SEXPToString (wtitle);
 	bool del_files = RKRSupport::SEXPToInt (del, 0) != 0;
+	bool do_prompt = RKRSupport::SEXPToInt (prompt, 0) != 0;
 
 	RK_ASSERT (file_strings.size () == title_strings.size ());
 	RK_ASSERT (file_strings.size () >= 1);
 
-	REditFilesHelper (file_strings, title_strings, wtitle_string, edit, del_files);
+	REditFilesHelper (file_strings, title_strings, wtitle_string, edit, del_files, do_prompt);
 
 	return (R_NilValue);
 }
 
-SEXP doEditFiles (SEXP files, SEXP titles, SEXP wtitle) {
-	return (doShowEditFiles (files, titles, wtitle, R_NilValue, RBackendRequest::EditFiles));
+SEXP doEditFiles (SEXP files, SEXP titles, SEXP wtitle, SEXP prompt) {
+	return (doShowEditFiles (files, titles, wtitle, R_NilValue, prompt, RBackendRequest::EditFiles));
 }
 
 int REditFile (const char *buf) {
@@ -610,14 +612,14 @@
 	return REditFiles (1, const_cast<const char**> (&buf), &title, editor);
 }
 
-SEXP doShowFiles (SEXP files, SEXP titles, SEXP wtitle, SEXP delete_files) {
-	return (doShowEditFiles (files, titles, wtitle, delete_files, RBackendRequest::ShowFiles));
+SEXP doShowFiles (SEXP files, SEXP titles, SEXP wtitle, SEXP delete_files, SEXP prompt) {
+	return (doShowEditFiles (files, titles, wtitle, delete_files, prompt, RBackendRequest::ShowFiles));
 }
 
 int RShowFiles (int nfile, const char **file, const char **headers, const char *wtitle, Rboolean del, const char */* pager */) {
 	RK_TRACE (RBACKEND);
 
-	REditFilesHelper (charPArrayToQStringList (file, nfile), charPArrayToQStringList (headers, nfile), QString (wtitle), RBackendRequest::ShowFiles, (bool) del);
+	REditFilesHelper (charPArrayToQStringList (file, nfile), charPArrayToQStringList (headers, nfile), QString (wtitle), RBackendRequest::ShowFiles, (bool) del, true);
 
 // default implementation seems to returns 1 on success, 0 on failure. see unix/std-sys.c
 	return 1;
@@ -1008,8 +1010,8 @@
 		{ "rk.get.structure", (DL_FUNC) &doGetStructure, 4 },
 		{ "rk.get.structure.global", (DL_FUNC) &doGetGlobalEnvStructure, 3 },
 		{ "rk.copy.no.eval", (DL_FUNC) &doCopyNoEval, 3 },
-		{ "rk.edit.files", (DL_FUNC) &doEditFiles, 3 },
-		{ "rk.show.files", (DL_FUNC) &doShowFiles, 4 },
+		{ "rk.edit.files", (DL_FUNC) &doEditFiles, 4 },
+		{ "rk.show.files", (DL_FUNC) &doShowFiles, 5 },
 		{ "rk.dialog", (DL_FUNC) &doDialog, 6 },
 		{ "rk.update.locale", (DL_FUNC) &doUpdateLocale, 0 },
 		{ "rk.locale.name", (DL_FUNC) &doLocaleName, 0 },

Added: trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R	                        (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R	2011-07-31 14:21:39 UTC (rev 3704)
@@ -0,0 +1,60 @@
+## Public functions related to help search / display
+# Like demo(), but opens the demo in a script editor window
+"rk.demo" <- function (topic, package=NULL, lib.loc=NULL) {
+	if (is.null (package)) {
+		package <- .packages (lib.loc=lib.loc)
+	}
+
+	loc <- ""
+	for (p in package) {
+		loc <- system.file ("demo", paste (topic, ".R", sep=""), package=p, lib.loc=lib.loc)
+		if (loc != "") break
+	}
+
+	if (loc == "") stop ("No demo found for topic'", topic, "'")
+	rk.edit.files (loc, prompt=FALSE)
+}
+
+## Internal functions related to help search / display
+
+# retrieve the (expected) "base" url of help files. Most importantly this will be a local port for R 2.10.0 and above, but a local directory for 2.9.x and below. As a side effect, in R 2.10.0 and above, the dynamic help server is started.
+".rk.getHelpBaseUrl" <- function () {
+	port <- NA
+	if (compareVersion (as.character (getRversion()), "2.10.0") >= 0) {
+		try ({
+			port <- tools::startDynamicHelp ()
+		})
+		if (is.na (port)) {
+			try ({
+				port <- tools:::httpdPort
+			})
+		}
+	}
+	if (is.na (port)) {
+		return (paste ("file://", R.home (), sep=""))
+	}
+	return (paste ("http://127.0.0.1", port, sep=":"))
+}
+
+# a simple wrapper around help() that makes it easier to detect in code, whether help was found or not.
+# used from RKHelpSearchWindow::getFunctionHelp
+".rk.getHelp" <- function (...) {
+	if (compareVersion (as.character (getRversion()), "2.10.0") >= 0) {
+		res <- help (..., help_type="html")
+	} else {
+		res <- help (..., chmhelp=FALSE, htmlhelp=TRUE)
+	}
+	if (!length (as.character (res))) {	# this seems undocumented, but it is what utils:::print.help_files_with_topic checks
+		show (res)
+		stop ("No help found")
+	}
+	show (res)
+	invisible (TRUE)
+}
+
+# Simple wrapper around help.search. Concatenates the relevant fields of the results in order for passing to the frontend.
+".rk.get.search.results" <- function (pattern, ...) {
+	H=as.data.frame (help.search(pattern, ...)$matches)
+	if (is.null (H$Type)) H$Type <- "help"
+	c (as.character (H$topic), as.character (H$title), as.character(H$Package), as.character(H$Type))
+}

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2011-07-31 14:21:39 UTC (rev 3704)
@@ -85,12 +85,6 @@
 	return (list (as.character (x$Package), as.character (titles), as.character (x$Version), as.character (x$LibPath)))
 }
 
-# Here we concatenate everything (same as above) to get search results easily
-".rk.get.search.results" <- function (pattern, ...) {
-	H=as.data.frame (help.search(pattern, ...)$matches)
-	return(c(as.vector(H$topic),as.vector(H$title),as.vector(H$Package)))
-}
-
 ".rk.available.packages.cache" <- NULL
 # This function works like available.packages (with no arguments), but does simple caching of the result, and of course uses a cache if available. Cache is only used, if it is less than 1 hour old, and options("repos") is unchanged.
 ".rk.cached.available.packages" <- function () {
@@ -350,41 +344,6 @@
 	}
 }
 
-# retrieve the (expected) "base" url of help files. Most importantly this will be a local port for R 2.10.0 and above, but a local directory for 2.9.x and below. As a side effect, in R 2.10.0 and above, the dynamic help server is started.
-".rk.getHelpBaseUrl" <- function () {
-	port <- NA
-	if (compareVersion (as.character (getRversion()), "2.10.0") >= 0) {
-		try ({
-			port <- tools::startDynamicHelp ()
-		})
-		if (is.na (port)) {
-			try ({
-				port <- tools:::httpdPort
-			})
-		}
-	}
-	if (is.na (port)) {
-		return (paste ("file://", R.home (), sep=""))
-	}
-	return (paste ("http://127.0.0.1", port, sep=":"))
-}
-
-# a simple wrapper around help() that makes it easier to detect in code, whether help was found or not.
-# used from RKHelpSearchWindow::getFunctionHelp
-".rk.getHelp" <- function (...) {
-	if (compareVersion (as.character (getRversion()), "2.10.0") >= 0) {
-		res <- help (..., help_type="html")
-	} else {
-		res <- help (..., chmhelp=FALSE, htmlhelp=TRUE)
-	}
-	if (!length (as.character (res))) {	# this seems undocumented, but it is what utils:::print.help_files_with_topic checks
-		show (res)
-		stop ("No help found")
-	}
-	show (res)
-	invisible (TRUE)
-}
-
 # Tries to replace a function inside its environemnt/namespace.
 # Function formals are copied from the original.
 # A backup of the original is stored as rkward::.rk.FUNCTIONNAME.default

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public.R	2011-07-31 14:21:39 UTC (rev 3704)
@@ -373,23 +373,23 @@
 	x
 }
 
-"rk.edit.files" <- function (file = file, title = file, name = NULL)
+"rk.edit.files" <- function (file = file, title = file, name = NULL, prompt = TRUE)
 {
 	if (!is.character (file)) {
 		nfile = tempfile()
 		env = environment (file)
 		dput (file, file=nfile, control=c ("useSource", "keepNA", "keepInteger", "showAttributes"))
-		.Call("rk.edit.files", nfile, title, name)
+		.Call("rk.edit.files", nfile, title, name, prompt)
 		x <- dget (nfile)
 		environment (x) <- env
 		return (x)
 	}
-	invisible (.Call ("rk.edit.files", file, title, name))
+	invisible (.Call ("rk.edit.files",  as.character (file),  as.character (title),  as.character (name), isTRUE (prompt)))
 }
 
-"rk.show.files" <- function (file = file, title = file, wtitle = NULL, delete=FALSE)
+"rk.show.files" <- function (file = file, title = file, wtitle = NULL, delete=FALSE, prompt = TRUE)
 {
-	invisible (.Call ("rk.show.files", as.character (file), as.character (title), as.character (wtitle), delete))
+	invisible (.Call ("rk.show.files", as.character (file), as.character (title), as.character (wtitle), delete, isTRUE (prompt)))
 }
 
 "rk.show.html" <- function (url) {

Added: trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.demo.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.demo.Rd	                        (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.demo.Rd	2011-07-31 14:21:39 UTC (rev 3704)
@@ -0,0 +1,36 @@
+\name{rk.demo}
+\alias{rk.demo}
+
+\title{Opens an R demo script for editing}
+
+\usage{
+rk.demo(topic, package=NULL, lib.loc=NULL)
+}
+
+\arguments{
+  \item{topic}{topic of the example}
+  \item{package}{package(s) to search for the demo. If NULL (the default), all currently loaded packages are searched.}
+  \item{lib.loc}{Library locations.}
+}
+
+\details{
+  \code{rk.demo} behaves similar to \code{\link{demo}}, but opens the demo script for editing, instead of sourcing it. Contrary to \code{\link{demo}}, the specification of a topic is mandatory.
+}
+
+\value{
+  Return \code{NULL}, unconditionally.
+}
+
+\author{Thomas Friedrichsmeier \email{rkward-devel at lists.sourceforge.net}}
+
+\seealso{
+  \code{\link{rk.edit.files}}, \code{\link{rk.show.files}}, \code{\link{demo}}
+}
+
+\examples{
+## Not run
+rk.demo("graphics")
+}
+
+\keyword{utilities}
+\keyword{IO}

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.edit.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.edit.Rd	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.edit.Rd	2011-07-31 14:21:39 UTC (rev 3704)
@@ -8,8 +8,8 @@
 
 \usage{
 rk.edit(x)
-rk.edit.files(file = file, title = file, name = NULL)
-rk.show.files(file = file, title = file, wtitle = NULL, delete = FALSE)
+rk.edit.files(file = file, title = file, name = NULL, prompt = TRUE)
+rk.show.files(file = file, title = file, wtitle = NULL, delete = FALSE, prompt = TRUE)
 rk.show.html(url)
 }
 
@@ -18,6 +18,7 @@
   \item{file}{character vector, filenames to show or edit.}
   \item{title}{character vector, of the same length as \code{file}; This can be used to give descriptive titles to each file, which will be displayed to the user.}
   \item{wtitle}{character vector, of length 1. This will be used as the window title.}
+  \item{prompt}{logical of length 1. If TRUE (the default) a prompt is dialog is shown along with the files to show / edit.}
   \item{delete}{a logical (not NA), when \code{TRUE} the shown file(s) are deleted after closing.}
 }
 

Modified: trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2011-07-31 14:21:39 UTC (rev 3704)
@@ -41,6 +41,7 @@
 #include "../core/robject.h"
 #include "../misc/rkcommonfunctions.h"
 #include "../misc/rkdummypart.h"
+#include "../misc/rkstandardicons.h"
 
 #define GET_HELP 1
 #define HELP_SEARCH 2
@@ -158,11 +159,15 @@
 	getFunctionHelp (result);
 }
 
-void RKHelpSearchWindow::getFunctionHelp (const QString &function_name, const QString &package) {
+void RKHelpSearchWindow::getFunctionHelp (const QString &function_name, const QString &package, const QString &type) {
 	RK_TRACE (APP);
 
 	// we use .rk.getHelp() instead of plain help() to receive an error, if no help could be found
-	QString command = ".rk.getHelp(" + RObject::rQuote (function_name);
+	QString command;
+	if (type.isEmpty () || type == "help") command = ".rk.getHelp(";
+	else if (type == "demo") command = "rk.demo(";
+	else if (type == "vignette") command = "vignette(";
+	command.append (RObject::rQuote (function_name));
 	if (!package.isEmpty ()) command.append (", package=" + package);
 	command.append (")");
 
@@ -211,10 +216,11 @@
 
 	int row = proxy_model->mapToSource (index).row ();
 	QString topic = results->data (results->index (row, COL_TOPIC)).toString ();
+	if (topic.isEmpty ()) return;
 	QString package = results->data (results->index (row, COL_PACKAGE)).toString ();
-	if (topic.isEmpty ()) return;
+	QString type = results->resultsType (row);
 
-	getFunctionHelp (topic, package);
+	getFunctionHelp (topic, package, type);
 }
 
 void RKHelpSearchWindow::rCommandDone (RCommand *command) {
@@ -224,7 +230,6 @@
 			RK_ASSERT (false);
 			return;
 		}
-		RK_ASSERT ((command->getDataLength () % 3) == 0);
 		RK_ASSERT (command->getDataType () == RData::StringVector);
 
 		results->setResults (command->getStringVector ());
@@ -258,12 +263,17 @@
 	RK_TRACE (APP);
 }
 
-void RKHelpSearchResultsModel::setResults (const QStringList &new_results) {
+void RKHelpSearchResultsModel::setResults (const QStringList &results) {
 	RK_TRACE (APP);
 
-	results = new_results;
-	result_count = results.size () / 3;
+	RK_ASSERT ((results.size () % 4) == 0);
 
+	result_count = results.size () / 4;
+	topics = results.mid (0, result_count);
+	titles = results.mid (result_count, result_count);
+	packages = results.mid (result_count*2, result_count);
+	types = results.mid (result_count*3, result_count);
+
 	reset ();
 }
 
@@ -279,6 +289,16 @@
 	return COL_COUNT;
 }
 
+QString RKHelpSearchResultsModel::resultsType (int row) {
+	RK_TRACE (APP);
+
+	if (row >= result_count) {
+		RK_ASSERT (false);
+		return QString ();
+	}
+	return types[row];
+}
+
 QVariant RKHelpSearchResultsModel::data (const QModelIndex& index, int role) const {
 	// don't trace
 
@@ -288,14 +308,16 @@
 	if (result_count) {
 		if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
 			if (row < result_count) {
-				if (col < COL_COUNT) {
-					return results[row + col * result_count];
-				} else {
-				
-				}
+				if (col == COL_TOPIC) return topics[row];
+				if (col == COL_TITLE) return titles[row];
+				if (col == COL_PACKAGE) return packages[row];
 			} else {
 				RK_ASSERT (false);
 			}
+		} else if ((col == 0) && (role == Qt::DecorationRole)) {
+			if (types[col] == "help") return RKStandardIcons::getIcon (RKStandardIcons::WindowHelp);
+			if (types[col] == "demo") return RKStandardIcons::getIcon (RKStandardIcons::WindowCommandEditor);
+			if (types[col] == "vignette") return RKStandardIcons::getIcon (RKStandardIcons::WindowFileBrowser);		// TODO: find a better icon
 		}
 	} else {
 		RK_ASSERT (false);

Modified: trunk/rkward/rkward/windows/rkhelpsearchwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.h	2011-06-27 15:06:42 UTC (rev 3703)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.h	2011-07-31 14:21:39 UTC (rev 3704)
@@ -2,7 +2,7 @@
                           rkhelpsearchwindow  -  description
                              -------------------
     begin                : Fri Feb 25 2005
-    copyright            : (C) 2005, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -47,7 +47,7 @@
 @param cursor_pos cursor position in the current line
 Will figure out the word under the cursor, and provide help on that (if there is such a word, and such help exists) */
 	void getContextHelp (const QString &context_line, int cursor_pos);
-	void getFunctionHelp (const QString &function_name, const QString &package=QString());
+	void getFunctionHelp (const QString &function_name, const QString &package=QString(), const QString &type=QString ());
 	static RKHelpSearchWindow *mainHelpSearch () { return main_help_search; };
 public slots:
 	void slotFindButtonClicked();
@@ -84,8 +84,12 @@
 	int columnCount (const QModelIndex& parent=QModelIndex()) const;
 	QVariant data (const QModelIndex& index, int role=Qt::DisplayRole) const;
 	QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
+	QString resultsType (int row);
 private:
-	QStringList results;
+	QStringList topics;
+	QStringList titles;
+	QStringList packages;
+	QStringList types;
 	int result_count;
 };
 


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