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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Mar 16 21:21:05 UTC 2010


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

Log Message:
-----------
Refine the 'paste special' action a bit, and add it to the console, too.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/misc/rkspecialactions.cpp
    trunk/rkward/rkward/misc/rkstandardactions.cpp
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/rkconsole.h
    trunk/rkward/rkward/rkconsolepart.rc
    trunk/rkward/rkward/rkwardui.rc
    trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc
    trunk/rkward/rkward/windows/rkstandardactions.rc

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/ChangeLog	2010-03-16 21:21:05 UTC (rev 2789)
@@ -1,3 +1,4 @@
+- Added "paste special" action to script editor and console for pasting R vectors and matrices from spreadsheets
 - Fix order of menus for detached windows
 - File->Open R Script File now allows to specify the character encoding to use
 - Fixed: No entries were added the recent script/workspaces actions after "save as"

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/TODO	2010-03-16 21:21:05 UTC (rev 2789)
@@ -15,7 +15,10 @@
 			- http://lists.kde.org/?l=kde-core-devel&m=103307809508725&w=2
 
 Bugs:
-	- "cannot create html package index" when installing package as a regular user (due to R.home ("doc") not writable)
+	- XMLGUI:
+		- The edit menu is broken in the main window, but not detached windows (for script editor, console)
+			- When adding the DefineGroups from detachedwindowcontainer.rc to rkwardui.rc, the edit menu goes totally mental, there, sometimes, even shuffling actions apparently more or less randomly.
+			- No idea, how to fix that
 	- There is definitely a memory leak in handling output!
 		- Produce lots and lots of output -> watch mem usage grow
 		- Probably the RKConsole is to blame (run outside console -> no significant increase)

Modified: trunk/rkward/rkward/misc/rkspecialactions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkspecialactions.cpp	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/misc/rkspecialactions.cpp	2010-03-16 21:21:05 UTC (rev 2789)
@@ -91,18 +91,20 @@
 	group_layout->addWidget (rbutton);
 	connect (dimensionality_group, SIGNAL (buttonClicked(int)), this, SLOT (updateState()));
 
+	const QMimeData* clipdata = QApplication::clipboard ()->mimeData ();
+
 	// 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->setChecked (true);		// tab-separated is a reasonable fallback guess
 	rbutton = new QRadioButton (i18n ("Comma"), box);
 	separator_group->addButton (rbutton, SepComma);
 	group_layout->addWidget (rbutton);
+	if (clipdata->hasFormat ("text/comma-separated-values")) rbutton->setChecked (true);
 	rbutton = new QRadioButton (i18n ("Single space"), box);
 	separator_group->addButton (rbutton, SepSpace);
 	group_layout->addWidget (rbutton);
@@ -213,24 +215,19 @@
 	if (reverse_h || reverse_v || transpose) matrix = matrix.transformed (reverse_h, reverse_v, transpose);
 
 	QString ret;
-	if (dim == DimMatrix) {
-		ret.append ("rbind (\n");
-	}
+	if (dim == DimMatrix) ret.append ("cbind (\n");
 
-	for (int i = 0; i < matrix.numRows (); ++i) {
+	for (int i = 0; i < matrix.numColumns (); ++i) {
 		if (i != 0) ret.append ("),\n");
 		ret.append ("c(");
-		for (int j = 0; j < matrix.numColumns (); ++j) {
+		for (int j = 0; j < matrix.numRows (); ++j) {
 			if (j != 0) ret.append (",");
-			ret.append (prepString (matrix.getText (i, j)));
+			ret.append (prepString (matrix.getText (j, i)));
 		}
-		if (i == (matrix.numRows () - 1)) ret.append (")\n");
+		if (i == (matrix.numColumns () - 1)) ret.append (")\n");
 	}
 
-	if (dim == DimMatrix) {
-		ret.append (")\n");
-	}
-
+	if (dim == DimMatrix) ret.append (")\n");
 	return (ret);
 }
 

Modified: trunk/rkward/rkward/misc/rkstandardactions.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkstandardactions.cpp	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/misc/rkstandardactions.cpp	2010-03-16 21:21:05 UTC (rev 2789)
@@ -33,6 +33,7 @@
 	KAction* ret = new RKPasteSpecialAction (window->standardActionCollection ());
 	window->standardActionCollection ()->addAction ("paste_special", ret);
 	ret->connect (ret, SIGNAL (pasteText (const QString&)), receiver, member);
+	ret->setShortcut (Qt::ShiftModifier + Qt::ControlModifier + Qt::Key_V);
 	return ret;
 }
 

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/rkconsole.cpp	2010-03-16 21:21:05 UTC (rev 2789)
@@ -813,6 +813,8 @@
 	copy_literal_action = ac->addAction ("rkconsole_copy_literal", this, SLOT (literalCopy()));
 	copy_literal_action->setText (i18n ("Copy selection literally"));
 
+	RKStandardActions::pasteSpecial (this, this, SLOT (submitBatch(const QString&)));
+
 	ac->addAction (KStandardAction::Clear, "rkconsole_clear", this, SLOT (clear()));
 	paste_action = ac->addAction (KStandardAction::Paste, "rkconsole_paste", this, SLOT (paste()));
 	QAction *action = ac->addAction ("rkconsole_configure", this, SLOT (configure()));

Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/rkconsole.h	2010-03-16 21:21:05 UTC (rev 2789)
@@ -2,7 +2,7 @@
                           rkconsole  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -55,9 +55,6 @@
 /** Destructor */
 	~RKConsole ();
 
-/** Submits a batch of commands, line by line.
-\param batch a QString containing the batch of commands to be executed */
-	void submitBatch (const QString &batch);
 /** Returns the command currently being edited (not executed yet) */
 	QString currentCommand ();
 /** Returns the current cursor position. Returns the column on which is the cursor.  */
@@ -179,6 +176,10 @@
 /** interrupt current command. */
 	void slotInterruptCommand ();
 	void runSelection ();
+
+/** Submits a batch of commands, line by line.
+\param batch a QString containing the batch of commands to be executed */
+	void submitBatch (const QString &batch);
 };
 
 /** A part interface to RKConsole. Provides the context-help functionality

Modified: trunk/rkward/rkward/rkconsolepart.rc
===================================================================
--- trunk/rkward/rkward/rkconsolepart.rc	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/rkconsolepart.rc	2010-03-16 21:21:05 UTC (rev 2789)
@@ -1,12 +1,13 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="rkward" version="51">
+<kpartgui name="rkward" version="53">
 	<MenuBar>
 		<Menu name="edit"><text>&Edit</text>
-			<Action name="rkconsole_copy"></Action>
-			<Action name="rkconsole_copy_literal"></Action>
-			<Action name="rkconsole_paste"></Action>
+			<Action name="rkconsole_copy" group="edit_paste_merge"/>
+			<Action name="rkconsole_copy_literal" group="edit_paste_merge"/>
+			<Action name="rkconsole_paste" group="edit_paste_merge"/>
+			<DefineGroup name="edit_paste_merge" append="edit_paste_merge"/>
 			<Separator/>
-			<Action name="rkconsole_clear"></Action>
+			<Action name="rkconsole_clear"/>
 		</Menu>
 		<Menu name="run"><text>&Run</text>
 			<Action name="interrupt" group="postrun_actions_merge"/>
@@ -19,17 +20,18 @@
 		<Action name="interrupt" group="postrun_actions_merge"/>
 	</ToolBar>
 	<Menu name="rkconsole_context_menu">
-		<Action name="rkconsole_copy"></Action>
-		<Action name="rkconsole_copy_literal"></Action>
-		<Action name="rkconsole_paste"></Action>
+		<Action name="rkconsole_copy"/>
+		<Action name="rkconsole_copy_literal"/>
+		<Action name="rkconsole_paste"/>
+		<DefineGroup name="edit_paste_merge" />
 		<Separator/>
-		<DefineGroup name="rkconsole_context_merge1" append="rkconsole_context_merge1"/>
-		<Action name="interrupt"></Action>
+		<DefineGroup name="rkconsole_context_merge1"/>
+		<Action name="interrupt"/>
 		<Separator/>
-		<DefineGroup name="rkconsole_context_merge2" append="rkconsole_context_merge2"/>
+		<DefineGroup name="rkconsole_context_merge2"/>
 		<Separator/>
-		<Action name="rkconsole_clear"></Action>
+		<Action name="rkconsole_clear"/>
 		<Separator/>
-		<Action name="rkconsole_configure"></Action>
+		<Action name="rkconsole_configure"/>
 	</Menu>
 </kpartgui>
\ No newline at end of file

Modified: trunk/rkward/rkward/rkwardui.rc
===================================================================
--- trunk/rkward/rkward/rkwardui.rc	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/rkwardui.rc	2010-03-16 21:21:05 UTC (rev 2789)
@@ -34,9 +34,6 @@
 	<!-- These menus are actually defined in KParts. We also declare them here, to avoid menus jumping around -->
 	<Menu name="edit"><text>&Edit</text>
 		<Action name="edit_menu_dummy"/>
-		<DefineGroup name="edit_paste_merge" append="edit_paste_merge" />
-		<DefineGroup name="after_edit_paste_merge" append="edit_paste_merge" />
-		<DefineGroup name="edit_select_merge" append="edit_select_merge" />
 	</Menu>
 	<Menu name="view"><text>&View</text>
 		<Action name="view_menu_dummy"/>

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.rc	2010-03-16 21:21:05 UTC (rev 2789)
@@ -5,7 +5,6 @@
 			<Menu name="tools"><text>&Tools Move</text>
 				<Merge/>
 			</Menu>
-			<Action name="copy"/>
 			<Action name="mark_block" group="edit_select_merge"/>
 			<Action name="unmark_block" group="edit_select_merge"/>
 		</Menu>

Modified: trunk/rkward/rkward/windows/rkstandardactions.rc
===================================================================
--- trunk/rkward/rkward/windows/rkstandardactions.rc	2010-03-16 12:02:45 UTC (rev 2788)
+++ trunk/rkward/rkward/windows/rkstandardactions.rc	2010-03-16 21:21:05 UTC (rev 2789)
@@ -37,6 +37,7 @@
 		<Action name="function_reference" group="ktexteditor_popup_merge2"/>
 	</Menu>
 	<Menu name="rkconsole_context_menu">
+		<Action name="paste_special" group="edit_paste_merge"/>
 		<Action name="run_selection" group="rkconsole_context_merge1"/>
 		<Action name="function_reference" group="rkconsole_context_merge2"/>
 	</Menu>


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