[rkward-cvs] SF.net SVN: rkward: [2088] branches/KDE4_port

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 17 21:48:54 UTC 2007


Revision: 2088
          http://rkward.svn.sourceforge.net/rkward/?rev=2088&view=rev
Author:   tfry
Date:     2007-10-17 14:48:54 -0700 (Wed, 17 Oct 2007)

Log Message:
-----------
Remove Qt3 legacy code in RKCommandLog

Modified Paths:
--------------
    branches/KDE4_port/TODO_KDE4
    branches/KDE4_port/rkward/rkconsole.cpp
    branches/KDE4_port/rkward/settings/rksettings.h
    branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp
    branches/KDE4_port/rkward/windows/rkcommandlog.cpp
    branches/KDE4_port/rkward/windows/rkcommandlog.h

Modified: branches/KDE4_port/TODO_KDE4
===================================================================
--- branches/KDE4_port/TODO_KDE4	2007-10-17 15:20:51 UTC (rev 2087)
+++ branches/KDE4_port/TODO_KDE4	2007-10-17 21:48:54 UTC (rev 2088)
@@ -85,11 +85,9 @@
 rkconsole:
 	- check whether all selection, editing, navigating really works as expected
 	- is tab completion for file names still crashy?
+		- currently, problem seems to be inside KUrlCompletion
+	- crash when max number of lines reached
 
-rkcommandlog:
-	- does the RMB-menu work?
-	- get rid of Q3TextEdit
-
 rkhtmlwindow:
 	- when this is open, we always seem to crash on close
 

Modified: branches/KDE4_port/rkward/rkconsole.cpp
===================================================================
--- branches/KDE4_port/rkward/rkconsole.cpp	2007-10-17 15:20:51 UTC (rev 2087)
+++ branches/KDE4_port/rkward/rkconsole.cpp	2007-10-17 21:48:54 UTC (rev 2088)
@@ -397,7 +397,7 @@
 			QString current_name = current_line.mid (quote_start + 1, quote_end - quote_start - 1);
 			KUrlCompletion comp (KUrlCompletion::FileCompletion);
 			comp.setDir (QDir::currentPath ());
-			QString test = comp.makeCompletion (current_name);
+			comp.makeCompletion (current_name);
 	
 			if (doTabCompletionHelper (current_line_num, current_line, quote_start+1, quote_end, comp.allMatches ())) return;
 		}

Modified: branches/KDE4_port/rkward/settings/rksettings.h
===================================================================
--- branches/KDE4_port/rkward/settings/rksettings.h	2007-10-17 15:20:51 UTC (rev 2087)
+++ branches/KDE4_port/rkward/settings/rksettings.h	2007-10-17 21:48:54 UTC (rev 2088)
@@ -88,8 +88,10 @@
 	~RKSettingsTracker ();
 
 	void settingsChangedObjectBrowser ();
+	void settingsChangedMaxCommandLogLines () { maxCommandLogLinesChanged (); };
 signals:
 	void objectBrowserSettingsChanged ();
+	void maxCommandLogLinesChanged ();
 };
 
 #endif

Modified: branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp
===================================================================
--- branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp	2007-10-17 15:20:51 UTC (rev 2087)
+++ branches/KDE4_port/rkward/settings/rksettingsmodulewatch.cpp	2007-10-17 21:48:54 UTC (rev 2088)
@@ -29,6 +29,7 @@
 #include <Q3VBoxLayout>
 
 #include "../rbackend/rcommand.h"
+#include "rksettings.h"
 #include "../rkglobals.h"
 
 #include "../debug.h"
@@ -266,7 +267,9 @@
 	app_filter = getFilterSettings (app_filter_boxes);
 	sync_filter = getFilterSettings (sync_filter_boxes);
 
-	max_log_lines = max_log_lines_spinner->value ();
+	unsigned int max_log_lines_new = max_log_lines_spinner->value ();
+	if (max_log_lines_new != max_log_lines) RKSettings::tracker ()->settingsChangedMaxCommandLogLines ();
+	max_log_lines = max_log_lines_new;
 }
 
 void RKSettingsModuleWatch::save (KConfig *config) {

Modified: branches/KDE4_port/rkward/windows/rkcommandlog.cpp
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandlog.cpp	2007-10-17 15:20:51 UTC (rev 2087)
+++ branches/KDE4_port/rkward/windows/rkcommandlog.cpp	2007-10-17 21:48:54 UTC (rev 2088)
@@ -29,12 +29,8 @@
 #include <qfont.h>
 #include <qlayout.h>
 #include <qsplitter.h>
-#include <q3popupmenu.h>
 #include <qobject.h>
-//Added by qt3to4:
-#include <Q3HBoxLayout>
-#include <QMouseEvent>
-#include <QEvent>
+#include <QMenu>
 
 #include <klocale.h>
 #include <kactioncollection.h>
@@ -48,11 +44,12 @@
 	RK_TRACE (APP);
 
 	log_view = new RKCommandLogView (this);
-	log_view->setTextFormat (Qt::PlainText);
+	log_view->setLineWrapMode (QTextEdit::NoWrap);
 	log_view->setUndoRedoEnabled (false);
 	log_view->setReadOnly (true);
 
-	Q3HBoxLayout *layout = new Q3HBoxLayout (this, 0, -1, "layout");
+	QHBoxLayout *layout = new QHBoxLayout (this);
+	layout->setContentsMargins (0, 0, 0, 0);
 	layout->addWidget (log_view);
 
 	setCaption (i18n ("Command log"));
@@ -65,6 +62,10 @@
 	setPart (new RKCommandLogPart (this));
 	initializeActivationSignals ();
 	setFocusPolicy (Qt::ClickFocus);
+
+// KDE4 TODO
+	connect (RKSettings::tracker (), SIGNAL (maxCommandLogLinesChanged()), this, SLOT (maxCommandLogLinesChanged()));
+	maxCommandLogLinesChanged ();
 }
 
 RKCommandLog::~RKCommandLog(){
@@ -87,21 +88,21 @@
 
 // TODO: make colors/styles configurable
 	if (command->type () & RCommand::User) {
-		log_view->setColor (Qt::red);
+		log_view->setTextColor (Qt::red);
 	} else if (command->type () & RCommand::Sync) {
-		log_view->setColor (Qt::gray);
+		log_view->setTextColor (Qt::gray);
 	} else if (command->type () & RCommand::Plugin) {
-		log_view->setColor (Qt::blue);
+		log_view->setTextColor (Qt::blue);
 	}
 
-	log_view->setItalic (true);
+	log_view->setFontItalic (true);
 
-	log_view->append (command->command () + '\n');
+	log_view->insert (command->command () + '\n');
 
 	checkRaiseWindow (command);
 	linesAdded ();
 
-	log_view->setItalic (false);
+	log_view->setFontItalic (false);
 
 	command_input_shown = command->id ();
 }
@@ -110,24 +111,28 @@
 	RK_TRACE (APP);
 
 	if (command->type () & RCommand::User) {
-		log_view->setColor (Qt::red);
+		log_view->setTextColor (Qt::red);
 	} else if (command->type () & RCommand::Sync) {
-		log_view->setColor (Qt::gray);
+		log_view->setTextColor (Qt::gray);
 	} else if (command->type () & RCommand::Plugin) {
-		log_view->setColor (Qt::blue);
+		log_view->setTextColor (Qt::blue);
 	}
-	log_view->setBold (true);
+	log_view->setFontWeight (QFont::Bold);
 	if (output->type != ROutput::Output) {
-		log_view->setParagraphBackgroundColor (log_view->paragraphs () - 1, QColor (255, 200, 200));
+		QTextBlockFormat f;
+		f.setBackground (QBrush (QColor (255, 200, 200)));
+		log_view->textCursor ().mergeBlockFormat (f);
 	}
 
 	log_view->insert (output->output);
 
 	if (output->type != ROutput::Output) {
-		log_view->setParagraphBackgroundColor (log_view->paragraphs () - 1, QColor (255, 255, 255));
+		QTextBlockFormat f;
+		f.setBackground (QBrush (QColor (255, 255, 255)));
+		log_view->textCursor ().mergeBlockFormat (f);
 	}
-	log_view->setBold (false);
-	log_view->setColor (Qt::black);
+	log_view->setFontWeight (QFont::Normal);
+	log_view->setTextColor (Qt::black);
 
 	checkRaiseWindow (command);
 	linesAdded ();
@@ -185,27 +190,21 @@
 		}
 	}
 
-	if (RKSettingsModuleWatch::shouldShowOutput (command)) log_view->append ("\n");
+	if (RKSettingsModuleWatch::shouldShowOutput (command)) log_view->insert ("\n");
 }
 
-void RKCommandLog::linesAdded () {
+void RKCommandLog::maxCommandLogLinesChanged () {
 	RK_TRACE (APP);
 
-// limit number of lines shown
-	if (RKSettingsModuleWatch::maxLogLines ()) {
-		uint c = (uint) log_view->paragraphs ();
-		if (c > RKSettingsModuleWatch::maxLogLines ()) {
-			log_view->setUpdatesEnabled (false);			// major performance boost while removing lines!
-			log_view->setSelection (0, 0, c - RKSettingsModuleWatch::maxLogLines (), 0, 1);
-			log_view->removeSelectedText (1);
-			log_view->setUpdatesEnabled (true);
-			log_view->update ();
-		}
-	}
+	log_view->document ()->setMaximumBlockCount (RKSettingsModuleWatch::maxLogLines ());
+}
 
+void RKCommandLog::linesAdded () {
+	RK_TRACE (APP);
+
 // scroll to bottom
-	log_view->moveCursor (Q3TextEdit::MoveEnd, false);
-	log_view->scrollToBottom ();
+	log_view->moveCursor (QTextCursor::End, QTextCursor::MoveAnchor);
+	log_view->ensureCursorVisible ();
 }
 
 void RKCommandLog::configureLog () {
@@ -216,12 +215,11 @@
 void RKCommandLog::clearLog () {
 	RK_TRACE (APP);
 
-	log_view->setText (QString::null);
+	log_view->setPlainText (QString ());
 
 	// set a fixed width font
 	QFont font ("Courier");
 	log_view->setCurrentFont (font);
-	log_view->setWordWrap (Q3TextEdit::NoWrap);
 }
 
 void RKCommandLog::runSelection () {
@@ -234,39 +232,26 @@
 /////////////////////// BEGIN RKCommandLogView ////////////////////////
 
 
-RKCommandLogView::RKCommandLogView (RKCommandLog *parent) : Q3TextEdit (parent) {
+RKCommandLogView::RKCommandLogView (RKCommandLog *parent) : QTextEdit (parent) {
 	RK_TRACE (APP);
-
-// KDE 4: disabled for now. And WTF was it supposed to be good for?
-/*	const QList<QObject*> list = children ();
-	QList<QObject*>::const_iterator it = list.constBegin ();
-
-	while (it != list.constEnd()) {
-		(*it)->installEventFilter (this);
-		++it;
-	} */
 }
 
 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);
-		}
-	}
+void RKCommandLogView::contextMenuEvent (QContextMenuEvent *event) {
+	RK_TRACE (APP);
 
-	return Q3TextEdit::eventFilter (o, e);
+	emit (popupMenuRequest (event->globalPos ()));
+	event->accept ();
 }
 
 void RKCommandLogView::selectAll () {
 	RK_TRACE (APP);
 
-	Q3TextEdit::selectAll (true);
+	moveCursor (QTextCursor::Start, QTextCursor::MoveAnchor);
+	moveCursor (QTextCursor::Start, QTextCursor::KeepAnchor);
 }
 
 //////////////////////// END RKCommandLogView /////////////////////////
@@ -304,7 +289,7 @@
 void RKCommandLogPart::doPopupMenu (const QPoint &pos) {
 	RK_TRACE (APP);
 
-	Q3PopupMenu *menu = static_cast<Q3PopupMenu *> (factory ()->container ("rkcommandlog_context_menu", this));
+	QMenu *menu = static_cast<QMenu *> (factory ()->container ("rkcommandlog_context_menu", this));
 	copy->setEnabled (log->getView ()->hasSelectedText ());
 	run_selection->setEnabled (log->getView ()->hasSelectedText ());
 

Modified: branches/KDE4_port/rkward/windows/rkcommandlog.h
===================================================================
--- branches/KDE4_port/rkward/windows/rkcommandlog.h	2007-10-17 15:20:51 UTC (rev 2087)
+++ branches/KDE4_port/rkward/windows/rkcommandlog.h	2007-10-17 21:48:54 UTC (rev 2088)
@@ -19,19 +19,14 @@
 #define RKCOMMANDLOG_H
 
 #include <qstring.h>
-#include <q3textedit.h>
-//Added by qt3to4:
-#include <QEvent>
+#include <qtextedit.h>
 
 #include "rkmdiwindow.h"
 #include "../rbackend/rcommandreceiver.h"
 
 class RCommand;
 class ROutput;
-class QPushButton;
 class Q3TextEdit;
-class RKCommandEditor;
-class Q3BoxLayout;
 class RKCommandLogView;
 class RKCommandLogPart;
 
@@ -62,6 +57,7 @@
 /** clears the log_view-window */
 	void clearLog ();
 	void runSelection ();
+	void maxCommandLogLinesChanged ();
 private:
 	void addInputNoCheck (RCommand *command);
 	void addOutputNoCheck (RCommand *command, ROutput *output);
@@ -79,7 +75,7 @@
 };
 
 /** Simply subclass of QTextEdit to override context menu handling */
-class RKCommandLogView : public Q3TextEdit {
+class RKCommandLogView : public QTextEdit {
 	Q_OBJECT
 public:
 	RKCommandLogView (RKCommandLog *parent);
@@ -89,7 +85,7 @@
 signals:
 	void popupMenuRequest (const QPoint &pos);
 protected:
-	bool eventFilter (QObject *o, QEvent *e);
+	void contextMenuEvent (QContextMenuEvent *event);
 };
 
 #include <kparts/part.h>


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