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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 28 16:07:56 UTC 2006


Revision: 970
          http://svn.sourceforge.net/rkward/?rev=970&view=rev
Author:   tfry
Date:     2006-11-28 08:07:56 -0800 (Tue, 28 Nov 2006)

Log Message:
-----------
More RMB menu options everywhere. RKCommandLog now has a part wrapper. Some small cleanups

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rkconsole.cpp
    trunk/rkward/rkward/rkconsole.h
    trunk/rkward/rkward/rkconsolepart.rc
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/windows/Makefile.am
    trunk/rkward/rkward/windows/rkcommandlog.cpp
    trunk/rkward/rkward/windows/rkcommandlog.h

Added Paths:
-----------
    trunk/rkward/rkward/windows/rkcommandlogpart.rc

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/ChangeLog	2006-11-28 16:07:56 UTC (rev 970)
@@ -1,5 +1,5 @@
 - add RMB menu to script editor windows
-- add option to clear console in the console RMB menu
+- add options to "clear" and "configure" in the console RMB menu, and the command log RMB menu
 - add option to save workplace layout not per workspace, but at the end of the session
 - add options ("printcmd") to settings
 - fix help menu for detached windows

Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/rkconsole.cpp	2006-11-28 16:07:56 UTC (rev 970)
@@ -33,14 +33,16 @@
 #include "rkglobals.h"
 #include "rkward.h"
 #include "khelpdlg.h"
-#include "debug.h"
 #include "rbackend/rinterface.h"
 #include "rbackend/rcommand.h"
+#include "settings/rksettings.h"
 #include "settings/rksettingsmoduleconsole.h"
 #include "misc/rkcommonfunctions.h"
 #include "core/robjectlist.h"
 #include "core/rfunctionobject.h"
 
+#include "debug.h"
+
 RKConsole::RKConsole () : QWidget (0) {
 	RK_TRACE (APP);
 
@@ -565,6 +567,10 @@
 	tryNextInBatch (true);
 }
 
+void RKConsole::configure () {
+	RK_TRACE (APP);
+	RKSettings::configureSettings (RKSettings::Console, this);
+}
 
 ///################### END RKConsole ########################
 ///################### BEGIN RKConsolePart ####################
@@ -588,10 +594,10 @@
 	interrupt_command->setShortcut ("Ctrl+C");
 
 	copy = new KAction (i18n ("Copy selection"), 0, console, SLOT (copy ()), actionCollection (), "rkconsole_copy");
-	clear = new KAction (i18n ("Clear Console"), 0, console, SLOT (clear ()), actionCollection (), "rkconsole_clear");
-	paste = new KAction (i18n ("Paste"), KShortcut ("Ctrl+V"), console, SLOT (paste ()), actionCollection (), "rkconsole_paste");
-// same HACK here
-	paste->setShortcut ("Ctrl+V");
+	KStdAction::clear (console, SLOT (clear ()), actionCollection (), "rkconsole_clear");
+	paste = KStdAction::paste (console, SLOT (paste ()), actionCollection (), "rkconsole_paste");
+	new KAction (i18n ("Configure"), 0, console, SLOT (configure ()), actionCollection (), "rkconsole_configure");
+
 	connect (console, SIGNAL (popupMenuRequest (const QPoint &)), this, SLOT (makePopupMenu (const QPoint &)));
 }
 

Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/rkconsole.h	2006-11-28 16:07:56 UTC (rev 970)
@@ -33,16 +33,15 @@
 class RCommand;
 
 /**
-** 	\brief Provides an R-like console.
-**
-** This class provides a console, which is very similar to the classic R console. It is mainly used by RKwatch to allow
-** the user to enter commands manualy. It is basically just a modified KTextEdit.
-** 
-	Do not construct directly. Construct an RKConsolePart instead.
-	
-** \sa RKwatch, KTextEdit
-** 
-** @author Pierre Ecochard
+\brief Provides an R-like console.
+
+This class provides a console, which is very similar to the classic R console. It is based on a heavily modified KatePart.
+
+Do not construct directly. Construct an RKConsolePart instead.
+
+\sa RKCommandLog
+
+ at author Pierre Ecochard
 **/
 
 class RKConsole : public QWidget, public RCommandReceiver, public RKScriptContextProvider {
@@ -94,7 +93,6 @@
 /** A list to store a commands batch that will be executed one line at a time */
 	QStringList commands_batch;
 /** Sets the cursor position to the end of the last line. */
-
 	void cursorAtTheEnd ();
 /** Submits the current command */
 	void submitCommand ();
@@ -136,7 +134,8 @@
 	void paste ();
 	void copy ();
 /** Clear the view, and add a prompt at the top. */
-	void clear();
+	void clear ();
+	void configure ();
 };
 
 /** A part interface to RKConsole. Provides the context-help functionality

Modified: trunk/rkward/rkward/rkconsolepart.rc
===================================================================
--- trunk/rkward/rkward/rkconsolepart.rc	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/rkconsolepart.rc	2006-11-28 16:07:56 UTC (rev 970)
@@ -24,5 +24,7 @@
 		<Action name="interrupt"></Action>
 		<Separator/>
 		<Action name="rkconsole_clear"></Action>
+		<Separator/>
+		<Action name="rkconsole_configure"></Action>
 	</Menu>
 </kpartgui>
\ No newline at end of file

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/rkward.cpp	2006-11-28 16:07:56 UTC (rev 970)
@@ -184,6 +184,7 @@
 	RKCommandLog::getLog ()->setIcon (SmallIcon ("text_block"));	// TODO: move to RKCommandLog
 	watch_view = addToolWindow (RKCommandLog::getLog (), KDockWidget::DockBottom, getMainDockWidget (), 10);
 	connect (RKCommandLog::getLog (), SIGNAL (raiseWindow ()), this, SLOT (raiseWatch ()));
+	partManager ()->addPart (RKCommandLog::getLog ()->getPart (), false);
 
 	RKGlobals::rcontrol->setCaption (i18n ("Pending Jobs"));
 	RKGlobals::rcontrol->setName ("rcontrol");

Modified: trunk/rkward/rkward/windows/Makefile.am
===================================================================
--- trunk/rkward/rkward/windows/Makefile.am	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/windows/Makefile.am	2006-11-28 16:07:56 UTC (rev 970)
@@ -9,4 +9,4 @@
 	rkworkplaceview.cpp rkworkplace.cpp qxembedcopy.cpp rkwindowcatcher.cpp rkcommandlog.cpp
 rcdir = $(kde_datadir)/rkward
 rc_DATA = rkcommandeditorwindowpart.rc rkoutputwindow.rc rkhelpwindow.rc detachedwindowcontainer.rc \
-	rkcatchedx11windowpart.rc
+	rkcatchedx11windowpart.rc rkcommandlogpart.rc

Modified: trunk/rkward/rkward/windows/rkcommandlog.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.cpp	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/windows/rkcommandlog.cpp	2006-11-28 16:07:56 UTC (rev 970)
@@ -23,15 +23,15 @@
 #include "../settings/rksettings.h"
 #include "rkcommandeditorwindow.h"
 
-#include <qtextedit.h>
 #include <qpushbutton.h>
 #include <qfont.h>
 #include <qlayout.h>
 #include <qsplitter.h>
 #include <qpopupmenu.h>
+#include <qobjectlist.h>
 
 #include <klocale.h>
-#include <kmenubar.h>
+#include <kstdaction.h>
 
 #include "../debug.h"
 
@@ -56,7 +56,7 @@
 RKCommandLog::RKCommandLog () : KMdiChildView () {
 	RK_TRACE (APP);
 
-	log_view = new QTextEdit (this);
+	log_view = new RKCommandLogView (this);
 	log_view->setTextFormat (PlainText);
 	log_view->setUndoRedoEnabled (false);
 	log_view->setReadOnly (true);
@@ -70,6 +70,8 @@
 
 	last_raised_command = 0;
 	command_input_shown = 0;
+
+	part = new RKCommandLogPart (this);
 }
 
 RKCommandLog::~RKCommandLog(){
@@ -216,4 +218,85 @@
 	log_view->setWordWrap (QTextEdit::NoWrap);
 }
 
+////////////////////////// END RKCommandLog ///////////////////////////
+/////////////////////// BEGIN RKCommandLogView ////////////////////////
+
+
+RKCommandLogView::RKCommandLogView (RKCommandLog *parent) : QTextEdit (parent) {
+	RK_TRACE (APP);
+
+	const QObjectList *list = children ();
+	QObjectListIt it (*list);
+	QObject *obj;
+	
+	while ((obj = it.current()) != 0) {
+		++it;
+		obj->installEventFilter (this);
+	}
+}
+
+RKCommandLogView::~RKCommandLogView () {
+	RK_TRACE (APP);
+}
+
+bool RKCommandLogView::eventFilter (QObject *o, QEvent *e) {
+	if (e->type () == QEvent::MouseButtonPress){
+		QMouseEvent *m = (QMouseEvent *)e;
+		if (m->button() == Qt::RightButton) {
+			emit (popupMenuRequest (m->globalPos ()));
+			return (true);
+		}
+	}
+
+	return QTextEdit::eventFilter (o, e);
+}
+
+void RKCommandLogView::selectAll () {
+	RK_TRACE (APP);
+
+	QTextEdit::selectAll (true);
+}
+
+//////////////////////// END RKCommandLogView /////////////////////////
+/////////////////////// BEGIN RKCommandLogPart ////////////////////////
+
+#include <kxmlguifactory.h>
+
+RKCommandLogPart::RKCommandLogPart (RKCommandLog *for_log) : KParts::Part (0) {
+	RK_TRACE (APP);
+
+	KInstance* instance = new KInstance ("rkward");
+	setInstance (instance);
+
+	setWidget (log = for_log);
+
+	setXMLFile ("rkcommandlogpart.rc");
+
+	copy = KStdAction::copy (log->getView (), SLOT (copy ()), actionCollection (), "log_copy");
+	KStdAction::clear (log, SLOT (clearLog ()), actionCollection (), "log_clear");
+	KStdAction::selectAll (log->getView (), SLOT (selectAll ()), actionCollection (), "log_select_all");
+	new KAction (i18n ("Configure"), 0, log, SLOT (configureLog ()), actionCollection (), "log_configure");
+
+	connect (log->getView (), SIGNAL (popupMenuRequest (const QPoint &)), this, SLOT (doPopupMenu (const QPoint &)));
+}
+
+RKCommandLogPart::~RKCommandLogPart () {
+	RK_TRACE (APP);
+}
+
+void RKCommandLogPart::doPopupMenu (const QPoint &pos) {
+	RK_TRACE (APP);
+
+	QPopupMenu *menu = static_cast<QPopupMenu *> (factory ()->container ("rkcommandlog_context_menu", this));
+	copy->setEnabled (log->getView ()->hasSelectedText ());
+
+	if (!menu) {
+		RK_ASSERT (false);
+		return;
+	}
+	menu->exec (pos);
+
+	copy->setEnabled (true);
+}
+
 #include "rkcommandlog.moc"

Modified: trunk/rkward/rkward/windows/rkcommandlog.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.h	2006-11-28 13:55:50 UTC (rev 969)
+++ trunk/rkward/rkward/windows/rkcommandlog.h	2006-11-28 16:07:56 UTC (rev 970)
@@ -19,6 +19,7 @@
 #define RKCOMMANDLOG_H
 
 #include <qstring.h>
+#include <qtextedit.h>
 #include <kmdichildview.h>
 
 #include "../rbackend/rcommandreceiver.h"
@@ -29,6 +30,8 @@
 class QTextEdit;
 class RKCommandEditor;
 class QBoxLayout;
+class RKCommandLogView;
+class RKCommandLogPart;
 
 /**
 	\brief This widget shows all executed commands and their result
@@ -46,6 +49,9 @@
 	static void create ();
 	static void destroy ();
 	static RKCommandLog *getLog () { return rkcommand_log; };
+
+	RKCommandLogView *getView () { return log_view; };
+	RKCommandLogPart *getPart () { return part; };
 signals:
 /** the log_view emits this, when it should be raised (apparently this can only be done from the main frame) */
 	void raiseWindow ();
@@ -70,9 +76,42 @@
 /** On a given command, the log_view should not be raised more than once */
 	int last_raised_command;
 
-	QTextEdit *log_view;
+	RKCommandLogView *log_view;
+	RKCommandLogPart *part;
 
 	static RKCommandLog *rkcommand_log;
 };
 
+/** Simply subclass of QTextEdit to override context menu handling */
+class RKCommandLogView : public QTextEdit {
+	Q_OBJECT
+public:
+	RKCommandLogView (RKCommandLog *parent);
+	~RKCommandLogView ();
+public slots:
+	void selectAll ();
+signals:
+	void popupMenuRequest (const QPoint &pos);
+protected:
+	bool eventFilter (QObject *o, QEvent *e);
+};
+
+#include <kparts/part.h>
+
+class KAction;
+
+/** Provides a part interface for the RKCommandLog */
+class RKCommandLogPart : public KParts::Part {
+	Q_OBJECT
+public:
+	RKCommandLogPart (RKCommandLog *for_log);
+	~RKCommandLogPart ();
+public slots:
+	void doPopupMenu (const QPoint &pos);
+private:
+	RKCommandLog *log;
+
+	KAction *copy;
+};
+
 #endif

Added: trunk/rkward/rkward/windows/rkcommandlogpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlogpart.rc	                        (rev 0)
+++ trunk/rkward/rkward/windows/rkcommandlogpart.rc	2006-11-28 16:07:56 UTC (rev 970)
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="rkward" version="0.4.2">
+	<Menu name="rkcommandlog_context_menu">
+		<Action name="log_copy"/>
+		<Separator/>
+		<Action name="log_select_all"/>
+		<Separator/>
+		<Action name="log_clear"/>
+		<Separator/>
+		<Action name="log_configure"/>
+	</Menu>
+</kpartgui>


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