Added LogViewer again #2
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Schroeder, SLSE, 2016-03-03
|
||||
#
|
||||
|
||||
# Make ${Qt6_Widgets} optional
|
||||
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
|
||||
set(Qt6_Widgets ${Qt6_Widgets})
|
||||
else()
|
||||
set(Qt6_Widgets "")
|
||||
endif()
|
||||
|
||||
|
||||
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
|
||||
|
||||
SET(logView_SRCS
|
||||
cmbfilterwidget.h
|
||||
datafilterwidget.cpp
|
||||
datafilterwidget.h
|
||||
datefilterwidget.cpp
|
||||
datefilterwidget.h
|
||||
filterwidget.cpp
|
||||
filterwidget.h
|
||||
levelfilterwidget.cpp
|
||||
levelfilterwidget.h
|
||||
locationfilterwidget.cpp
|
||||
locationfilterwidget.h
|
||||
loggerfilterwidget.cpp
|
||||
loggerfilterwidget.h
|
||||
logviewtablemodel.cpp
|
||||
logviewtablemodel.h
|
||||
logviewtableview.cpp
|
||||
logviewtableview.h
|
||||
lefilterwidget.cpp
|
||||
lefilterwidget.h
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
mainwindow.h
|
||||
sortfiltermodel.cpp
|
||||
sortfiltermodel.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(logView_SRCS
|
||||
ui/mainwindow.ui
|
||||
ui/datafilterwidget.ui
|
||||
ui/datefilterwidget.ui
|
||||
ui/levelfilterwidget.ui
|
||||
ui/locationfilterwidget.ui
|
||||
ui/loggerfilterwidget.ui
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(TOOLSSV NO_TRANSLATION LogViewer ${logView_SRCS})
|
||||
|
||||
if(QT6_GUI_AVAILABLE)
|
||||
NGL_TARGET_LINK_LIBRARIES(LogViewer
|
||||
${Qt6_Widgets}
|
||||
Qt6::Core
|
||||
nglapplication
|
||||
nglwidgets
|
||||
NGLLogger
|
||||
)
|
||||
endif()
|
||||
|
||||
NGL_INSTALL_TARGET(LogViewer)
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "filterwidget.h"
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
class CMBFilterWidget : public FilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using FilterWidget::FilterWidget;
|
||||
|
||||
virtual void addItems(const QStringList &strList) = 0;
|
||||
virtual int currentIndex() const = 0;
|
||||
virtual QString currentText() const = 0;
|
||||
virtual void clearCMB() = 0;
|
||||
virtual bool contentInside() const = 0;
|
||||
|
||||
signals:
|
||||
void cmbTextChanged(const QString &str);
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "datafilterwidget.h"
|
||||
#include "ui_datafilterwidget.h"
|
||||
|
||||
DataFilterWidget::DataFilterWidget(QWidget *parent)
|
||||
: LEFilterWidget(parent)
|
||||
, m_ui(new Ui::DataFilterWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->leFilterData->setFocus();
|
||||
|
||||
connect(m_ui->leFilterData, &QLineEdit::textChanged, this, &DataFilterWidget::contentTextChanged);
|
||||
}
|
||||
|
||||
DataFilterWidget::~DataFilterWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
const QString DataFilterWidget::textContent() const
|
||||
{
|
||||
return m_ui->leFilterData->text();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lefilterwidget.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DataFilterWidget;
|
||||
}
|
||||
|
||||
class DataFilterWidget : public LEFilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DataFilterWidget(QWidget *parent = nullptr);
|
||||
~DataFilterWidget();
|
||||
|
||||
const QString textContent() const;
|
||||
|
||||
private:
|
||||
Ui::DataFilterWidget *m_ui;
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "datefilterwidget.h"
|
||||
#include "ui_datefilterwidget.h"
|
||||
|
||||
DateFilterWidget::DateFilterWidget(QWidget *parent)
|
||||
: FilterWidget(parent)
|
||||
, m_ui(new Ui::DateFilterWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->dteUp->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss"));
|
||||
m_ui->dteTo->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss"));
|
||||
}
|
||||
|
||||
DateFilterWidget::~DateFilterWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QDateTime DateFilterWidget::dtimeUp() const
|
||||
{
|
||||
return m_ui->dteUp->dateTime();
|
||||
}
|
||||
|
||||
QDateTime DateFilterWidget::dtimeTo() const
|
||||
{
|
||||
return m_ui->dteTo->dateTime();
|
||||
}
|
||||
|
||||
void DateFilterWidget::enableMilliSecs(int state)
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
m_ui->dteUp->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss"));
|
||||
m_ui->dteTo->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss"));
|
||||
}
|
||||
else if (state == 2)
|
||||
{
|
||||
m_ui->dteUp->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss,zzz"));
|
||||
m_ui->dteTo->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss,zzz"));
|
||||
}
|
||||
}
|
||||
|
||||
void DateFilterWidget::enableTime(int state)
|
||||
{
|
||||
if (state == 0)
|
||||
{
|
||||
m_ui->dteUp->setDisplayFormat(QLatin1String("dd.MM.yyyy"));
|
||||
m_ui->dteTo->setDisplayFormat(QLatin1String("dd.MM.yyyy"));
|
||||
m_ui->chbMilliSecs->setEnabled(false);
|
||||
m_ui->chbMilliSecs->setChecked(false);
|
||||
}
|
||||
else if (state == 2)
|
||||
{
|
||||
m_ui->dteUp->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss"));
|
||||
m_ui->dteTo->setDisplayFormat(QLatin1String("dd.MM.yyyy HH:mm:ss"));
|
||||
m_ui->chbMilliSecs->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DateFilterWidget::resetDTEs()
|
||||
{
|
||||
m_ui->dteUp->setDateTime(m_start);
|
||||
m_ui->dteTo->setDateTime(m_end);
|
||||
m_ui->chbTime->setChecked(true);
|
||||
m_ui->chbMilliSecs->setChecked(false);
|
||||
}
|
||||
|
||||
void DateFilterWidget::setStartDateTimeValue(const QDateTime &dtime)
|
||||
{
|
||||
m_start = dtime.addMSecs(-1);
|
||||
m_ui->dteUp->setDateTime(m_start);
|
||||
}
|
||||
|
||||
void DateFilterWidget::setEndDateTimeValue(const QDateTime &dtime)
|
||||
{
|
||||
m_end = dtime.addMSecs(1);
|
||||
m_ui->dteTo->setDateTime(m_end);
|
||||
}
|
||||
|
||||
|
||||
int DateFilterWidget::height() const
|
||||
{
|
||||
return this->size().height();
|
||||
}
|
||||
|
||||
int DateFilterWidget::width() const
|
||||
{
|
||||
return this->size().width();
|
||||
}
|
||||
|
||||
bool DateFilterWidget::init()
|
||||
{
|
||||
connect(m_ui->dteUp, &QDateTimeEdit::dateTimeChanged, this, &DateFilterWidget::dateStartFilterChanged);
|
||||
connect(m_ui->dteTo, &QDateTimeEdit::dateTimeChanged, this, &DateFilterWidget::dateEndFilterChanged);
|
||||
connect(m_ui->chbMilliSecs, &QCheckBox::stateChanged, this, &DateFilterWidget::enableMilliSecs);
|
||||
connect(m_ui->chbTime, &QCheckBox::stateChanged, this, &DateFilterWidget::enableTime);
|
||||
connect(m_ui->pbReset, &QPushButton::clicked, this, &DateFilterWidget::resetDTEs);
|
||||
|
||||
emit setStartDateTime();
|
||||
emit setEndDateTime();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "filterwidget.h"
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DateFilterWidget;
|
||||
}
|
||||
|
||||
class DateFilterWidget : public FilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DateFilterWidget(QWidget *parent = nullptr);
|
||||
~DateFilterWidget();
|
||||
|
||||
QDateTime dtimeUp() const;
|
||||
QDateTime dtimeTo() const;
|
||||
int height() const;
|
||||
int width() const;
|
||||
bool init();
|
||||
|
||||
signals:
|
||||
void dateStartFilterChanged(const QDateTime &dtimeStart);
|
||||
void dateEndFilterChanged(const QDateTime &dtimeEnd);
|
||||
void setStartDateTime();
|
||||
void setEndDateTime();
|
||||
|
||||
public slots:
|
||||
void setStartDateTimeValue(const QDateTime &dtime);
|
||||
void setEndDateTimeValue(const QDateTime &dtime);
|
||||
|
||||
private slots:
|
||||
void enableMilliSecs(int state);
|
||||
void enableTime(int state);
|
||||
void resetDTEs();
|
||||
|
||||
private:
|
||||
Ui::DateFilterWidget *m_ui;
|
||||
QDateTime m_start;
|
||||
QDateTime m_end;
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "filterwidget.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
FilterWidget::FilterWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setWindowFlags(windowFlags() | Qt::Popup);
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
FilterWidget::~FilterWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void FilterWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mousePressEvent(e);
|
||||
if (e->buttons() == Qt::LeftButton)
|
||||
{
|
||||
// global coordinate of upper left corner of widget
|
||||
m_widgetClickCoords = e->pos();
|
||||
}
|
||||
}
|
||||
|
||||
void FilterWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->buttons() == Qt::LeftButton && !m_widgetClickCoords.isNull())
|
||||
{
|
||||
m_coords = QWidget::mapToGlobal(e->pos()) - m_widgetClickCoords;
|
||||
this->move(m_coords);
|
||||
}
|
||||
QWidget::mouseMoveEvent(e);
|
||||
}
|
||||
|
||||
void FilterWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mouseReleaseEvent(e);
|
||||
if (e->buttons() == Qt::LeftButton)
|
||||
m_widgetClickCoords = QPoint();
|
||||
}
|
||||
|
||||
void FilterWidget::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
QWidget::keyPressEvent(e);
|
||||
if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter)
|
||||
this->hide();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtCore/QPoint>
|
||||
|
||||
class FilterWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FilterWidget(QWidget *parent = nullptr);
|
||||
~FilterWidget();
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
QPoint m_coords;
|
||||
QPoint m_widgetClickCoords;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "lefilterwidget.h"
|
||||
|
||||
LEFilterWidget::LEFilterWidget(QWidget *parent)
|
||||
: FilterWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
LEFilterWidget::~LEFilterWidget()
|
||||
{
|
||||
}
|
||||
|
||||
int LEFilterWidget::height() const
|
||||
{
|
||||
return this->size().height();
|
||||
}
|
||||
|
||||
int LEFilterWidget::width() const
|
||||
{
|
||||
return this->size().width();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "filterwidget.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
class LEFilterWidget : public FilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LEFilterWidget(QWidget *parent = nullptr);
|
||||
~LEFilterWidget();
|
||||
|
||||
virtual const QString textContent() const = 0;
|
||||
virtual int height() const;
|
||||
virtual int width() const;
|
||||
|
||||
signals:
|
||||
void contentTextChanged(const QString &str);
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "levelfilterwidget.h"
|
||||
#include "ui_levelfilterwidget.h"
|
||||
|
||||
LevelFilterWidget::LevelFilterWidget(QWidget *parent)
|
||||
: CMBFilterWidget(parent)
|
||||
, m_ui(new Ui::LevelFilterWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->cmbLevel, &QComboBox::currentTextChanged, this, &LevelFilterWidget::cmbTextChanged);
|
||||
}
|
||||
|
||||
LevelFilterWidget::~LevelFilterWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void LevelFilterWidget::addItems(const QStringList &strList)
|
||||
{
|
||||
m_ui->cmbLevel->addItems(strList);
|
||||
}
|
||||
|
||||
|
||||
int LevelFilterWidget::currentIndex() const
|
||||
{
|
||||
return m_ui->cmbLevel->currentIndex();
|
||||
}
|
||||
|
||||
|
||||
QString LevelFilterWidget::currentText() const
|
||||
{
|
||||
return m_ui->cmbLevel->currentText();
|
||||
}
|
||||
|
||||
|
||||
void LevelFilterWidget::clearCMB()
|
||||
{
|
||||
m_ui->cmbLevel->clear();
|
||||
}
|
||||
|
||||
|
||||
bool LevelFilterWidget::contentInside() const
|
||||
{
|
||||
return (m_ui->cmbLevel->count() > 1);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cmbfilterwidget.h"
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LevelFilterWidget;
|
||||
}
|
||||
|
||||
class LevelFilterWidget : public CMBFilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LevelFilterWidget(QWidget *parent = nullptr);
|
||||
~LevelFilterWidget();
|
||||
|
||||
void addItems(const QStringList &strList);
|
||||
int currentIndex() const;
|
||||
QString currentText() const;
|
||||
void clearCMB();
|
||||
bool contentInside() const;
|
||||
|
||||
private:
|
||||
Ui::LevelFilterWidget *m_ui;
|
||||
};
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "locationfilterwidget.h"
|
||||
#include "ui_locationfilterwidget.h"
|
||||
|
||||
LocationFilterWidget::LocationFilterWidget(QWidget *parent)
|
||||
: LEFilterWidget(parent)
|
||||
, m_ui(new Ui::LocationFilterWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->leFilterLocation->setFocus();
|
||||
|
||||
connect(m_ui->leFilterLocation, &QLineEdit::textChanged, this, &LocationFilterWidget::contentTextChanged);
|
||||
}
|
||||
|
||||
LocationFilterWidget::~LocationFilterWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
const QString LocationFilterWidget::textContent() const
|
||||
{
|
||||
return m_ui->leFilterLocation->text();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lefilterwidget.h"
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtCore/QString>
|
||||
#include <QKeyEvent>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LocationFilterWidget;
|
||||
}
|
||||
|
||||
class LocationFilterWidget : public LEFilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LocationFilterWidget(QWidget *parent = nullptr);
|
||||
~LocationFilterWidget();
|
||||
|
||||
const QString textContent() const;
|
||||
|
||||
private:
|
||||
Ui::LocationFilterWidget *m_ui;
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "loggerfilterwidget.h"
|
||||
#include "ui_loggerfilterwidget.h"
|
||||
|
||||
LoggerFilterWidget::LoggerFilterWidget(QWidget *parent)
|
||||
: CMBFilterWidget(parent)
|
||||
, m_ui(new Ui::LoggerFilterWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setWindowFlags(windowFlags() | Qt::Popup);
|
||||
|
||||
connect(m_ui->cmbLogger, &QComboBox::currentTextChanged, this, &LoggerFilterWidget::cmbTextChanged);
|
||||
}
|
||||
|
||||
LoggerFilterWidget::~LoggerFilterWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void LoggerFilterWidget::addItems(const QStringList &strList)
|
||||
{
|
||||
m_ui->cmbLogger->clear();
|
||||
m_ui->cmbLogger->addItems(strList);
|
||||
}
|
||||
|
||||
int LoggerFilterWidget::currentIndex() const
|
||||
{
|
||||
return m_ui->cmbLogger->currentIndex();
|
||||
}
|
||||
|
||||
|
||||
QString LoggerFilterWidget::currentText() const
|
||||
{
|
||||
return m_ui->cmbLogger->currentText();
|
||||
}
|
||||
|
||||
|
||||
void LoggerFilterWidget::clearCMB()
|
||||
{
|
||||
m_ui->cmbLogger->clear();
|
||||
}
|
||||
|
||||
|
||||
bool LoggerFilterWidget::contentInside() const
|
||||
{
|
||||
return (m_ui->cmbLogger->count() > 1);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cmbfilterwidget.h"
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LoggerFilterWidget;
|
||||
}
|
||||
|
||||
class LoggerFilterWidget : public CMBFilterWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LoggerFilterWidget(QWidget *parent = nullptr);
|
||||
~LoggerFilterWidget();
|
||||
|
||||
void addItems(const QStringList &strList);
|
||||
int currentIndex() const;
|
||||
QString currentText() const;
|
||||
void clearCMB();
|
||||
bool contentInside() const;
|
||||
|
||||
private:
|
||||
Ui::LoggerFilterWidget *m_ui;
|
||||
};
|
||||
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "logviewtablemodel.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QtGui/QFont>
|
||||
|
||||
LogViewTableModel::LogViewTableModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("LogViewTableModel"))
|
||||
{
|
||||
setStdColors();
|
||||
}
|
||||
|
||||
void LogViewTableModel::setData(const QVector<LogViewTableModel::logInformation> &logData)
|
||||
{
|
||||
beginResetModel();
|
||||
m_logfile.clear();
|
||||
endResetModel();
|
||||
|
||||
if (logData.isEmpty())
|
||||
return;
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, logData.size() - 1);
|
||||
m_logfile = logData;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void LogViewTableModel::addData(const LogViewTableModel::logInformation &logLine)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_logfile.size(), m_logfile.size());
|
||||
m_logfile.append(logLine);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
bool LogViewTableModel::reset()
|
||||
{
|
||||
beginResetModel();
|
||||
m_logfile.clear();
|
||||
m_cellColors.level.clear();
|
||||
setStdColors();
|
||||
endResetModel();
|
||||
return true;
|
||||
}
|
||||
|
||||
void LogViewTableModel::startDateTime()
|
||||
{
|
||||
if (m_logfile.isEmpty())
|
||||
return;
|
||||
const QDateTime dtime = m_logfile.first().date;
|
||||
emit startTimeSetted(dtime);
|
||||
}
|
||||
|
||||
void LogViewTableModel::endDateTime()
|
||||
{
|
||||
if (m_logfile.isEmpty())
|
||||
return;
|
||||
const QDateTime dtime = m_logfile.last().date;
|
||||
emit endTimeSetted(dtime);
|
||||
}
|
||||
|
||||
|
||||
int LogViewTableModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return m_logfile.size();
|
||||
}
|
||||
|
||||
int LogViewTableModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return colLast + 1;
|
||||
}
|
||||
|
||||
QVariant LogViewTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (index.column() == colLevel)
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::BackgroundRole: // BACKGROUND COLOR
|
||||
{
|
||||
const QString logLevel = m_logfile.at(index.row()).level;
|
||||
QColor col = m_cellColors.level.value(logLevel);
|
||||
if (col.isValid())
|
||||
return col;
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
case Qt::TextColorRole: // TEXT COLOR
|
||||
{
|
||||
const QString logLevel = m_logfile.at(index.row()).level;
|
||||
QColor col = m_fontColors.level.value(logLevel);
|
||||
if (col.isValid())
|
||||
return col;
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (role != Qt::DisplayRole && role != Qt::UserRole)
|
||||
return QVariant();
|
||||
|
||||
int row = index.row();
|
||||
Columns col = static_cast<Columns>(index.column());
|
||||
switch (col)
|
||||
{
|
||||
case colDate:
|
||||
if (role == Qt::UserRole)
|
||||
return m_logfile.at(row).date;
|
||||
return m_logfile.at(row).date.toString(QLatin1String("yyyy-MM-dd hh:mm:ss,zzz"));
|
||||
|
||||
case colLevel:
|
||||
return m_logfile.at(row).level;
|
||||
|
||||
case colLogger:
|
||||
return m_logfile.at(row).logger;
|
||||
|
||||
case colData:
|
||||
return m_logfile.at(row).data;
|
||||
|
||||
case colLocation:
|
||||
return m_logfile.at(row).location;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool LogViewTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (role != Qt::EditRole)
|
||||
return false;
|
||||
|
||||
int row = index.row();
|
||||
Columns col = static_cast<Columns>(index.column());
|
||||
switch (col)
|
||||
{
|
||||
case colDate:
|
||||
m_logfile[row].date = value.toDateTime();
|
||||
return true;
|
||||
|
||||
case colLevel:
|
||||
m_logfile[row].level = value.toString();
|
||||
return true;
|
||||
|
||||
case colLogger:
|
||||
m_logfile[row].logger = value.toString();
|
||||
return true;
|
||||
|
||||
case colData:
|
||||
m_logfile[row].data = value.toString();
|
||||
return true;
|
||||
|
||||
case colLocation:
|
||||
m_logfile[row].location = value.toString();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant LogViewTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Horizontal
|
||||
&& role == Qt::DisplayRole)
|
||||
{
|
||||
Columns col = static_cast<Columns>(section);
|
||||
switch (col)
|
||||
{
|
||||
case colDate:
|
||||
return tr("Date");
|
||||
|
||||
case colLevel:
|
||||
return tr("Level");
|
||||
|
||||
case colLogger:
|
||||
return tr("Logger");
|
||||
|
||||
case colData:
|
||||
return tr("Data");
|
||||
|
||||
case colLocation:
|
||||
return tr("Location");
|
||||
}
|
||||
}
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
int LogViewTableModel::length() const
|
||||
{
|
||||
return m_logfile.length();
|
||||
}
|
||||
|
||||
QString LogViewTableModel::itemAt(int row, int index) const
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case colDate:
|
||||
return m_logfile.at(row).date.toString(QLatin1String("yyyy-MM-dd hh-mm-ss,zzz"));
|
||||
|
||||
case colLevel:
|
||||
return m_logfile.at(row).level;
|
||||
|
||||
case colLogger:
|
||||
return m_logfile.at(row).logger;
|
||||
|
||||
case colData:
|
||||
return m_logfile.at(row).data;
|
||||
|
||||
case colLocation:
|
||||
return m_logfile.at(row).location;
|
||||
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewTableModel::adjustCellColor(const QColor &color, const QString &str)
|
||||
{
|
||||
for (auto iter = m_cellColors.level.constBegin(); iter != m_cellColors.level.constEnd(); ++iter)
|
||||
{
|
||||
if (iter.key() == str)
|
||||
m_cellColors.level.insert(str, color);
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewTableModel::adjustFontColor(const QColor &color, const QString &str)
|
||||
{
|
||||
for (auto iter = m_fontColors.level.constBegin(); iter != m_fontColors.level.constEnd(); ++iter)
|
||||
{
|
||||
if (iter.key() == str)
|
||||
m_fontColors.level.insert(str, color);
|
||||
}
|
||||
}
|
||||
|
||||
void LogViewTableModel::setStdColors()
|
||||
{
|
||||
m_cellColors.level[QLatin1String("INFO")] = Qt::blue;
|
||||
m_cellColors.level[QLatin1String("WARN")] = Qt::yellow;
|
||||
m_cellColors.level[QLatin1String("ERROR")] = Qt::darkRed;
|
||||
m_cellColors.level[QLatin1String("FATAL")] = Qt::red;
|
||||
m_cellColors.level[QLatin1String("DEBUG")] = Qt::green;
|
||||
m_cellColors.level[QLatin1String("TRACE")] = Qt::lightGray;
|
||||
|
||||
m_fontColors.level[QLatin1String("INFO")] = Qt::white;
|
||||
m_fontColors.level[QLatin1String("WARN")] = Qt::black;
|
||||
m_fontColors.level[QLatin1String("ERROR")] = Qt::white;
|
||||
m_fontColors.level[QLatin1String("FATAL")] = Qt::black;
|
||||
m_fontColors.level[QLatin1String("DEBUG")] = Qt::black;
|
||||
m_fontColors.level[QLatin1String("TRACE")] = Qt::black;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QAbstractTableModel>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtGui/QColor>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
class LogViewTableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct logInformation
|
||||
{
|
||||
QDateTime date;
|
||||
QString level;
|
||||
QString logger;
|
||||
QString data;
|
||||
QString location;
|
||||
};
|
||||
|
||||
struct logColors
|
||||
{
|
||||
QColor date;
|
||||
QMap<QString, QColor> level;
|
||||
QColor logger;
|
||||
QColor data;
|
||||
QColor location;
|
||||
};
|
||||
|
||||
enum Columns
|
||||
{
|
||||
colDate = 0,
|
||||
colLevel = 1,
|
||||
colLogger = 2,
|
||||
colData = 3,
|
||||
colLocation = 4,
|
||||
colLast = colLocation
|
||||
};
|
||||
|
||||
public:
|
||||
explicit LogViewTableModel(QObject *parent = nullptr);
|
||||
|
||||
void setData(const QVector<logInformation> &logData);
|
||||
void addData(const logInformation &logLine);
|
||||
bool reset();
|
||||
|
||||
int rowCount(const QModelIndex &parent) const override final;
|
||||
int columnCount(const QModelIndex &parent) const override final;
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override final;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
|
||||
int length() const;
|
||||
QString itemAt(int row, int index) const;
|
||||
|
||||
signals:
|
||||
void startTimeSetted(const QDateTime &dtime);
|
||||
void endTimeSetted(const QDateTime &dtime);
|
||||
|
||||
public slots:
|
||||
void adjustCellColor(const QColor &color, const QString &str);
|
||||
void adjustFontColor(const QColor &color, const QString &str);
|
||||
void startDateTime();
|
||||
void endDateTime();
|
||||
|
||||
private:
|
||||
void setStdColors();
|
||||
|
||||
QVector<logInformation> m_logfile;
|
||||
logColors m_cellColors;
|
||||
logColors m_fontColors;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "logviewtableview.h"
|
||||
#include "logviewtablemodel.h"
|
||||
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtGui/QColor>
|
||||
#include <QColorDialog>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QMouseEvent>
|
||||
|
||||
LogViewTableView::LogViewTableView(QWidget *parent)
|
||||
: QTableView(parent)
|
||||
, m_contextMenu(new QMenu(this))
|
||||
, m_colorMenu(new QMenu(tr("Select Color"), m_contextMenu))
|
||||
, m_actionSetCellColor(new QAction(m_colorMenu))
|
||||
, m_actionSetFontColor(new QAction(m_colorMenu))
|
||||
, m_filterMenu(new QMenu(tr("Select Filter"), m_contextMenu))
|
||||
, m_actionFilterDate(nullptr)
|
||||
, m_actionFilterLevel(nullptr)
|
||||
, m_actionFilterLogger(nullptr)
|
||||
, m_actionFilterData(nullptr)
|
||||
, m_actionFilterLocation(nullptr)
|
||||
, m_actionResetFilter(nullptr)
|
||||
, m_coords()
|
||||
, m_contentAvailable(false)
|
||||
{
|
||||
this->setMouseTracking(true);
|
||||
|
||||
// ---------- COLOR ---------
|
||||
m_actionSetCellColor = m_colorMenu->addAction(tr("Cell-Color"));
|
||||
m_actionSetFontColor = m_colorMenu->addAction(tr("Font-Color"));
|
||||
m_contextMenu->addMenu(m_colorMenu);
|
||||
|
||||
|
||||
// ---------- FILTER ---------
|
||||
m_actionFilterDate = m_filterMenu->addAction(tr("Date"));
|
||||
m_actionFilterLevel = m_filterMenu->addAction(tr("Level"));
|
||||
m_actionFilterLogger = m_filterMenu->addAction(tr("Logger"));
|
||||
m_actionFilterData = m_filterMenu->addAction(tr("Data"));
|
||||
m_actionFilterLocation = m_filterMenu->addAction(tr("Location"));
|
||||
m_filterMenu->addSeparator();
|
||||
m_actionResetFilter = m_filterMenu->addAction(tr("Reset all filter"));
|
||||
m_contextMenu->addMenu(m_filterMenu);
|
||||
|
||||
// ICONS
|
||||
m_actionFilterDate->setIcon(QIcon(QLatin1String("://icons/16x16/dialog-ok-apply.png")));
|
||||
m_actionFilterLevel->setIcon(QIcon(QLatin1String("://icons/16x16/dialog-ok-apply.png")));
|
||||
m_actionFilterLogger->setIcon(QIcon(QLatin1String("://icons/16x16/dialog-ok-apply.png")));
|
||||
m_actionFilterData->setIcon(QIcon(QLatin1String("://icons/16x16/dialog-ok-apply.png")));
|
||||
m_actionFilterLocation->setIcon(QIcon(QLatin1String("://icons/16x16/dialog-ok-apply.png")));
|
||||
m_actionResetFilter->setIcon(QIcon(QLatin1String("://icons/16x16/edit-undo.png")));
|
||||
m_actionFilterDate->setIconVisibleInMenu(false);
|
||||
m_actionFilterLevel->setIconVisibleInMenu(false);
|
||||
m_actionFilterLogger->setIconVisibleInMenu(false);
|
||||
m_actionFilterData->setIconVisibleInMenu(false);
|
||||
m_actionFilterLocation->setIconVisibleInMenu(false);
|
||||
m_actionResetFilter->setIconVisibleInMenu(true);
|
||||
|
||||
connect(m_actionSetCellColor, &QAction::triggered, this, &LogViewTableView::setCellColor);
|
||||
connect(m_actionSetFontColor, &QAction::triggered, this, &LogViewTableView::setFontColor);
|
||||
connect(m_actionFilterDate, &QAction::triggered, this, &LogViewTableView::dateFilterIsAboutToChange);
|
||||
connect(m_actionFilterLevel, &QAction::triggered, this, &LogViewTableView::levelFilterIsAboutToChange);
|
||||
connect(m_actionFilterLogger, &QAction::triggered, this, &LogViewTableView::loggerFilterIsAboutToChange);
|
||||
connect(m_actionFilterData, &QAction::triggered, this, &LogViewTableView::dataFilterIsAboutToChange);
|
||||
connect(m_actionResetFilter, &QAction::triggered, this, &LogViewTableView::resetAllFilter);
|
||||
connect(m_actionFilterLocation, &QAction::triggered, this, &LogViewTableView::locationFilterIsAboutToChange);
|
||||
}
|
||||
|
||||
LogViewTableView::~LogViewTableView()
|
||||
{
|
||||
delete m_contextMenu;
|
||||
// all other menus and actions are children of m_contextMenu
|
||||
}
|
||||
|
||||
|
||||
void LogViewTableView::setCellColor()
|
||||
{
|
||||
QColor color = QColorDialog::getColor(Qt::white, this, tr("Select cell color"), QColorDialog::DontUseNativeDialog);
|
||||
QModelIndex index = indexAt(m_coords);
|
||||
QString level = index.data().toString();
|
||||
emit cellColorIsAboutToChange(color, level);
|
||||
}
|
||||
|
||||
void LogViewTableView::setFontColor()
|
||||
{
|
||||
QColor color = QColorDialog::getColor(Qt::white, this, tr("Select font color"), QColorDialog::DontUseNativeDialog);
|
||||
QModelIndex index = indexAt(m_coords);
|
||||
QString level = index.data().toString();
|
||||
emit fontColorIsAboutToChange(color, level);
|
||||
}
|
||||
|
||||
void LogViewTableView::showActivatedFilter(QVector<bool> &filter)
|
||||
{
|
||||
m_actionFilterDate->setIconVisibleInMenu(filter.at(LogViewTableModel::colDate));
|
||||
m_actionFilterLevel->setIconVisibleInMenu(filter.at(LogViewTableModel::colLevel));
|
||||
m_actionFilterLogger->setIconVisibleInMenu(filter.at(LogViewTableModel::colLogger));
|
||||
m_actionFilterData->setIconVisibleInMenu(filter.at(LogViewTableModel::colData));
|
||||
m_actionFilterLocation->setIconVisibleInMenu(filter.at(LogViewTableModel::colLocation));
|
||||
}
|
||||
|
||||
|
||||
void LogViewTableView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (QTableView::indexAt(m_coords).column() == LogViewTableModel::colLevel)
|
||||
enableColorSubMenuActions(true);
|
||||
else
|
||||
enableColorSubMenuActions(false);
|
||||
|
||||
if (event->button() == Qt::RightButton
|
||||
&& m_contentAvailable)
|
||||
{
|
||||
emit whichFilterAreActivated();
|
||||
m_contextMenu->exec(mapToGlobal(m_coords));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LogViewTableView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_coords.setX(event->x());
|
||||
m_coords.setY(event->y());
|
||||
emit mouseMoved(m_coords);
|
||||
}
|
||||
|
||||
|
||||
void LogViewTableView::enableColorSubMenuActions(bool checkState)
|
||||
{
|
||||
m_actionSetCellColor->setEnabled(checkState);
|
||||
m_actionSetFontColor->setEnabled(checkState);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QTableView>
|
||||
#include <QtCore/QPoint>
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
|
||||
class LogViewTableView : public QTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LogViewTableView(QWidget *parent = nullptr);
|
||||
~LogViewTableView();
|
||||
|
||||
void setContentAvailable(bool state)
|
||||
{
|
||||
m_contentAvailable = state;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void showActivatedFilter(QVector<bool> &filter);
|
||||
|
||||
private slots:
|
||||
void setCellColor();
|
||||
void setFontColor();
|
||||
|
||||
signals:
|
||||
void mouseMoved(const QPoint &coords);
|
||||
void cellColorIsAboutToChange(const QColor &color, const QString &str);
|
||||
void fontColorIsAboutToChange(const QColor &color, const QString &str);
|
||||
void dateFilterIsAboutToChange();
|
||||
void levelFilterIsAboutToChange();
|
||||
void loggerFilterIsAboutToChange();
|
||||
void dataFilterIsAboutToChange();
|
||||
void locationFilterIsAboutToChange();
|
||||
void resetAllFilter();
|
||||
void whichFilterAreActivated();
|
||||
|
||||
private:
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void enableColorSubMenuActions(bool checkState);
|
||||
|
||||
// Color
|
||||
QMenu *m_contextMenu;
|
||||
QMenu *m_colorMenu;
|
||||
QAction *m_actionSetCellColor;
|
||||
QAction *m_actionSetFontColor;
|
||||
|
||||
// Filter
|
||||
QMenu *m_filterMenu;
|
||||
QAction *m_actionFilterDate;
|
||||
QAction *m_actionFilterLevel;
|
||||
QAction *m_actionFilterLogger;
|
||||
QAction *m_actionFilterData;
|
||||
QAction *m_actionFilterLocation;
|
||||
QAction *m_actionResetFilter;
|
||||
|
||||
QPoint m_coords;
|
||||
bool m_contentAvailable;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <nglapplication/nglapplication.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication app(argc, argv);
|
||||
QCoreApplication::setApplicationName(QLatin1String("LogViewer"));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("RME"));
|
||||
|
||||
app.createLogger("LogViewer", "log4cxx_logviewer.props");
|
||||
NGL::INGLLogger &logger = app.baseLogger();
|
||||
|
||||
STARTUP_LOG(logger);
|
||||
|
||||
MainWindow w;
|
||||
w.init();
|
||||
w.show();
|
||||
|
||||
app.setQuitOnLastWindowClosed(true);
|
||||
|
||||
int retval = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(logger);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "cmbfilterwidget.h"
|
||||
#include "sortfiltermodel.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QSortFilterProxyModel>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, m_ui(new Ui::MainWindow)
|
||||
, m_logfileModel(new LogViewTableModel(this))
|
||||
, m_dateFilter(new DateFilterWidget())
|
||||
, m_levelFilter(new LevelFilterWidget())
|
||||
, m_loggerFilter(new LoggerFilterWidget())
|
||||
, m_dataFilter(new DataFilterWidget())
|
||||
, m_locationFilter(new LocationFilterWidget())
|
||||
, m_filterProxyModel(new SortFilterModel(this))
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("MainWindow"))
|
||||
, m_lbItemCount(new QLabel(this))
|
||||
, m_lbCoords(new QLabel(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_filterProxyModel->setSourceModel(m_logfileModel);
|
||||
m_ui->tvContent->setModel(m_filterProxyModel);
|
||||
m_ui->tvContent->resizeColumnsToContents();
|
||||
m_ui->tvContent->horizontalHeader()->setStretchLastSection(true);
|
||||
m_lbItemCount->setText(tr("Items: \t0"));
|
||||
m_lbCoords->setText(QLatin1String("x: \ty:"));
|
||||
m_ui->statusBar->addPermanentWidget(m_lbItemCount, 2);
|
||||
m_ui->statusBar->addPermanentWidget(m_lbCoords, 2);
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_logfileModel;
|
||||
delete m_filterProxyModel;
|
||||
delete m_lbItemCount;
|
||||
delete m_dateFilter;
|
||||
delete m_levelFilter;
|
||||
delete m_loggerFilter;
|
||||
delete m_dataFilter;
|
||||
delete m_locationFilter;
|
||||
delete m_lbCoords;
|
||||
}
|
||||
|
||||
bool MainWindow::init()
|
||||
{
|
||||
connect(m_ui->actionOpen, &QAction::triggered, this, &MainWindow::onActionOpen);
|
||||
connect(m_ui->actionReset, &QAction::triggered, this, &MainWindow::onActionReset);
|
||||
connect(m_ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
||||
connect(m_ui->tvContent, &LogViewTableView::cellColorIsAboutToChange, m_logfileModel, &LogViewTableModel::adjustCellColor);
|
||||
connect(m_ui->tvContent, &LogViewTableView::fontColorIsAboutToChange, m_logfileModel, &LogViewTableModel::adjustFontColor);
|
||||
connect(m_ui->tvContent, &LogViewTableView::mouseMoved, this, &MainWindow::showPosition);
|
||||
connect(m_dateFilter, &DateFilterWidget::dateStartFilterChanged, m_filterProxyModel, &SortFilterModel::setStartDateFilter);
|
||||
connect(m_dateFilter, &DateFilterWidget::dateEndFilterChanged, m_filterProxyModel, &SortFilterModel::setEndDateFilter);
|
||||
connect(m_ui->tvContent, &LogViewTableView::resetAllFilter, this, &MainWindow::onActionResetFilter);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::whichFilterAreActivated, m_filterProxyModel, &SortFilterModel::figureFilterOut);
|
||||
connect(m_filterProxyModel, &SortFilterModel::theseFilterAreActivated, m_ui->tvContent, &LogViewTableView::showActivatedFilter);
|
||||
|
||||
connect(m_dateFilter, &DateFilterWidget::setStartDateTime, m_logfileModel, &LogViewTableModel::startDateTime);
|
||||
connect(m_logfileModel, &LogViewTableModel::startTimeSetted, m_dateFilter, &DateFilterWidget::setStartDateTimeValue);
|
||||
|
||||
connect(m_dateFilter, &DateFilterWidget::setEndDateTime, m_logfileModel, &LogViewTableModel::endDateTime);
|
||||
connect(m_logfileModel, &LogViewTableModel::endTimeSetted, m_dateFilter, &DateFilterWidget::setEndDateTimeValue);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::dateFilterIsAboutToChange, this, &MainWindow::setFilterDate);
|
||||
connect(m_dateFilter, &DateFilterWidget::dateStartFilterChanged, m_ui->tvContent, &LogViewTableView::dateFilterIsAboutToChange);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::dateFilterIsAboutToChange, this, &MainWindow::setFilterDate);
|
||||
connect(m_dateFilter, &DateFilterWidget::dateEndFilterChanged, m_ui->tvContent, &LogViewTableView::dateFilterIsAboutToChange);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::levelFilterIsAboutToChange, this, &MainWindow::setFilterLevel);
|
||||
connect(m_levelFilter, &LevelFilterWidget::cmbTextChanged, m_ui->tvContent, &LogViewTableView::levelFilterIsAboutToChange);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::loggerFilterIsAboutToChange, this, &MainWindow::setFilterLogger);
|
||||
connect(m_loggerFilter, &LoggerFilterWidget::cmbTextChanged, m_ui->tvContent, &LogViewTableView::loggerFilterIsAboutToChange);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::dataFilterIsAboutToChange, this, &MainWindow::setFilterData);
|
||||
connect(m_dataFilter, &DataFilterWidget::contentTextChanged, m_ui->tvContent, &LogViewTableView::dataFilterIsAboutToChange);
|
||||
|
||||
connect(m_ui->tvContent, &LogViewTableView::locationFilterIsAboutToChange, this, &MainWindow::setFilterLocation);
|
||||
connect(m_locationFilter, &LocationFilterWidget::contentTextChanged, m_ui->tvContent, &LogViewTableView::locationFilterIsAboutToChange);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onActionOpen()
|
||||
{
|
||||
const QString fileName = QFileDialog::getOpenFileName(this, tr("Open Logfile"), QString(), tr("Logfile (*.log) (*.log)"));
|
||||
QFile file(fileName);
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
if (!file.exists() || !file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray ba = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (ba.isEmpty())
|
||||
{
|
||||
m_logfileModel->setData(QVector<LogViewTableModel::logInformation>());
|
||||
return;
|
||||
}
|
||||
|
||||
QString str(QString::fromUtf8(ba));
|
||||
|
||||
const QStringList strLines = str.split(QLatin1Char('\n'), QString::SkipEmptyParts);
|
||||
for (const QString &tempLines : strLines)
|
||||
{
|
||||
const QStringList strWords = tempLines.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
|
||||
LogViewTableModel::logInformation li;
|
||||
QDateTime firstDate;
|
||||
|
||||
// 2016-04-19 12:27:43,467 INFO zssiwi |#| Programm ist funktionsbereit (TDS-source-product/ZS/ZSSI/ZSSIWI/zssi_wi_Main.cpp:175)
|
||||
for (int counter = 0; counter < strWords.size(); counter++)
|
||||
{
|
||||
if (counter >= 0 && counter <= 1) // 2016-04-19 12:27:43,467
|
||||
{
|
||||
if (firstDate.date().isNull())
|
||||
{
|
||||
if (counter == 0)
|
||||
firstDate.setDate(QDate::fromString(strWords.at(counter), QLatin1String("yyyy-MM-dd")));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (counter == 1)
|
||||
{
|
||||
firstDate.setTime(QTime::fromString(strWords.at(counter), QLatin1String("hh:mm:ss,zzz")));
|
||||
li.date = firstDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (counter == 2) // INFO
|
||||
li.level = strWords.at(counter);
|
||||
else if (counter == 3) // zssiwi
|
||||
li.logger = strWords.at(counter);
|
||||
else // |#|
|
||||
{
|
||||
// |#| Programm ist funktionsbereit (TDS-source-product/ZS/ZSSI/ZSSIWI/zssi_wi_Main.cpp:175)
|
||||
int index = tempLines.indexOf(QLatin1String("|#|"), 0) + 4;
|
||||
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
// Programm ist funktionsbereit (TDS-source-product/ZS/ZSSI/ZSSIWI/zssi_wi_Main.cpp:175)
|
||||
QString subStrLines = tempLines.mid(index);
|
||||
int lastOpenBracket = subStrLines.lastIndexOf(QLatin1Char('('));
|
||||
|
||||
if (lastOpenBracket < 0)
|
||||
return;
|
||||
|
||||
QString debugStr = subStrLines.left(lastOpenBracket); // Programm ist funktionsbereit
|
||||
QString fileLine = subStrLines.mid(lastOpenBracket + 1); // (TDS-source-product/ZS/ZSSI/ZSSIWI/zssi_wi_Main.cpp:175)
|
||||
fileLine = fileLine.mid(0, fileLine.length() - 2);
|
||||
|
||||
li.data = debugStr;
|
||||
li.location = fileLine;
|
||||
}
|
||||
}
|
||||
m_logfileModel->addData(li);
|
||||
}
|
||||
|
||||
m_ui->tvContent->setContentAvailable(true);
|
||||
m_ui->actionReset->setEnabled(true);
|
||||
m_ui->actionResetFilter->setEnabled(true);
|
||||
m_ui->actionShowCurrentFilter->setEnabled(true);
|
||||
m_ui->tvContent->resizeColumnsToContents();
|
||||
m_ui->tvContent->horizontalHeader()->setStretchLastSection(true);
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_logfileModel->rowCount(QModelIndex())));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onActionReset()
|
||||
{
|
||||
int result = QMessageBox::critical(this, tr("Reset"), tr("Are you sure to reset the current view?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||
if (result == QMessageBox::Yes)
|
||||
{
|
||||
m_logfileModel->reset();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_logfileModel->rowCount(QModelIndex())));
|
||||
m_ui->actionReset->setEnabled(false);
|
||||
m_ui->actionResetFilter->setEnabled(false);
|
||||
m_ui->actionShowCurrentFilter->setEnabled(false);
|
||||
m_ui->tvContent->setContentAvailable(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onActionResetFilter()
|
||||
{
|
||||
m_filterProxyModel->resetAllFilter();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_logfileModel->rowCount(QModelIndex())));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showPosition(const QPoint &coords)
|
||||
{
|
||||
QString out;
|
||||
out.append(tr("x: "));
|
||||
out.append(QString::number(coords.x()));
|
||||
out.append(QLatin1String("\ty: "));
|
||||
out.append(QString::number(coords.y()));
|
||||
m_lbCoords->setText(out);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setFilterDate()
|
||||
{
|
||||
m_dateFilter->init();
|
||||
m_filterProxyModel->setStartDateFilter(m_dateFilter->dtimeUp());
|
||||
m_filterProxyModel->setEndDateFilter(m_dateFilter->dtimeTo());
|
||||
m_filterProxyModel->setFilterKeyColumn(0);
|
||||
|
||||
m_filterProxyModel->invalidate();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_filterProxyModel->rowCount(QModelIndex())));
|
||||
|
||||
m_dateFilter->move(QCursor::pos() - QPoint(m_dateFilter->width() / 2, m_dateFilter->height() / 2));
|
||||
m_dateFilter->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setFilterLevel()
|
||||
{
|
||||
if (m_levelFilter->currentIndex() == 0)
|
||||
m_filterProxyModel->setStringFilter(1, QString());
|
||||
else
|
||||
m_filterProxyModel->setStringFilter(1, m_levelFilter->currentText());
|
||||
|
||||
m_filterProxyModel->invalidate();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_filterProxyModel->rowCount(QModelIndex())));
|
||||
|
||||
if (!m_levelFilter->contentInside())
|
||||
this->loadDataInCMB(1);
|
||||
|
||||
m_levelFilter->move(QCursor::pos() - QPoint(m_levelFilter->width() / 2, m_levelFilter->height() / 2));
|
||||
m_levelFilter->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setFilterLogger()
|
||||
{
|
||||
if (m_loggerFilter->currentIndex() == 0)
|
||||
m_filterProxyModel->setStringFilter(2, QString());
|
||||
else
|
||||
m_filterProxyModel->setStringFilter(2, m_loggerFilter->currentText());
|
||||
|
||||
m_filterProxyModel->invalidate();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_filterProxyModel->rowCount(QModelIndex())));
|
||||
|
||||
if (!m_loggerFilter->contentInside())
|
||||
this->loadDataInCMB(2);
|
||||
|
||||
m_loggerFilter->move(QCursor::pos() - QPoint(m_loggerFilter->width() / 2, m_loggerFilter->height() / 2));
|
||||
m_loggerFilter->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setFilterData()
|
||||
{
|
||||
m_filterProxyModel->setStringFilter(3, m_dataFilter->textContent());
|
||||
m_filterProxyModel->invalidate();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_filterProxyModel->rowCount(QModelIndex())));
|
||||
|
||||
m_dataFilter->move(QCursor::pos() - QPoint(m_dataFilter->width() / 2, m_dataFilter->height() / 2));
|
||||
m_dataFilter->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setFilterLocation()
|
||||
{
|
||||
m_filterProxyModel->setStringFilter(4, m_locationFilter->textContent());
|
||||
m_filterProxyModel->invalidate();
|
||||
m_lbItemCount->setText(tr("Items: \t") + QString::number(m_filterProxyModel->rowCount(QModelIndex())));
|
||||
|
||||
m_locationFilter->move(QCursor::pos() - QPoint(m_locationFilter->width() / 2, m_locationFilter->height() / 2));
|
||||
m_locationFilter->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::loadDataInCMB(int column)
|
||||
{
|
||||
QStringList strList;
|
||||
strList.push_back(QLatin1String("- unfiltered -"));
|
||||
strList.reserve(m_logfileModel->length());
|
||||
for (int i = 0; i < m_logfileModel->length(); i++)
|
||||
{
|
||||
const QString val = m_logfileModel->itemAt(i, column);
|
||||
if (!strList.contains(val))
|
||||
strList.push_back(val);
|
||||
}
|
||||
|
||||
if (column == 1)
|
||||
m_levelFilter->addItems(strList);
|
||||
else if (column == 2)
|
||||
m_loggerFilter->addItems(strList);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "logviewtablemodel.h"
|
||||
#include "datefilterwidget.h"
|
||||
#include "levelfilterwidget.h"
|
||||
#include "loggerfilterwidget.h"
|
||||
#include "datafilterwidget.h"
|
||||
#include "locationfilterwidget.h"
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtCore/QPoint>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class SortFilterModel;
|
||||
class DateFilterWidget;
|
||||
class LevelFilterWidget;
|
||||
class LoggerFilterWidget;
|
||||
class DataFilterWidget;
|
||||
class LocationFilterWidget;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
bool init();
|
||||
|
||||
private slots:
|
||||
void onActionOpen();
|
||||
void onActionReset();
|
||||
void onActionResetFilter();
|
||||
void showPosition(const QPoint &coords);
|
||||
void setFilterDate();
|
||||
void setFilterLevel();
|
||||
void setFilterLogger();
|
||||
void setFilterData();
|
||||
void setFilterLocation();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *m_ui;
|
||||
LogViewTableModel *m_logfileModel;
|
||||
DateFilterWidget *m_dateFilter;
|
||||
LevelFilterWidget *m_levelFilter;
|
||||
LoggerFilterWidget *m_loggerFilter;
|
||||
DataFilterWidget *m_dataFilter;
|
||||
LocationFilterWidget *m_locationFilter;
|
||||
SortFilterModel *m_filterProxyModel;
|
||||
NGL::INGLLogger &m_logger;
|
||||
QLabel *m_lbItemCount;
|
||||
QLabel *m_lbCoords;
|
||||
|
||||
void loadDataInCMB(int column);
|
||||
};
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#include "sortfiltermodel.h"
|
||||
#include "logviewtablemodel.h"
|
||||
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
void SortFilterModel::setStartDateFilter(const QDateTime &start)
|
||||
{
|
||||
if (m_start == start)
|
||||
return;
|
||||
m_start = start;
|
||||
beginFilterChange();
|
||||
endFilterChange();
|
||||
}
|
||||
|
||||
|
||||
void SortFilterModel::setEndDateFilter(const QDateTime &end)
|
||||
{
|
||||
if (m_end == end)
|
||||
return;
|
||||
m_end = end;
|
||||
beginFilterChange();
|
||||
endFilterChange();
|
||||
}
|
||||
|
||||
void SortFilterModel::figureFilterOut()
|
||||
{
|
||||
QVector<bool> vecOut = activatedStringFilter();
|
||||
emit theseFilterAreActivated(vecOut);
|
||||
}
|
||||
|
||||
void SortFilterModel::resetAllFilter()
|
||||
{
|
||||
m_stringFilter.clear();
|
||||
m_start = QDateTime();
|
||||
m_end = QDateTime();
|
||||
figureFilterOut();
|
||||
beginFilterChange();
|
||||
endFilterChange();
|
||||
}
|
||||
|
||||
|
||||
void SortFilterModel::setStringFilter(int col, const QString &filter)
|
||||
{
|
||||
if (col < LogViewTableModel::colDate || col > LogViewTableModel::colLocation)
|
||||
return;
|
||||
|
||||
if (m_stringFilter.contains(col))
|
||||
{
|
||||
QRegularExpression currentFilter(QRegularExpression::escape(m_stringFilter[col]), QRegularExpression::CaseInsensitiveOption);
|
||||
if (currentFilter.match(filter).hasMatch())
|
||||
return;
|
||||
else
|
||||
m_stringFilter.insert(col, filter);
|
||||
}
|
||||
else
|
||||
m_stringFilter.insert(col, filter);
|
||||
}
|
||||
|
||||
|
||||
bool SortFilterModel::stringFilterIsEmpty() const
|
||||
{
|
||||
return (m_stringFilter.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
QVector<bool> SortFilterModel::activatedStringFilter() const
|
||||
{
|
||||
QVector<bool> vecOut;
|
||||
|
||||
// Col 0 -> DateFilter
|
||||
vecOut.push_back(m_start.isValid() && m_end.isValid());
|
||||
// StringFilter - Columns prüfen
|
||||
vecOut.push_back(m_stringFilter.contains(1) && !m_stringFilter.value(1).isEmpty());
|
||||
vecOut.push_back(m_stringFilter.contains(2) && !m_stringFilter.value(2).isEmpty());
|
||||
vecOut.push_back(m_stringFilter.contains(3));
|
||||
vecOut.push_back(m_stringFilter.contains(4));
|
||||
|
||||
return vecOut;
|
||||
}
|
||||
|
||||
|
||||
bool SortFilterModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (source_left.column() != source_right.column())
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
if (source_left.column() != 0)
|
||||
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
||||
|
||||
const QDateTime dtLeft = source_left.data(Qt::UserRole).toDateTime();
|
||||
const QDateTime dtRight = source_right.data(Qt::UserRole).toDateTime();
|
||||
return dtLeft < dtRight;
|
||||
}
|
||||
|
||||
|
||||
bool SortFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (m_start.isValid() && m_end.isValid())
|
||||
{
|
||||
const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
|
||||
const QDateTime dtime = sourceModel()->data(idx, Qt::UserRole).toDateTime();
|
||||
if (dtime <= m_start || dtime >= m_end)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_stringFilter.isEmpty())
|
||||
return true;
|
||||
|
||||
for (auto iter = m_stringFilter.constBegin(); iter != m_stringFilter.constEnd(); ++iter)
|
||||
{
|
||||
const QString &filterString = iter.value();
|
||||
const int filterColumn = iter.key();
|
||||
|
||||
QModelIndex index = sourceModel()->index(source_row, filterColumn, source_parent);
|
||||
if (!index.data().toString().contains(filterString))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* <short description>
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Schröder, SLSE, 2016-07-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QSortFilterProxyModel>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
class SortFilterModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
|
||||
void setStringFilter(int col, const QString &filter);
|
||||
bool stringFilterIsEmpty() const;
|
||||
QVector<bool> activatedStringFilter() const;
|
||||
|
||||
signals:
|
||||
void theseFilterAreActivated(QVector<bool> &filter);
|
||||
|
||||
public slots:
|
||||
void setStartDateFilter(const QDateTime &start);
|
||||
void setEndDateFilter(const QDateTime &end);
|
||||
void figureFilterOut();
|
||||
void resetAllFilter();
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override final;
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override final;
|
||||
|
||||
private:
|
||||
QMap<int, QString> m_stringFilter;
|
||||
QDateTime m_start;
|
||||
QDateTime m_end;
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DataFilterWidget</class>
|
||||
<widget class="QWidget" name="DataFilterWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>250</width>
|
||||
<height>44</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Filter Data</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbData">
|
||||
<property name="text">
|
||||
<string>Data:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leFilterData"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DateFilterWidget</class>
|
||||
<widget class="QWidget" name="DateFilterWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>265</width>
|
||||
<height>170</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Filter Date</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbUp">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Up:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDateTimeEdit" name="dteUp">
|
||||
<property name="displayFormat">
|
||||
<string>dd.MM.yy HH:mm:ss</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbTo">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDateTimeEdit" name="dteTo">
|
||||
<property name="displayFormat">
|
||||
<string>dd.MM.yy HH:mm:ss</string>
|
||||
</property>
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chbTime">
|
||||
<property name="text">
|
||||
<string>enable time</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chbMilliSecs">
|
||||
<property name="text">
|
||||
<string>enable milliseconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbReset">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LevelFilterWidget</class>
|
||||
<widget class="QWidget" name="LevelFilterWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>250</width>
|
||||
<height>43</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Filter Level</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbLevel"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LocationFilterWidget</class>
|
||||
<widget class="QWidget" name="LocationFilterWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>250</width>
|
||||
<height>43</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Filter Location</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbLocation">
|
||||
<property name="text">
|
||||
<string>Location:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leFilterLocation"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoggerFilterWidget</class>
|
||||
<widget class="QWidget" name="LoggerFilterWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>250</width>
|
||||
<height>43</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Filter Logger</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbLogger"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>851</width>
|
||||
<height>601</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>LogViewer</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="LogViewTableView" name="tvContent">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::DoubleClicked</set>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>851</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>Fi&le</string>
|
||||
</property>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionReset"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:/icons/16x16/document-open.png</normaloff>:/icons/16x16/document-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReset">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:/icons/16x16/edit-undo.png</normaloff>:/icons/16x16/edit-undo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Reset</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Del</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionResetFilter">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Reset filter</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowCurrentFilter">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Show current filter</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../Z/src/nglwidgets/nglresources.qrc">
|
||||
<normaloff>:/icons/16x16/dialog-close.png</normaloff>:/icons/16x16/dialog-close.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LogViewTableView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>logviewtableview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../../Z/src/nglwidgets/nglresources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in new issue
Block a user