Reinserts original comments

This commit is contained in:
torsten committed 2026-10-14 12:56:16 +00:00
1 parent 1dd1e86355
commit b662e4daf9
112 files changed
+7113 -5131

No files matched your search

@@ -1,17 +1,17 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "LogViewGui.hpp"
#include "LogViewTelegram.hpp"
@@ -50,7 +50,7 @@
namespace N_LogView
{
// static member initialization
const QLatin1String LogViewGui::WINDOW_GROUP("MainWindow");
const QLatin1String LogViewGui::SIZE("Size");
const QLatin1String LogViewGui::SCREEN("Screen");
@@ -59,9 +59,9 @@ const QLatin1String LogViewGui::SPLITTPOS("SplittPos");
const QLatin1String LogViewGui::TOOLBOXINDEX("ToolBoxIndex");
// ---------------------------------------------------------------
// ---------------------------------------------------------------
LogViewGui::LogViewGui(QWidget* a_parent)
: QMainWindow(a_parent)
, RADIO_BUTTON_ICON_SIZE(16, 16)
@@ -79,7 +79,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
QSettings settings;
settings.beginGroup(WINDOW_GROUP);
// status-bar
m_InjectionStatus = new QLabel(this);
m_InjectionStatus->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addPermanentWidget(m_InjectionStatus);
@@ -90,11 +90,11 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_TelegramStatus->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addPermanentWidget(m_TelegramStatus);
// tool-bar
// --------
QToolBar* toolBar = addToolBar(tr("Datei"));
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
// tool-bar: new logfile
QString tipText;
QAction* action = new QAction(tr("Neue Log-Datei"), this);
action->setIcon(QIcon(QLatin1String(":icons/16x16/document-new.png")));
@@ -104,7 +104,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
action->setToolTip(tipText);
connect(action, &QAction::triggered, this, &LogViewGui::newTelegramFile);
toolBar->addAction(action);
// tool-bar: add logfile
action = new QAction(tr("Log-Datei hinzu"), this);
action->setIcon(QIcon(QLatin1String(":icons/16x16/document-import.png")));
action->setShortcut(tr("Ctrl+O"));
@@ -113,7 +113,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
action->setToolTip(tipText);
connect(action, &QAction::triggered, this, &LogViewGui::loadTelegramFile);
toolBar->addAction(action);
// tool-bar: reload
m_reloadAction = new QAction(tr("&Reload"), this);
m_reloadAction->setCheckable(true);
m_reloadAction->setChecked(m_DoReload);
@@ -124,7 +124,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_reloadAction->setToolTip(tipText);
connect(m_reloadAction, &QAction::triggered, this, &LogViewGui::reloadOnOff);
toolBar->addAction(m_reloadAction);
// tool-bar: settings
action = new QAction(tr("&Einstellungen"), this);
action->setIcon(QIcon(QLatin1String(":icons/16x16/configure.png")));
action->setShortcut(tr("Ctrl+E"));
@@ -133,7 +133,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
action->setToolTip(tipText);
connect(action, &QAction::triggered, this, &LogViewGui::changeSettings);
toolBar->addAction(action);
// tool-bar: exit
toolBar->addSeparator();
action = new QAction(tr("&Beenden"), this);
action->setIcon(QIcon(QLatin1String(":icons/16x16/edit-delete.png")));
@@ -148,8 +148,8 @@ LogViewGui::LogViewGui(QWidget* a_parent)
createTetraSelectionWidget();
createWlsSelectionWidget();
// participant-selection
// ---------------------
m_ParticipantTableView = new QTableView(this);
m_participantProxyModel = new QSortFilterProxyModel(this);
m_participantModel = new ParticipantModel(this);
@@ -175,7 +175,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_ParticipantSelectionGroup->setLayout(participantBox);
connect(m_ParticipantSelectionGroup, &QGroupBox::toggled, this, &LogViewGui::selectedParticipantChanged);
// left side (filters)
m_ToolBox = new QToolBox(this);
m_ToolBox->addItem(m_CentralSelectionGroup, QIcon(QLatin1String(":/image/Central.png")), tr("&Zentral-Telegramm-Filter"));
m_ToolBox->addItem(m_TetraSelectionGroup, QIcon(QLatin1String(":/image/Tetra.png")), tr("TET&RA-Telegramm-Filter"));
@@ -184,8 +184,8 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_ToolBox->addItem(m_EditTelegramController->tableView(), QIcon(QLatin1String(":icons/16x16/document-edit.png")), tr("&Edit && Sende Telegramme"));
m_ToolBox->setCurrentIndex(settings.value(TOOLBOXINDEX).toInt());
// right side (logged telegrams)
// -----------------------------
m_logTelegramView = new QTableView(this);
m_logTelegramView->setAlternatingRowColors(true);
m_logTelegramView->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -194,9 +194,9 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_logTelegramView->verticalHeader()->setMinimumSectionSize(QApplication::font().pointSize() * 2.5);
m_logTelegramView->verticalHeader()->setDefaultSectionSize(QApplication::font().pointSize() * 2.5);
m_logTelegramView->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
m_logTelegramView->setContextMenuPolicy(Qt::CustomContextMenu);
m_logTelegramView->setContextMenuPolicy(Qt::CustomContextMenu); //Custom Contextmenu enabled
connect(m_logTelegramView, &QTableView::customContextMenuRequested,
this, &LogViewGui::customMenuRequested);
this, &LogViewGui::customMenuRequested); //connect table to contextmenu
m_telegramModel = new TelegramModel(m_logTelegramView);
m_telegramProxyModel = new TelegramProxyModel(m_logTelegramView);
m_telegramProxyModel->setSourceModel(m_telegramModel);
@@ -212,7 +212,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
QGroupBox* telegramGroup = new QGroupBox(tr("&Log-Telegramme"), this);
telegramGroup->setLayout(telegramBox);
// splitter between toolbox and log-telegram-list
m_Splitter = new QSplitter(Qt::Horizontal, this);
m_Splitter->addWidget(m_ToolBox);
m_Splitter->addWidget(telegramGroup);
@@ -231,8 +231,8 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_Splitter->setSizes(splitterSizes);
setCentralWidget(m_Splitter);
// initialize the telegram-filters (this should be done before load of telegrams, otherwise the telegram-list
// will be shown several times and this could be slow when the telegram-list is slow)
m_CentralSelectionGroup->setChecked(true);
m_ackCentralTelCheckBox->setChecked(true);
m_ackCentralTelCheckBox->setChecked(false);
@@ -258,7 +258,7 @@ LogViewGui::LogViewGui(QWidget* a_parent)
m_SentWlsTelCheckBox->setChecked(true);
m_ReceivedWlsTelCheckBox->setChecked(true);
// set the size and position of main-window
QSize size = settings.value(SIZE, sizeHint()).toSize();
resize(size.isNull() ? QSize(1280, 768) : size);
move(settings.value(POS, QPoint(0, 0)).toPoint());
@@ -273,13 +273,13 @@ LogViewGui::LogViewGui(QWidget* a_parent)
void LogViewGui::createCentralSelectionWidget()
{
// send-checkbox
m_SentCentralTelCheckBox = createRadioButton(tr("&gesendete Telegramme"), QLatin1String(":/image/P2C.png"));
// received-checkbox
m_ReceivedCentralTelCheckBox = createRadioButton(tr("&empfangene Telegramme"), QLatin1String(":/image/C2P.png"));
// pos-checkbox
m_PosCentralTelCheckBox = createRadioButton(tr("&Positionsmeldungen"), QLatin1String(":/image/CentralPos.png"));
// ack-checkbox
m_ackCentralTelCheckBox = createRadioButton(tr("&Bestaetigungstelegramme"), QLatin1String(":/image/CentralAck.png"));
QVBoxLayout* centralFilterBox = new QVBoxLayout;
@@ -298,21 +298,21 @@ void LogViewGui::createCentralSelectionWidget()
void LogViewGui::createTetraSelectionWidget()
{
// sent-checkbox
m_SentTetraTelCheckBox = createRadioButton(tr("&gesendete Telegramme"), QLatin1String(":/image/T2P.png"));
// received-checkbox
m_ReceivedTetraTelCheckBox = createRadioButton(tr("&empfangene Telegramme"), QLatin1String(":/image/P2T.png"));
// pos-checkbox
m_PosTetraTelCheckBox = createRadioButton(tr("&Positionsmeldungen"), QLatin1String(":/image/TetraPos.png"));
// fragmented-checkbox
m_FragmentedTetraTelCheckBox = createRadioButton(tr("&Fragmentierte Meldungen"), QLatin1String(":/image/TetraFragmented.png"));
// login-checkbox
m_LoginTetraTelCheckBox = createRadioButton(tr("&Loginmeldungen"), QLatin1String(":/image/TetraLogin.png"));
// register-checkbox
m_RegisterTetraTelCheckBox = createRadioButton(tr("&Registermeldungen"), QLatin1String(":/image/TetraRegister.png"));
// report-checkbox
m_ReportTetraTelCheckBox = createRadioButton(tr("&Reportmeldungen"), QLatin1String(":/image/TetraReport.png"));
// air-interface-load-checkbox
m_AirInterfaceLoadTetraTelCheckBox = createRadioButton(tr("&Air-Load Meldungen"), QLatin1String(":/image/TetraAirInterface.png"));
QVBoxLayout* tetraFilterBox = new QVBoxLayout;
@@ -335,11 +335,11 @@ void LogViewGui::createTetraSelectionWidget()
void LogViewGui::createWlsSelectionWidget()
{
// send-checkbox
m_SentWlsTelCheckBox = createRadioButton(tr("&gesendete Telegramme"), QLatin1String(":/image/P2W.png"));
// received-checkbox
m_ReceivedWlsTelCheckBox = createRadioButton(tr("&empfangene Telegramme"), QLatin1String(":/image/W2P.png"));
// pos-checkbox
m_PosWlsTelCheckBox = createRadioButton(tr("&Positionsmeldungen"), QLatin1String(":/image/WlsPos.png"));
QVBoxLayout* wlsFilterBox = new QVBoxLayout;
@@ -356,10 +356,10 @@ void LogViewGui::createWlsSelectionWidget()
}
// ---------------------------------------------------------------
void LogViewGui::customMenuRequested(const QPoint &pos)
{
//create Menu with Actions
QMenu menu(this);
menu.addAction(tr("Add Telegram to EditList"), this, &LogViewGui::addTelegramToEdit);
menu.addAction(tr("Show HexData"), this, &LogViewGui::showHexData);
@@ -376,7 +376,7 @@ void LogViewGui::customMenuRequested(const QPoint &pos)
}
// ---------------------------------------------------------------
void LogViewGui::addTelegramToEdit()
{
for (const QModelIndex &orig: m_logTelegramView->selectionModel()->selectedRows())
@@ -390,7 +390,7 @@ void LogViewGui::addTelegramToEdit()
}
// ---------------------------------------------------------------
void LogViewGui::showHexData()
{
const QModelIndex idx = m_telegramProxyModel->mapToSource(m_logTelegramView->currentIndex());
@@ -402,7 +402,7 @@ void LogViewGui::showHexData()
showTelegramDialog->showDataDump(tele, false);
}
// ---------------------------------------------------------------
void LogViewGui::exportAsCsv()
{
const int idx = m_ActualLogfile.lastIndexOf(QLatin1Char('.'));
@@ -441,7 +441,7 @@ void LogViewGui::exportAsCsv()
f.write("\n");
}
f.close();
}
}// ---------------------------------------------------------------
void LogViewGui::exportAsJson()
{
@@ -468,7 +468,7 @@ void LogViewGui::exportAsJson()
f.close();
}
// ---------------------------------------------------------------
void LogViewGui::onStartLogReplay()
{
#ifndef LTS_DEBUG
@@ -526,7 +526,7 @@ void LogViewGui::onReplayTimerTimeout()
if (!checkTele())
return;
uint64_t nextSendTime = (tele->getLogTimeMsec() - curSendTime);
uint64_t nextSendTime = (tele->getLogTimeMsec() - curSendTime); // micro -> milli
DEBUG_LOG(m_logger) << "Next SendTime: " << nextSendTime
<< ", telId: " << tele->getTelId()
<< ", next row: " << m_currentReplayRow
@@ -536,13 +536,13 @@ void LogViewGui::onReplayTimerTimeout()
m_replayTimer->start(nextSendTime);
}
// ---------------------------------------------------------------
void LogViewGui::loadSpecificationFiles()
{
QSettings settings;
settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP);
// load central-protocol spezification
QString defString = QCoreApplication::applicationDirPath() + QLatin1String("/training_area_telegrams.h");
QString filename = settings.value(LogViewOptionDialog::P0_FILENAME, defString).toString();
INFO_LOG(m_logger) << "Load central-protocol spezification-file: " << filename.toStdString();
@@ -553,7 +553,7 @@ void LogViewGui::loadSpecificationFiles()
}
LogViewTelegram::jsonParser()->parse(filename);
// load tetra-protocol spezification
defString = QCoreApplication::applicationDirPath() + QLatin1String("/zsksxd_tetraForLogView.x");
filename = settings.value(LogViewOptionDialog::P5_FILENAME, defString).toString();
INFO_LOG(m_logger) << "Load tetra-protocol spezification-file: " << filename.toStdString();
@@ -570,29 +570,29 @@ void LogViewGui::loadSpecificationFiles()
}
// ---------------------------------------------------------------
void LogViewGui::newTelegramFile()
{
if (m_TailTimer) m_TailTimer->stop();
// delete all participants
m_participantModel->clearParticipants();
m_telegramModel->clearTelegrams();
m_participantListTelCount.clear();
m_participantListIssi.clear();
m_ParticipantStatus->setText(tr("0 Teilnehmer"));
// load a telegram-file
loadTelegramFile();
}
// ---------------------------------------------------------------
void LogViewGui::loadTelegramFile()
{
const QLatin1String DIR("Dir");
QSettings settings;
settings.beginGroup(QLatin1String("LogFiles"));
QString filename = QFileDialog::getOpenFileName(this, tr("Bitte eine Log-Datei auswaehlen"), settings.value(DIR).toString(), LogViewOptionDialog::KRLOG_FILES);
QString filename = QFileDialog::getOpenFileName(this, tr("Bitte eine Log-Datei auswaehlen"), settings.value(DIR).toString(), LogViewOptionDialog::KRLOG_FILES/*tr("Log-Dateien (*.krlog)")*/);
if (filename.isEmpty())
return;
@@ -605,7 +605,7 @@ void LogViewGui::loadTelegramFile()
m_logTelegramView->resizeColumnsToContents();
m_ParticipantTableView->resizeColumnsToContents();
// start the time for checking whether new entries were added to the log-file
if (!m_TailTimer)
m_TailTimer = new QTimer(this);
connect(m_TailTimer, &QTimer::timeout, this, &LogViewGui::updateLogfile, Qt::QueuedConnection);
@@ -614,11 +614,11 @@ void LogViewGui::loadTelegramFile()
}
// ---------------------------------------------------------------
// Checks whether the size of actual logfile has changed. If
// yes, the new log-entries will be read and shown within
// table.
// ---------------------------------------------------------------
void LogViewGui::updateLogfile()
{
if(!m_DoReload)
@@ -636,12 +636,12 @@ void LogViewGui::updateLogfile()
catch (const std::exception& e)
{
WARNING_LOG(m_logger) << "Error: " << e.what();
// simply read the telegram in the next update
}
}
else
{
//check if one newer file exists and load it
QString dateFromFile;
const QString format = QStringLiteral("yyMMdd_hh");
for (int iterator = fileInfo.baseName().size() - format.size(); iterator < fileInfo.baseName().size(); ++iterator)
@@ -677,10 +677,10 @@ void LogViewGui::updateLogfile()
}
// ---------------------------------------------------------------
void LogViewGui::readTelegramsFromLogFile(const QString& a_fileName, const qint64 a_filePos)
{
// open the log-file
QFile telegramFile(a_fileName);
if (telegramFile.open(QIODevice::ReadOnly))
{
@@ -690,7 +690,7 @@ void LogViewGui::readTelegramsFromLogFile(const QString& a_fileName, const qint6
m_logTelegramView->blockSignals(true);
m_logTelegramView->setUpdatesEnabled(false);
QVector<QSharedPointer<LogViewTelegram> > newTelegrams;
// read the header of telegram-entry
N_CoPrtCnv::CoPrtCnvLogHeader lh;
while (true)
{
@@ -698,7 +698,7 @@ void LogViewGui::readTelegramsFromLogFile(const QString& a_fileName, const qint6
{
if (lh.m_Version == 3 || lh.m_Version == 4)
{
// read the telegram itself
qint64 telegramLength = lh.m_Length - sizeof(lh);
QByteArray buf(telegramLength, Qt::Uninitialized);
if (telegramLength == telegramFile.read(buf.data(), telegramLength))
@@ -708,11 +708,11 @@ void LogViewGui::readTelegramsFromLogFile(const QString& a_fileName, const qint6
if (lh.m_Version == 4)
buf = qUncompress(buf);
// add the telegram to telegram-list
N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol protocol =
static_cast<N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol>(lh.m_Protocol);
QSharedPointer<LogViewTelegram> telegram(new LogViewTelegram(protocol, lh.m_Time, buf));
// this checks the telegram and raises a messagebox if the telegram is wrong
if (!telegram->isValid())
{
ERROR_LOG(m_logger) << "Trying to read/parse unknown data from logfile '" << a_fileName
@@ -721,7 +721,7 @@ void LogViewGui::readTelegramsFromLogFile(const QString& a_fileName, const qint6
}
newTelegrams.push_back(telegram);
// add the pariticipant to the participant-list
addToParticipantList(telegram);
}
}
@@ -754,7 +754,7 @@ void LogViewGui::readTelegramsFromLogFile(const QString& a_fileName, const qint6
}
// ---------------------------------------------------------------
void LogViewGui::selectedParticipantChanged()
{
std::set<int> selectedParticipantIds;
@@ -762,7 +762,7 @@ void LogViewGui::selectedParticipantChanged()
const QModelIndexList selectedParticipants = m_ParticipantTableView->selectionModel()->selectedRows(0);
for (const QModelIndex &participantIdx : selectedParticipants)
{
// row 0 -> eqId
const QModelIndex idx = m_participantProxyModel->mapToSource(participantIdx);
selectedParticipantIds.insert(m_participantModel->data(idx).toInt());
}
@@ -788,7 +788,7 @@ static void updateFilteredPosTelegramIds(std::set<int> &teleIds, bool bEnable)
}
}
// ---------------------------------------------------------------
void LogViewGui::showTelegramTable()
{
updateFilteredPosTelegramIds(m_CentralTelegramFilterList, m_PosCentralTelCheckBox->isChecked());
@@ -872,7 +872,7 @@ void LogViewGui::syncParticipantList()
m_participantModel->addUpdateParticipants(eqIds, issis, numberOfTelegrams);
}
// ---------------------------------------------------------------
void LogViewGui::changeSettings()
{
LogViewOptionDialog optionDialog(this);
@@ -883,7 +883,7 @@ void LogViewGui::changeSettings()
}
// ---------------------------------------------------------------
QCheckBox* LogViewGui::createRadioButton(const QString& a_buttonName, const QString& a_iconName)
{
QCheckBox* checkBox = new QCheckBox(a_buttonName, this);
@@ -894,10 +894,10 @@ QCheckBox* LogViewGui::createRadioButton(const QString& a_buttonName, const QStr
}
// ---------------------------------------------------------------
// starts the thread, which trys to connect to the injection-
// server of PrtCnv
// ---------------------------------------------------------------
void LogViewGui::startInjectionThread()
{
if (m_InjectionThread)
@@ -933,26 +933,26 @@ void LogViewGui::startInjectionThread()
}
// ---------------------------------------------------------------
// Toggles whether the logfile must be periodically checked
// for changes
// ---------------------------------------------------------------
void LogViewGui::reloadOnOff()
{
m_DoReload = !m_DoReload;
}
// ---------------------------------------------------------------
void LogViewGui::closeEvent(QCloseEvent* a_closeEvent)
{
QSettings settings;
settings.beginGroup(WINDOW_GROUP);
// store the actual toolbox selection
settings.setValue(TOOLBOXINDEX, m_ToolBox->currentIndex());
// store the actual size
settings.setValue(SIZE, size());
QPoint position = pos();
settings.setValue(POS, position);
@@ -960,7 +960,7 @@ void LogViewGui::closeEvent(QCloseEvent* a_closeEvent)
int screenNbr = QGuiApplication::screens().indexOf(scr);
settings.setValue(SCREEN, screenNbr);
// store the splitter-position
const QList<int> splitterSizes = m_Splitter->sizes();
QList<QVariant> splitterSizesAsVariant;
splitterSizesAsVariant.reserve(splitterSizes.size());
@@ -974,14 +974,14 @@ void LogViewGui::closeEvent(QCloseEvent* a_closeEvent)
QMainWindow::closeEvent(a_closeEvent);
}
// ---------------------------------------------------------------
void LogViewGui::updateInjectionStatus(const QString& a_picName, const QString& a_toopTipText)
{
m_InjectionStatus->setPixmap(QPixmap(a_picName));
m_InjectionStatus->setToolTip(a_toopTipText);
}
// ---------------------------------------------------------------
void LogViewGui::onLogTelegramViewDoubleClicked(const QModelIndex &index)
{
if (!m_telegramProxyModel || !m_telegramModel)
@@ -1005,4 +1005,4 @@ void LogViewGui::onSettingsChanged(uint32_t changedFlags)
startInjectionThread();
}
}
} // namespace N_LogView