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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 28 13:45:54 UTC 2006


Revision: 968
          http://svn.sourceforge.net/rkward/?rev=968&view=rev
Author:   tfry
Date:     2006-11-28 05:45:54 -0800 (Tue, 28 Nov 2006)

Log Message:
-----------
Rename RKwatch -> RKCommandLog, and move to windows directory

Modified Paths:
--------------
    trunk/rkward/rkward/Makefile.am
    trunk/rkward/rkward/rbackend/rcommand.cpp
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rinterface.h
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/windows/Makefile.am

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

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

Modified: trunk/rkward/rkward/Makefile.am
===================================================================
--- trunk/rkward/rkward/Makefile.am	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/Makefile.am	2006-11-28 13:45:54 UTC (rev 968)
@@ -21,11 +21,11 @@
 
 bin_PROGRAMS = rkward.bin
 
-rkward_bin_SOURCES = rkwatch.cpp rkward.cpp main.cpp \
+rkward_bin_SOURCES = rkward.cpp main.cpp \
 	rkglobals.cpp robjectbrowser.cpp robjectviewer.cpp \
 	khelpdlg.cpp rkconsole.cpp rkward.skel rkwardapplication.cpp
 
-noinst_HEADERS = rkwatch.h rkward.h debug.h \
+noinst_HEADERS = rkward.h debug.h \
 	rkglobals.h robjectbrowser.h robjectviewer.h \
 	khelpdlg.h rkconsole.h rkwardapplication.h
 

Modified: trunk/rkward/rkward/rbackend/rcommand.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rcommand.cpp	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/rbackend/rcommand.cpp	2006-11-28 13:45:54 UTC (rev 968)
@@ -18,7 +18,7 @@
 #include "rcommand.h"
 #include "rcommandreceiver.h"
 #include "rinterface.h"
-#include "../rkwatch.h"
+#include "../windows/rkcommandlog.h"
 
 #include "../debug.h"
 #include "../rkglobals.h"
@@ -44,7 +44,7 @@
 	RCommand::receivers = new RCommandReceiver* [MAX_RECEIVERS];
 	num_receivers = 0;
 	addReceiver (receiver);
-	addReceiver (RKGlobals::rInterface ()->watch);
+	addReceiver (RKCommandLog::getLog ());
 }
 
 RCommand::~RCommand(){

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2006-11-28 13:45:54 UTC (rev 968)
@@ -17,7 +17,6 @@
 
 #include "rinterface.h"
 
-#include "../rkwatch.h"
 #include "rthread.h"
 #include "rcommandstack.h"
 #include "../rkward.h"
@@ -31,6 +30,7 @@
 #include "../agents/showedittextfileagent.h"
 #include "../windows/rcontrolwindow.h"
 #include "../windows/rkworkplace.h"
+#include "../windows/rkcommandlog.h"
 
 #include "../windows/rkwindowcatcher.h"
 #ifndef DISABLE_RKWINDOWCATCHER
@@ -72,11 +72,10 @@
 
 	RCommandStack::regular_stack = new RCommandStack ();
 	running_command_canceled = 0;
-	
+
+	RKCommandLog::create ();
 	r_thread = new RThread ();
 
-	watch = new RKwatch ();
-
 	flush_timer = new QTimer (this);
 	connect (flush_timer, SIGNAL (timeout ()), this, SLOT (flushOutput ()));
 	flush_timer->start (FLUSH_INTERVAL);
@@ -106,7 +105,7 @@
 	}
 
 	delete flush_timer;
-	delete watch;
+	RKCommandLog::destroy ();
 	delete window_catcher;
 }
 
@@ -134,7 +133,7 @@
 			r_thread->pauseOutput (false);
 		}
 	} else if (e->type () == RCOMMAND_IN_EVENT) {
-		watch->addInput (static_cast <RCommand *> (e->data ()));
+		RKCommandLog::getLog ()->addInput (static_cast <RCommand *> (e->data ()));
 		RKGlobals::controlWindow ()->setCommandRunning (static_cast <RCommand *> (e->data ()));
 	} else if (e->type () == RCOMMAND_OUT_EVENT) {
 		RCommand *command = static_cast <RCommand *> (e->data ());

Modified: trunk/rkward/rkward/rbackend/rinterface.h
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.h	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/rbackend/rinterface.h	2006-11-28 13:45:54 UTC (rev 968)
@@ -32,7 +32,6 @@
 #define MUTEX_UNLOCK RInterface::mutex.unlock ();
 #endif
 
-class RKwatch;
 class RCommand;
 class RKWardMainWindow;
 struct RCallbackArgs;
@@ -104,8 +103,6 @@
 	void processRCallbackRequest (RCallbackArgs *args);
 friend class RKWardMainWindow;
 friend class RCommand;
-/** pointer to the RKwatch. TODO: (re-)move this pointer */
-	RKwatch *watch;
 /** Used (once!) to start the RThread. Need to make this separate to avoid race conditions */
 	void startThread ();
 protected:

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/rkward.cpp	2006-11-28 13:45:54 UTC (rev 968)
@@ -52,7 +52,6 @@
 // application specific includes
 #include "rkward.h"
 #include "core/rkmodificationtracker.h"
-#include "rkwatch.h"
 #include "plugin/rkcomponentmap.h"
 #include "settings/rksettings.h"
 #include "settings/rksettingsmoduleplugins.h"
@@ -71,6 +70,7 @@
 #include "windows/rkhtmlwindow.h"
 #include "windows/rkworkplaceview.h"
 #include "windows/rkworkplace.h"
+#include "windows/rkcommandlog.h"
 #include "khelpdlg.h"
 #include "rkconsole.h"
 #include "debug.h"
@@ -180,10 +180,10 @@
 	object_browser->setIcon(SmallIcon("view_tree"));
 	addToolWindow(object_browser,KDockWidget::DockLeft, getMainDockWidget(), 30 , i18n ("Existing objects in your workspace.") , i18n ("Workspace"));
 	
-	RKGlobals::rInterface ()->watch->setName ("Command log");
-	RKGlobals::rInterface ()->watch->setIcon (SmallIcon ("text_block"));
-	watch_view = addToolWindow (RKGlobals::rInterface ()->watch, KDockWidget::DockBottom, getMainDockWidget (), 10);
-	connect (RKGlobals::rInterface ()->watch, SIGNAL (raiseWatch ()), this, SLOT (raiseWatch ()));
+	RKCommandLog::getLog ()->setName ("Command log");		// TODO: move to RKCommandLog
+	RKCommandLog::getLog ()->setIcon (SmallIcon ("text_block"));	// TODO: move to RKCommandLog
+	watch_view = addToolWindow (RKCommandLog::getLog (), KDockWidget::DockBottom, getMainDockWidget (), 10);
+	connect (RKCommandLog::getLog (), SIGNAL (raiseWatch ()), this, SLOT (raiseWatch ()));
 
 	RKGlobals::rcontrol->setCaption (i18n ("Pending Jobs"));
 	RKGlobals::rcontrol->setName ("rcontrol");

Deleted: trunk/rkward/rkward/rkwatch.cpp
===================================================================
--- trunk/rkward/rkward/rkwatch.cpp	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/rkwatch.cpp	2006-11-28 13:45:54 UTC (rev 968)
@@ -1,202 +0,0 @@
-/***************************************************************************
-                          rkwatch.cpp  -  description
-                             -------------------
-    begin                : Sun Nov 3 2002
-    copyright            : (C) 2002 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 "rkwatch.h"
-
-#include "rbackend/rinterface.h"
-#include "rkglobals.h"
-#include "settings/rksettingsmodulewatch.h"
-#include "settings/rksettings.h"
-#include "windows/rkcommandeditorwindow.h"
-
-#include <qtextedit.h>
-#include <qpushbutton.h>
-#include <qfont.h>
-#include <qlayout.h>
-#include <qsplitter.h>
-#include <qpopupmenu.h>
-
-#include <klocale.h>
-#include <kmenubar.h>
-
-#include "debug.h"
-
-RKwatch::RKwatch () : KMdiChildView () {
-	RK_TRACE (APP);
-	
-	
-	watch = new QTextEdit (this);
-	watch->setTextFormat (PlainText);
-	watch->setUndoRedoEnabled (false);
-	watch->setReadOnly (true);
-
-	pLayout = new QHBoxLayout( this, 0, -1, "layout");
-	pLayout->addWidget(watch);
-
-	setCaption (i18n ("Command log"));
-	
-	clearWatch ();
-
-	last_raised_command = 0;
-	command_input_shown = 0;
-}
-
-RKwatch::~RKwatch(){
-	RK_TRACE (APP);
-}
-
-void RKwatch::addInput (RCommand *command) {
-	RK_TRACE (APP);
-	if (!RKSettingsModuleWatch::shouldShowInput (command)) return;
-
-// commands submitted via the console are often incomplete. We delay showing the input, until the command is finished.
-	if (command->type () & RCommand::Console) return;
-
-	addInputNoCheck (command);
-}
-
-void RKwatch::addInputNoCheck (RCommand *command) {
-	RK_TRACE (APP);
-	if (command->id () == command_input_shown) return;		// already shown
-
-// TODO: make colors/styles configurable
-	if (command->type () & RCommand::User) {
-		watch->setColor (Qt::red);
-	} else if (command->type () & RCommand::Sync) {
-		watch->setColor (Qt::gray);
-	} else if (command->type () & RCommand::Plugin) {
-		watch->setColor (Qt::blue);
-	}
-
-	watch->setItalic (true);
-
-	watch->append (command->command () + "\n");
-
-	checkRaiseWatch (command);
-	linesAdded ();
-
-	watch->setItalic (false);
-
-	command_input_shown = command->id ();
-}
-
-void RKwatch::addOutputNoCheck (RCommand *command, const QString &output) {
-	RK_TRACE (APP);
-
-	if (command->type () & RCommand::User) {
-		watch->setColor (Qt::red);
-	} else if (command->type () & RCommand::Sync) {
-		watch->setColor (Qt::gray);
-	} else if (command->type () & RCommand::Plugin) {
-		watch->setColor (Qt::blue);
-	}
-
-    watch->setBold (true);
-
-	watch->insert (output);
-
-	checkRaiseWatch (command);
-	linesAdded ();
-
-	watch->setBold (false);
-	watch->setColor (Qt::black);
-}
-
-void RKwatch::checkRaiseWatch (RCommand *command) {
-	// called during output. do not trace
-	if (command->id () == last_raised_command) return;
-	if (!RKSettingsModuleWatch::shouldRaiseWindow (command)) return;
-	if (command->type () & RCommand::Console) return;
-
-	last_raised_command = command->id ();
-	emit (raiseWatch ());
-}
-
-void RKwatch::newOutput (RCommand *command, ROutput *output_fragment) {
-	RK_TRACE (APP);
-
-	if (!RKSettingsModuleWatch::shouldShowOutput (command)) return;
-
-	if (RKSettingsModuleWatch::shouldShowInput (command)) addInputNoCheck (command);
-
-	addOutputNoCheck (command, output_fragment->output);
-}
-
-void RKwatch::rCommandDone (RCommand *command) {
-	RK_TRACE (APP);
-
-	if (command->type () & RCommand::Console) {
-		if (command->errorIncomplete ()) return;
-	}
-
-// the case we have to deal with here, is that the command/output has not been shown, yet, but should, due to errors
-	if (command->failed ()) {
-		if (RKSettingsModuleWatch::shouldShowError (command)) {
-			if (!RKSettingsModuleWatch::shouldShowInput (command)) addInputNoCheck (command);
-			if (!RKSettingsModuleWatch::shouldShowOutput (command)) addOutputNoCheck (command, command->fullOutput ());
-			if (command->error ().isEmpty ()) {
-				if (command->errorIncomplete ()) {
-					addOutputNoCheck (command, i18n ("Incomplete statement.\n"));
-				} else if (command->errorSyntax ()) {
-					addOutputNoCheck (command, i18n ("Syntax error.\n"));
-				} else {
-					addOutputNoCheck (command, i18n ("An unspecified error occured while running the command.\n"));
-				}
-			}
-		}
-	}
-
-	if (RKSettingsModuleWatch::shouldShowOutput (command)) watch->append ("\n");
-}
-
-void RKwatch::linesAdded () {
-	RK_TRACE (APP);
-
-// limit number of lines shown
-	if (RKSettingsModuleWatch::maxLogLines ()) {
-		uint c = (uint) watch->paragraphs ();
-		if (c > RKSettingsModuleWatch::maxLogLines ()) {
-			watch->setUpdatesEnabled (false);			// major performance boost while removing lines!
-			watch->setSelection (0, 0, c - RKSettingsModuleWatch::maxLogLines (), 0, 1);
-			watch->removeSelectedText (1);
-			watch->setUpdatesEnabled (true);
-			watch->update ();
-		}
-	}
-
-// scroll to bottom
-	watch->moveCursor (QTextEdit::MoveEnd, false);
-	watch->scrollToBottom ();
-}
-
-void RKwatch::configureWatch () {
-	RK_TRACE (APP);
-	RKSettings::configureSettings (RKSettings::Watch, this);
-}
-
-void RKwatch::clearWatch () {
-	RK_TRACE (APP);
-
-	watch->setText (QString::null);
-
-	// set a fixed width font
-	QFont font ("Courier");
-	watch->setCurrentFont (font);
-	watch->setWordWrap (QTextEdit::NoWrap);
-}
-
-#include "rkwatch.moc"

Deleted: trunk/rkward/rkward/rkwatch.h
===================================================================
--- trunk/rkward/rkward/rkwatch.h	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/rkwatch.h	2006-11-28 13:45:54 UTC (rev 968)
@@ -1,73 +0,0 @@
-/***************************************************************************
-                          rkwatch.h  -  description
-                             -------------------
-    begin                : Sun Nov 3 2002
-    copyright            : (C) 2002 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 RKWATCH_H
-#define RKWATCH_H
-
-#include <qstring.h>
-#include <kmdichildview.h>
-
-#include "rbackend/rcommandreceiver.h"
-
-class RCommand;
-class ROutput;
-class QPushButton;
-class QTextEdit;
-class RKCommandEditor;
-class QBoxLayout;
-
-/**
-	\brief This widget shows all executed commands and their result
- at author Thomas Friedrichsmeier
-*/
-
-class RKwatch : public KMdiChildView, public RCommandReceiver {
-	Q_OBJECT
-public: 
-	RKwatch ();
-	~RKwatch ();
-/** Adds input to the watch-window (i.e. commands issued) */
-	void addInput (RCommand *command);
-/** Adds output to the watch-window (i.e. replies received) */
-	void newOutput (RCommand *command, ROutput *output_fragment);
-signals:
-/** the watch emits this, when it should be raised (apparently this can only be done from the main frame) */
-	void raiseWatch ();
-protected:
-/** Command has finished. If the command has failed, it may be neccessary to print some more information */
-	void rCommandDone (RCommand *command);
-public slots:
-/** configures the watch-window */
-	void configureWatch ();
-/** clears the watch-window */
-	void clearWatch ();
-private:
-	void addInputNoCheck (RCommand *command);
-	void addOutputNoCheck (RCommand *command, const QString &output);
-	void checkRaiseWatch (RCommand *command);
-/** internal helper function, called whenever a line/lines have been added. Check whether log is longer than maximum setting. Scroll to the bottom */
-	void linesAdded ();
-/** Id of last command the input (i.e. the command itself) was shown for. Used to keep track of whether a command's input should be shown or not */
-	int command_input_shown;
-/** On a given command, the watch should not be raised more than once */
-	int last_raised_command;
-
-	QTextEdit *watch;
-	QBoxLayout* pLayout;
-};
-
-#endif

Modified: trunk/rkward/rkward/windows/Makefile.am
===================================================================
--- trunk/rkward/rkward/windows/Makefile.am	2006-11-28 13:03:55 UTC (rev 967)
+++ trunk/rkward/rkward/windows/Makefile.am	2006-11-28 13:45:54 UTC (rev 968)
@@ -3,10 +3,10 @@
 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
+	rkworkplaceview.h rkworkplace.h qxembedcopy.h rkwindowcatcher.h rkcommandlog.h
 libwindows_a_SOURCES = rkcommandeditorwindow.cpp rkcommandeditorwindowpart.cpp \
 	rkhtmlwindow.cpp rcontrolwindow.cpp detachedwindowcontainer.cpp rkmdiwindow.cpp \
-	rkworkplaceview.cpp rkworkplace.cpp qxembedcopy.cpp rkwindowcatcher.cpp
+	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

Copied: trunk/rkward/rkward/windows/rkcommandlog.cpp (from rev 907, trunk/rkward/rkward/rkwatch.cpp)
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.cpp	                        (rev 0)
+++ trunk/rkward/rkward/windows/rkcommandlog.cpp	2006-11-28 13:45:54 UTC (rev 968)
@@ -0,0 +1,219 @@
+/***************************************************************************
+                          rkcommandlog  -  description
+                             -------------------
+    begin                : Sun Nov 3 2002
+    copyright            : (C) 2002, 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 "rkcommandlog.h"
+
+#include "../rbackend/rinterface.h"
+#include "../rkglobals.h"
+#include "../settings/rksettingsmodulewatch.h"
+#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 <klocale.h>
+#include <kmenubar.h>
+
+#include "../debug.h"
+
+//static
+RKCommandLog *RKCommandLog::rkcommand_log = 0;
+
+void RKCommandLog::create () {
+	RK_TRACE (APP);
+	RK_ASSERT (!rkcommand_log);
+
+	rkcommand_log = new RKCommandLog;
+}
+
+void RKCommandLog::destroy () {
+	RK_TRACE (APP);
+	RK_ASSERT (rkcommand_log);
+
+	delete rkcommand_log;
+	rkcommand_log = 0;
+}
+
+RKCommandLog::RKCommandLog () : KMdiChildView () {
+	RK_TRACE (APP);
+
+	watch = new QTextEdit (this);
+	watch->setTextFormat (PlainText);
+	watch->setUndoRedoEnabled (false);
+	watch->setReadOnly (true);
+
+	pLayout = new QHBoxLayout( this, 0, -1, "layout");
+	pLayout->addWidget(watch);
+
+	setCaption (i18n ("Command log"));
+	
+	clearWatch ();
+
+	last_raised_command = 0;
+	command_input_shown = 0;
+}
+
+RKCommandLog::~RKCommandLog(){
+	RK_TRACE (APP);
+}
+
+void RKCommandLog::addInput (RCommand *command) {
+	RK_TRACE (APP);
+	if (!RKSettingsModuleWatch::shouldShowInput (command)) return;
+
+// commands submitted via the console are often incomplete. We delay showing the input, until the command is finished.
+	if (command->type () & RCommand::Console) return;
+
+	addInputNoCheck (command);
+}
+
+void RKCommandLog::addInputNoCheck (RCommand *command) {
+	RK_TRACE (APP);
+	if (command->id () == command_input_shown) return;		// already shown
+
+// TODO: make colors/styles configurable
+	if (command->type () & RCommand::User) {
+		watch->setColor (Qt::red);
+	} else if (command->type () & RCommand::Sync) {
+		watch->setColor (Qt::gray);
+	} else if (command->type () & RCommand::Plugin) {
+		watch->setColor (Qt::blue);
+	}
+
+	watch->setItalic (true);
+
+	watch->append (command->command () + "\n");
+
+	checkRaiseWatch (command);
+	linesAdded ();
+
+	watch->setItalic (false);
+
+	command_input_shown = command->id ();
+}
+
+void RKCommandLog::addOutputNoCheck (RCommand *command, const QString &output) {
+	RK_TRACE (APP);
+
+	if (command->type () & RCommand::User) {
+		watch->setColor (Qt::red);
+	} else if (command->type () & RCommand::Sync) {
+		watch->setColor (Qt::gray);
+	} else if (command->type () & RCommand::Plugin) {
+		watch->setColor (Qt::blue);
+	}
+
+    watch->setBold (true);
+
+	watch->insert (output);
+
+	checkRaiseWatch (command);
+	linesAdded ();
+
+	watch->setBold (false);
+	watch->setColor (Qt::black);
+}
+
+void RKCommandLog::checkRaiseWatch (RCommand *command) {
+	// called during output. do not trace
+	if (command->id () == last_raised_command) return;
+	if (!RKSettingsModuleWatch::shouldRaiseWindow (command)) return;
+	if (command->type () & RCommand::Console) return;
+
+	last_raised_command = command->id ();
+	emit (raiseWatch ());
+}
+
+void RKCommandLog::newOutput (RCommand *command, ROutput *output_fragment) {
+	RK_TRACE (APP);
+
+	if (!RKSettingsModuleWatch::shouldShowOutput (command)) return;
+
+	if (RKSettingsModuleWatch::shouldShowInput (command)) addInputNoCheck (command);
+
+	addOutputNoCheck (command, output_fragment->output);
+}
+
+void RKCommandLog::rCommandDone (RCommand *command) {
+	RK_TRACE (APP);
+
+	if (command->type () & RCommand::Console) {
+		if (command->errorIncomplete ()) return;
+	}
+
+// the case we have to deal with here, is that the command/output has not been shown, yet, but should, due to errors
+	if (command->failed ()) {
+		if (RKSettingsModuleWatch::shouldShowError (command)) {
+			if (!RKSettingsModuleWatch::shouldShowInput (command)) addInputNoCheck (command);
+			if (!RKSettingsModuleWatch::shouldShowOutput (command)) addOutputNoCheck (command, command->fullOutput ());
+			if (command->error ().isEmpty ()) {
+				if (command->errorIncomplete ()) {
+					addOutputNoCheck (command, i18n ("Incomplete statement.\n"));
+				} else if (command->errorSyntax ()) {
+					addOutputNoCheck (command, i18n ("Syntax error.\n"));
+				} else {
+					addOutputNoCheck (command, i18n ("An unspecified error occured while running the command.\n"));
+				}
+			}
+		}
+	}
+
+	if (RKSettingsModuleWatch::shouldShowOutput (command)) watch->append ("\n");
+}
+
+void RKCommandLog::linesAdded () {
+	RK_TRACE (APP);
+
+// limit number of lines shown
+	if (RKSettingsModuleWatch::maxLogLines ()) {
+		uint c = (uint) watch->paragraphs ();
+		if (c > RKSettingsModuleWatch::maxLogLines ()) {
+			watch->setUpdatesEnabled (false);			// major performance boost while removing lines!
+			watch->setSelection (0, 0, c - RKSettingsModuleWatch::maxLogLines (), 0, 1);
+			watch->removeSelectedText (1);
+			watch->setUpdatesEnabled (true);
+			watch->update ();
+		}
+	}
+
+// scroll to bottom
+	watch->moveCursor (QTextEdit::MoveEnd, false);
+	watch->scrollToBottom ();
+}
+
+void RKCommandLog::configureWatch () {
+	RK_TRACE (APP);
+	RKSettings::configureSettings (RKSettings::Watch, this);
+}
+
+void RKCommandLog::clearWatch () {
+	RK_TRACE (APP);
+
+	watch->setText (QString::null);
+
+	// set a fixed width font
+	QFont font ("Courier");
+	watch->setCurrentFont (font);
+	watch->setWordWrap (QTextEdit::NoWrap);
+}
+
+#include "rkcommandlog.moc"

Copied: trunk/rkward/rkward/windows/rkcommandlog.h (from rev 907, trunk/rkward/rkward/rkwatch.h)
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.h	                        (rev 0)
+++ trunk/rkward/rkward/windows/rkcommandlog.h	2006-11-28 13:45:54 UTC (rev 968)
@@ -0,0 +1,79 @@
+/***************************************************************************
+                          rkcommandlog  -  description
+                             -------------------
+    begin                : Sun Nov 3 2002
+    copyright            : (C) 2002, 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 RKCOMMANDLOG_H
+#define RKCOMMANDLOG_H
+
+#include <qstring.h>
+#include <kmdichildview.h>
+
+#include "../rbackend/rcommandreceiver.h"
+
+class RCommand;
+class ROutput;
+class QPushButton;
+class QTextEdit;
+class RKCommandEditor;
+class QBoxLayout;
+
+/**
+	\brief This widget shows all executed commands and their result
+ at author Thomas Friedrichsmeier
+*/
+
+class RKCommandLog : public KMdiChildView, public RCommandReceiver {
+	Q_OBJECT
+public: 
+/** Adds input to the watch-window (i.e. commands issued) */
+	void addInput (RCommand *command);
+/** Adds output to the watch-window (i.e. replies received) */
+	void newOutput (RCommand *command, ROutput *output_fragment);
+
+	static void create ();
+	static void destroy ();
+	static RKCommandLog *getLog () { return rkcommand_log; };
+signals:
+/** the watch emits this, when it should be raised (apparently this can only be done from the main frame) */
+	void raiseWatch ();
+protected:
+/** Command has finished. If the command has failed, it may be neccessary to print some more information */
+	void rCommandDone (RCommand *command);
+	RKCommandLog ();
+	~RKCommandLog ();
+public slots:
+/** configures the watch-window */
+	void configureWatch ();
+/** clears the watch-window */
+	void clearWatch ();
+private:
+	void addInputNoCheck (RCommand *command);
+	void addOutputNoCheck (RCommand *command, const QString &output);
+	void checkRaiseWatch (RCommand *command);
+/** internal helper function, called whenever a line/lines have been added. Check whether log is longer than maximum setting. Scroll to the bottom */
+	void linesAdded ();
+/** Id of last command the input (i.e. the command itself) was shown for. Used to keep track of whether a command's input should be shown or not */
+	int command_input_shown;
+/** On a given command, the watch should not be raised more than once */
+	int last_raised_command;
+
+	QTextEdit *watch;
+	QBoxLayout* pLayout;
+
+	static RKCommandLog *rkcommand_log;
+};
+
+#endif


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