From 24a579044f2789698b7e051f2861b09ae78c7449 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 13 Oct 2014 02:56:08 -0700 Subject: [PATCH] Ability to adjust line limit --- src/platform/qt/LogView.cpp | 18 +++++++++++++++++- src/platform/qt/LogView.h | 5 ++++- src/platform/qt/LogView.ui | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/platform/qt/LogView.cpp b/src/platform/qt/LogView.cpp index deb999ec4..a1f2308ab 100644 --- a/src/platform/qt/LogView.cpp +++ b/src/platform/qt/LogView.cpp @@ -17,8 +17,10 @@ LogView::LogView(QWidget* parent) connect(m_ui.levelFatal, SIGNAL(toggled(bool)), this, SLOT(setLevelFatal(bool))); connect(m_ui.levelGameError, SIGNAL(toggled(bool)), this, SLOT(setLevelGameError(bool))); connect(m_ui.clear, SIGNAL(clicked()), this, SLOT(clear())); + connect(m_ui.maxLines, SIGNAL(valueChanged(int)), this, SLOT(setMaxLines(int))); m_logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL; m_lines = 0; + m_ui.maxLines->setValue(DEFAULT_LINE_LIMIT); } void LogView::postLog(int level, const QString& log) { @@ -27,13 +29,14 @@ void LogView::postLog(int level, const QString& log) { } m_ui.view->appendPlainText(QString("%1:\t%2").arg(toString(level)).arg(log)); ++m_lines; - if (m_lines > LINE_LIMIT) { + if (m_lines > m_lineLimit) { clearLine(); } } void LogView::clear() { m_ui.view->clear(); + m_lines = 0; } void LogView::setLevelDebug(bool set) { @@ -43,6 +46,7 @@ void LogView::setLevelDebug(bool set) { clearLevel(GBA_LOG_DEBUG); } } + void LogView::setLevelStub(bool set) { if (set) { setLevel(GBA_LOG_STUB); @@ -50,6 +54,7 @@ void LogView::setLevelStub(bool set) { clearLevel(GBA_LOG_STUB); } } + void LogView::setLevelInfo(bool set) { if (set) { setLevel(GBA_LOG_INFO); @@ -57,6 +62,7 @@ void LogView::setLevelInfo(bool set) { clearLevel(GBA_LOG_INFO); } } + void LogView::setLevelWarn(bool set) { if (set) { setLevel(GBA_LOG_WARN); @@ -64,6 +70,7 @@ void LogView::setLevelWarn(bool set) { clearLevel(GBA_LOG_WARN); } } + void LogView::setLevelError(bool set) { if (set) { setLevel(GBA_LOG_ERROR); @@ -71,6 +78,7 @@ void LogView::setLevelError(bool set) { clearLevel(GBA_LOG_ERROR); } } + void LogView::setLevelFatal(bool set) { if (set) { setLevel(GBA_LOG_FATAL); @@ -78,6 +86,7 @@ void LogView::setLevelFatal(bool set) { clearLevel(GBA_LOG_FATAL); } } + void LogView::setLevelGameError(bool set) { if (set) { setLevel(GBA_LOG_GAME_ERROR); @@ -86,6 +95,13 @@ void LogView::setLevelGameError(bool set) { } } +void LogView::setMaxLines(int limit) { + m_lineLimit = limit; + while (m_lines > m_lineLimit) { + clearLine(); + } +} + QString LogView::toString(int level) { switch (level) { case GBA_LOG_DEBUG: diff --git a/src/platform/qt/LogView.h b/src/platform/qt/LogView.h index 2d366396c..c235408a7 100644 --- a/src/platform/qt/LogView.h +++ b/src/platform/qt/LogView.h @@ -30,12 +30,15 @@ private slots: void setLevelFatal(bool); void setLevelGameError(bool); + void setMaxLines(int); + private: - static const int LINE_LIMIT = 1000; + static const int DEFAULT_LINE_LIMIT = 1000; Ui::LogView m_ui; int m_logLevel; int m_lines; + int m_lineLimit; static QString toString(int level); void setLevel(int level) { m_logLevel |= level; } diff --git a/src/platform/qt/LogView.ui b/src/platform/qt/LogView.ui index 703bb75fd..f9aa13475 100644 --- a/src/platform/qt/LogView.ui +++ b/src/platform/qt/LogView.ui @@ -131,6 +131,24 @@ + + + + + + Max Lines + + + + + + + 9999 + + + + +