Add ability to filter log messages by type.

This commit is contained in:
sledgehammer999 2016-01-24 21:38:45 +02:00
commit 73832a5ed8
10 changed files with 194 additions and 46 deletions

View file

@ -35,18 +35,20 @@
#include <QPalette>
#include "executionlog.h"
#include "ui_executionlog.h"
#include "base/logger.h"
#include "base/preferences.h"
#include "guiiconprovider.h"
#include "loglistwidget.h"
ExecutionLog::ExecutionLog(QWidget *parent)
: QWidget(parent)
, ui(new Ui::ExecutionLog)
, m_msgList(new LogListWidget(MAX_LOG_MESSAGES))
, m_peerList(new LogListWidget(MAX_LOG_MESSAGES))
{
ui->setupUi(this);
m_msgList = new LogListWidget(MAX_LOG_MESSAGES,
Log::MsgTypes(Preferences::instance()->executionLogMessageTypes()));
ui->tabConsole->setTabIcon(0, GuiIconProvider::instance()->getIcon("view-calendar-journal"));
ui->tabConsole->setTabIcon(1, GuiIconProvider::instance()->getIcon("view-filter"));
ui->tabGeneral->layout()->addWidget(m_msgList);
@ -68,6 +70,11 @@ ExecutionLog::~ExecutionLog()
delete ui;
}
void ExecutionLog::showMsgTypes(const Log::MsgTypes &types)
{
m_msgList->showMsgTypes(types);
}
void ExecutionLog::addLogMessage(const Log::Msg &msg)
{
QString text;
@ -89,7 +96,7 @@ void ExecutionLog::addLogMessage(const Log::Msg &msg)
}
text = "<font color='grey'>" + time.toString(Qt::SystemLocaleShortDate) + "</font> - <font color='" + color.name() + "'>" + msg.message + "</font>";
m_msgList->appendLine(text);
m_msgList->appendLine(text, msg.type);
}
void ExecutionLog::addPeerMessage(const Log::Peer& peer)
@ -102,5 +109,5 @@ void ExecutionLog::addPeerMessage(const Log::Peer& peer)
else
text = "<font color='grey'>" + time.toString(Qt::SystemLocaleShortDate) + "</font> - " + tr("<font color='red'>%1</font> was banned", "x.y.z.w was banned").arg(peer.ip);
m_peerList->appendLine(text);
m_peerList->appendLine(text, Log::NORMAL);
}