summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-08-19 08:14:00 +0000
committerdeva <deva>2010-08-19 08:14:00 +0000
commit145bc8467b9f4271ca15654bc4bc6f7a8bc816b6 (patch)
treedf15aa4038ac3feda8791292b93591d40abb935d
parent9df4f44e051cf0fa467b8280ee77799163e5c841 (diff)
Added filter.
-rw-r--r--client/debug.cc31
-rw-r--r--client/debug.h4
2 files changed, 31 insertions, 4 deletions
diff --git a/client/debug.cc b/client/debug.cc
index 1507b2e..67608a3 100644
--- a/client/debug.cc
+++ b/client/debug.cc
@@ -33,6 +33,11 @@
#include <QAbstractItemView>
#include <QToolBar>
#include <QAction>
+#include <QWidgetAction>
+#include <QLabel>
+#include <QLineEdit>
+
+#include <stdio.h>
static const char * const class_str[] =
{ "debug", "error", "warn", "log" };
@@ -82,6 +87,18 @@ DebugWindow::DebugWindow()
connect(a, SIGNAL(toggled(bool)), this, SLOT(log_toggled(bool)));
a->setChecked(true);
+ QWidgetAction *wa = new QWidgetAction(toolbar2);
+ wa->setDefaultWidget(new QLabel("Filter:"));
+ toolbar2->addAction(wa);
+
+ wa = new QWidgetAction(toolbar2);
+ QLineEdit *fe = new QLineEdit();
+ wa->setDefaultWidget(fe);
+ toolbar2->addAction(wa);
+ connect(fe, SIGNAL(textChanged(QString)),
+ this, SLOT(filter_changed(QString)));
+ fe->setText(".*");
+
QSettings settings("Aasimon.org", "Pracro");
settings.beginGroup("DebugWindow");
resize(settings.value("size", QSize(700, 800)).toSize());
@@ -107,6 +124,11 @@ void DebugWindow::clear()
lst->clear();
}
+void DebugWindow::filter_changed(QString f)
+{
+ filter = f;
+}
+
void DebugWindow::debug_toggled(bool on)
{
show_debug = on;
@@ -135,8 +157,6 @@ void DebugWindow::log(const char *func, const char *file, const int line,
if(cl == _warn && show_warning == false) return; // Ignore
if(cl == _log && show_log == false) return; // Ignore
- timer.stop();
-
// Remove trailing newlines.
while(msg.endsWith("\n")) msg = msg.left(msg.length() - 1);
@@ -146,15 +166,18 @@ void DebugWindow::log(const char *func, const char *file, const int line,
class_str[(unsigned)cl], file, func, line);
txt += " : " + msg;
+ QRegExp r(filter);
+ if(r.indexIn(txt) == -1) return;
+
+ timer.stop();
+
QListWidgetItem *item = new QListWidgetItem();
item->setText(txt);
if(cl == _error) item->setBackground(QBrush(QColor(230, 200, 200)));
if(cl == _warn) item->setBackground(QBrush(QColor(200, 200, 230)));
if(cl == _log) item->setBackground(QBrush(QColor(200, 230, 200)));
-
lst->addItem(item);
- // lst->scrollToBottom();
timer.start(100);
}
diff --git a/client/debug.h b/client/debug.h
index e583afc..e75dad0 100644
--- a/client/debug.h
+++ b/client/debug.h
@@ -31,6 +31,7 @@
#include <QListWidget>
#include <QCloseEvent>
#include <QTimer>
+#include <QString>
typedef enum {
_debug,
@@ -56,11 +57,14 @@ private slots:
void error_toggled(bool);
void warning_toggled(bool);
void log_toggled(bool);
+ void filter_changed(QString);
private:
QListWidget *lst;
QTimer timer;
+ QString filter;
+
bool show_debug;
bool show_error;
bool show_warning;