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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Mar 16 12:02:45 UTC 2010


Revision: 2788
          http://rkward.svn.sourceforge.net/rkward/?rev=2788&view=rev
Author:   tfry
Date:     2010-03-16 12:02:45 +0000 (Tue, 16 Mar 2010)

Log Message:
-----------
Add 'paste special...'-action to script editor.
Some things still need polishing, and should also be added to console window.

Modified Paths:
--------------
    trunk/rkward/rkward/dataeditor/rktextmatrix.cpp
    trunk/rkward/rkward/dataeditor/rktextmatrix.h
    trunk/rkward/rkward/misc/CMakeLists.txt
    trunk/rkward/rkward/misc/rkstandardactions.cpp
    trunk/rkward/rkward/misc/rkstandardactions.h
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h
    trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc
    trunk/rkward/rkward/windows/rkcommandlog.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkstandardactions.rc

Added Paths:
-----------
    trunk/rkward/rkward/misc/rkspecialactions.cpp
    trunk/rkward/rkward/misc/rkspecialactions.h

Modified: trunk/rkward/rkward/dataeditor/rktextmatrix.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rktextmatrix.cpp	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/dataeditor/rktextmatrix.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -96,6 +96,38 @@
 	QApplication::clipboard()->setMimeData (data);
 }
 
+RKTextMatrix RKTextMatrix::transformed (bool reverse_h, bool reverse_v, bool transpose) const {
+	RK_TRACE (EDITOR);
+
+	RKTextMatrix ret;
+	if (isEmpty ()) return ret;		// empty matrices would violate some assumptions of the following code
+
+	const int maxrow = rows.size () - 1;		// for easier typing
+	const int maxcol = rows[0].size () - 1;
+
+	if (transpose) ret.upsize (maxcol, maxrow);		// set dimensions from the start to save a few cycles
+	else ret.upsize (maxrow, maxcol);
+
+	for (int row=0; row <= maxrow; ++row) {
+		for (int col=0; col <= maxcol; ++col) {
+			int dest_row = row;
+			if (reverse_v) dest_row = maxrow - row;
+			int dest_col = col;
+			if (reverse_h) dest_col = maxcol - col;
+
+			if (transpose) {
+				int dummy = dest_row;
+				dest_row = dest_col;
+				dest_col = dummy;
+			}
+
+			ret.setText (dest_row, dest_col, rows[row][col]);
+		}
+	}
+
+	return ret;
+}
+
 void RKTextMatrix::setText (int row, int col, const QString& text) {
 //	RK_TRACE (EDITOR);
 

Modified: trunk/rkward/rkward/dataeditor/rktextmatrix.h
===================================================================
--- trunk/rkward/rkward/dataeditor/rktextmatrix.h	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/dataeditor/rktextmatrix.h	2010-03-16 12:02:45 UTC (rev 2788)
@@ -50,6 +50,12 @@
 	/** get the contents of an entire row at once */
 	QStringList getRow (int row) const;
 
+	/** Return a transformed matrix. Not optimized for performance!
+	@param reverse_h Reverse order of columns
+	@param reverse_v Reverse order of rows
+	@param transpose Switch rows against columns */
+	RKTextMatrix transformed (bool reverse_h, bool reverse_v, bool transpose) const;
+
 	void clear ();
 	bool isEmpty () const;
 

Modified: trunk/rkward/rkward/misc/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/misc/CMakeLists.txt	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/misc/CMakeLists.txt	2010-03-16 12:02:45 UTC (rev 2788)
@@ -13,6 +13,7 @@
    rkprogresscontrol.cpp
    rksaveobjectchooser.cpp
    rkdummypart.cpp
+   rkspecialactions.cpp
    rkstandardicons.cpp
    rkstandardactions.cpp
    rkxmlguisyncer.cpp

Added: trunk/rkward/rkward/misc/rkspecialactions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkspecialactions.cpp	                        (rev 0)
+++ trunk/rkward/rkward/misc/rkspecialactions.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -0,0 +1,252 @@
+/***************************************************************************
+                          rkspecialactions  -  description
+                             -------------------
+    begin                : Mon Mar 15 2010
+    copyright            : (C) 2010 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 "rkspecialactions.h"
+
+#include <klocale.h>
+
+#include "../debug.h"
+
+RKPasteSpecialAction::RKPasteSpecialAction (QObject* parent) : KPasteTextAction (parent) {
+	RK_TRACE (MISC);
+
+	setText (i18n ("Paste special..."));
+	connect (this, SIGNAL (triggered(bool)), this, SLOT (doSpecialPaste()));
+}
+
+RKPasteSpecialAction::~RKPasteSpecialAction () {
+	RK_TRACE (MISC);
+}
+
+void RKPasteSpecialAction::doSpecialPaste () {
+	RK_TRACE (MISC);
+
+	RKPasteSpecialDialog* dialog = new RKPasteSpecialDialog (associatedWidgets ().first ());
+	int res = dialog->exec ();
+	if (res == QDialog::Accepted) {
+		emit (pasteText (dialog->resultingText()));
+	}
+	dialog->deleteLater ();
+}
+
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QButtonGroup>
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QApplication>
+#include <QClipboard>
+#include <QMimeData>
+
+#include <kvbox.h>
+#include <khbox.h>
+
+#include "../dataeditor/rktextmatrix.h"
+#include "../core/robject.h"
+
+RKPasteSpecialDialog::RKPasteSpecialDialog (QWidget* parent) : KDialog (parent) {
+	RK_TRACE (MISC);
+
+	setCaption (i18n ("Paste special..."));
+	setButtons (KDialog::Ok | KDialog::Cancel);
+
+	KVBox* page = new KVBox (this);
+	setMainWidget (page);
+	KHBox* row = new KHBox (page);
+
+	QGroupBox* box;
+	QVBoxLayout* group_layout;
+	QHBoxLayout* h_layout;
+	QRadioButton* rbutton;
+
+	// Mode box
+	box = new QGroupBox (i18n ("Paste mode"), row);
+	group_layout = new QVBoxLayout (box);
+	dimensionality_group = new QButtonGroup (box);
+	rbutton = new QRadioButton (i18n ("Single string"), box);
+	dimensionality_group->addButton (rbutton, DimSingleString);
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Vector"), box);
+	dimensionality_group->addButton (rbutton, DimVector);
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Matrix"), box);
+	dimensionality_group->addButton (rbutton, DimMatrix);
+	rbutton->setChecked (true);
+	group_layout->addWidget (rbutton);
+	connect (dimensionality_group, SIGNAL (buttonClicked(int)), this, SLOT (updateState()));
+
+	// Separator box
+	box = new QGroupBox (i18n ("Field separator"), row);
+	group_layout = new QVBoxLayout (box);
+	separator_group = new QButtonGroup (box);
+	rbutton = new QRadioButton (i18n ("Tab"), box);
+	rbutton->setChecked (true);
+	separator_group->addButton (rbutton, SepTab);
+#warning TODO: autodetection heuristics
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Comma"), box);
+	separator_group->addButton (rbutton, SepComma);
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Single space"), box);
+	separator_group->addButton (rbutton, SepSpace);
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Any whitespace"), box);
+	separator_group->addButton (rbutton, SepWhitespace);
+	group_layout->addWidget (rbutton);
+	h_layout = new QHBoxLayout ();
+	rbutton = new QRadioButton (i18n ("Other:"), box);
+	separator_group->addButton (rbutton, SepCustom);
+	h_layout->addWidget (rbutton);
+	separator_freefield = new QLineEdit (";", box);
+	h_layout->addWidget (separator_freefield);
+	group_layout->addLayout (h_layout);
+	connect (separator_group, SIGNAL (buttonClicked(int)), this, SLOT (updateState()));
+
+	row = new KHBox (page);
+
+	// Quoting box
+	box = new QGroupBox (i18n ("Quoting"), row);
+	group_layout = new QVBoxLayout (box);
+	quoting_group = new QButtonGroup (box);
+	rbutton = new QRadioButton (i18n ("Do not quote values"), box);
+	quoting_group->addButton (rbutton, QuoteNone);
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Automatic"), box);
+	rbutton->setChecked (true);
+	quoting_group->addButton (rbutton, QuoteAuto);
+	group_layout->addWidget (rbutton);
+	rbutton = new QRadioButton (i18n ("Quote all values"), box);
+	quoting_group->addButton (rbutton, QuoteAll);
+	group_layout->addWidget (rbutton);
+	connect (quoting_group, SIGNAL (buttonClicked(int)), this, SLOT (updateState()));
+
+	// further controls
+	box = new QGroupBox (i18n ("Transformations"), row);
+	group_layout = new QVBoxLayout (box);
+	reverse_h_box = new QCheckBox (i18n ("Reverse horizontally"), box);
+	group_layout->addWidget (reverse_h_box);
+	reverse_v_box = new QCheckBox (i18n ("Reverse vertically"), box);
+	group_layout->addWidget (reverse_v_box);
+	transpose_box = new QCheckBox (i18n ("Flip rows/columns"), box);
+	group_layout->addWidget (transpose_box);
+	insert_nas_box = new QCheckBox (i18n ("Insert NAs where needed"), box);
+	insert_nas_box->setChecked (true);
+	group_layout->addWidget (insert_nas_box);
+
+	updateState ();		// initialize
+}
+
+RKPasteSpecialDialog::~RKPasteSpecialDialog () {
+	RK_TRACE (MISC);
+}
+
+void RKPasteSpecialDialog::updateState () {
+	RK_TRACE (MISC);
+
+	int dimensionality = dimensionality_group->checkedId ();
+	
+	static_cast<QWidget*> (separator_group->parent ())->setEnabled (dimensionality != DimSingleString);
+	reverse_h_box->setEnabled (dimensionality != DimSingleString);
+	reverse_v_box->setEnabled (dimensionality == DimMatrix);
+	insert_nas_box->setEnabled (dimensionality != DimSingleString);
+	transpose_box->setEnabled (dimensionality == DimMatrix);
+
+	separator_freefield->setEnabled ((dimensionality != DimSingleString) && (separator_group->checkedId () == SepCustom));
+}
+
+QString RKPasteSpecialDialog::resultingText () {
+	RK_TRACE (MISC);
+
+	const int sep = separator_group->checkedId ();		// for easier typing
+	const int dim = dimensionality_group->checkedId ();
+	const bool reverse_h = reverse_h_box->isChecked () && (dim != DimSingleString);
+	const bool reverse_v = reverse_v_box->isChecked () && (dim == DimMatrix);
+	const bool transpose = transpose_box->isChecked () && (dim == DimMatrix);
+
+	QString clip;
+
+	const QMimeData* data = QApplication::clipboard ()->mimeData ();
+	if ((dim != DimSingleString) && (sep == SepTab) && data->hasFormat ("text/tab-separated-values")) {
+		clip = QString::fromLocal8Bit (data->data ("text/tab-separated-values"));
+	} else if ((dim != DimSingleString) && (sep == SepComma) && data->hasFormat ("text/comma-separated-values")) {
+		clip = QString::fromLocal8Bit (data->data ("text/comma-separated-values"));
+	} else {
+		clip = data->text ();
+	}
+
+	if (dim == DimSingleString) return prepString (clip);
+
+	QRegExp fieldsep;
+	if (sep == SepCustom) fieldsep.setPattern (separator_freefield->text ());
+	else if (sep == SepWhitespace) fieldsep.setPattern ("\\s+");
+	else if (sep == SepSpace) fieldsep.setPattern (" ");
+	else if (sep == SepTab) fieldsep.setPattern ("\t");
+	else if (sep == SepComma) fieldsep.setPattern ("\\,");
+	else RK_ASSERT (false);
+
+	RKTextMatrix matrix = RKTextMatrix::matrixFromSeparatedValues (clip, fieldsep);
+	if (dim == DimVector) {
+		// transform list to single row matrix. This is wasteful on resources, but easy to code...
+		QStringList list;
+		for (int i = 0; i < matrix.numRows (); ++i) {
+			list += matrix.getRow (i);
+		}
+		matrix = RKTextMatrix::matrixFromSeparatedValues (list.join ("\t"));
+	}
+
+	if (reverse_h || reverse_v || transpose) matrix = matrix.transformed (reverse_h, reverse_v, transpose);
+
+	QString ret;
+	if (dim == DimMatrix) {
+		ret.append ("rbind (\n");
+	}
+
+	for (int i = 0; i < matrix.numRows (); ++i) {
+		if (i != 0) ret.append ("),\n");
+		ret.append ("c(");
+		for (int j = 0; j < matrix.numColumns (); ++j) {
+			if (j != 0) ret.append (",");
+			ret.append (prepString (matrix.getText (i, j)));
+		}
+		if (i == (matrix.numRows () - 1)) ret.append (")\n");
+	}
+
+	if (dim == DimMatrix) {
+		ret.append (")\n");
+	}
+
+	return (ret);
+}
+
+QString RKPasteSpecialDialog::prepString (const QString& src) const {
+//	RK_TRACE (MISC);
+
+	const int quot = quoting_group->checkedId ();
+	if (quot == QuoteAll) return (RObject::rQuote (src));
+	if (src.isEmpty() && insert_nas_box->isChecked ()) return ("NA");
+	if (quot == QuoteNone) return (src);
+	RK_ASSERT (quot == QuoteAuto);
+
+	bool numeric = false;
+	src.toDouble (&numeric);	// side-effect of setting numeric to true, if number conversion succeeds
+	if (!numeric) return (RObject::rQuote (src));
+	return src;
+}
+
+#include "rkspecialactions.moc"

Added: trunk/rkward/rkward/misc/rkspecialactions.h
===================================================================
--- trunk/rkward/rkward/misc/rkspecialactions.h	                        (rev 0)
+++ trunk/rkward/rkward/misc/rkspecialactions.h	2010-03-16 12:02:45 UTC (rev 2788)
@@ -0,0 +1,87 @@
+/***************************************************************************
+                          rkspecialactions  -  description
+                             -------------------
+    begin                : Mon Mar 15 2010
+    copyright            : (C) 2010 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 RKSPECIALACTIONS_H
+#define RKSPECIALACTIONS_H
+
+#include <kpastetextaction.h>
+
+/** This namespace provides functions to generate some standard actions, i.e. actions which are needed at more than one place.
+
+ at author Thomas Friedrichsmeier */
+class RKPasteSpecialAction : public KPasteTextAction {
+	Q_OBJECT
+public:
+	RKPasteSpecialAction (QObject* parent);
+	~RKPasteSpecialAction ();
+public slots:
+/** The actual workhorse of the action. */
+	void doSpecialPaste ();
+signals:
+/** Connect to this signal to receive the resulting text to be pasted */
+	void pasteText (const QString&);
+};
+
+
+#include <kdialog.h>
+
+class QButtonGroup;
+class QLineEdit;
+class QCheckBox;
+
+/** Dialog used in RKPasteSpecialAction */
+class RKPasteSpecialDialog : public KDialog {
+	Q_OBJECT
+public:
+	RKPasteSpecialDialog (QWidget* parent);
+	~RKPasteSpecialDialog ();
+
+	enum Dimensionality {
+		DimSingleString,
+		DimVector,
+		DimMatrix
+	};
+	enum Separator {
+		SepTab,
+		SepComma,
+		SepSpace,
+		SepWhitespace,
+		SepCustom
+	};
+	enum Quoting {
+		QuoteNone,
+		QuoteAuto,
+		QuoteAll
+	};
+	
+	QString resultingText ();
+public slots:
+	void updateState ();
+private:
+	QString prepString (const QString& src) const;
+
+	QButtonGroup* dimensionality_group;
+	QButtonGroup* separator_group;
+	QLineEdit* separator_freefield;
+	QButtonGroup* quoting_group;
+	QCheckBox* transpose_box;
+	QCheckBox* reverse_h_box;
+	QCheckBox* reverse_v_box;
+	QCheckBox* insert_nas_box;
+};
+
+#endif

Modified: trunk/rkward/rkward/misc/rkstandardactions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkstandardactions.cpp	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/misc/rkstandardactions.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -2,7 +2,7 @@
                           rkstandardactions  -  description
                              -------------------
     begin                : Sun Nov 18 2007
-    copyright            : (C) 2007, 2009 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2009, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -22,44 +22,54 @@
 #include <kaction.h>
 
 #include "rkstandardicons.h"
+#include "rkspecialactions.h"
 #include "../windows/rkmdiwindow.h"
 
 #include "../debug.h"
 
-KAction* RKStandardActions::runLine (RKMDIWindow *window, const QString &name, const QObject *receiver, const char *member) {
+KAction* RKStandardActions::pasteSpecial (RKMDIWindow *window, const QObject *receiver, const char *member) {
 	RK_TRACE (MISC);
 
-	KAction* ret = window->standardActionCollection ()->addAction (name, receiver, member);
+	KAction* ret = new RKPasteSpecialAction (window->standardActionCollection ());
+	window->standardActionCollection ()->addAction ("paste_special", ret);
+	ret->connect (ret, SIGNAL (pasteText (const QString&)), receiver, member);
+	return ret;
+}
+
+KAction* RKStandardActions::runLine (RKMDIWindow *window, const QObject *receiver, const char *member) {
+	RK_TRACE (MISC);
+
+	KAction* ret = window->standardActionCollection ()->addAction ("run_line", receiver, member);
 	ret->setText (i18n ("Run current line"));
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunLine));
 	ret->setShortcut (Qt::ShiftModifier + Qt::Key_F7);
 	return ret;
 }
 
-KAction* RKStandardActions::runSelection (RKMDIWindow *window, const QString &name, const QObject *receiver, const char *member) {
+KAction* RKStandardActions::runSelection (RKMDIWindow *window, const QObject *receiver, const char *member) {
 	RK_TRACE (MISC);
 
-	KAction* ret = window->standardActionCollection ()->addAction (name, receiver, member);
+	KAction* ret = window->standardActionCollection ()->addAction ("run_selection", receiver, member);
 	ret->setText (i18n ("Run selection"));
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunSelection));
 	ret->setShortcut (Qt::ShiftModifier + Qt::Key_F8);
 	return ret;
 }
 
-KAction* RKStandardActions::runAll (RKMDIWindow *window, const QString &name, const QObject *receiver, const char *member) {
+KAction* RKStandardActions::runAll (RKMDIWindow *window, const QObject *receiver, const char *member) {
 	RK_TRACE (MISC);
 
-	KAction* ret = window->standardActionCollection ()->addAction (name, receiver, member);
+	KAction* ret = window->standardActionCollection ()->addAction ("run_all", receiver, member);
 	ret->setText (i18n ("Run all"));
 	ret->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRunAll));
 	ret->setShortcut (Qt::ShiftModifier + Qt::Key_F9);
 	return ret;
 }
 
-KAction* RKStandardActions::functionHelp (RKMDIWindow *window, const QString &name, const QObject *receiver, const char *member) {
+KAction* RKStandardActions::functionHelp (RKMDIWindow *window, const QObject *receiver, const char *member) {
 	RK_TRACE (MISC);
 
-	KAction* ret = window->standardActionCollection ()->addAction (name, receiver, member);
+	KAction* ret = window->standardActionCollection ()->addAction ("function_reference", receiver, member);
 	ret->setText (i18n ("&Function reference"));
 	ret->setShortcut (Qt::Key_F2);
 	return ret;

Modified: trunk/rkward/rkward/misc/rkstandardactions.h
===================================================================
--- trunk/rkward/rkward/misc/rkstandardactions.h	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/misc/rkstandardactions.h	2010-03-16 12:02:45 UTC (rev 2788)
@@ -2,7 +2,7 @@
                           rkstandardactions  -  description
                              -------------------
     begin                : Sun Nov 18 2007
-    copyright            : (C) 2007, 2009 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2009, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -27,11 +27,15 @@
 
 @author Thomas Friedrichsmeier */
 namespace RKStandardActions {
-	KAction* runLine (RKMDIWindow *window, const QString &name, const QObject *receiver=0, const char *member=0);
-	KAction* runSelection (RKMDIWindow *window, const QString &name, const QObject *receiver=0, const char *member=0);
-	KAction* runAll (RKMDIWindow *window, const QString &name, const QObject *receiver=0, const char *member=0);
+/** Allows special pasting modes for script windows.
+ at param member needs to have the signature void fun (const QString&). */
+	KAction* pasteSpecial (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
 
-	KAction* functionHelp (RKMDIWindow *window, const QString &name, const QObject *receiver=0, const char *member=0);
+	KAction* runLine (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
+	KAction* runSelection (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
+	KAction* runAll (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
+
+	KAction* functionHelp (RKMDIWindow *window, const QObject *receiver=0, const char *member=0);
 };
 
 #endif

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/rkconsole.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -2,7 +2,7 @@
                           rkconsole  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -797,9 +797,9 @@
 void RKConsole::initializeActions (KActionCollection *ac) {
 	RK_TRACE (APP);
 
-	context_help_action = RKStandardActions::functionHelp (this, "function_reference", this, SLOT(showContextHelp()));
+	context_help_action = RKStandardActions::functionHelp (this, this, SLOT(showContextHelp()));
 
-	run_selection_action = RKStandardActions::runSelection (this, "run_selection", this, SLOT (runSelection()));
+	run_selection_action = RKStandardActions::runSelection (this, this, SLOT (runSelection()));
 
 	interrupt_command_action = ac->addAction ("interrupt", this, SLOT (slotInterruptCommand()));
 	interrupt_command_action->setText (i18n ("Interrupt running command"));

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -157,12 +157,14 @@
 void RKCommandEditorWindow::initializeActions (KActionCollection* ac) {
 	RK_TRACE (COMMANDEDITOR);
 
-	action_run_all = RKStandardActions::runAll (this, "run_all", this, SLOT (runAll()));
-	action_run_selection = RKStandardActions::runSelection (this, "run_selection", this, SLOT (runSelection()));
+	RKStandardActions::pasteSpecial (this, this, SLOT (paste(const QString&)));
+
+	action_run_all = RKStandardActions::runAll (this, this, SLOT (runAll()));
+	action_run_selection = RKStandardActions::runSelection (this, this, SLOT (runSelection()));
 	action_run_selection->setEnabled (false);
-	action_run_line = RKStandardActions::runLine (this, "run_line", this, SLOT (runLine()));
+	action_run_line = RKStandardActions::runLine (this, this, SLOT (runLine()));
 
-	action_help_function = RKStandardActions::functionHelp (this, "function_reference", this, SLOT (showHelp()));
+	action_help_function = RKStandardActions::functionHelp (this, this, SLOT (showHelp()));
 
 	actionmenu_run_block = new KActionMenu (i18n ("Run block"), this);
 	actionmenu_run_block->setDelayed (false);	// KDE4: TODO does not work correctly in the tool bar.
@@ -253,6 +255,8 @@
 	setPopupMenu ();
 }
 
+/** NOTE: this function still needed?
+- Still needed in KDE 4.3.4. */
 void RKCommandEditorWindow::setPopupMenu () {
 	RK_TRACE (COMMANDEDITOR);
 
@@ -446,6 +450,12 @@
 	return true;
 }
 
+void RKCommandEditorWindow::paste (const QString& text) {
+	RK_TRACE (COMMANDEDITOR);
+
+	m_view->insertText (text);
+}
+
 void RKCommandEditorWindow::setWDToScript () {
 	RK_TRACE (COMMANDEDITOR);
 

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2010-03-16 12:02:45 UTC (rev 2788)
@@ -183,6 +183,8 @@
 	void selectionChanged (KTextEditor::View* view);
 /** change to the directory of the current script */
 	void setWDToScript ();
+/** paste the given text at the current cursor position */
+	void paste (const QString &text);
 
 /** apply our customizations to the katepart GUI */
 	void fixupPartGUI ();

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc	2010-03-16 12:02:45 UTC (rev 2788)
@@ -6,7 +6,6 @@
 				<Merge/>
 			</Menu>
 			<Action name="copy"/>
-			<Action name="paste_vector" group="after_edit_paste_merge"/>
 			<Action name="mark_block" group="edit_select_merge"/>
 			<Action name="unmark_block" group="edit_select_merge"/>
 		</Menu>

Modified: trunk/rkward/rkward/windows/rkcommandlog.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.cpp	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/windows/rkcommandlog.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -2,7 +2,7 @@
                           rkcommandlog  -  description
                              -------------------
     begin                : Sun Nov 3 2002
-    copyright            : (C) 2002, 2004, 2005 2006, 2007, 2009 by Thomas Friedrichsmeier
+    copyright            : (C) 2002, 2004, 2005 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -284,7 +284,7 @@
 	QAction *configure = actionCollection ()->addAction ("log_configure", log, SLOT(configureLog()));
 	configure->setText (i18n ("Configure"));
 
-	run_selection = RKStandardActions::runSelection (log, "run_selection", log, SLOT(runSelection()));
+	run_selection = RKStandardActions::runSelection (log, log, SLOT(runSelection()));
 
 	connect (log->getView (), SIGNAL (popupMenuRequest (const QPoint &)), this, SLOT (doPopupMenu (const QPoint &)));
 }

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2010-03-16 12:02:45 UTC (rev 2788)
@@ -122,7 +122,7 @@
 
 	print = actionCollection ()->addAction (KStandardAction::Print, "print_html", this, SLOT (slotPrint()));
 
-	run_selection = RKStandardActions::runSelection (this, "run_selection", this, SLOT (runSelection()));
+	run_selection = RKStandardActions::runSelection (this, this, SLOT (runSelection()));
 
 		// needed to enable / disable the run selection action
 	connect (khtmlpart, SIGNAL (selectionChanged()), this, SLOT (selectionChanged()));

Modified: trunk/rkward/rkward/windows/rkstandardactions.rc
===================================================================
--- trunk/rkward/rkward/windows/rkstandardactions.rc	2010-03-16 10:14:30 UTC (rev 2787)
+++ trunk/rkward/rkward/windows/rkstandardactions.rc	2010-03-16 12:02:45 UTC (rev 2788)
@@ -1,9 +1,12 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="rkward" version="51">
+<kpartgui name="rkward" version="53">
 <!-- What is this for, wouldn't it be easier to just inline these actions in the parts where they
      end up? Yes, but then they would be separate actions, internally, and each could be assigned
      a shortcut of its own. This is needed to tie them all together. -->
 	<MenuBar>
+		<Menu name="edit">
+			<Action name="paste_special" group="after_edit_paste_merge"/>
+		</Menu>
 		<Menu name="run">
 			<Action name="run_line" group="run_actions_merge"/>
 			<Action name="run_selection" group="run_actions_merge"/>
@@ -25,6 +28,7 @@
 
 
 	<Menu name="ktexteditor_popup">
+		<Action name="paste_special" group="edit_paste_merge"/>
 		<Menu name="run">
 			<Action name="run_line" group="run_actions_merge"/>
 			<Action name="run_selection" group="run_actions_merge"/>


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