1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include "ListWidgetLogger.h"
namespace SyntopiaCore {
namespace Logging {
ListWidgetLogger::ListWidgetLogger(QWidget* parent) : parent(parent) {
listWidget = new QListWidget(parent);
}
ListWidgetLogger::~ListWidgetLogger() {
}
void ListWidgetLogger::log(QString message, LogLevel priority) {
QListWidgetItem* i = new QListWidgetItem(message, listWidget);
// Levels: NoneLevel, DebugLevel, TimingLevel, InfoLevel, WarningLevel, CriticalLevel, AllLevel
if ( priority == InfoLevel ) {
i->setBackgroundColor(QColor(255,255,255));
} else if ( priority == WarningLevel ) {
parent->show();
i->setBackgroundColor(QColor(255,243,73));
} else if ( priority == CriticalLevel ) {
parent->show();
i->setBackgroundColor(QColor(255,2,0));
} else if ( priority == TimingLevel ) {
parent->show();
i->setBackgroundColor(QColor(25,255,0));
} else {
i->setBackgroundColor(QColor(220,220,220));
}
listWidget->scrollToItem(i);
}
}
}
|