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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Sep 28 09:23:12 UTC 2012


Revision: 4321
          http://rkward.svn.sourceforge.net/rkward/?rev=4321&view=rev
Author:   tfry
Date:     2012-09-28 09:23:12 +0000 (Fri, 28 Sep 2012)
Log Message:
-----------
Add command history to debug console (shared with the main console's history)

Modified Paths:
--------------
    trunk/rkward/rkward/rkconsole.h
    trunk/rkward/rkward/windows/rkdebugconsole.cpp
    trunk/rkward/rkward/windows/rkdebugconsole.h

Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h	2012-09-27 15:11:46 UTC (rev 4320)
+++ trunk/rkward/rkward/rkconsole.h	2012-09-28 09:23:12 UTC (rev 4321)
@@ -74,6 +74,7 @@
 	void activate (bool with_focus=true);
 	void setCommandHistory (const QStringList &new_history, bool append);
 	QStringList commandHistory () const { return commands_history.getHistory (); };
+	void addCommandToHistory (const QString& text) { commands_history.append (text); };
 protected:
 /** Handle keystrokes before they reach the kate-part. Return TRUE if we want the kate-part to ignore it
 \param e the QKeyEvent */

Modified: trunk/rkward/rkward/windows/rkdebugconsole.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkdebugconsole.cpp	2012-09-27 15:11:46 UTC (rev 4320)
+++ trunk/rkward/rkward/windows/rkdebugconsole.cpp	2012-09-28 09:23:12 UTC (rev 4321)
@@ -19,17 +19,18 @@
 
 #include <QPushButton>
 #include <QTextEdit>
-#include <QLineEdit>
 #include <QLabel>
 #include <QVBoxLayout>
 #include <QHBoxLayout>
 
 #include <klocale.h>
 #include <kmessagebox.h>
+#include <khistorycombobox.h>
 
 #include "../agents/rkdebughandler.h"
 #include "../misc/rkdummypart.h"
 #include "../misc/rkcommonfunctions.h"
+#include "../rkconsole.h"
 
 #include "../debug.h"
 
@@ -72,7 +73,8 @@
 
 	prompt_label = new QLabel (this);
 	lower_layout->addWidget (prompt_label);
-	reply_edit = new QLineEdit (this);
+	reply_edit = new KHistoryComboBox (this);
+	reply_edit->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
 	connect (reply_edit, SIGNAL (returnPressed()), this, SLOT (sendReply()));
 	lower_layout->addWidget (reply_edit);
 	setFocusProxy (reply_edit);
@@ -105,6 +107,13 @@
 		context_view->setPlainText (RKDebugHandler::instance ()->outputContext ());
 		prompt_label->setText (RKDebugHandler::instance ()->debugPrompt ());
 		reply_edit->setEnabled (true);	// must come before focus
+		QStringList ch = RKConsole::mainConsole ()->commandHistory ();
+		QStringList ch_rev;	// limit to 100 items (dropdown list!), and reverse to have most recent item first.
+		for (int i = ch.size () - 1; i >= qMax (0, ch.size () - 101); --i) {
+			ch_rev.append (ch[i]);
+		}
+		reply_edit->setMaxCount (ch_rev.size ());
+		reply_edit->setHistoryItems (ch_rev);
 		activate (true);
 	}
 
@@ -118,7 +127,9 @@
 void RKDebugConsole::sendReply () {
 	RK_TRACE (APP);
 
-	sendReply (reply_edit->text ());
+	QString reply = reply_edit->currentText ();
+	sendReply (reply);
+	RKConsole::mainConsole ()->addCommandToHistory (reply);
 	reply_edit->clear ();
 }
 

Modified: trunk/rkward/rkward/windows/rkdebugconsole.h
===================================================================
--- trunk/rkward/rkward/windows/rkdebugconsole.h	2012-09-27 15:11:46 UTC (rev 4320)
+++ trunk/rkward/rkward/windows/rkdebugconsole.h	2012-09-28 09:23:12 UTC (rev 4321)
@@ -21,7 +21,7 @@
 #include "rkmdiwindow.h"
 
 class QPushButton;
-class QLineEdit;
+class KHistoryComboBox;
 class QTextEdit;
 class QLabel;
 
@@ -48,7 +48,7 @@
 	void sendReply (const QString &reply);
 
 	QTextEdit* context_view;
-	QLineEdit* reply_edit;
+	KHistoryComboBox* reply_edit;
 	QLabel* prompt_label;
 
 	QPushButton* step_button;

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