Continue the Qt5->Qt6 migration so the LTS Projects (Group 10) and LTS
Application (Group 11) compile, link, and ctest runs.
Qt5->Qt6 API migration (resolves removed/deprecated Qt6 APIs) across Lts
Tools and Apps, e.g. QAction->QActionGroup, QAbstractSocket::errorOccurred,
Qt::SkipEmptyParts, QRandomGenerator, QInputDevice::DeviceType,
QRegularExpression, QLatin1Literal->QStringLiteral, and the SampleModel
m_description->description rename.
CMake build fixes:
- CMakeLists.txt: add Lts/Common to CMAKE_AUTOMOC_INCLUDE_DIRECTORIES so moc
resolves Q_INTERFACES(ProjectPlugin::Plugin) for the migrated Projects.
- cmake/NGLMacros.cmake: NGL_COMPILE_RESOURCES - replace return() (which aborts
the calling CMakeLists.txt) with an if/else/endif.
- OpApp/THP: guard the ArcGISQt5Hack link with $<IF:$<TARGET_EXISTS:...>> (the
target is absent when the SituationMap viewer is stubbed); matches
CentralEffectSimulation.
- LtsSession: prefer the in-tree svcCoreClient target over a FIND_LIBRARY in
/usr/local/lib.
- CnrProxyTester/DotMatrixDisplay: set AUTOUIC_SEARCH_PATHS for the ui/ subdir.
- TopicDiscover: link NGLLogger.
Export-header visibility stubs (expand the empty *_EXPORT macro to
__attribute__((visibility("default"))); the build sets -fvisibility=hidden and
these stubs shadow the CMake-generated header):
- include/LtsProjectionWorkstation/ltsprojectionworkstation_export.h (fixes
undefined reference to LtsProjectionWorkstation::getInstance /
setProjectionOperatorPreset)
- include/LtsSession/ltssession_export.h, include/LtsUtilsGuiDds/ltsutilsguidds_export.h (same pattern)
New plugin modules (copied from legacy) so LtsAppDescriptorChecker finds the
gui:3 IIDs referenced by the Projects' apps.json:
- TakeHomePackageManager/OldTHP gui:3:tpm.man, gui:3:tpm.usb
- PresentationManagement/.../ScriptEditor gui:3:pre.script.edit
- Timeline/Gui/EventTimelineClassic gui:3:tln.view
new_docker_build.sh: correct group targets to the actual CMake target names,
guard LtsReportDisplay on BUILD_CODIFICATION, and skip modules unavailable in
the prebuilt image (AsmWorkstationCertifier/botan2, TrajectoryWidget,
VideoImport, thp_viewer/VLC).
260 lines
5.8 KiB
C++
Executable File
260 lines
5.8 KiB
C++
Executable File
/*
|
|
* @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::ForegroundRole: // 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;
|
|
}
|