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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Feb 28 16:22:25 UTC 2007


Revision: 1505
          http://svn.sourceforge.net/rkward/?rev=1505&view=rev
Author:   tfry
Date:     2007-02-28 08:22:24 -0800 (Wed, 28 Feb 2007)

Log Message:
-----------
Move khelpdlg.h/.cpp to windows and rename to rkhelpsearchwindow.h/.cpp

Modified Paths:
--------------
    trunk/rkward/rkward/Makefile.am
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/robjectbrowser.cpp
    trunk/rkward/rkward/windows/Makefile.am
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp

Added Paths:
-----------
    trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
    trunk/rkward/rkward/windows/rkhelpsearchwindow.h

Removed Paths:
-------------
    trunk/rkward/rkward/khelpdlg.cpp
    trunk/rkward/rkward/khelpdlg.h

Modified: trunk/rkward/rkward/Makefile.am
===================================================================
--- trunk/rkward/rkward/Makefile.am	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/Makefile.am	2007-02-28 16:22:24 UTC (rev 1505)
@@ -23,11 +23,11 @@
 
 rkward_bin_SOURCES = rkward.cpp main.cpp \
 	rkglobals.cpp robjectbrowser.cpp robjectviewer.cpp \
-	khelpdlg.cpp rkconsole.cpp rkward.skel rkwardapplication.cpp
+	rkconsole.cpp rkward.skel rkwardapplication.cpp
 
 noinst_HEADERS = rkward.h debug.h \
 	rkglobals.h robjectbrowser.h robjectviewer.h \
-	khelpdlg.h rkconsole.h rkwardapplication.h
+	rkconsole.h rkwardapplication.h
 
 rkward_bin_LDADD = $(top_builddir)/rkward/windows/libwindows.a \
 	$(top_builddir)/rkward/agents/libagents.a $(top_builddir)/rkward/dialogs/libdialogs.a \

Deleted: trunk/rkward/rkward/khelpdlg.cpp
===================================================================
--- trunk/rkward/rkward/khelpdlg.cpp	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/khelpdlg.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -1,216 +0,0 @@
-/***************************************************************************
-                          khelpdlg  -  description
-                             -------------------
-    begin                : Fri Feb 25 2005
-    copyright            : (C) 2005, 2006 by Thomas Friedrichsmeier
-    email                : tfry at users.sourceforge.net
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#include "khelpdlg.h"
-
-#include <klocale.h>
-#include <kurl.h>
-#include <kmessagebox.h>
-
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qlistview.h>
-#include <qlineedit.h>
-#include <qlayout.h>
-#include <qlabel.h>
-
-#include "rbackend/rinterface.h"
-#include "rbackend/rcommandreceiver.h"
-#include "debug.h"
-#include "rkglobals.h"
-#include "rkward.h"
-#include "misc/rkcommonfunctions.h"
-#include "misc/rkdummypart.h"
-
-#define GET_HELP_URL 1
-#define HELP_SEARCH 2
-#define GET_INSTALLED_PACKAGES 3
-
-RKHelpSearchWindow* RKHelpSearchWindow::main_help_search = 0;
-
-RKHelpSearchWindow::RKHelpSearchWindow (QWidget *parent, bool tool_window, char *name) : RKMDIWindow (parent, SearchHelpWindow, tool_window, name) {
-	RK_TRACE (APP);
-	part = new RKDummyPart (0, this);
-	setFocusPolicy (QWidget::ClickFocus);
-	initializeActivationSignals ();
-
-	QVBoxLayout* main_layout = new QVBoxLayout (this, RKGlobals::marginHint (), RKGlobals::spacingHint ());
-	QHBoxLayout* selection_layout = new QHBoxLayout (main_layout, RKGlobals::spacingHint ());
-
-	QVBoxLayout* labels_layout = new QVBoxLayout (selection_layout, RKGlobals::spacingHint ());
-	QLabel *label = new QLabel (i18n ("Find:"), this);
-	label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
-	labels_layout->addWidget (label);
-	label = new QLabel (i18n ("Fields:"), this);
-	label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
-	labels_layout->addWidget (label);
-
-	QVBoxLayout* main_settings_layout = new QVBoxLayout (selection_layout, RKGlobals::spacingHint ());
-	field = new QComboBox (true, this);
-	field->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
-	connect (field->lineEdit () , SIGNAL (returnPressed ()), this, SLOT (slotFindButtonClicked ()));
-	main_settings_layout->addWidget (field);
-
-	QHBoxLayout* fields_packages_layout = new QHBoxLayout (main_settings_layout, RKGlobals::spacingHint ());
-	fieldsList = new QComboBox (false, this);
-	// HACK the sequence of options is hardcoded, do not modify
-	fieldsList->insertItem (i18n("All"));
-	fieldsList->insertItem (i18n("All but keywords"));
-	fieldsList->insertItem (i18n("Keywords"));
-	fieldsList->insertItem (i18n("Title"));
-	fields_packages_layout->addWidget (fieldsList);
-
-	label = new QLabel (i18n ("Package:"), this);
-	label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
-	fields_packages_layout->addWidget (label);
-
-	packagesList = new QComboBox (false, this);
-	packagesList->insertItem (i18n("All"));
-	fields_packages_layout->addWidget (packagesList);
-
-	QVBoxLayout* checkboxes_layout = new QVBoxLayout (selection_layout, RKGlobals::spacingHint ());
-	caseSensitiveCheckBox = new QCheckBox (i18n ("Case sensitive"), this);
-	checkboxes_layout->addWidget (caseSensitiveCheckBox);
-	fuzzyCheckBox = new QCheckBox (i18n ("Fuzzy matching"), this);
-	fuzzyCheckBox->setChecked (true);
-	checkboxes_layout->addWidget (fuzzyCheckBox);
-
-	findButton = new QPushButton (i18n ("Find"), this);
-	findButton->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
-	connect (findButton, SIGNAL (clicked ()), this, SLOT (slotFindButtonClicked ()));
-	selection_layout->addWidget (findButton);
-
-	resultsList = new QListView (this);
-	resultsList->addColumn (i18n ("Topic"));
-	resultsList->addColumn (i18n ("Title"));
-	resultsList->addColumn (i18n ("Package"));
-	connect (resultsList, SIGNAL (doubleClicked (QListViewItem*, const QPoint&, int)), this, SLOT (slotResultsListDblClicked (QListViewItem*, const QPoint&, int)));
-	main_layout->addWidget (resultsList);
-
-	RKGlobals::rInterface ()->issueCommand (".rk.get.installed.packages ()[[1]]", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, GET_INSTALLED_PACKAGES, 0);
-
-	setCaption (i18n ("Help search"));
-}
-
-RKHelpSearchWindow::~RKHelpSearchWindow () {
-	RK_TRACE (APP);
-}
-
-void RKHelpSearchWindow::getContextHelp (const QString &context_line, int cursor_pos) {
-	RK_TRACE (APP);
-	QString result = RKCommonFunctions::getCurrentSymbol (context_line, cursor_pos);
-	if (result.isEmpty ()) return;
-
-	getFunctionHelp (result);
-}
-
-void RKHelpSearchWindow::getFunctionHelp (const QString &function_name) {
-	RK_TRACE (APP);
-	RKGlobals::rInterface ()->issueCommand ("help(\"" + function_name + "\", htmlhelp=TRUE)[1]", RCommand::App | RCommand::GetStringVector, QString::null, this, GET_HELP_URL, 0);
-}
-
-void RKHelpSearchWindow::slotFindButtonClicked () {
-	RK_TRACE (APP);
-
-	if (field->currentText ().isEmpty ()) {
-		return;
-	}
-	
-	QString agrep = "FALSE";
-	if (fuzzyCheckBox->isChecked ()) {
-		agrep="NULL";
-	}
-	
-	QString ignoreCase = "TRUE";
-	if(caseSensitiveCheckBox->isChecked ()) {
-		ignoreCase="FALSE";
-	}
-	
-	QString package = "NULL";
-	if (packagesList->currentItem ()!=0) {
-		package="\"";
-		package.append (packagesList->currentText ());
-		package.append ("\"");
-	}
-
-	// HACK the sequence of options is hardcoded, do not modify
-	QString fields;
-	
-	switch (fieldsList->currentItem ()) {
-		case 1: fields = "c(\"alias\", \"concept\", \"title\")";break;
-		case 2: fields = "c(\"keyword\")";break;
-		case 3: fields = "c(\"title\")";break;
-		default: fields = "c(\"alias\", \"concept\", \"title\",\"keyword\")";
-	}
-
-	QString s = ".rk.get.search.results (\"" + field->currentText () + "\",agrep=" + agrep + ", ignore.case=" + ignoreCase + ", package=" + package + ", fields=" + fields +")";
-	
-	RKGlobals::rInterface ()->issueCommand (s, RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, HELP_SEARCH, 0);
-	setEnabled (false);
-	field->insertItem (field->currentText ());
-}
-
-void RKHelpSearchWindow::slotResultsListDblClicked (QListViewItem * item, const QPoint &, int) {
-	RK_TRACE (APP);
-	if (item == NULL) {
-		return;
-	}
-	if (item->text(0).isEmpty ()) {
-		return;
-	}
-	
-	QString s="help(\"";
-	s.append (item->text (0));
-	s.append ("\", htmlhelp=TRUE, package= \"");
-	s.append (item->text (2));
-	s.append ("\")");
-	
-	RKGlobals::rInterface ()->issueCommand (s, RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, GET_HELP_URL, 0);
-}
-
-void RKHelpSearchWindow::rCommandDone (RCommand *command) {
-	RK_TRACE (APP);
-	KURL url;
-	if (command->getFlags () == HELP_SEARCH) {
-		resultsList->clear ();
-		RK_ASSERT ((command->getDataLength () % 3) == 0);
-		int count = (command->getDataLength () / 3);
-		for (int i=0; i < count; ++i) {
-			new QListViewItem (resultsList, command->getStringVector ()[i], command->getStringVector ()[count + i], command->getStringVector ()[2*count + i]);
-		}
-		setEnabled(true);
-	} else if (command->getFlags () == GET_HELP_URL) {
-		RK_ASSERT (command->getDataLength ());
-		url.setPath(command->getStringVector ()[0]);
-		if (QFile::exists (url.path ())) {
-			RKWardMainWindow::getMain ()->openHTML (url);
-			return;
-		} else {
-			KMessageBox::sorry (this, i18n ("No help found on '%1'. Maybe the corresponding package is not installed/loaded, or maybe you mistyped the command. Try using Help->Search R Help for more options.").arg (command->command ().section ("\"", 1, 1)), i18n ("No help found"));
-		}
-	} else if (command->getFlags () == GET_INSTALLED_PACKAGES) {
-		RK_ASSERT (command->getDataType () == RData::StringVector);
-		unsigned int count = command->getDataLength ();
-		for (unsigned int i=0; i < count; ++i) {
-			packagesList->insertItem (command->getStringVector ()[i]);
-		}
-	} else {
-		RK_ASSERT (false);
-	}
-}
-
-#include "khelpdlg.moc"

Deleted: trunk/rkward/rkward/khelpdlg.h
===================================================================
--- trunk/rkward/rkward/khelpdlg.h	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/khelpdlg.h	2007-02-28 16:22:24 UTC (rev 1505)
@@ -1,68 +0,0 @@
-/***************************************************************************
-                          khelpdlg  -  description
-                             -------------------
-    begin                : Fri Feb 25 2005
-    copyright            : (C) 2005, 2006 by Thomas Friedrichsmeier
-    email                : tfry at users.sourceforge.net
- ***************************************************************************/
-
-/***************************************************************************
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- ***************************************************************************/
-
-#ifndef RKHELPSEARCHWINDOW_H
-#define RKHELPSEARCHWINDOW_H
-
-#include <qwidget.h>
-
-#include "rbackend/rcommandreceiver.h"
-#include "windows/rkmdiwindow.h"
-
-class QComboBox;
-class QCheckBox;
-class QPushButton;
-class QListView;
-class QListViewItem;
-
-class RCommandChain;
-
-/** Provides a UI interface for help-search.
-
- at author Pierre Ecochard */
-class RKHelpSearchWindow : public RKMDIWindow, public RCommandReceiver {
-	Q_OBJECT
-public:
-	RKHelpSearchWindow (QWidget *parent, bool tool_window, char *name=0);
-	~RKHelpSearchWindow ();
-	void rCommandDone (RCommand *command);
-
-	KParts::Part *getPart () { return part; };
-/** small convenience function to get context help for RKCommandEditorWindow and RKConsole.
- at param context_line The current line
- at 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);
-	static RKHelpSearchWindow *mainHelpSearch () { return main_help_search; };
-public slots:
-	void slotFindButtonClicked();
-	void slotResultsListDblClicked( QListViewItem *item, const QPoint &, int );
-private:
-	QComboBox* field;
-	QComboBox* fieldsList;
-	QComboBox* packagesList;
-	QCheckBox* caseSensitiveCheckBox;
-	QCheckBox* fuzzyCheckBox;
-	QPushButton* findButton;
-	QListView* resultsList;
-	KParts::Part *part;
-friend class RKWardMainWindow;
-	static RKHelpSearchWindow *main_help_search;
-};
-
-#endif

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/rkconsole.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -33,7 +33,7 @@
 
 #include "rkglobals.h"
 #include "rkward.h"
-#include "khelpdlg.h"
+#include "windows/rkhelpsearchwindow.h"
 #include "rbackend/rinterface.h"
 #include "rbackend/rcommand.h"
 #include "settings/rksettings.h"

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/rkward.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -73,7 +73,7 @@
 #include "windows/rkworkplaceview.h"
 #include "windows/rkworkplace.h"
 #include "windows/rkcommandlog.h"
-#include "khelpdlg.h"
+#include "windows/rkhelpsearchwindow.h"
 #include "rkconsole.h"
 #include "debug.h"
 

Modified: trunk/rkward/rkward/robjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/robjectbrowser.cpp	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/robjectbrowser.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -29,7 +29,7 @@
 #include <kmessagebox.h>
 
 #include "rkward.h"
-#include "khelpdlg.h"
+#include "windows/rkhelpsearchwindow.h"
 #include "windows/rkcommandeditorwindow.h"
 #include "rkglobals.h"
 #include "core/robjectlist.h"

Modified: trunk/rkward/rkward/windows/Makefile.am
===================================================================
--- trunk/rkward/rkward/windows/Makefile.am	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/windows/Makefile.am	2007-02-28 16:22:24 UTC (rev 1505)
@@ -3,10 +3,12 @@
 noinst_LIBRARIES =  libwindows.a
 noinst_HEADERS = rkcommandeditorwindow.h rkcommandeditorwindowpart.h \
 	rkhtmlwindow.h rcontrolwindow.h detachedwindowcontainer.h rkmdiwindow.h \
-	rkworkplaceview.h rkworkplace.h qxembedcopy.h rkwindowcatcher.h rkcommandlog.h
+	rkworkplaceview.h rkworkplace.h qxembedcopy.h rkwindowcatcher.h rkcommandlog.h \
+	rkhelpsearchwindow.h
 libwindows_a_SOURCES = rkcommandeditorwindow.cpp rkcommandeditorwindowpart.cpp \
 	rkhtmlwindow.cpp rcontrolwindow.cpp detachedwindowcontainer.cpp rkmdiwindow.cpp \
-	rkworkplaceview.cpp rkworkplace.cpp qxembedcopy.cpp rkwindowcatcher.cpp rkcommandlog.cpp
+	rkworkplaceview.cpp rkworkplace.cpp qxembedcopy.cpp rkwindowcatcher.cpp rkcommandlog.cpp \
+	rkhelpsearchwindow.cpp
 rcdir = $(kde_datadir)/rkward
 rc_DATA = rkcommandeditorwindowpart.rc rkoutputwindow.rc rkhelpwindow.rc detachedwindowcontainer.rc \
 	rkcatchedx11windowpart.rc rkcommandlogpart.rc

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -51,7 +51,7 @@
 #include "../core/robjectlist.h"
 #include "../rkglobals.h"
 #include "../rkward.h"
-#include "../khelpdlg.h"
+#include "rkhelpsearchwindow.h"
 #include "rkcommandeditorwindowpart.h"
 
 #include "../debug.h"

Copied: trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp (from rev 1504, trunk/rkward/rkward/khelpdlg.cpp)
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	                        (rev 0)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -0,0 +1,216 @@
+/***************************************************************************
+                          khelpdlg  -  description
+                             -------------------
+    begin                : Fri Feb 25 2005
+    copyright            : (C) 2005, 2006 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "rkhelpsearchwindow.h"
+
+#include <klocale.h>
+#include <kurl.h>
+#include <kmessagebox.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlistview.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include "../rbackend/rinterface.h"
+#include "../rbackend/rcommandreceiver.h"
+#include "../debug.h"
+#include "../rkglobals.h"
+#include "../rkward.h"
+#include "../misc/rkcommonfunctions.h"
+#include "../misc/rkdummypart.h"
+
+#define GET_HELP_URL 1
+#define HELP_SEARCH 2
+#define GET_INSTALLED_PACKAGES 3
+
+RKHelpSearchWindow* RKHelpSearchWindow::main_help_search = 0;
+
+RKHelpSearchWindow::RKHelpSearchWindow (QWidget *parent, bool tool_window, char *name) : RKMDIWindow (parent, SearchHelpWindow, tool_window, name) {
+	RK_TRACE (APP);
+	part = new RKDummyPart (0, this);
+	setFocusPolicy (QWidget::ClickFocus);
+	initializeActivationSignals ();
+
+	QVBoxLayout* main_layout = new QVBoxLayout (this, RKGlobals::marginHint (), RKGlobals::spacingHint ());
+	QHBoxLayout* selection_layout = new QHBoxLayout (main_layout, RKGlobals::spacingHint ());
+
+	QVBoxLayout* labels_layout = new QVBoxLayout (selection_layout, RKGlobals::spacingHint ());
+	QLabel *label = new QLabel (i18n ("Find:"), this);
+	label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
+	labels_layout->addWidget (label);
+	label = new QLabel (i18n ("Fields:"), this);
+	label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
+	labels_layout->addWidget (label);
+
+	QVBoxLayout* main_settings_layout = new QVBoxLayout (selection_layout, RKGlobals::spacingHint ());
+	field = new QComboBox (true, this);
+	field->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+	connect (field->lineEdit () , SIGNAL (returnPressed ()), this, SLOT (slotFindButtonClicked ()));
+	main_settings_layout->addWidget (field);
+
+	QHBoxLayout* fields_packages_layout = new QHBoxLayout (main_settings_layout, RKGlobals::spacingHint ());
+	fieldsList = new QComboBox (false, this);
+	// HACK the sequence of options is hardcoded, do not modify
+	fieldsList->insertItem (i18n("All"));
+	fieldsList->insertItem (i18n("All but keywords"));
+	fieldsList->insertItem (i18n("Keywords"));
+	fieldsList->insertItem (i18n("Title"));
+	fields_packages_layout->addWidget (fieldsList);
+
+	label = new QLabel (i18n ("Package:"), this);
+	label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum);
+	fields_packages_layout->addWidget (label);
+
+	packagesList = new QComboBox (false, this);
+	packagesList->insertItem (i18n("All"));
+	fields_packages_layout->addWidget (packagesList);
+
+	QVBoxLayout* checkboxes_layout = new QVBoxLayout (selection_layout, RKGlobals::spacingHint ());
+	caseSensitiveCheckBox = new QCheckBox (i18n ("Case sensitive"), this);
+	checkboxes_layout->addWidget (caseSensitiveCheckBox);
+	fuzzyCheckBox = new QCheckBox (i18n ("Fuzzy matching"), this);
+	fuzzyCheckBox->setChecked (true);
+	checkboxes_layout->addWidget (fuzzyCheckBox);
+
+	findButton = new QPushButton (i18n ("Find"), this);
+	findButton->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
+	connect (findButton, SIGNAL (clicked ()), this, SLOT (slotFindButtonClicked ()));
+	selection_layout->addWidget (findButton);
+
+	resultsList = new QListView (this);
+	resultsList->addColumn (i18n ("Topic"));
+	resultsList->addColumn (i18n ("Title"));
+	resultsList->addColumn (i18n ("Package"));
+	connect (resultsList, SIGNAL (doubleClicked (QListViewItem*, const QPoint&, int)), this, SLOT (slotResultsListDblClicked (QListViewItem*, const QPoint&, int)));
+	main_layout->addWidget (resultsList);
+
+	RKGlobals::rInterface ()->issueCommand (".rk.get.installed.packages ()[[1]]", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, GET_INSTALLED_PACKAGES, 0);
+
+	setCaption (i18n ("Help search"));
+}
+
+RKHelpSearchWindow::~RKHelpSearchWindow () {
+	RK_TRACE (APP);
+}
+
+void RKHelpSearchWindow::getContextHelp (const QString &context_line, int cursor_pos) {
+	RK_TRACE (APP);
+	QString result = RKCommonFunctions::getCurrentSymbol (context_line, cursor_pos);
+	if (result.isEmpty ()) return;
+
+	getFunctionHelp (result);
+}
+
+void RKHelpSearchWindow::getFunctionHelp (const QString &function_name) {
+	RK_TRACE (APP);
+	RKGlobals::rInterface ()->issueCommand ("help(\"" + function_name + "\", htmlhelp=TRUE)[1]", RCommand::App | RCommand::GetStringVector, QString::null, this, GET_HELP_URL, 0);
+}
+
+void RKHelpSearchWindow::slotFindButtonClicked () {
+	RK_TRACE (APP);
+
+	if (field->currentText ().isEmpty ()) {
+		return;
+	}
+	
+	QString agrep = "FALSE";
+	if (fuzzyCheckBox->isChecked ()) {
+		agrep="NULL";
+	}
+	
+	QString ignoreCase = "TRUE";
+	if(caseSensitiveCheckBox->isChecked ()) {
+		ignoreCase="FALSE";
+	}
+	
+	QString package = "NULL";
+	if (packagesList->currentItem ()!=0) {
+		package="\"";
+		package.append (packagesList->currentText ());
+		package.append ("\"");
+	}
+
+	// HACK the sequence of options is hardcoded, do not modify
+	QString fields;
+	
+	switch (fieldsList->currentItem ()) {
+		case 1: fields = "c(\"alias\", \"concept\", \"title\")";break;
+		case 2: fields = "c(\"keyword\")";break;
+		case 3: fields = "c(\"title\")";break;
+		default: fields = "c(\"alias\", \"concept\", \"title\",\"keyword\")";
+	}
+
+	QString s = ".rk.get.search.results (\"" + field->currentText () + "\",agrep=" + agrep + ", ignore.case=" + ignoreCase + ", package=" + package + ", fields=" + fields +")";
+	
+	RKGlobals::rInterface ()->issueCommand (s, RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, HELP_SEARCH, 0);
+	setEnabled (false);
+	field->insertItem (field->currentText ());
+}
+
+void RKHelpSearchWindow::slotResultsListDblClicked (QListViewItem * item, const QPoint &, int) {
+	RK_TRACE (APP);
+	if (item == NULL) {
+		return;
+	}
+	if (item->text(0).isEmpty ()) {
+		return;
+	}
+	
+	QString s="help(\"";
+	s.append (item->text (0));
+	s.append ("\", htmlhelp=TRUE, package= \"");
+	s.append (item->text (2));
+	s.append ("\")");
+	
+	RKGlobals::rInterface ()->issueCommand (s, RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, GET_HELP_URL, 0);
+}
+
+void RKHelpSearchWindow::rCommandDone (RCommand *command) {
+	RK_TRACE (APP);
+	KURL url;
+	if (command->getFlags () == HELP_SEARCH) {
+		resultsList->clear ();
+		RK_ASSERT ((command->getDataLength () % 3) == 0);
+		int count = (command->getDataLength () / 3);
+		for (int i=0; i < count; ++i) {
+			new QListViewItem (resultsList, command->getStringVector ()[i], command->getStringVector ()[count + i], command->getStringVector ()[2*count + i]);
+		}
+		setEnabled(true);
+	} else if (command->getFlags () == GET_HELP_URL) {
+		RK_ASSERT (command->getDataLength ());
+		url.setPath(command->getStringVector ()[0]);
+		if (QFile::exists (url.path ())) {
+			RKWardMainWindow::getMain ()->openHTML (url);
+			return;
+		} else {
+			KMessageBox::sorry (this, i18n ("No help found on '%1'. Maybe the corresponding package is not installed/loaded, or maybe you mistyped the command. Try using Help->Search R Help for more options.").arg (command->command ().section ("\"", 1, 1)), i18n ("No help found"));
+		}
+	} else if (command->getFlags () == GET_INSTALLED_PACKAGES) {
+		RK_ASSERT (command->getDataType () == RData::StringVector);
+		unsigned int count = command->getDataLength ();
+		for (unsigned int i=0; i < count; ++i) {
+			packagesList->insertItem (command->getStringVector ()[i]);
+		}
+	} else {
+		RK_ASSERT (false);
+	}
+}
+
+#include "rkhelpsearchwindow.moc"

Copied: trunk/rkward/rkward/windows/rkhelpsearchwindow.h (from rev 1504, trunk/rkward/rkward/khelpdlg.h)
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.h	                        (rev 0)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.h	2007-02-28 16:22:24 UTC (rev 1505)
@@ -0,0 +1,68 @@
+/***************************************************************************
+                          khelpdlg  -  description
+                             -------------------
+    begin                : Fri Feb 25 2005
+    copyright            : (C) 2005, 2006 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef RKHELPSEARCHWINDOW_H
+#define RKHELPSEARCHWINDOW_H
+
+#include <qwidget.h>
+
+#include "../rbackend/rcommandreceiver.h"
+#include "rkmdiwindow.h"
+
+class QComboBox;
+class QCheckBox;
+class QPushButton;
+class QListView;
+class QListViewItem;
+
+class RCommandChain;
+
+/** Provides a UI interface for help-search.
+
+ at author Pierre Ecochard */
+class RKHelpSearchWindow : public RKMDIWindow, public RCommandReceiver {
+	Q_OBJECT
+public:
+	RKHelpSearchWindow (QWidget *parent, bool tool_window, char *name=0);
+	~RKHelpSearchWindow ();
+	void rCommandDone (RCommand *command);
+
+	KParts::Part *getPart () { return part; };
+/** small convenience function to get context help for RKCommandEditorWindow and RKConsole.
+ at param context_line The current line
+ at 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);
+	static RKHelpSearchWindow *mainHelpSearch () { return main_help_search; };
+public slots:
+	void slotFindButtonClicked();
+	void slotResultsListDblClicked( QListViewItem *item, const QPoint &, int );
+private:
+	QComboBox* field;
+	QComboBox* fieldsList;
+	QComboBox* packagesList;
+	QCheckBox* caseSensitiveCheckBox;
+	QCheckBox* fuzzyCheckBox;
+	QPushButton* findButton;
+	QListView* resultsList;
+	KParts::Part *part;
+friend class RKWardMainWindow;
+	static RKHelpSearchWindow *main_help_search;
+};
+
+#endif

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-02-28 16:14:13 UTC (rev 1504)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-02-28 16:22:24 UTC (rev 1505)
@@ -32,7 +32,7 @@
 #include <qdir.h>
 
 #include "../rkglobals.h"
-#include "../khelpdlg.h"
+#include "rkhelpsearchwindow.h"
 #include "../rkward.h"
 #include "../settings/rksettingsmodulegeneral.h"
 #include "../misc/rkcommonfunctions.h"


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