diff options
Diffstat (limited to 'client/debug.cc')
-rw-r--r-- | client/debug.cc | 31 |
1 files changed, 27 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); } |