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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Dec 4 09:16:29 UTC 2012


Revision: 4475
          http://rkward.svn.sourceforge.net/rkward/?rev=4475&view=rev
Author:   tfry
Date:     2012-12-04 09:16:28 +0000 (Tue, 04 Dec 2012)
Log Message:
-----------
Use text edit instead of tree widget

Modified Paths:
--------------
    trunk/rkward/rkward/windows/rkdebugmessagewindow.cpp
    trunk/rkward/rkward/windows/rkdebugmessagewindow.h

Modified: trunk/rkward/rkward/windows/rkdebugmessagewindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkdebugmessagewindow.cpp	2012-12-03 19:07:31 UTC (rev 4474)
+++ trunk/rkward/rkward/windows/rkdebugmessagewindow.cpp	2012-12-04 09:16:28 UTC (rev 4475)
@@ -20,8 +20,7 @@
 #include <QShowEvent>
 #include <QHideEvent>
 #include <QVBoxLayout>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
+#include <QTextEdit>
 
 #include <kvbox.h>
 #include <kmessagebox.h>
@@ -105,8 +104,10 @@
 
 	QVBoxLayout *v_layout = new QVBoxLayout (this);
 	v_layout->setContentsMargins (0, 0, 0, 0);
-	message_viewer = new QTreeWidget (this);
-	message_viewer->setHeaderLabels (QStringList () << i18nc ("Severity level of debug message: Info, Warning, Error, etc. Keep this short.", "Level") << i18n ("Message"));
+	message_viewer = new QTextEdit (this);
+	message_viewer->setUndoRedoEnabled (false);
+	message_viewer->setReadOnly (true);
+	message_viewer->setTextBackgroundColor (Qt::white);
 	v_layout->addWidget (message_viewer);
 }
 
@@ -116,46 +117,26 @@
 
 void RKDebugMessageWindowWidget::newMessage (const int flags, const int level, const QString &message) {
 	Q_UNUSED (flags);
+
 	// Not tracing this! That might lead to infinite recursion!
-	QTreeWidgetItem *item = new QTreeWidgetItem (message_viewer);
 	if (level == DL_TRACE) {
-		item->setForeground (0, Qt::lightGray);
-		item->setText (0, "TRACE");
+		message_viewer->setTextColor (Qt::gray);
+		message_viewer->insertPlainText ("TRACE\t");
 	} else if (level == DL_DEBUG) {
-		item->setForeground (0, Qt::gray);
-		item->setText (0, "DEBUG");
+		message_viewer->setTextColor (Qt::blue);
+		message_viewer->insertPlainText ("DEBUG\t");
 	} else if (level == DL_INFO) {
-		item->setText (0, "INFO");
+		message_viewer->setTextColor (Qt::green);
+		message_viewer->insertPlainText ("INFO\t");
 	} else if (level == DL_WARNING) {
-		item->setForeground (0, Qt::yellow);
-		item->setText (0, "WARNING");
+		message_viewer->setTextColor (Qt::darkYellow);
+		message_viewer->insertPlainText ("WARNING\t");
 	} else {
-		item->setForeground (0, Qt::red);
-		item->setText (0, "ERROR");
+		message_viewer->setTextColor (Qt::red);
+		message_viewer->insertPlainText ("ERROR\t");
 	}
+	message_viewer->setTextColor (Qt::black);
 
-	// totally arbitrary and crude fuzzy wrapping
-	QString wrapped;
-	wrapped.reserve (message.size ());
-	int linelength = 0;
-	for (int i = 0; i < message.size (); ++i) {
-		if ((linelength > 100 && (message[i].isSpace()))
-			|| (linelength > 160 && (!message[i].isLetterOrNumber()))
-			|| (linelength > 200)) {
-			wrapped.append ('\n');
-			linelength = -1;
-		}
-		
-		wrapped.append (message[i]);
-		linelength++;
-	}
-	QString wrapped_short = wrapped;
-	if (wrapped.size () > 1500) {
-		wrapped_short = wrapped.mid (0, 1500) + "...";
-	}
-
-	item->setText (1, wrapped);
-	item->setToolTip (1, wrapped_short);
-	item->setTextAlignment (1, Qt::AlignTop | Qt::AlignLeft);
+	message_viewer->insertPlainText (message + "\n");
 }
 

Modified: trunk/rkward/rkward/windows/rkdebugmessagewindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkdebugmessagewindow.h	2012-12-03 19:07:31 UTC (rev 4474)
+++ trunk/rkward/rkward/windows/rkdebugmessagewindow.h	2012-12-04 09:16:28 UTC (rev 4475)
@@ -21,7 +21,7 @@
 #include "rkmdiwindow.h"
 
 class RKDebugMessageWindowWidget;
-class QTreeWidget;
+class QTextEdit;
 
 /** Tool window for displaying RKWard debug messages. Mainly targetted at plugin
  * developers. */
@@ -55,7 +55,7 @@
 
 	void newMessage (const int flags, const int level, const QString &message);
 private:
-	QTreeWidget *message_viewer;
+	QTextEdit *message_viewer;
 };
 
 #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