ui: log tab

This commit is contained in:
Andreas Stallinger
2016-11-10 11:09:24 +01:00
parent 338335acf3
commit cf8e8c7655
23 changed files with 514 additions and 168 deletions
+2 -2
View File
@@ -394,7 +394,7 @@
</aggregation>
</edge>
</graph>
<error>
<table>
<background>#494949</background>
<table>#C4C4C4</table>
<text>
@@ -409,7 +409,7 @@
<normal>#383838</normal>
<active>#7B7B7B</active>
</table_line_2>
</error>
</table>
<tab>
<background>#494949</background>
<active>#C4C4C4</active>
+10 -7
View File
@@ -362,6 +362,15 @@
</graph>
<error>
<background>white</background>
</error>
<tab>
<background>white</background>
<active>black</active>
<hover>#878787</hover>
<text>#878787</text>
</tab>
<table>
<background>white</background>
<table>#aaa</table>
<text>
<normal>black</normal>
@@ -375,11 +384,5 @@
<normal>#F1F1F1</normal>
<active>grey</active>
</table_line_2>
</error>
<tab>
<background>white</background>
<active>black</active>
<hover>#878787</hover>
<text>#878787</text>
</tab>
</table>
</config>
+2 -2
View File
@@ -389,7 +389,7 @@
</aggregation>
</edge>
</graph>
<error>
<table>
<background>#272728</background>
<table>white</table>
<text>
@@ -404,7 +404,7 @@
<normal>#343434</normal>
<active>#969696</active>
</table_line_2>
</error>
</table>
<tab>
<background>#272728</background>
<active>white</active>
@@ -1,92 +0,0 @@
QTableView {
color: <color:error/text/normal>;
background-color: <color:error/table_line_1/normal>;
alternate-background-color: <color:error/table_line_2/normal>;
border-radius: 10px;
border: 1px solid <color:error/table>;
margin: 10px;
padding-right: 10px;
font-size: <setting:font_size>px;
}
QFrame {
background-color: <color:error/background>;
}
QTableView::item {
border-left: 1px solid <color:error/table>;
}
QTableView::item:selected {
color: <color:error/text/active>;
background-color: <color:error/table_line_1/active>;
alternate-background-color: <color:error/table_line_2/active>;
}
QHeaderView {
background-color: transparent;
}
QHeaderView::section:horizontal {
background-color: transparent;
border: none;
border-bottom: 1px solid <color:error/table>;
border-left: 1px solid <color:error/table>;
color: <color:error/text/normal>;
font-size: <setting:font_size>px;
font-weight: bold;
padding: 1px 6px;
height: <setting:font_size+5>px;
}
QHeaderView::section:vertical {
background-color: transparent;
border: none;
color: <color:error/text/normal>;
font-size: <setting:font_size>px;
padding-right: 5px;
padding-left: 5px;
}
QCheckBox {
color: <color:error/text/normal>;
border-color: <color:error/table>;
/*background-color: <color:error/table>;*/
}
QScrollBar:vertical {
}
QScrollBar::handle:vertical {
min-height: 20px;
}
QScrollBar::add-line:vertical {
height: 20px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
height: 20px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
width: 3px;
height: 3px;
background: white;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QTableView QTableCornerButton::section {
background-color: <color:error/background>;
border-bottom: 1px solid <color:error/table>;
border-top-left-radius: 10px;
}
@@ -29,3 +29,95 @@ QTabWidget::pane {
margin: 0px;
padding: 0px;
}
QTableView {
color: <color:table/text/normal>;
background-color: <color:table/table_line_1/normal>;
alternate-background-color: <color:table/table_line_2/normal>;
border-radius: 10px;
border: 1px solid <color:table/table>;
margin: 10px;
padding-right: 10px;
font-size: <setting:font_size>px;
}
QFrame {
background-color: <color:tab/background>;
}
QTableView::item {
border-left: 1px solid <color:table/table>;
}
QTableView::item:selected {
color: <color:table/text/active>;
background-color: <color:table/table_line_1/active>;
alternate-background-color: <color:table/table_line_2/active>;
}
QHeaderView {
background-color: transparent;
}
QHeaderView::section:horizontal {
background-color: transparent;
border: none;
border-bottom: 1px solid <color:table/table>;
border-left: 1px solid <color:table/table>;
color: <color:table/text/normal>;
font-size: <setting:font_size>px;
font-weight: bold;
padding: 1px 6px;
height: <setting:font_size+5>px;
}
QHeaderView::section:vertical {
background-color: transparent;
border: none;
color: <color:table/text/normal>;
font-size: <setting:font_size>px;
padding-right: 5px;
padding-left: 5px;
}
QCheckBox {
color: <color:table/text/normal>;
border-color: <color:table/table>;
/*background-color: <color:table/table>;*/
}
QScrollBar:vertical {
}
QScrollBar::handle:vertical {
min-height: 20px;
}
QScrollBar::add-line:vertical {
height: 20px;
subcontrol-position: bottom;
subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
height: 20px;
subcontrol-position: top;
subcontrol-origin: margin;
}
QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
width: 3px;
height: 3px;
background: white;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QTableView QTableCornerButton::section {
background-color: <color:table/background>;
border-bottom: 1px solid <color:table/table>;
border-top-left-radius: 10px;
}
+13 -9
View File
@@ -7,7 +7,7 @@ if (UNIX AND APPLE)
set(CLANG_BUILD_PATH "$ENV{CLANG_DIR}/build_debug")
endif()
elseif(UNIX)
set(CLANG_BUILD_PATH "${EXTERNAL_BUILD}/llvm")
set(CLANG_BUILD_PATH "${EXTERNAL_BUILD}/llvm")
else()
set(CLANG_BUILD_PATH "$ENV{CLANG_DIR}/build")
endif()
@@ -21,16 +21,20 @@ execute_process(
string(REPLACE "-fno-exceptions" "" CLANG_DEFINITIONS "${CLANG_DEFINITIONS}")
string(REPLACE "-fno-rtti" "" CLANG_DEFINITIONS "${CLANG_DEFINITIONS}")
if(CMAKE_COMPILER_IS_GNUCXX)
string(REPLACE "-Wcovered-switch-default" "" CLANG_DEFINITIONS "${CLANG_DEFINITIONS}")
endif()
if(UNIX AND NOT APPLE)
set(CLANG_INCLUDE_DIRS
"${EXTERNAL_SRC}/clang/include"
"${CLANG_BUILD_PATH}/tools/clang/include"
)
set(CLANG_INCLUDE_DIRS
"${EXTERNAL_SRC}/clang/include"
"${CLANG_BUILD_PATH}/tools/clang/include"
)
else()
set(CLANG_INCLUDE_DIRS
"$ENV{CLANG_DIR}/llvm/tools/clang/include"
"${CLANG_BUILD_PATH}/tools/clang/include"
)
set(CLANG_INCLUDE_DIRS
"$ENV{CLANG_DIR}/llvm/tools/clang/include"
"${CLANG_BUILD_PATH}/tools/clang/include"
)
endif()
set(CLANG_LIBRARY_DIRS "${CLANG_BUILD_PATH}/lib")
+2 -2
View File
@@ -15,7 +15,7 @@ endfunction()
set(upxPath ${CMAKE_CURRENT_LIST_DIR}/../bin/app/Release)
execute_process(
COMMAND ${upxPath}/Coati -z /home/vagrant/dev/license.txt
COMMAND ${upxPath}/Coati -z $ENV{HOME}/dev/license.txt
)
execute_process(
@@ -29,7 +29,7 @@ endfunction()
#execute_process(
#COMMAND ${upxPath}/Coati -f -d ${upxPath}/../data/projects/javaparser/javaparser.coatiproject
#)
#SET (NO_UPX 1)
SET (NO_UPX 1)
if (NO_UPX)
execute_process(
+3 -3
View File
@@ -12,13 +12,13 @@ COATI_PATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
#setup data folder
if [ ! -d "${HOME}/.config/coati" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
mkdir -p ${HOME}/.config/coati
mkdir -p "${HOME}/.config/coati"
echo "First start of Coati from this user, copy default configfiles to ~/.config/coati"
fi
cp -rn $COATI_PATH/user/* ${HOME}/.config/coati/
cp -rn "$COATI_PATH/user/*" "${HOME}/.config/coati/"
export LD_LIBRARY_PATH="$COATI_PATH/lib:LD_LIBRARY_PATH"
export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb:$QT_XKB_CONFIG_ROOT"
export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR"
exec $COATI_PATH/Coati $@
exec "$COATI_PATH/Coati" $@
-26
View File
@@ -1,26 +0,0 @@
#!/bin/sh
# get the current directory
SOURCE="${0}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
COATI_PATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
#setup data folder
echo $COATI_PATH
if [ ! -d "${HOME}/.config/coatitrial" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
mkdir -p ${HOME}/.config/coatitrial
echo "First start of Coati from this user, copy default configfiles to ~/.config/coati"
fi
cp -nr $COATI_PATH/user/* ${HOME}/.config/coatitrial/
export LD_LIBRARY_PATH="$COATI_PATH/lib:LD_LIBRARY_PATH"
export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb:$QT_XKB_CONFIG_ROOT"
export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR"
exec $COATI_PATH/Coati_trial
+1
View File
@@ -285,6 +285,7 @@ add_files(
utility/messaging/type/MessageLoadProject.h
utility/messaging/type/MessageMoveIDECursor.h
utility/messaging/type/MessageNewErrors.h
utility/messaging/type/MessageNewLog.h
utility/messaging/type/MessagePluginPortChange.h
utility/messaging/type/MessageProjectEdit.h
utility/messaging/type/MessageProjectNew.h
+5 -1
View File
@@ -20,6 +20,8 @@
#include "component/view/UndoRedoView.h"
#include "component/view/ViewFactory.h"
#include "utility/logging/LogManager.h"
std::shared_ptr<ComponentFactory> ComponentFactory::create(ViewFactory* viewFactory, StorageAccess* storageAccess)
{
std::shared_ptr<ComponentFactory> ptr(new ComponentFactory());
@@ -63,7 +65,9 @@ std::shared_ptr<Component> ComponentFactory::createErrorComponent(ViewLayout* vi
std::shared_ptr<Component> ComponentFactory::createLogComponent(ViewLayout* viewLayout)
{
std::shared_ptr<LogView> view = m_viewFactory->createLogView(viewLayout);
std::shared_ptr<LogController> controller = std::make_shared<LogController>(m_storageAccess);
std::shared_ptr<LogController> controller = std::make_shared<LogController>();
LogManager::getInstance()->addLogger(controller);
return std::make_shared<Component>(view, controller);
}
+2 -2
View File
@@ -63,8 +63,8 @@ void ComponentManager::setup(ViewLayout* viewLayout)
std::shared_ptr<Component> errorComponent = m_componentFactory->createErrorComponent(tabbedView.get());
m_components.push_back(errorComponent);
//std::shared_ptr<Component> logComponent = m_componentFactory->createLogComponent(tabbedView.get());
//m_components.push_back(logComponent);
std::shared_ptr<Component> logComponent = m_componentFactory->createLogComponent(tabbedView.get());
m_components.push_back(logComponent);
}
void ComponentManager::clearComponents()
+29 -2
View File
@@ -1,9 +1,10 @@
#include "component/controller/LogController.h"
#include "data/access/StorageAccess.h"
#include "utility/logging/LogManager.h"
LogController::LogController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
LogController::LogController()
: Logger("WindowLogger")
{
}
@@ -20,3 +21,29 @@ void LogController::clear()
{
getView()->clear();
}
void LogController::logInfo(const LogMessage& message )
{
addLog(LOG_INFOS, message);
}
void LogController::logError(const LogMessage& message )
{
addLog(LOG_ERRORS, message);
}
void LogController::logWarning(const LogMessage& message )
{
addLog(LOG_WARNINGS, message);
}
void LogController::addLog(Logger::LogLevel type, const LogMessage& message)
{
MessageNewLog(type,message).dispatch();
}
void LogController::handleMessage(MessageNewLog* message)
{
getView()->addLog(message->type, message->message);
}
+14 -2
View File
@@ -4,21 +4,33 @@
#include "component/controller/Controller.h"
#include "component/view/LogView.h"
#include "utility/logging/Logger.h"
#include "utility/logging/LogMessage.h"
#include "utility/messaging/type/MessageNewLog.h"
#include "utility/messaging/MessageListener.h"
class StorageAccess;
class LogController
: public Controller
, public Logger
, public MessageListener<MessageNewLog>
{
public:
LogController(StorageAccess* storageAccess);
LogController();
~LogController();
private:
LogView* getView() const;
virtual void handleMessage(MessageNewLog* message);
virtual void clear();
StorageAccess* m_storageAccess;
virtual void logInfo(const LogMessage& message);
virtual void logWarning(const LogMessage& message);
virtual void logError(const LogMessage& message);
void addLog(Logger::LogLevel type, const LogMessage& message);
};
#endif // LOG_CONTROLLER_H
+4
View File
@@ -3,6 +3,9 @@
#include "component/view/View.h"
#include "utility/logging/LogMessage.h"
#include "utility/logging/Logger.h"
class LogView
: public View
{
@@ -13,6 +16,7 @@ public:
virtual std::string getName() const;
virtual void clear() = 0;
virtual void addLog(Logger::LogLevel type, const LogMessage& message) = 0;
};
#endif // LOG_VIEW_H
+1 -1
View File
@@ -18,7 +18,7 @@ ColorScheme::~ColorScheme()
std::string ColorScheme::getColor(const std::string& key) const
{
return getValue<std::string>(key, "");
return getValue<std::string>(key, "#FF1493");
}
std::string ColorScheme::getColor(const std::string& key, const std::string& defaultColor) const
@@ -0,0 +1,34 @@
#ifndef MESSAGE_NEW_LOG_H
#define MESSAGE_NEW_LOG_H
#include "utility/messaging/Message.h"
#include "utility/logging/logging.h"
class MessageNewLog
: public Message<MessageNewLog>
{
public:
MessageNewLog(const Logger::LogLevel type, const LogMessage& message)
: type(type)
, message(message)
{
setSendAsTask(false);
setIsLogged(false);
}
static const std::string getStaticType()
{
return "MessageNewLog";
}
virtual void print(std::ostream& os) const
{
os << "Log: " << message.message;
}
const Logger::LogLevel type;
const LogMessage message;
};
#endif // MESSAGE_NEW_LOG_H
+2
View File
@@ -46,6 +46,8 @@ namespace utility
template<typename T>
std::vector<std::string> toStrings(const std::vector<T>& d);
template<>
std::vector<std::string> toStrings(const std::vector<FilePath>& d);
template<typename T>
bool isPermutation(const std::vector<T>& a, const std::vector<T>& b)
+24
View File
@@ -5,9 +5,31 @@
#include <QHeaderView>
#include <QResizeEvent>
#include <QScrollBar>
#include <QStyledItemDelegate>
#include <QLineEdit>
#include "settings/ApplicationSettings.h"
class SelectableCellDelegate : public QStyledItemDelegate
{
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
QWidget* SelectableCellDelegate::createEditor(
QWidget* parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QWidget* editor = QStyledItemDelegate::createEditor(parent, option, index);
QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(editor);
if (lineEdit != nullptr)
{
lineEdit->setReadOnly(true);
}
return editor;
}
QtTable::QtTable(QWidget* parent)
: QTableView(parent)
, m_rowsToFill(0)
@@ -15,6 +37,8 @@ QtTable::QtTable(QWidget* parent)
setAlternatingRowColors(true);
setShowGrid(false);
this->setItemDelegate(new SelectableCellDelegate());
verticalHeader()->sectionResizeMode(QHeaderView::Fixed);
verticalHeader()->setDefaultAlignment(Qt::AlignRight);
+12 -13
View File
@@ -184,9 +184,8 @@ void QtErrorView::setStyleSheet() const
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
utility::setWidgetBackgroundColor(widget, ColorScheme::getInstance()->getColor("error/background"));
QPalette palette(m_showErrors->palette());
palette.setColor(QPalette::WindowText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
palette.setColor(QPalette::WindowText, QColor(ColorScheme::getInstance()->getColor("table/text/normal").c_str()));
//palette.setColor(QPalette::Text, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::ButtonText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
@@ -196,9 +195,9 @@ void QtErrorView::setStyleSheet() const
m_showNonIndexedErrors->setPalette(palette);
m_showNonIndexedFatals->setPalette(palette);
widget->setStyleSheet(
utility::getStyleSheet(ResourcePaths::getGuiPath() + "error_view/error_view.css").c_str()
);
//widget->setStyleSheet(
//utility::getStyleSheet(ResourcePaths::getGuiPath() + "error_view/error_view.css").c_str()
//);
m_table->updateRows();
}
@@ -241,10 +240,10 @@ QCheckBox* QtErrorView::createFilterCheckbox(const QString& name, bool checked,
m_table->selectionModel()->clearSelection();
ErrorFilter filter;
filter.error = m_showErrors->checkState() == Qt::Checked;
filter.fatal = m_showFatals->checkState() == Qt::Checked;
filter.unindexedError = m_showNonIndexedErrors->checkState() == Qt::Checked;
filter.unindexedFatal = m_showNonIndexedFatals->checkState() == Qt::Checked;
filter.error = m_showErrors->isChecked();
filter.fatal = m_showFatals->isChecked();
filter.unindexedError = m_showNonIndexedErrors->isChecked();
filter.unindexedFatal = m_showNonIndexedFatals->isChecked();
MessageErrorFilterChanged(filter).dispatch();
}
@@ -258,19 +257,19 @@ QCheckBox* QtErrorView::createFilterCheckbox(const QString& name, bool checked,
bool QtErrorView::isShownError(const ErrorInfo& error)
{
if (!error.fatal && error.indexed && m_showErrors->checkState() == Qt::Checked)
if (!error.fatal && error.indexed && m_showErrors->isChecked())
{
return true;
}
if (error.fatal && error.indexed && m_showFatals->checkState() == Qt::Checked)
if (error.fatal && error.indexed && m_showFatals->isChecked())
{
return true;
}
if (!error.fatal && !error.indexed && m_showNonIndexedErrors->checkState() == Qt::Checked)
if (!error.fatal && !error.indexed && m_showNonIndexedErrors->isChecked())
{
return true;
}
if (error.fatal && !error.indexed && m_showNonIndexedFatals->checkState() == Qt::Checked)
if (error.fatal && !error.indexed && m_showNonIndexedFatals->isChecked())
{
return true;
}
+204 -3
View File
@@ -3,11 +3,21 @@
#include <QBoxLayout>
#include <QFrame>
#include <QLabel>
#include <QCheckBox>
#include <QStandardItemModel>
#include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/ResourcePaths.h"
#include "qt/utility/utilityQt.h"
#include "qt/element/QtTable.h"
QtLogView::QtLogView(ViewLayout* viewLayout)
: LogView(viewLayout)
, m_addLogFunctor(std::bind(&QtLogView::doAddLog, this, std::placeholders::_1, std::placeholders::_2))
, m_clearFunctor(std::bind(&QtLogView::doClear, this))
, m_refreshFunctor(std::bind(&QtLogView::doRefreshView, this))
{
@@ -27,17 +37,107 @@ void QtLogView::initView()
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(0, 10, 0, 5);
layout->setSpacing(0);
widget->setLayout(layout);
QLabel* label = new QLabel("test log view");
QHBoxLayout* headerLayout = new QHBoxLayout();
headerLayout->addSpacing(10);
widget->layout()->addWidget(label);
m_viewEnabled = new QCheckBox("Enable");
m_viewEnabled->setChecked(ApplicationSettings::getInstance()->getLoggingEnabled());
connect(m_viewEnabled, &QCheckBox::stateChanged,
[=](int){
setLoggingEnabled(m_viewEnabled->isChecked());
}
);
headerLayout->addWidget(m_viewEnabled);
headerLayout->addSpacing(25);
m_showAstLogging = new QCheckBox("Ast");
m_showAstLogging->setEnabled(m_viewEnabled->isChecked());
m_showAstLogging->setChecked(ApplicationSettings::getInstance()->getVerboseIndexerLoggingEnabled());
connect(m_showAstLogging, &QCheckBox::stateChanged,
[=](int){
setAstLoggingEnabled(m_showAstLogging->isChecked());
}
);
headerLayout->addWidget(m_showAstLogging);
headerLayout->addStretch();
layout->addLayout(headerLayout);
m_table = new QtTable(this);
m_model = new QStandardItemModel(this);
m_table->setModel(m_model);
m_model->setColumnCount(3);
m_table->setColumnWidth(LOGVIEW_COLUMN::TYPE, 100);
m_table->setColumnWidth(LOGVIEW_COLUMN::TIMESTAMP, 150);
m_table->setColumnWidth(LOGVIEW_COLUMN::TYPE, 100);
QStringList headers;
headers << "Type" << "Timestamp" << "Message";
m_model->setHorizontalHeaderLabels(headers);
layout->addWidget(m_table);
QHBoxLayout* filters = new QHBoxLayout();
filters->addSpacing(15);
m_showErrors = createFilterCheckbox("error", filters, true);
m_showWarnings = createFilterCheckbox("warnings", filters, true);
m_showInfo = createFilterCheckbox("info", filters);
filters->addStretch();
updateMask();
layout->addLayout(filters);
doRefreshView();
}
QCheckBox* QtLogView::createFilterCheckbox(const QString& name, QBoxLayout* layout, bool checked)
{
QCheckBox* checkbox = new QCheckBox(name);
checkbox->setChecked(checked);
connect(checkbox, &QCheckBox::stateChanged,
[=](int)
{
m_table->selectionModel()->clearSelection();
updateMask();
updateTable();
}
);
layout->addWidget(checkbox);
layout->addSpacing(25);
return checkbox;
}
void QtLogView::setLoggingEnabled(bool enabled)
{
m_showAstLogging->setEnabled(enabled);
ApplicationSettings::getInstance()->setLoggingEnabled(enabled);
ApplicationSettings::getInstance()->save();
MessageRefresh msg;
msg.reloadSettings = true;
msg.uiOnly = true;
msg.dispatchImmediately();
}
void QtLogView::setAstLoggingEnabled(bool enabled)
{
ApplicationSettings::getInstance()->setVerboseIndexerLoggingEnabled(enabled);
ApplicationSettings::getInstance()->save();
MessageRefresh msg;
msg.reloadSettings = true;
msg.uiOnly = true;
msg.dispatchImmediately();
}
void QtLogView::refreshView()
{
m_refreshFunctor();
@@ -48,10 +148,111 @@ void QtLogView::clear()
m_clearFunctor();
}
void QtLogView::addLog(Logger::LogLevel type, const LogMessage& message)
{
m_addLogFunctor(type, message);
}
void QtLogView::doClear()
{
}
void QtLogView::doRefreshView()
{
setStyleSheet();
}
void QtLogView::setStyleSheet() const
{
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
utility::setWidgetBackgroundColor(widget, ColorScheme::getInstance()->getColor("error/background"));
QPalette palette(m_showErrors->palette());
palette.setColor(QPalette::WindowText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::Text, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//palette.setColor(QPalette::ButtonText, QColor(ColorScheme::getInstance()->getColor("error/text/normal").c_str()));
//m_showErrors->setAutoFillBackground(true);
//m_showErrors->setPalette(palette);
//m_showFatals->setPalette(palette);
//m_showNonIndexedErrors->setPalette(palette);
//m_showNonIndexedFatals->setPalette(palette);
widget->setStyleSheet(
utility::getStyleSheet(ResourcePaths::getGuiPath() + "error_view/error_view.css").c_str()
);
m_table->updateRows();
}
const char* QtLogView::getLogType(Logger::LogLevel type) const
{
switch (type)
{
case Logger::LOG_INFOS:
return "INFO";
case Logger::LOG_WARNINGS:
return "WARNING";
case Logger::LOG_ERRORS:
return "ERROR";
case Logger::LOG_ALL:
return "UNKNOWN";
}
}
bool QtLogView::isCheckedType(const Logger::LogLevel type) const
{
return m_mask & type;
}
void QtLogView::updateTable()
{
if (!m_model->index(0, 0).data(Qt::DisplayRole).toString().isEmpty())
{
m_model->removeRows(0, m_model->rowCount());
}
for ( Log log : m_logs )
{
if (log.type & m_mask)
{
addLogToTable(log);
}
}
}
void QtLogView::updateMask()
{
m_mask =
(m_showInfo->isChecked() ? Logger::LOG_INFOS : 0) +
(m_showWarnings->isChecked() ? Logger::LOG_WARNINGS : 0) +
(m_showErrors->isChecked() ? Logger::LOG_ERRORS : 0);
}
void QtLogView::addLogToTable(Log log)
{
const int rowNumber = m_table->getFilledRowCount();
if (rowNumber < m_model->rowCount())
{
m_model->insertRow(rowNumber);
}
m_model->setItem(rowNumber, LOGVIEW_COLUMN::TYPE, new QStandardItem(getLogType(log.type)));
m_model->setItem(rowNumber, LOGVIEW_COLUMN::TIMESTAMP, new QStandardItem(log.timestamp.c_str()));
m_model->setItem(rowNumber, LOGVIEW_COLUMN::MESSAGE, new QStandardItem(log.message.c_str()));
m_table->updateRows();
}
void QtLogView::doAddLog(Logger::LogLevel type, const LogMessage& message)
{
if (m_viewEnabled->isChecked() && isCheckedType(type))
{
Log log(
type,
(message.getFileName().empty() ? "" : message.getFileName() + ": ") + message.message,
message.getTimeString("%H:%M:%S"));
m_logs.push_back(log);
addLogToTable(log);
}
}
+57
View File
@@ -1,11 +1,21 @@
#ifndef QT_LOG_VIEW_H
#define QT_LOG_VIEW_H
#include <QWidget>
#include "component/view/LogView.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "utility/logging/Logger.h"
class QBoxLayout;
class QCheckBox;
class QPalette;
class QStandardItemModel;
class QtTable;
class QtLogView
: public LogView
, public QWidget
{
public:
QtLogView(ViewLayout* viewLayout);
@@ -16,12 +26,59 @@ public:
virtual void initView();
virtual void refreshView();
// Log View Implementation
virtual void clear();
virtual void addLog(Logger::LogLevel type, const LogMessage& message);
private:
enum LOGVIEW_COLUMN
{
TYPE = 0,
TIMESTAMP = 1,
MESSAGE = 2,
};
struct Log
{
Log(const Logger::LogLevel type, const std::string message, const std::string timestamp)
: type(type)
, message(message)
, timestamp(timestamp){}
const Logger::LogLevel type;
const std::string message;
const std::string timestamp;
};
void doClear();
void doRefreshView();
void doAddLog(Logger::LogLevel type, const LogMessage& message);
std::vector<Log> m_logs;
const char* getLogType(Logger::LogLevel type) const;
void addLogToTable(Log log);
bool isCheckedType(const Logger::LogLevel type) const;
QCheckBox* createFilterCheckbox(const QString& name, QBoxLayout* layout, bool checked = false);
void setStyleSheet() const;
void setLoggingEnabled(bool enabled);
void setAstLoggingEnabled(bool enabled);
void updateMask();
void updateTable();
int m_mask;
QtTable* m_table;
QStandardItemModel* m_model;
QCheckBox* m_viewEnabled;
QCheckBox* m_showAstLogging;
QCheckBox* m_showErrors;
QCheckBox* m_showWarnings;
QCheckBox* m_showInfo;
QtThreadedFunctor<Logger::LogLevel, const LogMessage&> m_addLogFunctor;
QtThreadedFunctor<void> m_clearFunctor;
QtThreadedFunctor<void> m_refreshFunctor;
};
+1 -1
View File
@@ -226,7 +226,7 @@ void QtIndexingDialog::handleClose()
if (m_type == DIALOG_INDEXING)
{
MessageInterruptTasks().dispatch();
MessageInterruptTasks().dispatchImmediately();
return;
}