From 473462cbdbe53f8042ad620f42f7134956ff46d9 Mon Sep 17 00:00:00 2001 From: berrux_dev Date: Mon, 16 Nov 2026 20:24:04 +0100 Subject: [PATCH] Fix LogView consistency and LtsUtilsGuiDds link after the merge - LogView: take the complete XmlPatterns (d327c66c4) file set - the auto-merged mix (XmlPatterns .cpp + validation .hpp) left duplicated m_logger members and constructor signature mismatches, because the two lineages reworked the module differently. - LogView CMakeLists: the cleanup version (separate LogViewLogger static library, required by tabPluginTetraJson and present in the Release 2 target list). - LtsUtilsGuiDds: link ddscore (BUILD_RTI) for the Core::FunctionReply symbols, as in story/release-2-cleanup. Full-scope ninja all is green; ctest 20/22 (the two failures, GrantleeParserSmoke and utils_test, are out of the driver's 46-target scope and 'Not Run' in the official baseline). --- .../LtsUtilsGui/LtsUtilsGuiDds/CMakeLists.txt | 6 + .../TetraIF/LogView/Console/main.cpp | 167 ++-- .../TetraIF/LogView/IntegerCalculator.cpp | 903 +++++++++--------- .../TetraIF/LogView/IntegerCalculator.hpp | 293 ++---- .../TetraIF/LogView/LogViewBooleanEdit.cpp | 55 +- .../TetraIF/LogView/LogViewBooleanEdit.hpp | 17 +- .../TetraIF/LogView/LogViewDateTimeEdit.cpp | 138 +-- .../TetraIF/LogView/LogViewDateTimeEdit.hpp | 58 +- .../TetraIF/LogView/LogViewEnumEdit.cpp | 153 +-- .../TetraIF/LogView/LogViewEnumEdit.hpp | 59 +- .../TetraIF/LogView/LogViewField.hpp | 76 +- .../LogView/LogViewInjectionThread.hpp | 53 +- .../TetraIF/LogView/LogViewModels.hpp | 160 ++-- .../TetraIF/LogView/LogViewOptionDialog.cpp | 300 +++--- .../TetraIF/LogView/LogViewOptionDialog.hpp | 128 ++- .../TetraIF/LogView/LogViewSpinBox.cpp | 87 +- .../TetraIF/LogView/LogViewSpinBox.hpp | 64 +- .../TetraIF/LogView/LogViewTabWidget.cpp | 219 +++-- .../TetraIF/LogView/LogViewTabWidget.hpp | 58 +- .../TetraIF/LogView/LogViewTableWidget.cpp | 542 ++++++----- .../TetraIF/LogView/LogViewTableWidget.hpp | 55 +- .../TetraIF/LogView/LogViewTelegram.hpp | 363 +++---- .../LogView/LogViewTelegramEditModel.cpp | 287 +++--- .../LogView/LogViewTelegramEditModel.hpp | 52 +- .../LogViewTelegramSelectionDialog.cpp | 89 +- .../LogViewTelegramSelectionDialog.hpp | 50 +- .../TetraIF/LogView/LogViewTextEdit.cpp | 139 +-- .../TetraIF/LogView/LogViewTextEdit.hpp | 58 +- .../TetraIF/LogView/LogViewValueEdit.cpp | 205 ++-- .../TetraIF/LogView/LogViewValueEdit.hpp | 59 +- .../TetraIF/LogView/LogViewXdrElement.cpp | 104 +- .../TetraIF/LogView/LogViewXdrElement.hpp | 52 +- .../LogView/LogViewXdrStandardType.cpp | 137 +-- .../LogView/LogViewXdrStandardType.hpp | 128 +-- .../TetraIF/LogView/LogViewXdrStruct.cpp | 186 ++-- .../TetraIF/LogView/LogViewXdrStruct.hpp | 60 +- .../TetraIF/LogView/LogViewXdrType.cpp | 186 ++-- .../TetraIF/LogView/LogViewXdrType.hpp | 121 +-- .../TetraIF/LogView/LogViewXdrValue.cpp | 57 +- .../TetraIF/LogView/LogViewXdrValue.hpp | 37 +- .../TetraIF/LogView/logger.cpp | 46 +- .../TetraIF/LogView/logger.h | 23 +- 42 files changed, 2779 insertions(+), 3251 deletions(-) diff --git a/qt6-after/qt6-migrated-legatus/Lts/Common/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/CMakeLists.txt b/qt6-after/qt6-migrated-legatus/Lts/Common/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/CMakeLists.txt index 8d1671979..5590d0ffa 100755 --- a/qt6-after/qt6-migrated-legatus/Lts/Common/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/CMakeLists.txt +++ b/qt6-after/qt6-migrated-legatus/Lts/Common/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/CMakeLists.txt @@ -45,6 +45,9 @@ if(QT6_GUI_AVAILABLE) Qt6::Svg ) endif() +IF(BUILD_RTI) + TARGET_LINK_LIBRARIES(LtsUtilsGuiDds PUBLIC ddscore) +ENDIF(BUILD_RTI) NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds PUBLIC REQUEST_HELPER_WITH_GUI @@ -77,3 +80,6 @@ NGL_TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC Qt6::Core ) +IF(BUILD_RTI) + TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC ddscore) +ENDIF(BUILD_RTI) diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/Console/main.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/Console/main.cpp index c48ac607e..a04437a52 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/Console/main.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/Console/main.cpp @@ -17,7 +17,8 @@ #include static QSet s_eqIds; -template bool validEqId(const T &tele) +template +bool validEqId(const T &tele) { if (!s_eqIds.isEmpty() && !s_eqIds.contains(tele.header.equipmentNumber)) return false; @@ -38,28 +39,31 @@ int main(int argc, char **argv) QCoreApplication app(argc, argv); - // Check alle 30 Sekunden + NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx_tetra.props", false); NGL::INGLLogger &logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()); if (app.arguments().count() < 3) { - ERROR_LOG(logger) << "Usage: " << app.arguments().at(0) << " "; + ERROR_LOG(logger) << "Usage: " << app.arguments().at(0) + << " "; return 1; } QFile telegramFile(app.arguments().at(1)); if (!telegramFile.open(QIODevice::ReadOnly)) { - ERROR_LOG(logger) << "Error opening " << telegramFile.fileName() << " for reading: " << telegramFile.errorString(); + ERROR_LOG(logger) << "Error opening " << telegramFile.fileName() + << " for reading: " << telegramFile.errorString(); return 2; } bool bOk; int telIdToSearch = app.arguments().at(2).toUShort(&bOk); if (!bOk) { - ERROR_LOG(logger) << "Error reading telId - not a (valid) number: " << app.arguments().at(2); + ERROR_LOG(logger) << "Error reading telId - not a (valid) number: " + << app.arguments().at(2); return 3; } s_eqIds.clear(); @@ -68,102 +72,119 @@ int main(int argc, char **argv) int eqId = app.arguments().at(i).toUShort(&bOk); if (!bOk) { - ERROR_LOG(logger) << "Error reading equipId - not a (valid) number: " << app.arguments().at(i); + ERROR_LOG(logger) << "Error reading equipId - not a (valid) number: " + << app.arguments().at(i); return 4; } s_eqIds += eqId; } - //fprintf(stdout, "Counter;EqID;TelID;TelTime;LogTime;Diff\n"); + while (true) { - // read the header of telegram-entry + N_CoPrtCnv::CoPrtCnvLogHeader lh; if (sizeof(lh) == telegramFile.read((char *)&lh, sizeof(lh))) { if (lh.m_Version == 3) { - // read the telegram itself + qint64 telegramLength = lh.m_Length - sizeof(lh); QByteArray telegramData(telegramLength, Qt::Uninitialized); if (telegramLength == telegramFile.read(telegramData.data(), telegramLength)) { - // add the telegram to telegram-list - N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol dest = - (N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol)(lh.m_Protocol & N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolMask); + + N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol dest = (N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol) + (lh.m_Protocol & N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolMask); switch (dest) { - case N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolCentral: + case N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolCentral: + { + const QJsonObject obj = QJsonDocument::fromJson(telegramData).object(); + int telId = obj.value(QStringLiteral("typeId")).toInt(); + if (telIdToSearch != telId) + continue; + + const QJsonObject objData = obj.value(QStringLiteral("data")).toObject(); + + const QByteArray tBA = formatTime(lh.m_Time); + const char *timeStr = tBA.constData(); + + switch (telId) { - const QJsonObject obj = QJsonDocument::fromJson(telegramData).object(); - int telId = obj.value(QStringLiteral("typeId")).toInt(); - if (telIdToSearch != telId) - continue; - - const QJsonObject objData = obj.value(QStringLiteral("data")).toObject(); + case Constraints::id(): + { + const CreateFunctionalArea tele(CreateFunctionalArea::fromJson(objData)); + if (!validEqId(tele)) + break; + fprintf(stdout, "%s, FUNKTIONSRAUM: '%s', %d, %d\n", + timeStr, + tele.name.c_str(), + tele.aesDdsId, + tele.header.equipmentNumber + ); + break; + } + case Constraints::id(): + { + const DeactivateEffectSimulation tele(DeactivateEffectSimulation::fromJson(objData)); + fprintf(stdout, "%s, DEAKTIVIERUNG_WIRKFELD: typ: %d - kennung: %d\n", + timeStr, + int(tele.aesType), + tele.aesDdsId + ); + break; + } + case Constraints::id(): + { + const PositionReport tele(PositionReport::fromJson(objData)); + if (!validEqId(tele)) + break; + if (tele.opsPosition.opsId == 0) + break; + fprintf(stdout, "%s, IPS_POSITIONSDATEN: %d - OPS: %d\n", + timeStr, + tele.header.equipmentNumber, + tele.opsPosition.opsId + ); + break; + } + case BESTAETIGUNG: + case UMGEBUNGS_MELDUNG2: + break; + default: + fprintf(stderr, "Printing telegram with id %d not implemented\n", telId); + break; + } + break; + } + case N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolTetra: + { + N_CoPrtCnv::CoPrtCnvRadioTelegram radioTelegram(telegramData); + gef_telegramm_id_et telId = radioTelegram.getTelID(); + if (telId == GEF_UMGEBUNGS_MELDUNG2) + { const QByteArray tBA = formatTime(lh.m_Time); const char *timeStr = tBA.constData(); - - switch (telId) + static uint16_t bci = 0xFFFF; + if (bci != radioTelegram.getBroadcastIndex()) { - case Constraints::id(): + if (bci > radioTelegram.getBroadcastIndex() && bci != 0xFFFF) { - const CreateFunctionalArea tele(CreateFunctionalArea::fromJson(objData)); - if (!validEqId(tele)) - break; - fprintf(stdout, "%s, FUNKTIONSRAUM: '%s', %d, %d\n", timeStr, tele.name.c_str(), tele.aesDdsId, tele.header.equipmentNumber); - break; + fprintf(stdout, "BCI reset in %s at %s!\n", + qPrintable(telegramFile.fileName()), + timeStr); } - case Constraints::id(): - { - const DeactivateEffectSimulation tele(DeactivateEffectSimulation::fromJson(objData)); - fprintf(stdout, "%s, DEAKTIVIERUNG_WIRKFELD: typ: %d - kennung: %d\n", timeStr, int(tele.aesType), tele.aesDdsId); - break; - } - case Constraints::id(): - { - const PositionReport tele(PositionReport::fromJson(objData)); - if (!validEqId(tele)) - break; - if (tele.opsPosition.opsId == 0) - break; - fprintf(stdout, "%s, IPS_POSITIONSDATEN: %d - OPS: %d\n", timeStr, tele.header.equipmentNumber, tele.opsPosition.opsId); - break; - } - case BESTAETIGUNG: - case UMGEBUNGS_MELDUNG2: - break; - default: - fprintf(stderr, "Printing telegram with id %d not implemented\n", telId); - break; + fprintf(stdout, "BCI: %d\n", radioTelegram.getBroadcastIndex()); + bci = radioTelegram.getBroadcastIndex(); } - break; } - case N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolTetra: - { - N_CoPrtCnv::CoPrtCnvRadioTelegram radioTelegram(telegramData); - gef_telegramm_id_et telId = radioTelegram.getTelID(); - if (telId == GEF_UMGEBUNGS_MELDUNG2) - { - const QByteArray tBA = formatTime(lh.m_Time); - const char *timeStr = tBA.constData(); - static uint16_t bci = 0xFFFF; - if (bci != radioTelegram.getBroadcastIndex()) - { - if (bci > radioTelegram.getBroadcastIndex() && bci != 0xFFFF) - { - fprintf(stdout, "BCI reset in %s at %s!\n", qPrintable(telegramFile.fileName()), timeStr); - } - fprintf(stdout, "BCI: %d\n", radioTelegram.getBroadcastIndex()); - bci = radioTelegram.getBroadcastIndex(); - } - } - break; - } - default: - break; + break; + } + default: + break; } } } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.cpp index adf68f0f8..a31e417e0 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.cpp @@ -1,17 +1,17 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** -// manual class headers + + + + + + + + + + + + + #include "IntegerCalculator.hpp" #include @@ -19,492 +19,479 @@ namespace N_SST { - IntegerCalculator::IntegerCalculator() - : m_OperationList({{"*", 6}, {"/", 6}, {"%", 6}, {"+", 5}, {"-", 5}, {"<<", 4}, {">>", 4}}) - , m_AdditionalErrorText() - , m_ParanthesisCount(0) - , m_Error(IntegerCalculator::e_Ok) +IntegerCalculator::IntegerCalculator() + : m_OperationList({{"*", 6},{"/", 6},{"%", 6},{"+", 5},{"-", 5},{"<<", 4},{">>", 4}}) + , m_AdditionalErrorText() + , m_ParanthesisCount(0) + , m_Error(IntegerCalculator::e_Ok) +{ +} + + + + + + + + +int64_t IntegerCalculator::calc(const std::string& a_calcText, E_Error& a_error, std::string* a_addErrorText) +{ + std::string calcText = a_calcText; + + for (auto iter = m_OperationList.begin(); iter != m_OperationList.end(); ++iter) + replace(calcText, iter->first, " "+iter->first+" "); + + + replace(calcText, "(", " ( "); + replace(calcText, ")", " ) "); + + + + m_ParanthesisCount = 0; + m_Error = e_Ok; + m_AdditionalErrorText = ""; + size_t pos = 0; + bool dummy; + int64_t value = calc(calcText, pos, dummy, "", 0, "+"); + + + + if (m_Error == e_Ok) { - } - - // --------------------------------------------------------------- - // Converts the expressen in a_calcText into a signed value. - // Returns whether an error happend in the variable a_error. - // If an error happend, the variable a_addErrorText can - // contain more informaition about the error (see E_Error for - // more information about errors). - // --------------------------------------------------------------- - int64_t IntegerCalculator::calc(const std::string &a_calcText, E_Error &a_error, std::string *a_addErrorText) - { - std::string calcText = a_calcText; - // separate operations from variables - for (auto iter = m_OperationList.begin(); iter != m_OperationList.end(); ++iter) - replace(calcText, iter->first, " " + iter->first + " "); - - // separate paranthesis from variables - replace(calcText, "(", " ( "); - replace(calcText, ")", " ) "); - - - // now calculate the expression - m_ParanthesisCount = 0; - m_Error = e_Ok; - m_AdditionalErrorText = ""; - size_t pos = 0; - bool dummy; - int64_t value = calc(calcText, pos, dummy, "", 0, "+"); // todo: use member-variable m_CalcText - //M_INFO("calc: " << calcText << " value: " << value); - - // check the paranthesis - if (m_Error == e_Ok) + if (m_ParanthesisCount > 0) { - if (m_ParanthesisCount > 0) - { - m_Error = e_MissingRightParanthesis; - } - else if (m_ParanthesisCount < 0) - { - m_Error = e_MissingLeftParanthesis; - } - else if (pos != calcText.length()) - { - m_Error = e_UnknownError; - } + m_Error = e_MissingRightParanthesis; } - - // actions if a failure happens - a_error = m_Error; - if (a_error != e_Ok) + else if (m_ParanthesisCount < 0) { - value = 0; - if (a_addErrorText) - { - *a_addErrorText = m_AdditionalErrorText; - } + m_Error = e_MissingLeftParanthesis; } - return value; - } - - // --------------------------------------------------------------- - // Adds or changes a case-sensitive variable to the calculator. - // --------------------------------------------------------------- - void IntegerCalculator::addVariable(const std::string &a_name, const int64_t a_value) - { - std::map::iterator iter = m_VariableList.find(a_name); - if (iter != m_VariableList.end()) - removeVariable(a_name); - m_VariableList.insert(std::make_pair(a_name, a_value)); - } - - - // --------------------------------------------------------------- - // Removes a case-sensitive variable from the calculator. - // --------------------------------------------------------------- - void IntegerCalculator::removeVariable(const std::string &a_name) - { - std::map::iterator iter = m_VariableList.find(a_name); - if (iter != m_VariableList.end()) - m_VariableList.erase(iter); - } - - - // --------------------------------------------------------------- - // Calculates the expression (recursive) - // --------------------------------------------------------------- - int64_t IntegerCalculator::calc(const std::string &a_calcText, - size_t &a_pos, - bool &a_IsEndParanthesis, - const std::string &a_prevOp, - const int64_t a_prevValue, - const std::string &a_initOp) - { - std::string operation = a_initOp; - int64_t value1 = a_prevValue; - bool isNegative = false; - std::string calcText = a_calcText; - a_IsEndParanthesis = false; - - while (a_pos < calcText.length()) + else if (pos != calcText.length()) { - if (' ' == calcText[a_pos]) - { - a_pos++; - } - else if ('(' == calcText[a_pos]) - { - m_ParanthesisCount++; - bool dummy; - int64_t value2 = calcSign(calc(calcText, ++a_pos, dummy), isNegative); - value1 = doOperation(value1, operation, value2); + m_Error = e_UnknownError; + } + } - // get next operation to check priority of operation - size_t tmpPos = a_pos; // do not change the position, we only pre-read - std::string nextOp = getToken(a_calcText, tmpPos); - if (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp)) - { - // end of higher priority operation - return value1; - } + + a_error = m_Error; + if (a_error != e_Ok) + { + value = 0; + if (a_addErrorText) + { + *a_addErrorText = m_AdditionalErrorText; + } + } + return value; +} - operation = ""; - } - else if (')' == calcText[a_pos]) + + + +void IntegerCalculator::addVariable(const std::string& a_name, const int64_t a_value) +{ + std::map::iterator iter = m_VariableList.find(a_name); + if (iter != m_VariableList.end()) + removeVariable(a_name); + m_VariableList.insert(std::make_pair(a_name, a_value)); +} + + + + + +void IntegerCalculator::removeVariable(const std::string& a_name) +{ + std::map::iterator iter = m_VariableList.find(a_name); + if (iter != m_VariableList.end()) + m_VariableList.erase(iter); +} + + + + + +int64_t IntegerCalculator::calc(const std::string& a_calcText, size_t& a_pos, bool& a_IsEndParanthesis, + const std::string& a_prevOp, const int64_t a_prevValue, + const std::string& a_initOp) +{ + std::string operation = a_initOp; + int64_t value1 = a_prevValue; + bool isNegative = false; + std::string calcText = a_calcText; + a_IsEndParanthesis = false; + + while (a_pos < calcText.length()) + { + if (' ' == calcText[a_pos]) + { + a_pos++; + } + else if ('(' == calcText[a_pos]) + { + m_ParanthesisCount++; + bool dummy; + int64_t value2 = calcSign(calc(calcText, ++a_pos, dummy), isNegative); + value1 = doOperation(value1, operation, value2); + + + size_t tmpPos = a_pos; + std::string nextOp = getToken(a_calcText, tmpPos); + if (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp)) { - m_ParanthesisCount--; - a_pos++; - a_IsEndParanthesis = true; + return value1; } - else if (isDigit(calcText[a_pos])) - { - // value - // ----- - int64_t value2 = calcSign(convertValue(calcText, a_pos), isNegative); - if (calcWithPriority(calcText, a_pos, value1, operation, value2, a_prevOp)) - return value1; - } - else - { - // operation or variable - // --------------------- - std::string oldOperation = operation; - operation = getToken(calcText, a_pos); - // is it a variable? - if (!isOperation(operation)) + operation = ""; + } + else if (')' == calcText[a_pos]) + { + m_ParanthesisCount--; + a_pos++; + a_IsEndParanthesis = true; + return value1; + } + else if (isDigit(calcText[a_pos])) + { + + + int64_t value2 = calcSign(convertValue(calcText, a_pos), isNegative); + if (calcWithPriority(calcText, a_pos, value1, operation, value2, a_prevOp)) return value1; + } + else + { + + + std::string oldOperation = operation; + operation = getToken(calcText, a_pos); + + + if (!isOperation(operation)) + { + int64_t value2 = 0; + if (getVariableValue(operation, value2)) { - int64_t value2 = 0; - if (getVariableValue(operation, value2)) - { - value2 = calcSign(value2, isNegative); - if (calcWithPriority(calcText, a_pos, value1, oldOperation, value2, a_prevOp)) - return value1; - operation = ""; - } - else - { - // error - m_Error = e_UnknownOperationOrVariable; - m_AdditionalErrorText = operation; - } + value2 = calcSign(value2, isNegative); + if (calcWithPriority(calcText, a_pos, value1, oldOperation, value2, a_prevOp)) return value1; + operation = ""; } else { - // do we have a sign? - if (oldOperation != "") + + m_Error = e_UnknownOperationOrVariable; + m_AdditionalErrorText = operation; + } + } + else + { + + if (oldOperation != "") + { + if (operation == "+") { - if (operation == "+") - { - operation = oldOperation; - } - else if (operation == "-") - { - isNegative = !isNegative; - operation = oldOperation; - } - else - { - m_Error = e_NoOperandBetweenOperators; - m_AdditionalErrorText = oldOperation + " " + operation; - return 0; - } + operation = oldOperation; + } + else if (operation == "-") + { + isNegative = !isNegative; + operation = oldOperation; + } + else + { + m_Error = e_NoOperandBetweenOperators; + m_AdditionalErrorText = oldOperation + " " + operation; + return 0; } } } } - return value1; + } + return value1; +} + + + + + + +bool IntegerCalculator::calcWithPriority(const std::string& a_calcText, size_t& a_pos, int64_t& a_value1, std::string& a_operation, int64_t a_value2, const std::string& a_prevOp) +{ + bool isParaEnd = false; + + size_t tmpPos = a_pos; + std::string nextOp = getToken(a_calcText, tmpPos); + if (isOperation(a_operation) && isOperation(nextOp) && isOperationPriorityHigher(nextOp, a_operation)) + { + + a_value2 = calc(a_calcText, a_pos, isParaEnd, a_operation, a_value2); + } + a_value1 = doOperation(a_value1, a_operation, a_value2); + if (isParaEnd || (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp))) + { + + return true; + } + a_operation = ""; + return false; +} + + + + + + + + +int64_t IntegerCalculator::calcSign(const int64_t a_value, bool& a_isNegative) +{ + if (a_isNegative) + { + a_isNegative = false; + return -a_value; + } + return a_value; +} + + + + + + +int64_t IntegerCalculator::convertValue(const std::string &a_valueText, size_t& a_pos) +{ + std::string valueText = a_valueText.substr(a_pos); + int base = 10; + size_t startpos = 0; + + bool isHex = (0 == valueText.find("0X")) || (0 == valueText.find("0x")); + bool isBin = (0 == valueText.find("0B")) || (0 == valueText.find("0b")); + if (isHex) + { + base = 16; + startpos = 2; + } + else if (isBin) + { + base = 2; + startpos = 2; + } + + size_t i; + for (i=startpos; i i && valueText[i] != ' ') + { + m_Error = e_InvalidOperand; + int spacePos = valueText.find(' '); + m_AdditionalErrorText = valueText.substr(0, spacePos); + } + a_pos += i; + + int64_t value = 0; + std::stringstream stream; + stream.str(valueText.substr(startpos, i-startpos)); + if (2 == base) + { + + const std::string binValueAsText = stream.str(); + for (const char c : binValueAsText) + { + value = value << 1; + if (c == '1') + value += 1; + } + } + else + { + stream << std::setbase(base); + stream >> value; + } + return value; +} + + + + + + +std::string IntegerCalculator::getToken(const std::string &a_calcText, size_t& a_pos) +{ + + while (a_pos < a_calcText.length()) + { + if (a_calcText[a_pos] == ' ') a_pos++; + else break; } - - // --------------------------------------------------------------- - // Calculates an operation with respecting the priority of - // operations. This will be done with recursion. - // --------------------------------------------------------------- - bool IntegerCalculator::calcWithPriority(const std::string &a_calcText, - size_t &a_pos, - int64_t &a_value1, - std::string &a_operation, - int64_t a_value2, - const std::string &a_prevOp) + + size_t startPos = a_pos; + while (a_pos < a_calcText.length()) { - bool isParaEnd = false; - // get next operation to check priority of operation - size_t tmpPos = a_pos; // only pre-read - std::string nextOp = getToken(a_calcText, tmpPos); - if (isOperation(a_operation) && isOperation(nextOp) && isOperationPriorityHigher(nextOp, a_operation)) - { - // next operation has higher priority => calc the next operation first - a_value2 = calc(a_calcText, a_pos, isParaEnd, a_operation, a_value2); - } - a_value1 = doOperation(a_value1, a_operation, a_value2); - if (isParaEnd || (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp))) - { - // end of higher priority operation - return true; - } - a_operation = ""; - return false; + if (' ' == a_calcText[a_pos]) break; + a_pos++; } + return a_calcText.substr(startPos, a_pos-startPos); +} - // --------------------------------------------------------------- - // Returns the inverted a_value if a_isNegative is true. - // a_isNegative will be false after calling this function. - // If a_isNegative is true, the NOT inverted a_value will be - // returned. - // --------------------------------------------------------------- - int64_t IntegerCalculator::calcSign(const int64_t a_value, bool &a_isNegative) + + + +bool IntegerCalculator::isOperation(const std::string& a_operation) const +{ + std::map::const_iterator iter = m_OperationList.find(a_operation); + return (iter != m_OperationList.end()); +} + + + + + + +int64_t IntegerCalculator::doOperation(const int64_t a_value1, const std::string& a_operation, const int64_t a_value2) +{ + + if (("+" == a_operation) || a_operation.empty()) { - if (a_isNegative) - { - a_isNegative = false; - return -a_value; - } - return a_value; + return a_value1 + a_value2; } - - - // --------------------------------------------------------------- - // Converts the value in form of text to a number. The Text - // can be decimal, hex (0x) or binary (0b). - // --------------------------------------------------------------- - int64_t IntegerCalculator::convertValue(const std::string &a_valueText, size_t &a_pos) + else if ("-" == a_operation) { - std::string valueText = a_valueText.substr(a_pos); - int base = 10; - size_t startpos = 0; - // hex- and binary-stuff - bool isHex = (0 == valueText.find("0X")) || (0 == valueText.find("0x")); - bool isBin = (0 == valueText.find("0B")) || (0 == valueText.find("0b")); - if (isHex) + return a_value1 - a_value2; + } + else if ("*" == a_operation) + { + return a_value1 * a_value2; + } + else if ("/" == a_operation) + { + if (0 == a_value2) { - base = 16; - startpos = 2; - } - else if (isBin) - { - base = 2; - startpos = 2; - } - // search end of value - size_t i; - for (i = startpos; i < valueText.length(); i++) - { - if (!isDigit(valueText[i], isHex, isBin)) - { - break; - } - } - // check the next char, it must be a space - if (valueText.length() > i && valueText[i] != ' ') - { - m_Error = e_InvalidOperand; - int spacePos = valueText.find(' '); - m_AdditionalErrorText = valueText.substr(0, spacePos); - } - a_pos += i; - - int64_t value = 0; - std::stringstream stream; - stream.str(valueText.substr(startpos, i - startpos)); - if (2 == base) - { - // our stl is not able to read in binary-values, therefore we have to implement it ourself - const std::string binValueAsText = stream.str(); - for (const char c : binValueAsText) - { - value = value << 1; - if (c == '1') - value += 1; - } + m_Error = e_DivisionByZero; } else { - stream << std::setbase(base); - stream >> value; + return a_value1 / a_value2; } - return value; } - - - // --------------------------------------------------------------- - // Returns the next token (with space as separator). Heading - // spaces will be ignored. - // --------------------------------------------------------------- - std::string IntegerCalculator::getToken(const std::string &a_calcText, size_t &a_pos) + else if ("%" == a_operation) { - // skip spaces at begin - while (a_pos < a_calcText.length()) + if (0 == a_value2) { - if (a_calcText[a_pos] == ' ') - a_pos++; - else - break; - } - - // search until next space (or end) - size_t startPos = a_pos; - while (a_pos < a_calcText.length()) - { - if (' ' == a_calcText[a_pos]) - break; - a_pos++; - } - return a_calcText.substr(startPos, a_pos - startPos); - } - - - // --------------------------------------------------------------- - // returns true if a_operation is a known operation. - // --------------------------------------------------------------- - bool IntegerCalculator::isOperation(const std::string &a_operation) const - { - std::map::const_iterator iter = m_OperationList.find(a_operation); - return (iter != m_OperationList.end()); - } - - - // --------------------------------------------------------------- - // Calculates the opeation a_operations with a_value1 as first - // and a_value2 as second operand. - // --------------------------------------------------------------- - int64_t IntegerCalculator::doOperation(const int64_t a_value1, const std::string &a_operation, const int64_t a_value2) - { - // M_INFO("" << a_value1 << " " << a_operation << " " << a_value2); - if (("+" == a_operation) || a_operation.empty()) - { - return a_value1 + a_value2; - } - else if ("-" == a_operation) - { - return a_value1 - a_value2; - } - else if ("*" == a_operation) - { - return a_value1 * a_value2; - } - else if ("/" == a_operation) - { - if (0 == a_value2) - { - m_Error = e_DivisionByZero; - } - else - { - return a_value1 / a_value2; - } - } - else if ("%" == a_operation) - { - if (0 == a_value2) - { - m_Error = e_DivisionByZero; - } - else - { - return a_value1 % a_value2; - } - } - else if ("<<" == a_operation) - { - return a_value1 << a_value2; - } - else if (">>" == a_operation) - { - return a_value1 >> a_value2; + m_Error = e_DivisionByZero; } else { - m_Error = e_UnknownOperationOrVariable; - m_AdditionalErrorText = a_operation; - } - return 0; - } - - - // --------------------------------------------------------------- - // returns true if priority of a_opeation1 is higher than - // priority of a_operation2. - // --------------------------------------------------------------- - bool IntegerCalculator::isOperationPriorityHigher(const std::string &a_operation1, const std::string &a_operation2) const - { - return (getPriority(a_operation1) > getPriority(a_operation2)); - } - - - // --------------------------------------------------------------- - // Returns true if the variable named a_variableName is known - // and a_value will be filled with its value. If the variable - // is not found false will be returned. - // Overload this virtual function if you want to implement - // your own variable-list. - // --------------------------------------------------------------- - bool IntegerCalculator::getVariableValue(const std::string &a_variableName, int64_t &a_value) const - { - auto iter = m_VariableList.find(a_variableName); - if (iter != m_VariableList.end()) - { - a_value = iter->second; - return true; - } - - // error - return false; - } - - - // --------------------------------------------------------------- - // Returns true if a_char is a digit. When a_isHex is true, - // also the charactes a-f will be accepted as digits. When - // a_isBin is true, only 0 and 1 will be treated as digit. - // --------------------------------------------------------------- - bool IntegerCalculator::isDigit(const char a_char, const bool a_isHex, const bool a_isBin) - { - if (a_isHex) - { - // for hex-values also A..F are 'digits' - return (a_char >= '0' && a_char <= '9') || (a_char >= 'A' && a_char <= 'F') || (a_char >= 'a' && a_char <= 'f'); - } - else if (a_isBin) - { - // for binary-values only 0 and 1 are allowed - return (a_char >= '0' && a_char <= '1'); - } - // normal digits - return (a_char >= '0' && a_char <= '9'); - } - - - // --------------------------------------------------------------- - // Returns the priority of the operation. A higher value means - // more priority. - // --------------------------------------------------------------- - int16_t IntegerCalculator::getPriority(const std::string &a_operation) const - { - std::map::const_iterator iter = m_OperationList.find(a_operation); - if (iter != m_OperationList.end()) - return iter->second; - - return -1; - } - - - // --------------------------------------------------------------- - // replaces in a_haystack all a_searchText with a_replaceText - // (not greedy). - // --------------------------------------------------------------- - void IntegerCalculator::replace(std::string &a_haystack, const std::string &a_searchText, const std::string &a_replaceText) - { - std::string::size_type searchSize = a_searchText.length(); - std::string::size_type replaceSize = a_replaceText.length(); - - std::string::size_type pos = a_haystack.find(a_searchText, 0); - while (std::string::npos != pos) - { - a_haystack.replace(pos, searchSize, a_replaceText); - pos += replaceSize; - pos = a_haystack.find(a_searchText, pos); + return a_value1 % a_value2; } } + else if ("<<" == a_operation) + { + return a_value1 << a_value2; + } + else if (">>" == a_operation) + { + return a_value1 >> a_value2; + } + else + { + m_Error = e_UnknownOperationOrVariable; + m_AdditionalErrorText = a_operation; + } + return 0; +} -} // namespace N_SST + + + + + +bool IntegerCalculator::isOperationPriorityHigher(const std::string& a_operation1, const std::string& a_operation2) const +{ + return (getPriority(a_operation1) > getPriority(a_operation2)); +} + + + + + + + + + +bool IntegerCalculator::getVariableValue(const std::string& a_variableName, int64_t& a_value) const +{ + auto iter = m_VariableList.find(a_variableName); + if (iter != m_VariableList.end()) + { + a_value = iter->second; + return true; + } + + + return false; +} + + + + + + + +bool IntegerCalculator::isDigit(const char a_char, const bool a_isHex, const bool a_isBin) +{ + if (a_isHex) + { + + return (a_char >= '0' && a_char <= '9') || (a_char >= 'A' && a_char <= 'F') || (a_char >= 'a' && a_char <= 'f'); + } + else if (a_isBin) + { + + return (a_char >= '0' && a_char <= '1'); + } + + return (a_char >= '0' && a_char <= '9'); +} + + + + + + +int16_t IntegerCalculator::getPriority(const std::string& a_operation) const +{ + std::map::const_iterator iter = m_OperationList.find(a_operation); + if (iter != m_OperationList.end()) + return iter->second; + + return -1; +} + + + + + + +void IntegerCalculator::replace(std::string& a_haystack, const std::string &a_searchText, const std::string &a_replaceText) +{ + std::string::size_type searchSize = a_searchText.length(); + std::string::size_type replaceSize = a_replaceText.length(); + + std::string::size_type pos = a_haystack.find(a_searchText, 0); + while (std::string::npos != pos) + { + a_haystack.replace(pos, searchSize, a_replaceText); + pos += replaceSize; + pos = a_haystack.find(a_searchText, pos); + } +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.hpp index 10c273a81..22fbf2db7 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/IntegerCalculator.hpp @@ -1,15 +1,15 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once @@ -18,65 +18,39 @@ namespace N_SST { - /** - * This class calculates algebraic texts with integer values and returns its - * result as a signed value. It handles the operations - +, -, *, /, %, <<, >>. It - * understands the paranthesis and priorities of operations, like * before -. It - * also computes with variables, which names are case-sensitive. The values can be - * decimal, hexadecimal (0x) or binary (0b). The variable-system implemented - * virtual, so you can implement your own variable system (see getVariableValue()). - * - * - * @author alois.wismer - * @version 1.0 - * @created 12-Mai-2010 16:26:43 - */ + + class IntegerCalculator { public: - /** - * Describes the error happend while calculation of an expression - * - * @author alois.wismer - * @version 1.0 - * @created 17-Mai-2010 16:38:24 - */ + + + enum E_Error { - /** - * No error happend - */ + + e_Ok, - /** - * The divisor is 0 - */ + + e_DivisionByZero, - /** - * The operation/variable is not known. a_addErrorText will contain the unknown - * operation/variable. - */ + + e_UnknownOperationOrVariable, - /** - * Between to operators no variable/operand exists. a_addErrorText contains the 2 - * operations. - */ + + e_NoOperandBetweenOperators, - /** - * The operand contains invalid characters. a_addErrorText contains the invalid - * operand. - */ + + e_InvalidOperand, - /** - * There are more ) than ( - */ + + e_MissingLeftParanthesis, - /** - * There are more ) than ( - */ + + e_MissingRightParanthesis, - /** - * Something else went wrong - */ + + e_UnknownError }; @@ -84,173 +58,86 @@ namespace N_SST IntegerCalculator(); virtual ~IntegerCalculator() = default; - /** - * Converts the expressen in a_calcText into a signed value. Returns whether an - * error happend in the variable a_error. If an error happend, the variable - * a_addErrorText can contain more informaition about the error (see E_Error for - * more information about errors). - * - * @param a_calcText - * @param a_error - * @param a_addErrorText - */ - int64_t calc(const std::string &a_calcText, E_Error &a_error, std::string *a_addErrorText = nullptr); + - /** - * Adds or changes a case-sensitive variable to the calculator. - * - * @param a_name - * @param a_value - */ - void addVariable(const std::string &a_name, const int64_t a_value); + int64_t calc(const std::string& a_calcText, E_Error& a_error, std::string* a_addErrorText = nullptr); - /** - * Removes a case-sensitive variable from the calculator. - * - * @param a_name - */ - void removeVariable(const std::string &a_name); + + + void addVariable(const std::string& a_name, const int64_t a_value); + + + + void removeVariable(const std::string& a_name); protected: - /** - * Contains all supported operations - */ + + + const std::map m_OperationList; - /** - * Contains all variables - */ + + std::map m_VariableList; - /** - * The additional text for errors - */ + + std::string m_AdditionalErrorText; - /** - * The number of open paranthesis - */ + + int32_t m_ParanthesisCount; E_Error m_Error; - /** - * Calculates the expression (recursive) - * - * @param a_calcText - * @param a_pos - * @param a_IsEndParanthesis - * @param a_prevOp - * @param a_prevValue - * @param a_initOp - */ - int64_t calc(const std::string &a_calcText, - size_t &a_pos, - bool &a_IsEndParanthesis, - const std::string &a_prevOp = std::string(), - const int64_t a_prevValue = 0, - const std::string &a_initOp = std::string()); + - /** - * Calculates an operation with respecting the priority of operations. This will - * be done with recursion. - * - * @param a_calcText - * @param a_pos - * @param a_value1 - * @param a_operation - * @param a_value2 - * @param a_prevOp - */ - bool calcWithPriority(const std::string &a_calcText, size_t &a_pos, int64_t &a_value1, std::string &a_operation, int64_t a_value2, const std::string &a_prevOp); + int64_t calc(const std::string& a_calcText, size_t& a_pos, bool& a_IsEndParanthesis, + const std::string& a_prevOp = std::string(), const int64_t a_prevValue = 0, + const std::string& a_initOp = std::string()); - /** - * Returns the inverted a_value if a_isNegative is true. a_isNegative will be - * false after calling this function. - * If a_isNegative is true, the NOT inverted a_value will be returned. - * - * @param a_value - * @param a_isNegative - */ - static int64_t calcSign(const int64_t a_value, bool &a_isNegative); + - /** - * Converts the value in form of text to a number. The Text can be decimal, hex - * (0x) or binary (0b). - * - * @param a_valueText - * @param a_pos - */ - int64_t convertValue(const std::string &a_valueText, size_t &a_pos); + bool calcWithPriority(const std::string& a_calcText, size_t& a_pos, int64_t& a_value1, + std::string& a_operation, int64_t a_value2, const std::string& a_prevOp); - /** - * Returns the next token (with space as separator). Heading spaces will be - * ignored. - * - * @param a_calcText - * @param a_pos - */ - static std::string getToken(const std::string &a_calcText, size_t &a_pos); + - /** - * returns true if a_operation is a known operation. - * - * @param a_operation - */ - bool isOperation(const std::string &a_operation) const; + static int64_t calcSign(const int64_t a_value, bool& a_isNegative); - /** - * Calculates the opeation a_operations with a_value1 as first and a_value2 as - * second operand. - * - * @param a_value1 - * @param a_operation - * @param a_value2 - */ - int64_t doOperation(const int64_t a_value1, const std::string &a_operation, const int64_t a_value2); + - /** - * returns true if priority of a_opeation1 is higher than priority of a_operation2. - * - * - * @param a_operation1 - * @param a_operation2 - */ - bool isOperationPriorityHigher(const std::string &a_operation1, const std::string &a_operation2) const; + int64_t convertValue(const std::string& a_valueText, size_t& a_pos); - /** - * Returns true if the variable named a_variableName is known and a_value will be - * filled with its value. If the variable is not found false will be returned. - * Overload this virtual function if you want to implement your own variable-list. - * - * @param a_variableName - * @param a_value - */ - virtual bool getVariableValue(const std::string &a_variableName, int64_t &a_value) const; + + + static std::string getToken(const std::string& a_calcText, size_t& a_pos); + + + + bool isOperation(const std::string& a_operation) const; + + + + int64_t doOperation(const int64_t a_value1, const std::string& a_operation, const int64_t a_value2); + + + + bool isOperationPriorityHigher(const std::string& a_operation1, const std::string& a_operation2) const; + + + + virtual bool getVariableValue(const std::string& a_variableName, int64_t& a_value) const; + + - /** - * Returns true if a_char is a digit. When a_isHex is true, also the charactes a-f - * will be accepted as digits. When a_isBin is true, only 0 and 1 will be treated - * as digit. - * - * @param a_char - * @param a_isHex - * @param a_isBin - */ static bool isDigit(const char a_char, const bool a_isHex = false, const bool a_isBin = false); - /** - * Returns the priority of the operation. A higher value means more priority. - * - * @param a_operation - */ - int16_t getPriority(const std::string &a_operation) const; + + + int16_t getPriority(const std::string& a_operation) const; + + + + static void replace(std::string& a_haystack, const std::string& a_searchText, const std::string& a_replaceText); - /** - * replaces in a_haystack all a_searchText with a_replaceText (not greedy). - * - * @param a_haystack - * @param a_searchText - * @param a_replaceText - */ - static void replace(std::string &a_haystack, const std::string &a_searchText, const std::string &a_replaceText); }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.cpp index 3e719893e..4b3ec1b6b 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.cpp @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * Edit boolean values - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #include "LogViewBooleanEdit.hpp" #include "LogViewField.hpp" @@ -13,29 +8,29 @@ namespace N_LogView { - // --------------------------------------------------------------- - LogViewBooleanEdit::LogViewBooleanEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) - : QCheckBox(a_parent) - , LogViewWidget(a_field, this, a_parent, a_readonly) + +LogViewBooleanEdit::LogViewBooleanEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly) + : QCheckBox (a_parent) + , LogViewWidget(a_field, this, a_parent, a_readonly) +{ + const QString valueText = a_field->value(0); + + setChecked(valueText.toInt() == 1); + setEnabled(!a_readonly); +} + + +bool LogViewBooleanEdit::saveContent(LogViewTelegram* a_telegram) +{ + if (m_Valid) { - const QString valueText = a_field->value(0); - - setChecked(valueText.toInt() == 1); - setEnabled(!a_readonly); + if (a_telegram->isJsonTelegram()) + a_telegram->setJsonValue(m_Field->jsonPath(), isChecked()); + else + a_telegram->setUIntX(getSize(), isChecked()); + return true; } + return false; +} - // --------------------------------------------------------------- - bool LogViewBooleanEdit::saveContent(LogViewTelegram *a_telegram) - { - if (m_Valid) - { - if (a_telegram->isJsonTelegram()) - a_telegram->setJsonValue(m_Field->jsonPath(), isChecked()); - else - a_telegram->setUIntX(getSize(), isChecked()); - return true; - } - return false; - } - -} // namespace N_LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.hpp index c5646e959..abcba5c04 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewBooleanEdit.hpp @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * Edit boolean values - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #pragma once @@ -13,14 +8,12 @@ namespace N_LogView { - class LogViewBooleanEdit - : public QCheckBox - , public LogViewWidget + class LogViewBooleanEdit : public QCheckBox, public LogViewWidget { Q_OBJECT public: - LogViewBooleanEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly); - bool saveContent(LogViewTelegram *a_telegram) override; + LogViewBooleanEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly); + bool saveContent(LogViewTelegram* a_telegram) override; }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.cpp index 31b2f0e6a..b3af104e4 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.cpp @@ -1,17 +1,17 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** -// manual class headers + + + + + + + + + + + + + #include "LogViewDateTimeEdit.hpp" #include #include "LogViewField.hpp" @@ -20,65 +20,67 @@ namespace N_LogView { - // --------------------------------------------------------------- - LogViewDateTimeEdit::LogViewDateTimeEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) - : QDateTimeEdit(a_parent) - , LogViewWidget(a_field, this, a_parent, a_readonly) + +LogViewDateTimeEdit::LogViewDateTimeEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly) + : QDateTimeEdit(a_parent) + , LogViewWidget(a_field, this, a_parent, a_readonly) +{ + if (a_readonly) { - if (a_readonly) - { - setReadOnly(true); - setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); - } - - // date-time-field - qint64 unixTime = 0; - if (a_field->hasContent()) - { - if (a_field->isMSecsField()) - unixTime = a_field->value(0, true).toLongLong(); - else - unixTime = a_field->value(0, true).toInt() * 1000LL; - } - // take actual date and time if time is 0 - if (0 == unixTime && !a_readonly) - unixTime = ::time(nullptr) * 1000LL; - - //valueWidget = new QDateTimeEdit(dateTime); - setDateTime(QDateTime::fromMSecsSinceEpoch(unixTime)); - setDisplayFormat(QLatin1String("dd MMM yyyy hh:mm:ss")); - setCalendarPopup(true); - updateToolTip(QString::number(unixTime)); - //setToolTip(a_field->getToolTipText()); - // checkAndOvertakeContent(); - - connect(this, &LogViewDateTimeEdit::editingFinished, this, &LogViewDateTimeEdit::checkAndOvertakeContent); + setReadOnly(true); + setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); } - - // --------------------------------------------------------------- - void LogViewDateTimeEdit::checkAndOvertakeContent() + + qint64 unixTime = 0; + if (a_field->hasContent()) { - updateToolTip(QString::number(dateTime().toMSecsSinceEpoch() / 1000)); - } - - - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewDateTimeEdit::saveContent(LogViewTelegram *a_telegram) - { - if (a_telegram->isJsonTelegram()) - { - a_telegram->setJsonValue(m_Field->jsonPath(), dateTime().toMSecsSinceEpoch()); - } + if (a_field->isMSecsField()) + unixTime = a_field->value(0, true).toLongLong(); else - { - a_telegram->setNextFieldAsGpsTimeField(); // fixme: muss noch der feldname auf GPS Zeit geprüft werden? - a_telegram->setUIntX(getSize(), dateTime().toMSecsSinceEpoch() / 1000); - } - return true; + unixTime = a_field->value(0, true).toInt() * 1000LL; } + + if (0 == unixTime && !a_readonly) + unixTime = ::time(nullptr) * 1000LL; + + + setDateTime(QDateTime::fromMSecsSinceEpoch(unixTime)); + setDisplayFormat(QLatin1String("dd MMM yyyy hh:mm:ss")); + setCalendarPopup(true); + updateToolTip(QString::number(unixTime)); + + + + connect(this, &LogViewDateTimeEdit::editingFinished, + this, &LogViewDateTimeEdit::checkAndOvertakeContent); +} + + + +void LogViewDateTimeEdit::checkAndOvertakeContent() +{ + updateToolTip(QString::number(dateTime().toMSecsSinceEpoch() / 1000)); +} + + + + + + +bool LogViewDateTimeEdit::saveContent(LogViewTelegram* a_telegram) +{ + if (a_telegram->isJsonTelegram()) + { + a_telegram->setJsonValue(m_Field->jsonPath(), dateTime().toMSecsSinceEpoch()); + } + else + { + a_telegram->setNextFieldAsGpsTimeField(); + a_telegram->setUIntX(getSize(), dateTime().toMSecsSinceEpoch() / 1000); + } + return true; +} + +} -} // namespace N_LogView diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.hpp index 2c72f4cce..94ec4e521 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewDateTimeEdit.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewWidget.hpp" @@ -18,37 +18,23 @@ namespace N_LogView { - /** - * Used for date & time - * - * @author alois.wismer - * @version 1.0 - * @created 20-Mai-2010 17:41:28 - */ - class LogViewDateTimeEdit - : public QDateTimeEdit - , public LogViewWidget + + + class LogViewDateTimeEdit : public QDateTimeEdit, public LogViewWidget { Q_OBJECT public: - /** - * - * @param a_field - * @param a_parent - * @param a_readonly - */ - LogViewDateTimeEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly); + - /** - * Writes the content into telegram. - * Returns true if successful. - * - * @param a_telegram - */ - bool saveContent(LogViewTelegram *a_telegram) override; + LogViewDateTimeEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly); + + + + bool saveContent(LogViewTelegram* a_telegram) override; public slots: void checkAndOvertakeContent(); + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.cpp index 5763d6459..8f8da7b96 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.cpp @@ -1,17 +1,17 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** -// manual class headers + + + + + + + + + + + + + #include "LogViewEnumEdit.hpp" #include "LogViewXdrStruct.hpp" #include "LogViewXdrValue.hpp" @@ -23,82 +23,83 @@ namespace N_LogView { - // --------------------------------------------------------------- - LogViewEnumEdit::LogViewEnumEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, const int a_index) - : QComboBox(a_parent) - , LogViewWidget(a_field, this, a_parent, a_readonly) + +LogViewEnumEdit::LogViewEnumEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly, const int a_index) + : QComboBox(a_parent) + , LogViewWidget(a_field, this, a_parent, a_readonly) +{ + QString value = a_field->value(a_index); + + + setToolTip(a_field->toolTipText()); + + + bool bCurrentIndexSet = false; + int i = 0; + while (LogViewXdrValue* child = (static_cast(a_field->xdrElement()))->getChildAsValue(i++)) { - QString value = a_field->value(a_index); - - // show the tool-tip with special-case for TETRA bitfields - setToolTip(a_field->toolTipText()); - - // fill combobox - bool bCurrentIndexSet = false; - int i = 0; - while (LogViewXdrValue *child = (static_cast(a_field->xdrElement()))->getChildAsValue(i++)) + QString enumText = LogViewField::makeClean(child->getName()); + if (!a_readonly || enumText == value) { - QString enumText = LogViewField::makeClean(child->getName()); - if (!a_readonly || enumText == value) - { - addItem(QStringLiteral("%1 (%2)").arg(enumText).arg(child->getValue()), QVariant::fromValue(child->getValue())); - if (a_readonly) - bCurrentIndexSet = true; - } - - if (enumText == value) - { - setCurrentIndex(a_readonly ? 0 : i - 1); + addItem(QStringLiteral("%1 (%2)").arg(enumText).arg(child->getValue()), QVariant::fromValue(child->getValue())); + if (a_readonly) bCurrentIndexSet = true; - if (!a_readonly || (0 != a_index)) - updateToolTip(itemData(currentIndex()).toString()); - } } - if (!bCurrentIndexSet) + if (enumText == value) { - addItem(value); - setCurrentIndex(findText(value)); + setCurrentIndex(a_readonly ? 0 : i - 1); + bCurrentIndexSet = true; + if (!a_readonly || (0 != a_index)) + updateToolTip(itemData(currentIndex()).toString()); } - - // connect signals - connect(this, QOverload::of(&LogViewEnumEdit::currentIndexChanged), this, &LogViewEnumEdit::checkAndOvertakeContent); } - - // --------------------------------------------------------------- - uint16_t LogViewEnumEdit::getSize() const + if (!bCurrentIndexSet) { - // todo: check ob wirklich ein struct - const LogViewXdrStruct *xdrStruct = static_cast(m_Field->xdrElement()); - return xdrStruct->getEnumSize(); + addItem(value); + setCurrentIndex(findText(value)); } + + connect(this, QOverload::of(&LogViewEnumEdit::currentIndexChanged), + this, &LogViewEnumEdit::checkAndOvertakeContent); +} - // --------------------------------------------------------------- - void LogViewEnumEdit::checkAndOvertakeContent() + + +uint16_t LogViewEnumEdit::getSize() const +{ + + const LogViewXdrStruct* xdrStruct = static_cast(m_Field->xdrElement()); + return xdrStruct->getEnumSize(); +} + + + +void LogViewEnumEdit::checkAndOvertakeContent() +{ + updateToolTip(itemData(currentIndex()).toString()); +} + + + + + + +bool LogViewEnumEdit::saveContent(LogViewTelegram* a_telegram) +{ + bool ok; + int value = itemData(currentIndex()).toInt(&ok); + if (ok) { - updateToolTip(itemData(currentIndex()).toString()); + if (a_telegram->isJsonTelegram()) + a_telegram->setJsonValue(m_Field->jsonPath(), value); + else + a_telegram->setUIntX(getSize(), value); + return true; } + return false; +} - - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewEnumEdit::saveContent(LogViewTelegram *a_telegram) - { - bool ok; - int value = itemData(currentIndex()).toInt(&ok); - if (ok) - { - if (a_telegram->isJsonTelegram()) - a_telegram->setJsonValue(m_Field->jsonPath(), value); - else - a_telegram->setUIntX(getSize(), value); - return true; - } - return false; // failure while conversion - } - -} // namespace N_LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.hpp index 9300d15bf..eb2b708af 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewEnumEdit.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewWidget.hpp" @@ -18,41 +18,26 @@ namespace N_LogView { - /** - * Used for enums - * - * @author alois.wismer - * @version 1.0 - * @created 21-Mai-2010 09:31:16 - */ - class LogViewEnumEdit - : public QComboBox - , public LogViewWidget + + + class LogViewEnumEdit : public QComboBox, public LogViewWidget { Q_OBJECT public: - /** - * - * @param a_field - * @param a_parent - * @param a_readonly - * @param a_index the array-index - */ - LogViewEnumEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, const int a_index); + + + LogViewEnumEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly, const int a_index); uint16_t getSize() const override; - /** - * Writes the content into telegram. - * Returns true if successful. - * - * @param a_telegram - */ - bool saveContent(LogViewTelegram *a_telegram) override; + + + bool saveContent(LogViewTelegram* a_telegram) override; protected slots: void checkAndOvertakeContent(); + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewField.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewField.hpp index d937ea014..473c9ce43 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewField.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewField.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include @@ -34,7 +34,7 @@ namespace N_LogView }; - LogViewField(const QString &a_name, const E_FieldKind a_kind, const LogViewXdrElement *a_xdrElement); + LogViewField(const QString& a_name, const E_FieldKind a_kind, const LogViewXdrElement* a_xdrElement); virtual ~LogViewField(); LogViewField *clone(int arrayIdx) const; @@ -44,7 +44,7 @@ namespace N_LogView void setName(const QString &newVal) { m_Name = newVal; } - void addChild(LogViewField *a_child); + void addChild(LogViewField* a_child); void removeLastChild(); LogViewField *child(int arrayIdx); int childCount() const { return m_Child.size(); } @@ -57,15 +57,8 @@ namespace N_LogView void addValue(const QString &value); void addValueBinaryHex(const QString &value); - /** - * Returns the value at position a_index converted to a string. If the field is a - * date-time-field, the returned value is converted to a string containing date - * and time, execpt when a_doNotMakeSpecialConversions is set to true, the unix- - * time will be returned as value. - * - * @param a_index - * @param a_doNotMakeSpecialConversions - */ + + QString value(int arrayIdx, const bool a_doNotMakeSpecialConversions = false) const; int valueListSize() const { return m_ValueList.size(); } @@ -81,21 +74,12 @@ namespace N_LogView int64_t getHighestValue() const; int64_t getLowestValue() const; - /** - * - * @param a_indent - */ + + void dump(const QString &a_indent = QString()) const; - /** - * Makes the text pretty for human readable. It does following: - * - generates umlaute (ä, ö, ü) - * - removes _rt at end - * - replaces _ with space - * - uppercase of every word - * - * @param a_uncleanText - */ + + static QString makeClean(const QString &text); @@ -103,11 +87,10 @@ namespace N_LogView void setSize(int newVal) { m_Size = newVal; } - const LogViewXdrElement *xdrElement() const { return m_XdrElement; } + const LogViewXdrElement* xdrElement() const { return m_XdrElement; } + + - /** - * returns true if the field is a date-time - */ bool isDateTimeField() const; bool isMSecsField() const; @@ -115,9 +98,8 @@ namespace N_LogView uint16_t maxArraySize() const { return m_MaxArraySize; } void setMaxArraySize(uint16_t newVal, const bool a_isDynamic); - /** - * True if the array is dynamic. - */ + + bool isDynamicArray() const { return m_IsDynamicArray; } @@ -130,7 +112,6 @@ namespace N_LogView QStringList jsonPath() const { return m_jsonPath; } protected: - NGL::INGLLogger &m_logger; QString m_Name; QString m_type; @@ -141,13 +122,12 @@ namespace N_LogView uint16_t m_Offset; int m_Size; uint16_t m_MaxArraySize; - /** - * True if the array is dynamic. - */ + + bool m_IsDynamicArray; bool m_HasContent; bool m_bDeleteXdr; - QVector m_Child; + QVector m_Child; E_FieldKind m_Kind; diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewInjectionThread.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewInjectionThread.hpp index 88e0409ef..af94bc3c9 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewInjectionThread.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewInjectionThread.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include @@ -24,15 +24,13 @@ namespace N_LogView { class LogViewTelegram; - /** - * @author alois.wismer - * @version 1.0 - * @created 05-Aug-2010 16:02:15 - */ + + class LogViewInjectionThread : public QThread { Q_OBJECT public: + LogViewInjectionThread(); void run(); @@ -41,15 +39,12 @@ namespace N_LogView bool isSendingPossible() const; - /** - * - * @param a_telegram - * @param a_doSendAsCentralTelegram - */ - void sendTelegram(LogViewTelegram *a_telegram, const bool a_doSendAsCentralTelegram); + + + void sendTelegram(LogViewTelegram* a_telegram, const bool a_doSendAsCentralTelegram); protected: - NGL::INGLLogger &m_logger; + bool m_DoStartConnection; bool m_SendingPossible; QString m_Hostname; @@ -72,12 +67,10 @@ namespace N_LogView public: signals: - /** - * - * @param a_picName - * @param a_toolTipText - */ - void updateStatus(const QString &a_picName, const QString &a_toolTipText); + + + void updateStatus(const QString& a_picName, const QString& a_toolTipText); + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewModels.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewModels.hpp index 634193d68..3e0419915 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewModels.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewModels.hpp @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * some models for LogViewGui - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #pragma once @@ -21,95 +16,94 @@ namespace N_LogView { - class ParticipantModel final : public QAbstractTableModel - { - Q_OBJECT - public: - using QAbstractTableModel::QAbstractTableModel; +class ParticipantModel final : public QAbstractTableModel +{ + Q_OBJECT +public: + using QAbstractTableModel::QAbstractTableModel; - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; - void clearParticipants(); - bool addUpdateParticipants(const QVector &eqIds, const QVector &issis, const QVector &numberOfTelegrams); + void clearParticipants(); + bool addUpdateParticipants(const QVector &eqIds, + const QVector &issis, + const QVector &numberOfTelegrams); +protected: + void updateHeatMap() const; +protected: + + QVector > m_particpants; + + QHash m_particpantMap; + + mutable QHash m_participantHeatmap; +}; - protected: - void updateHeatMap() const; +class TelegramModel final : public QAbstractTableModel +{ + Q_OBJECT +public: + using QAbstractTableModel::QAbstractTableModel; - protected: - // eqId , issi - QVector> m_particpants; - // eqid, count telegrams - QHash m_particpantMap; - // eqId, QColor for heatmap - mutable QHash m_participantHeatmap; - }; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; - class TelegramModel final : public QAbstractTableModel - { - Q_OBJECT - public: - using QAbstractTableModel::QAbstractTableModel; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + void clearTelegrams(); + void appendTelegrams(const QVector > &telegrams); + void appendTelegram(const QSharedPointer &telegram); + QSharedPointer telegram(int row) const; +protected: + QVector > m_telegrams; +}; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; +class TelegramProxyModel final : public QSortFilterProxyModel +{ + Q_OBJECT +public: + using QSortFilterProxyModel::QSortFilterProxyModel; - void clearTelegrams(); - void appendTelegrams(const QVector> &telegrams); - void appendTelegram(const QSharedPointer &telegram); - QSharedPointer telegram(int row) const; + void setFilterByEquipmentIds(bool bFilterByEquipmentIds); + void setAllowedEquipmentIds(const std::set &allowedEquipmentIds); - protected: - QVector> m_telegrams; - }; + void setFilteredCentralTelegramIds(const std::set &filteredCentralTelegramIds); + void setFilteredTetraTelegramIds(const std::set &filteredTetraTelegramIds); + void setFilteredWlsTelegramIds(const std::set &filteredWlsTelegramIds); - class TelegramProxyModel final : public QSortFilterProxyModel - { - Q_OBJECT - public: - using QSortFilterProxyModel::QSortFilterProxyModel; + void setFilterCentralTelegrams(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol direction, bool bFilter); + void setFilterTetraTelegrams(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol direction, bool bFilter); + void setFilterTetraPDU(N_CoPrtCnv::CoPrtCnvRadioTelegram::E_PDU_Type pduType, bool bFilter); + void setFilterWlsTelegrams(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol direction, bool bFilter); - void setFilterByEquipmentIds(bool bFilterByEquipmentIds); - void setAllowedEquipmentIds(const std::set &allowedEquipmentIds); + void setFilterTetraLogin(bool bFilter); + void setFilterTetraFragmented(bool bFilter); - void setFilteredCentralTelegramIds(const std::set &filteredCentralTelegramIds); - void setFilteredTetraTelegramIds(const std::set &filteredTetraTelegramIds); - void setFilteredWlsTelegramIds(const std::set &filteredWlsTelegramIds); + QSharedPointer telegram(int row) const; +protected: + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; +protected: + std::set m_allowedEquipmentIds; + std::set m_filteredCentralTelegramIds; + std::set m_filteredTetraTelegramIds; + std::set m_filteredWlsTelegramIds; + bool m_bFilterByEquipmentIds = false; + bool m_bFilterLoginTelegrams = false; + bool m_bFilterFragmentedTelegrams = false; + std::set m_filterCentralTelegrams; + std::set m_filterTetraTelegrams; + std::set m_filterWlsTelegrams; + std::set m_filterTetraPDU; +}; - void setFilterCentralTelegrams(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol direction, bool bFilter); - void setFilterTetraTelegrams(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol direction, bool bFilter); - void setFilterTetraPDU(N_CoPrtCnv::CoPrtCnvRadioTelegram::E_PDU_Type pduType, bool bFilter); - void setFilterWlsTelegrams(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol direction, bool bFilter); - - void setFilterTetraLogin(bool bFilter); - void setFilterTetraFragmented(bool bFilter); - - QSharedPointer telegram(int row) const; - - protected: - bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; - bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; - - protected: - std::set m_allowedEquipmentIds; - std::set m_filteredCentralTelegramIds; - std::set m_filteredTetraTelegramIds; - std::set m_filteredWlsTelegramIds; - bool m_bFilterByEquipmentIds = false; - bool m_bFilterLoginTelegrams = false; - bool m_bFilterFragmentedTelegrams = false; - std::set m_filterCentralTelegrams; - std::set m_filterTetraTelegrams; - std::set m_filterWlsTelegrams; - std::set m_filterTetraPDU; - }; - -} // namespace N_LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.cpp index 1b3dd134f..59edcb395 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.cpp @@ -1,15 +1,15 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewOptionDialog.hpp" #include @@ -28,153 +28,155 @@ namespace N_LogView { - // static member initialization - const QString LogViewOptionDialog::SPEC_FILES = tr("Spezifikations-Dateien (*.x)"); - const QString LogViewOptionDialog::KRLOG_FILES = tr("Log-Dateien (*.krlog)"); - const QLatin1String LogViewOptionDialog::SPEC_FILES_GROUP("SpecFiles"); - const QLatin1String LogViewOptionDialog::DIR("Dir"); - const QLatin1String LogViewOptionDialog::P0_FILENAME("Central2PrtCnv"); - const QLatin1String LogViewOptionDialog::P5_FILENAME("PrtCnv2TETRA"); - const QLatin1String LogViewOptionDialog::SERVER_GROUP("ServerPorts"); - const QLatin1String LogViewOptionDialog::CENTRAL_PORT("Central"); - const QLatin1String LogViewOptionDialog::TETRA_PORT("Tetra"); - const QLatin1String LogViewOptionDialog::LOG_FILENAME("LogFilename"); - const QLatin1String LogViewOptionDialog::INJECTION_GROUP("InjectionServer"); - const QLatin1String LogViewOptionDialog::INJECTION_HOSTNAME("InjectionHostname"); - const QLatin1String LogViewOptionDialog::INJECTION_PORT("InjectionPort"); + +const QString LogViewOptionDialog::SPEC_FILES = tr("Spezifikations-Dateien (*.x)"); +const QString LogViewOptionDialog::KRLOG_FILES = tr("Log-Dateien (*.krlog)"); +const QLatin1String LogViewOptionDialog::SPEC_FILES_GROUP("SpecFiles"); +const QLatin1String LogViewOptionDialog::DIR("Dir"); +const QLatin1String LogViewOptionDialog::P0_FILENAME("Central2PrtCnv"); +const QLatin1String LogViewOptionDialog::P5_FILENAME("PrtCnv2TETRA"); +const QLatin1String LogViewOptionDialog::SERVER_GROUP("ServerPorts"); +const QLatin1String LogViewOptionDialog::CENTRAL_PORT("Central"); +const QLatin1String LogViewOptionDialog::TETRA_PORT("Tetra"); +const QLatin1String LogViewOptionDialog::LOG_FILENAME("LogFilename"); +const QLatin1String LogViewOptionDialog::INJECTION_GROUP("InjectionServer"); +const QLatin1String LogViewOptionDialog::INJECTION_HOSTNAME("InjectionHostname"); +const QLatin1String LogViewOptionDialog::INJECTION_PORT("InjectionPort"); - // --------------------------------------------------------------- - LogViewOptionDialog::LogViewOptionDialog(QWidget *a_parent) - : QDialog(a_parent) + +LogViewOptionDialog::LogViewOptionDialog(QWidget* a_parent) + : QDialog(a_parent) +{ + QVBoxLayout* layout = new QVBoxLayout(this); + + + m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); + QGroupBox* groupBox = new QGroupBox(tr("Telegramm-Spezifikations-Dateien"), this); + layout->addWidget(groupBox); + + QGridLayout* groupLayout = new QGridLayout(); + + QLabel* p0Label = new QLabel(tr("&Zentrale - Protokollkonverter"), this); + groupLayout->addWidget(p0Label, 0, 0, 1, 2); + QString defString = QCoreApplication::applicationDirPath() + QLatin1String("/training_area_telegrams.h"); + m_P0Edit = new QLineEdit(m_Settings.value(P0_FILENAME, defString).toString(), this); + m_P0Edit->setMinimumWidth(400); + groupLayout->addWidget(m_P0Edit); + QPushButton* p0Browse = new QPushButton(tr("Browse"), this); + p0Label->setBuddy(p0Browse); + connect(p0Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP0File); + groupLayout->addWidget(p0Browse, 1, 1); + + QLabel* p5Label = new QLabel(tr("Protokollkonverter - &TETRA"), this); + groupLayout->addWidget(p5Label, 2, 0, 1, 2); + defString = QCoreApplication::applicationDirPath() + QLatin1String("/zsksxd_tetraForLogView.x"); + m_P5Edit = new QLineEdit(m_Settings.value(P5_FILENAME, defString).toString(), this); + groupLayout->addWidget(m_P5Edit); + QPushButton* p5Browse = new QPushButton(tr("Browse"), this); + p5Label->setBuddy(p5Browse); + connect(p5Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP5File); + groupLayout->addWidget(p5Browse, 3, 1); + + groupBox->setLayout(groupLayout); + m_Settings.endGroup(); + + + m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP); + groupBox = new QGroupBox(tr("Telegram Injection Server"), this); + layout->addWidget(groupBox); + QGridLayout* injectLayout = new QGridLayout(); + + QLabel* injectPortLabel = new QLabel(tr("Port"), this); + injectLayout->addWidget(injectPortLabel, 1, 0); + m_InjectPortEdit = new QLineEdit(m_Settings.value(INJECTION_PORT).toString(), this); + QIntValidator* validator = new QIntValidator(1024, 65535, this); + m_InjectPortEdit->setValidator(validator); + injectLayout->addWidget(m_InjectPortEdit, 1, 1); + + QLabel* injectHostnameLabel = new QLabel(tr("Hostname"), this); + injectLayout->addWidget(injectHostnameLabel, 0, 0); + m_InjectHostnameEdit = new QLineEdit(m_Settings.value(INJECTION_HOSTNAME).toString(), this); + injectLayout->addWidget(m_InjectHostnameEdit, 0, 1); + + groupBox->setLayout(injectLayout); + m_Settings.endGroup(); + + + layout->addStretch(); + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &LogViewOptionDialog::save); + connect(buttonBox, &QDialogButtonBox::rejected, this, &LogViewOptionDialog::reject); + layout->addWidget(buttonBox); + + +} + + + +void LogViewOptionDialog::browseP0File() +{ + QString newFilename = QFileDialog::getOpenFileName(this, + tr("Zentrale - Protokollkonverter Spezifikations-Datei"), + m_Settings.value(DIR).toString(), + tr("TrainingArea Telegram Headerdatei (training_area_telegrams.h)")); + if (!newFilename.isEmpty()) { - QVBoxLayout *layout = new QVBoxLayout(this); - - // telegram specification files + m_P0Edit->setText(newFilename); + QDir dir; m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); - QGroupBox *groupBox = new QGroupBox(tr("Telegramm-Spezifikations-Dateien"), this); - layout->addWidget(groupBox); - - QGridLayout *groupLayout = new QGridLayout(); - - QLabel *p0Label = new QLabel(tr("&Zentrale - Protokollkonverter"), this); - groupLayout->addWidget(p0Label, 0, 0, 1, 2); - QString defString = QCoreApplication::applicationDirPath() + QLatin1String("/training_area_telegrams.h"); - m_P0Edit = new QLineEdit(m_Settings.value(P0_FILENAME, defString).toString(), this); - m_P0Edit->setMinimumWidth(400); - groupLayout->addWidget(m_P0Edit); - QPushButton *p0Browse = new QPushButton(tr("Browse"), this); - p0Label->setBuddy(p0Browse); - connect(p0Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP0File); - groupLayout->addWidget(p0Browse, 1, 1); - - QLabel *p5Label = new QLabel(tr("Protokollkonverter - &TETRA"), this); - groupLayout->addWidget(p5Label, 2, 0, 1, 2); - defString = QCoreApplication::applicationDirPath() + QLatin1String("/zsksxd_tetraForLogView.x"); - m_P5Edit = new QLineEdit(m_Settings.value(P5_FILENAME, defString).toString(), this); - groupLayout->addWidget(m_P5Edit); - QPushButton *p5Browse = new QPushButton(tr("Browse"), this); - p5Label->setBuddy(p5Browse); - connect(p5Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP5File); - groupLayout->addWidget(p5Browse, 3, 1); - - groupBox->setLayout(groupLayout); + m_Settings.setValue(DIR, dir.filePath(newFilename)); m_Settings.endGroup(); - - // injection - m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP); - groupBox = new QGroupBox(tr("Telegram Injection Server"), this); - layout->addWidget(groupBox); - QGridLayout *injectLayout = new QGridLayout(); - - QLabel *injectPortLabel = new QLabel(tr("Port"), this); - injectLayout->addWidget(injectPortLabel, 1, 0); - m_InjectPortEdit = new QLineEdit(m_Settings.value(INJECTION_PORT).toString(), this); - QIntValidator *validator = new QIntValidator(1024, 65535, this); - m_InjectPortEdit->setValidator(validator); - injectLayout->addWidget(m_InjectPortEdit, 1, 1); - - QLabel *injectHostnameLabel = new QLabel(tr("Hostname"), this); - injectLayout->addWidget(injectHostnameLabel, 0, 0); - m_InjectHostnameEdit = new QLineEdit(m_Settings.value(INJECTION_HOSTNAME).toString(), this); - injectLayout->addWidget(m_InjectHostnameEdit, 0, 1); - - groupBox->setLayout(injectLayout); - m_Settings.endGroup(); - - // buttons - layout->addStretch(); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - connect(buttonBox, &QDialogButtonBox::accepted, this, &LogViewOptionDialog::save); - connect(buttonBox, &QDialogButtonBox::rejected, this, &LogViewOptionDialog::reject); - layout->addWidget(buttonBox); - - //setLayout(layout); } +} - // --------------------------------------------------------------- - void LogViewOptionDialog::browseP0File() + +void LogViewOptionDialog::browseP5File() +{ + QString newFilename = QFileDialog::getOpenFileName(this, tr("Protokollkonverter - TETRA Spezifikations-Datei"), m_Settings.value(DIR).toString(), SPEC_FILES); + if (!newFilename.isEmpty()) { - QString newFilename = QFileDialog::getOpenFileName(this, - tr("Zentrale - Protokollkonverter Spezifikations-Datei"), - m_Settings.value(DIR).toString(), - tr("TrainingArea Telegram Headerdatei (training_area_telegrams.h)")); - if (!newFilename.isEmpty()) - { - m_P0Edit->setText(newFilename); - QDir dir; - m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); - m_Settings.setValue(DIR, dir.filePath(newFilename)); - m_Settings.endGroup(); - } - } - - - // --------------------------------------------------------------- - void LogViewOptionDialog::browseP5File() - { - QString newFilename = QFileDialog::getOpenFileName(this, tr("Protokollkonverter - TETRA Spezifikations-Datei"), m_Settings.value(DIR).toString(), SPEC_FILES); - if (!newFilename.isEmpty()) - { - m_P5Edit->setText(newFilename); - QDir dir; - m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); - m_Settings.setValue(DIR, dir.filePath(newFilename)); - m_Settings.endGroup(); - } - } - - // --------------------------------------------------------------- - void LogViewOptionDialog::save() - { - uint32_t changedFlags = 0; - - // check group wise for changes - // specification files + m_P5Edit->setText(newFilename); + QDir dir; m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); - QString string = m_Settings.value(P0_FILENAME).toString(); - if ((string != m_P0Edit->text()) || (m_Settings.value(P5_FILENAME).toString() != m_P5Edit->text())) - { - m_Settings.setValue(P0_FILENAME, m_P0Edit->text()); - m_Settings.setValue(P5_FILENAME, m_P5Edit->text()); - changedFlags |= SpecFilesGroup; - } + m_Settings.setValue(DIR, dir.filePath(newFilename)); m_Settings.endGroup(); - - // injection settings - m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP); - if ((m_Settings.value(INJECTION_HOSTNAME).toString() != m_InjectHostnameEdit->text()) || (m_Settings.value(INJECTION_PORT).toString() != m_InjectPortEdit->text())) - { - m_Settings.setValue(INJECTION_HOSTNAME, m_InjectHostnameEdit->text()); - m_Settings.setValue(INJECTION_PORT, m_InjectPortEdit->text()); - changedFlags |= InjectionGroup; - } - m_Settings.endGroup(); - - emit settingsChanged(changedFlags); - - accept(); } +} -} // namespace N_LogView + +void LogViewOptionDialog::save() +{ + uint32_t changedFlags = 0; + + + + m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); + QString string = m_Settings.value(P0_FILENAME).toString(); + if ((string != m_P0Edit->text()) || + (m_Settings.value(P5_FILENAME).toString() != m_P5Edit->text())) + { + m_Settings.setValue(P0_FILENAME, m_P0Edit->text()); + m_Settings.setValue(P5_FILENAME, m_P5Edit->text()); + changedFlags |= SpecFilesGroup; + } + m_Settings.endGroup(); + + + m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP); + if ((m_Settings.value(INJECTION_HOSTNAME).toString() != m_InjectHostnameEdit->text()) || + (m_Settings.value(INJECTION_PORT).toString() != m_InjectPortEdit->text())) + { + m_Settings.setValue(INJECTION_HOSTNAME, m_InjectHostnameEdit->text()); + m_Settings.setValue(INJECTION_PORT, m_InjectPortEdit->text()); + changedFlags |= InjectionGroup; + } + m_Settings.endGroup(); + + emit settingsChanged(changedFlags); + + accept(); +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.hpp index e8e775e38..bea0b03a4 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewOptionDialog.hpp @@ -1,15 +1,15 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once @@ -20,64 +20,58 @@ class QLineEdit; namespace N_LogView { - /** - * This class lets the user view and change the settings of the application - * - * @author alois.wismer - * @version 1.0 - * @created 09-Mrz-2010 14:49:40 - */ - class LogViewOptionDialog : public QDialog - { - Q_OBJECT - public: - enum SettingsChangedFlag - { - SpecFilesGroup = 0x01, - ServerGroup = 0x02, - InjectionGroup = 0x04 - }; - - static const QString KRLOG_FILES; - static const QLatin1String SPEC_FILES_GROUP; - static const QLatin1String P0_FILENAME; - static const QLatin1String P5_FILENAME; - static const QLatin1String SERVER_GROUP; - static const QLatin1String CENTRAL_PORT; - static const QLatin1String TETRA_PORT; - static const QLatin1String SIZE; - static const QLatin1String POS; - static const QLatin1String CENTRAL_IS_SERVER; - static const QLatin1String CENTRAL_HOSTNAME; - static const QLatin1String LOG_FILENAME; - static const QLatin1String INJECTION_GROUP; - static const QLatin1String INJECTION_HOSTNAME; - static const QLatin1String INJECTION_PORT; - /** - * - * @param a_parent a_parent - */ - explicit LogViewOptionDialog(QWidget *a_parent); +class LogViewOptionDialog : public QDialog +{ + Q_OBJECT +public: - signals: - void settingsChanged(uint32_t changed); // bitfield of SettingsChangedFlag enum - - protected: - static const QString SPEC_FILES; - static const QLatin1String DIR; - bool m_IsServer; - QLineEdit *m_P0Edit; - QLineEdit *m_P5Edit; - QSettings m_Settings; - QLineEdit *m_InjectHostnameEdit; - QLineEdit *m_InjectPortEdit; - - protected slots: - void browseP0File(); - void browseP5File(); - void save(); + enum SettingsChangedFlag { + SpecFilesGroup = 0x01, + ServerGroup = 0x02, + InjectionGroup = 0x04 }; + static const QString KRLOG_FILES; + static const QLatin1String SPEC_FILES_GROUP; + static const QLatin1String P0_FILENAME; + static const QLatin1String P5_FILENAME; + static const QLatin1String SERVER_GROUP; + static const QLatin1String CENTRAL_PORT; + static const QLatin1String TETRA_PORT; + static const QLatin1String SIZE; + static const QLatin1String POS; + static const QLatin1String CENTRAL_IS_SERVER; + static const QLatin1String CENTRAL_HOSTNAME; + static const QLatin1String LOG_FILENAME; + static const QLatin1String INJECTION_GROUP; + static const QLatin1String INJECTION_HOSTNAME; + static const QLatin1String INJECTION_PORT; + + + + + explicit LogViewOptionDialog(QWidget* a_parent); + +signals: + void settingsChanged(uint32_t changed); + +protected: + + static const QString SPEC_FILES; + static const QLatin1String DIR; + bool m_IsServer; + QLineEdit *m_P0Edit; + QLineEdit *m_P5Edit; + QSettings m_Settings; + QLineEdit *m_InjectHostnameEdit; + QLineEdit *m_InjectPortEdit; + +protected slots: + void browseP0File(); + void browseP5File(); + void save(); +}; + } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.cpp index c72bf2725..904caa08c 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.cpp @@ -1,58 +1,59 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewSpinBox.hpp" #include "LogViewField.hpp" namespace N_LogView { - // --------------------------------------------------------------- - LogViewSpinBox::LogViewSpinBox(LogViewField *a_field, QWidget *a_parent, const int a_value) - : QSpinBox(a_parent) - , LogViewWidget(a_field, this, a_parent, false) - { - // set range - uint16_t maxArraySize = a_field->maxArraySize(); - setRange(0, maxArraySize); - // set the actual value - setValue(a_value); +LogViewSpinBox::LogViewSpinBox(LogViewField* a_field, QWidget* a_parent, const int a_value) + : QSpinBox(a_parent) + , LogViewWidget(a_field, this, a_parent, false) +{ + + uint16_t maxArraySize = a_field->maxArraySize(); + setRange(0, maxArraySize); - // set tooltip-text - setToolTip(tr("Wertebereich: 0..%1").arg(maxArraySize)); + + setValue(a_value); - // connect - connect(this, &LogViewSpinBox::editingFinished, this, &LogViewSpinBox::finishEditing); - } + + setToolTip(tr("Wertebereich: 0..%1").arg(maxArraySize)); + + + connect(this, &LogViewSpinBox::editingFinished, + this, &LogViewSpinBox::finishEditing); +} - // --------------------------------------------------------------- - void LogViewSpinBox::finishEditing() - { - emit valueEditingFinished(text().toInt()); - } + +void LogViewSpinBox::finishEditing() +{ + emit valueEditingFinished(text().toInt()); +} - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewSpinBox::saveContent(LogViewTelegram *a_telegram) - { - Q_UNUSED(a_telegram); - // not yet implemented - return false; - } -} // namespace N_LogView + + + +bool LogViewSpinBox::saveContent(LogViewTelegram* a_telegram) +{ + Q_UNUSED(a_telegram); + + return false; +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.hpp index 803da0bf0..8cf3d0e94 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewSpinBox.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include @@ -18,44 +18,28 @@ namespace N_LogView { - /** - * Used for changing size of dyn. arrays. - * - * @author alois.wismer - * @version 1.0 - * @created 25-Mai-2010 10:39:45 - */ - class LogViewSpinBox - : public QSpinBox - , public LogViewWidget + + + class LogViewSpinBox : public QSpinBox, public LogViewWidget { Q_OBJECT public: - /** - * - * @param a_field - * @param a_parent - * @param a_value - */ - LogViewSpinBox(LogViewField *a_field, QWidget *a_parent, const int a_value); + - /** - * Writes the content into telegram. - * Returns true if successful. - * - * @param a_telegram - */ - bool saveContent(LogViewTelegram *a_telegram) override; + LogViewSpinBox(LogViewField* a_field, QWidget* a_parent, const int a_value); + + + + bool saveContent(LogViewTelegram* a_telegram) override; protected slots: void finishEditing(); signals: - /** - * - * @param a_newValue - */ + + void valueEditingFinished(int a_newValue); + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.cpp index 03a44ef5e..220b7effd 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.cpp @@ -1,15 +1,15 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewTabWidget.hpp" #include @@ -25,116 +25,115 @@ namespace N_LogView { - LogViewTabWidget::LogViewTabWidget(LogViewField *a_field, LogViewTelegramDialog *a_parent, LogViewSpinBox *a_spinBox, NGL::INGLLogger &logger) - : QTabWidget(a_parent) - , LogViewWidget(a_field, this, a_parent, false) - , m_TelegramDialog(a_parent) - , m_SpinBox(a_spinBox) - , m_logger(logger) +LogViewTabWidget::LogViewTabWidget(LogViewField* a_field, LogViewTelegramDialog* a_parent, LogViewSpinBox* a_spinBox) + : QTabWidget(a_parent) + , LogViewWidget(a_field, this, a_parent, false) + , m_TelegramDialog(a_parent) + , m_SpinBox(a_spinBox) +{ + setVisible(false); +} + + + +void LogViewTabWidget::changeSize(const int a_newSize) +{ + + for (int i = count(); i < a_newSize; i++) + addTab(m_Field, true, i); + + + while (count() > a_newSize) { - setVisible(false); + QStringList path = m_Field->jsonPath(); + path += QStringLiteral("index: %1").arg(count() - 1); + m_TelegramDialog->removeItemsFromEditInfoList(path); + removeTab(count() - 1); } + while (m_Field->childCount() > a_newSize) + m_Field->removeLastChild(); - // --------------------------------------------------------------- - void LogViewTabWidget::changeSize(const int a_newSize) - { - // add new tabs - for (int i = count(); i < a_newSize; i++) - addTab(m_Field, true, i); - - // remove old tabs - while (count() > a_newSize) - { - QStringList path = m_Field->jsonPath(); - path += QStringLiteral("index: %1").arg(count() - 1); - m_TelegramDialog->removeItemsFromEditInfoList(path); - removeTab(count() - 1); - } - while (m_Field->childCount() > a_newSize) - m_Field->removeLastChild(); + setVisible(a_newSize > 0); + m_TelegramDialog->makePretty(); +} - setVisible(a_newSize > 0); - m_TelegramDialog->makePretty(); // fixme: funktioniert so nicht, muss als signal realisiert werden - } - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewTabWidget::saveContent(LogViewTelegram *a_telegram) - { - if (a_telegram->isJsonTelegram()) - return true; - // if m_SpinBox is NULL, we have a static array => no size has to be stored - if (m_SpinBox) - { - if (!isValid()) - return false; - a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, count()); - } + + +bool LogViewTabWidget::saveContent(LogViewTelegram* a_telegram) +{ + if (a_telegram->isJsonTelegram()) return true; - } - - - // --------------------------------------------------------------- - void LogViewTabWidget::addTab(LogViewField *a_field, const bool a_isEmpty, int arrayIdx) + + if (m_SpinBox) { - if (arrayIdx < 0) - { - WARNING_LOG(m_logger) << "Invalid array index given: " << arrayIdx; - return; - } + if (!isValid()) + return false; + a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, count()); + } + return true; +} - QFrame *frame = new QFrame; - QGridLayout *box = new QGridLayout(frame); - QTabWidget::addTab(frame, QStringLiteral("%1 %2").arg(a_field->cleanName()).arg(count() + 1)); - if (a_isEmpty) - a_field->setHasContent(false); - auto *childTree = a_field->child(arrayIdx); - while (!childTree) - { - const auto *first = a_field->child(0); - if (first) - { - LogViewField *fNew = first->clone(arrayIdx); - a_field->addChild(fNew); - childTree = a_field->child(arrayIdx); - } - else - { - LogViewTetraTelegramsParser *p = LogViewTelegram::jsonParser(); - const StructInformation si = p->structFromType(a_field->type()); - if (si.type != a_field->type()) - { - WARNING_LOG(m_logger) << "Could not find type '" << a_field->type() << "' - can not add substructure"; - return; - } - LogViewField *tc = new LogViewField(a_field->name() + QStringLiteral("TabChild"), LogViewField::e_FieldKindTabChild, a_field->xdrElement()); - tc->setJsonPath(a_field->jsonPath()); - a_field->addChild(tc); - const QString path(QStringLiteral("index: %1")); - LogViewTelegram::addFieldTreeStruct(QJsonObject(), tc, si, path.arg(arrayIdx), m_logger); - childTree = a_field->child(arrayIdx); - } - } - m_TelegramDialog->showTree(childTree, box); - // todo: sind nach dem dyn. array noch weitere Felder, so wird addTab nicht richtig funktionieren, weil die - // neuen Felder des Tabs am Ende von m_EditInfoList hinzugefügt werden => diese müssen mittendrin (an der richtigen - // position) eingefügt werden. - // update spinbox - if (m_SpinBox) - { - int spinValue = m_SpinBox->value(); - if (spinValue < count()) - m_SpinBox->setValue(count()); - } - - setVisible(true); +void LogViewTabWidget::addTab(LogViewField* a_field, const bool a_isEmpty, int arrayIdx) +{ + if (arrayIdx < 0) + { + WARNING_LOG(m_logger) << "Invalid array index given: " << arrayIdx; + return; } -} // namespace N_LogView + QFrame *frame = new QFrame; + QGridLayout *box = new QGridLayout(frame); + QTabWidget::addTab(frame, QStringLiteral("%1 %2").arg(a_field->cleanName()).arg(count()+1)); + if (a_isEmpty) + a_field->setHasContent(false); + auto *childTree = a_field->child(arrayIdx); + while (!childTree) + { + const auto *first = a_field->child(0); + if (first) + { + LogViewField *fNew = first->clone(arrayIdx); + a_field->addChild(fNew); + childTree = a_field->child(arrayIdx); + } + else + { + LogViewTetraTelegramsParser *p = LogViewTelegram::jsonParser(); + const StructInformation si = p->structFromType(a_field->type()); + if (si.type != a_field->type()) + { + WARNING_LOG(m_logger) << "Could not find type '" << a_field->type() << "' - can not add substructure"; + return; + } + LogViewField *tc = new LogViewField(a_field->name() + QStringLiteral("TabChild"), LogViewField::e_FieldKindTabChild, a_field->xdrElement()); + tc->setJsonPath(a_field->jsonPath()); + a_field->addChild(tc); + const QString path(QStringLiteral("index: %1")); + LogViewTelegram::addFieldTreeStruct(QJsonObject(), tc, si, path.arg(arrayIdx), m_logger); + childTree = a_field->child(arrayIdx); + } + } + m_TelegramDialog->showTree(childTree, box); + + + + + + + if (m_SpinBox) + { + int spinValue = m_SpinBox->value(); + if (spinValue < count()) + m_SpinBox->setValue(count()); + } + + setVisible(true); +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.hpp index 14460cf17..070e281d5 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTabWidget.hpp @@ -1,21 +1,20 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include #include "LogViewWidget.hpp" -#include "logger.h" namespace N_LogView @@ -23,35 +22,28 @@ namespace N_LogView class LogViewTelegramDialog; class LogViewSpinBox; - /** - * Used for arrays of structures - * - * @author alois.wismer - * @version 1.0 - * @created 26-Mai-2010 17:12:30 - */ - class LogViewTabWidget - : public QTabWidget - , public LogViewWidget + + + class LogViewTabWidget : public QTabWidget, public LogViewWidget { Q_OBJECT public: - LogViewTabWidget(LogViewField *a_field, LogViewTelegramDialog *a_parent, LogViewSpinBox *a_spinBox, NGL::INGLLogger &logger); - bool saveContent(LogViewTelegram *a_telegram) override; - void addTab(LogViewField *a_field, const bool a_isEmpty, int arrayIdx); + LogViewTabWidget(LogViewField* a_field, LogViewTelegramDialog* a_parent, LogViewSpinBox* a_spinBox); + + bool saveContent(LogViewTelegram* a_telegram) override; + void addTab(LogViewField* a_field, const bool a_isEmpty, int arrayIdx); public slots: - /** - * - * @param a_newSize - */ + + void changeSize(const int a_newSize); protected: - LogViewTelegramDialog *m_TelegramDialog; - LogViewSpinBox *m_SpinBox; - NGL::INGLLogger &m_logger; + + LogViewTelegramDialog* m_TelegramDialog; + LogViewSpinBox* m_SpinBox; + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.cpp index d1b4a094d..51c8d4b3d 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.cpp @@ -1,17 +1,17 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** -// manual class headers + + + + + + + + + + + + + #include "LogViewTableWidget.hpp" #include "LogViewField.hpp" #include @@ -24,290 +24,288 @@ namespace N_LogView { - LogViewTableWidget::LogViewTableWidget(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, NGL::INGLLogger &logger) - : QTableWidget(0, 2, a_parent) - , LogViewWidget(a_field, this, a_parent, a_readonly) - , m_IsFloat(false) - , m_IsEnum(false) - , m_logger(logger) +LogViewTableWidget::LogViewTableWidget(LogViewField* a_field, QWidget* a_parent, const bool a_readonly) + : QTableWidget(0, 2, a_parent) + , LogViewWidget(a_field, this, a_parent, a_readonly) + , m_IsFloat(false) + , m_IsEnum(false) +{ + switch (m_Field->xdrElement()->getKind()) { - switch (m_Field->xdrElement()->getKind()) - { - case LogViewXdrElement::e_KindEnum: - m_IsEnum = true; - break; - default: - m_IsFloat = LogViewXdrStandardType::e_Float == static_cast(m_Field->xdrElement())->getValueKind(); - } - if (!m_IsFloat) - setColumnCount(3); - if (m_IsEnum) - setColumnCount(1); - - setHorizontalHeaderItem(0, new QTableWidgetItem(m_IsEnum ? tr("Enum") : tr("Dez"))); - if (!m_IsEnum) - { - setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Hex"))); - if (!m_IsFloat) - { - setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Bin"))); - } - } - setAlternatingRowColors(true); - - // make pretty - // horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); - - updateToolTip(); - - // for debugging only - // INFO_LOG(m_logger) << "type=" << static_cast(a_field->getXdrElement())->getValueKind(); - // INFO_LOG(m_logger) << "name=" << static_cast(a_field->getXdrElement())->getName().toStdString(); - // a_field->getXdrElement()->dump(); - - // fill in the values - // fixme: implementiere den Fall isHasContent() false - int nbrOfRows = a_field->valueListSize(); - setRowCount(nbrOfRows); - for (int i = 0; i < nbrOfRows; i++) - changeRow(i, a_field->value(i)); - - makePretty(); - - // connect signals - connect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent); + case LogViewXdrElement::e_KindEnum: + m_IsEnum = true; + break; + default: + m_IsFloat = LogViewXdrStandardType::e_Float == static_cast(m_Field->xdrElement())->getValueKind(); } + if (!m_IsFloat) + setColumnCount(3); + if (m_IsEnum) + setColumnCount(1); - - // --------------------------------------------------------------- - void LogViewTableWidget::changeSize(const int a_newSize) + setHorizontalHeaderItem(0, new QTableWidgetItem(m_IsEnum ? tr("Enum") : tr("Dez"))); + if (!m_IsEnum) { - setRowCount(a_newSize); - - disconnect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent); - // check and set the new fields - for (int i = 0; i < a_newSize; i++) - changeRow(i, QLatin1String("0")); - - connect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent); - - makePretty(); - - m_Valid = true; - } - - - // --------------------------------------------------------------- - void LogViewTableWidget::changeRow(const int a_rowIndex, const QString &a_value) - { - // INFO_LOG(m_logger) << "a_rowIndex=" << a_rowIndex << " a_value=" << a_value.toStdString(); - - if (m_IsEnum) - { - // enum - QWidget *enumItem = cellWidget(a_rowIndex, 0); - if (!enumItem) - setCellWidget(a_rowIndex, 0, new LogViewEnumEdit(m_Field, this, m_Readonly, a_rowIndex)); - } - else - { - QFont font; - font.setStyleHint(QFont::TypeWriter); - font.setFamily(QString()); - // decimal - QTableWidgetItem *decItem = item(a_rowIndex, 0); - if (!decItem) - { - decItem = new QTableWidgetItem(); - //decItem->setData(Qt::DisplayRole, 0); - decItem->setText(a_value); - decItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - if (!m_Readonly) - { - decItem->setFlags(decItem->flags() | Qt::ItemIsEditable); - } - decItem->setFont(font); - decItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); - setItem(a_rowIndex, 0, decItem); - } - - // hexadecimal - QTableWidgetItem *hexItem = item(a_rowIndex, 1); - if (!hexItem) - { - hexItem = new QTableWidgetItem(); - hexItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - hexItem->setFont(font); - hexItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); - setItem(a_rowIndex, 1, hexItem); - } - - // binary - if (!m_IsFloat) - { - QTableWidgetItem *binItem = item(a_rowIndex, 2); - if (!binItem) - { - binItem = new QTableWidgetItem(); - binItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - binItem->setFont(font); - binItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); - setItem(a_rowIndex, 2, binItem); - } - } - - // set the values - checkAndOvertakeContent(decItem); - makePretty(); - } - } - - - // --------------------------------------------------------------- - void LogViewTableWidget::checkAndOvertakeContent(QTableWidgetItem *a_changedItem) - { - if (a_changedItem->column() != 0) - return; - - int row = a_changedItem->row(); - QString text = a_changedItem->text(); - - - bool ok; - int64_t intValue = 0; - double floatValue = 0.0; - - // get the calculated and checked value - if (m_IsFloat) - floatValue = getFloat(text, (uint64_t &)intValue, ok, true); - else - intValue = getInteger(text, ok); - - // handle errors - if (!ok) - { - setFocus(); - // selectAll(); - setCurrentCell(row, 0); // todo: funktioniert nicht - return; - } - - // set the decimal value - QTableWidgetItem *decField = item(row, 0); - if (decField) - decField->setText(QString::number(m_IsFloat ? floatValue : intValue)); - - // set the hex value - QTableWidgetItem *hexField = item(row, 1); - if (hexField) - hexField->setText(toHex(intValue)); - - // set the binary value + setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Hex"))); if (!m_IsFloat) { - QTableWidgetItem *binField = item(row, 2); - if (binField) - binField->setText(toBin(intValue)); + setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Bin"))); } } + setAlternatingRowColors(true); + + - // --------------------------------------------------------------- - void LogViewTableWidget::makePretty() + updateToolTip(); + + + + + + + + + int nbrOfRows = a_field->valueListSize(); + setRowCount(nbrOfRows); + for (int i = 0; i < nbrOfRows; i++) + changeRow(i, a_field->value(i)); + + makePretty(); + + + connect(this, &LogViewTableWidget::itemChanged, + this, &LogViewTableWidget::checkAndOvertakeContent); +} + + + +void LogViewTableWidget::changeSize(const int a_newSize) +{ + setRowCount(a_newSize); + + disconnect(this, &LogViewTableWidget::itemChanged, + this, &LogViewTableWidget::checkAndOvertakeContent); + + for (int i = 0; i < a_newSize; i++) + changeRow(i, QLatin1String("0")); + + connect(this, &LogViewTableWidget::itemChanged, + this, &LogViewTableWidget::checkAndOvertakeContent); + + makePretty(); + + m_Valid = true; +} + + + +void LogViewTableWidget::changeRow(const int a_rowIndex, const QString& a_value) +{ + + + if (m_IsEnum) { - //horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); - resizeColumnsToContents(); - resizeRowsToContents(); - - // set the height of table-widget - //// QWidget* cellWdg = tableWidget->cellWidget(0, 0); - // int showRows = 7; - // if (m_Field->getValueListSize() < (showRows-1)) - // { - // showRows = m_Field->getValueListSize()+1; - // setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // } - // else - // { - // setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - // } - // setFixedHeight(showRows*tableWidget->rowHeight(0)); + + QWidget* enumItem = cellWidget(a_rowIndex, 0); + if (!enumItem) + setCellWidget(a_rowIndex, 0, new LogViewEnumEdit(m_Field, this, m_Readonly, a_rowIndex)); } - - - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewTableWidget::saveContent(LogViewTelegram *a_telegram) + else { - if (!isValid()) - return false; - - if (a_telegram->isJsonTelegram()) + QFont font; + font.setStyleHint(QFont::TypeWriter); + font.setFamily(QString()); + + QTableWidgetItem* decItem = item(a_rowIndex, 0); + if (!decItem) { - if (m_Field->kind() == LogViewField::e_FieldKindPodArray) + decItem = new QTableWidgetItem(); + + decItem->setText(a_value); + decItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + if (!m_Readonly) { - QJsonArray arr; - for (int i = 0; i < rowCount(); ++i) - arr += item(i, 0)->text().toInt(); - a_telegram->setJsonValue(m_Field->jsonPath(), arr); + decItem->setFlags(decItem->flags() | Qt::ItemIsEditable); } - else - { - QString value; - value.reserve(rowCount() * 2); - for (int i = 0; i < rowCount(); ++i) - { - int val = item(i, 0)->text().toInt(); - value += QStringLiteral("%1").arg(val, 2, 16, QLatin1Char('0')); - } - a_telegram->setJsonValue(m_Field->jsonPath(), value); - } - return true; + decItem->setFont(font); + decItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + setItem(a_rowIndex, 0, decItem); } - uint16_t arraySize; - if (m_Field->isDynamicArray()) + + QTableWidgetItem* hexItem = item(a_rowIndex, 1); + if (!hexItem) { - arraySize = rowCount(); - a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize); - // fixme: bei vielen Telegrammen muss Länge auf die Länge des Textes gesetzt werden. Dies kann nicht automatisch gemacht werden. Aber vielleicht kann man schauen, ob vor dem dyn. Array ein Feld Länge vorkommt, oder hartcodieren, oder konfigurierbaren + hexItem = new QTableWidgetItem(); + hexItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + hexItem->setFont(font); + hexItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + setItem(a_rowIndex, 1, hexItem); + } + + + if (!m_IsFloat) + { + QTableWidgetItem* binItem = item(a_rowIndex, 2); + if (!binItem) + { + binItem = new QTableWidgetItem(); + binItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + binItem->setFont(font); + binItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + setItem(a_rowIndex, 2, binItem); + } + } + + + checkAndOvertakeContent(decItem); + makePretty(); + } +} + + + +void LogViewTableWidget::checkAndOvertakeContent(QTableWidgetItem* a_changedItem) +{ + if (a_changedItem->column() != 0) return; + + int row = a_changedItem->row(); + QString text = a_changedItem->text(); + + + bool ok; + int64_t intValue = 0; + double floatValue = 0.0; + + + if (m_IsFloat) + floatValue = getFloat(text, (uint64_t&)intValue, ok, true); + else + intValue = getInteger(text, ok); + + + if (!ok) + { + setFocus(); + + setCurrentCell(row, 0); + return; + } + + + QTableWidgetItem* decField = item(row, 0); + if (decField) decField->setText(QString::number(m_IsFloat ? floatValue : intValue)); + + + QTableWidgetItem* hexField = item(row, 1); + if (hexField) hexField->setText(toHex(intValue)); + + + if (!m_IsFloat) + { + QTableWidgetItem* binField = item(row, 2); + if (binField) binField->setText(toBin(intValue)); + } +} + + + +void LogViewTableWidget::makePretty() +{ + + resizeColumnsToContents(); + resizeRowsToContents(); + + + + + + + + + + + + + + +} + + + + + + +bool LogViewTableWidget::saveContent(LogViewTelegram* a_telegram) +{ + if (!isValid()) + return false; + + if (a_telegram->isJsonTelegram()) + { + if (m_Field->kind() == LogViewField::e_FieldKindPodArray) + { + QJsonArray arr; + for (int i = 0; i < rowCount(); ++i) + arr += item(i, 0)->text().toInt(); + a_telegram->setJsonValue(m_Field->jsonPath(), arr); } else { - // todo: teste mit opaque[] - arraySize = m_Field->maxArraySize(); - } - // copy the data - INFO_LOG(m_logger) << "arraySize=" << arraySize; - for (int i = 0; i < arraySize; i++) - { - if (m_IsEnum) + QString value; + value.reserve(rowCount() * 2); + for (int i = 0; i < rowCount(); ++i) { - LogViewEnumEdit *enumEdit = dynamic_cast(cellWidget(i, 0)); - enumEdit->saveContent(a_telegram); - } - else - { - uint16_t size = getSize(); - QString text = item(i, 0)->text(); - if (!m_IsFloat) - { - a_telegram->setUIntX(size, text.toULong()); - } - else - { - const LogViewXdrStandardType *stdType = static_cast(m_Field->xdrElement()); - LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder(); - uint64_t hex; - getFloat(text, hex, m_Valid); - a_telegram->setUIntX(size, hex, byteOrder); - } + int val = item(i, 0)->text().toInt(); + value += QStringLiteral("%1").arg(val, 2, 16, QLatin1Char('0')); } + a_telegram->setJsonValue(m_Field->jsonPath(), value); } - return true; } -} // namespace N_LogView + uint16_t arraySize; + if (m_Field->isDynamicArray()) + { + arraySize = rowCount(); + a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize); + + } + else + { + + arraySize = m_Field->maxArraySize(); + } + + INFO_LOG(m_logger) << "arraySize=" << arraySize; + for (int i = 0; i < arraySize; i++) + { + if (m_IsEnum) + { + LogViewEnumEdit *enumEdit = dynamic_cast(cellWidget(i,0)); + enumEdit->saveContent(a_telegram); + } + else + { + uint16_t size = getSize(); + QString text = item(i, 0)->text(); + if (!m_IsFloat) + { + a_telegram->setUIntX(size, text.toULong()); + } + else + { + const LogViewXdrStandardType *stdType = static_cast(m_Field->xdrElement()); + LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder(); + uint64_t hex; + getFloat(text, hex, m_Valid); + a_telegram->setUIntX(size, hex, byteOrder); + } + } + } + + return true; +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.hpp index 458e4cd8f..9b48f3045 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTableWidget.hpp @@ -1,59 +1,46 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include #include "LogViewWidget.hpp" -#include "logger.h" namespace N_LogView { - /** - * Used for arrays of data (opaque) - * - * @author alois.wismer - * @version 1.0 - * @created 25-Mai-2010 09:34:24 - */ - class LogViewTableWidget - : public QTableWidget - , public LogViewWidget + + + class LogViewTableWidget : public QTableWidget, public LogViewWidget { Q_OBJECT public: - LogViewTableWidget(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, NGL::INGLLogger &logger); + LogViewTableWidget(LogViewField* a_field, QWidget* a_parent, const bool a_readonly); - /** - * Writes the content into telegram. - * Returns true if successful. - * - * @param a_telegram - */ - bool saveContent(LogViewTelegram *a_telegram) override; + + + bool saveContent(LogViewTelegram* a_telegram) override; public slots: void changeSize(const int a_newSize); protected: - void changeRow(const int a_rowIndex, const QString &a_value); + void changeRow(const int a_rowIndex, const QString& a_value); void makePretty(); protected slots: - void checkAndOvertakeContent(QTableWidgetItem *a_changedItem); + void checkAndOvertakeContent(QTableWidgetItem* a_changedItem); private: bool m_IsFloat; bool m_IsEnum; - NGL::INGLLogger &m_logger; }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegram.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegram.hpp index e8fcab481..da137bdb9 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegram.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegram.hpp @@ -1,15 +1,15 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once @@ -32,28 +32,14 @@ namespace N_LogView class LogViewTetraTelegramsParser; class LogViewXdrParser; class LogViewXdrType; - /** - * The header and the data of a logged or a edited telegram. - * - * Writing telegrams: - * 1. allocate a telegram with the constructor LogViewTelegram(N_CoPrtCnv:: - * CoPrtCnvLogHeader::e_DestProtocolCentral, telegramId) - * 2. prepare with resetOffset() - * 3. write data with setUIntX() - * 4. finish with setNewSize(); - * - * @author alois.wismer - * @version 1.0 - * @created 04-Feb-2010 13:15:43 - */ + + class LogViewTelegram final { public: - /** - * @author alois.wismer - * @version 1.0 - * @created 12-Mrz-2010 11:04:14 - */ + + + enum E_Validity { e_NotYetEvaluated, @@ -61,11 +47,8 @@ namespace N_LogView e_Invalid }; - /** - * @author alois.wismer - * @version 1.0 - * @created 05-Mai-2010 09:07:22 - */ + + enum E_Column { e_ColName, @@ -78,83 +61,55 @@ namespace N_LogView ~LogViewTelegram(); - /** - * The size of the field which defines the size of the dyn. array for central- - * telegrams - */ + + static const uint16_t SIZE_CENTRAL_DYN_ARRAY_SIZE; - /** - * Copy ctor - */ + + LogViewTelegram(const LogViewTelegram &o); - // no assignment (needed) + LogViewTelegram &operator=(const LogViewTelegram &o) = delete; - /** - * Constructor for new telegrams (only receive central-telegrams are allowd), - * which will be edited - * - * @param a_destination - * @param a_telId - */ - LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination, int telegramId); + - /** - * Constructor for existing telegrams - * - * @param a_destination - * @param a_unixTime - * @param a_telegramData - * @param a_telegramSize - */ - LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination, const quint64 a_unixTime, const QByteArray &a_telegramData); + LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination, + int telegramId); - /** - * Writes a_value with size a_size at actual position of m_Data (given with - * m_ActOffset). m_ActOffset will be updated after writing data. - * If the size of m_Data is not big enough, it will be made bigger. - * - * @param a_size - * @param a_value - * @param a_byteOrder - */ - void setUIntX(const uint8_t a_size, quint64 a_value, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian); + + + LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination, + const quint64 a_unixTime, + const QByteArray &a_telegramData); + + + + void setUIntX(const uint8_t a_size, + quint64 a_value, + const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian); + + - /** - * Returns true if a_data could be written. - * Returns false if a_offset is outside of range and therefore a_data could not be - * written. - * - * @param a_offset - * @param a_data - */ bool setData(const uint16_t a_offset, const uint8_t a_data); - /** - * Returns the log-time of the telegram - */ + + quint64 getLogTime() const { return m_LogTime; } quint64 getLogTimeMsec() const; - /** - * Returns the log-time of the telegram as pretty formatted text - */ + + QString getLogTimeText() const; QString getDestinationText() const; - /** - * Returns the gps-time of the telegram - */ + + quint64 getGpsTime() const { return m_GpsTime; } - /** - * Returns the GPS-time of the telegram as pretty formatted text. Only telegrams - * from TETRA to central have a GPS-time, for all other telegrams an empty string - * will be returned. - */ + + QString getGpsTimeText() const; @@ -163,26 +118,19 @@ namespace N_LogView int getParticipantId() const { return m_ParticipantId; } - /** - * Returns the difference between GPS-time and log-time in seconds. Only telegrams - * from TETRA to central have a GPS-time (and therefore only for this telegrams a - * time-difference can be calculated), for all other telegrams 0 will be returned. - */ + + int32_t getDelay() const; - /** - * Returns the tool-tip text for the with a_col defined column for this telegram. - * Its content depends on the type and subtype of telegram. - * - * @param a_col - */ + + QString getToolTipText(const E_Column a_col); void resetOffset(); - LogViewField *getFieldTree(); + LogViewField* getFieldTree(); void dump() const; @@ -210,46 +158,34 @@ namespace N_LogView bool isJsonTelegram() const { return N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolCentral == m_Protocol; } void clearJsonData() { m_json.remove(QStringLiteral("data")); } - void rebuildJsonString() - { - if (!m_json.isEmpty()) - m_data.clear(); - } + void rebuildJsonString() { if (!m_json.isEmpty()) m_data.clear(); } void setJsonValue(const QStringList &path, const QJsonValue &val); QJsonObject jsonData() const { return m_json; } void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonObject &obj); void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonArray &arr); - const N_CoPrtCnv::CoPrtCnvRadioTelegram *getTetraTelegram() const; + const N_CoPrtCnv::CoPrtCnvRadioTelegram* getTetraTelegram() const; static LogViewTetraTelegramsParser *jsonParser(); static LogViewXdrParser *tetraParser(); QByteArray getData(QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Compact) const; - /** - * The time to wait after sending this telegram in milliseconds. - */ + + uint32_t getWaitTime() const { return m_WaitTime; } - /** - * The time to wait after sending this telegram in milliseconds. - * - * @param newVal - */ + + void setWaitTime(uint32_t newVal) { m_WaitTime = newVal; } - /** - * The name of the telegram, shown in edit-list - */ + + QString getName() const { return m_Name; } - /** - * The name of the telegram, shown in edit-list - * - * @param newVal - */ + + void setName(const QString &newVal) { m_Name = newVal; } @@ -261,9 +197,8 @@ namespace N_LogView void actualizeGpsTime(); - /** - * Create the tooltip text for the column 'Name' - */ + + void createToolTipTextForColName(); @@ -273,40 +208,32 @@ namespace N_LogView static uint32_t floatToXdr(float in); protected: - /** - * The name of the telegram, shown in edit-list - */ + + + QString m_Name; - /** - * The tooltip text for caching purposes - */ + + std::vector m_ToolTipText; - /** - * The time to wait after sending this telegram in milliseconds. - */ + + uint32_t m_WaitTime; int m_ParticipantId; - /** - * The ISSI of TETRA-Protocol - */ + + uint32_t m_ISSI; - /** - * The allocated size of m_Data. (Used for optimizing of speed) - */ + + int m_AllocatedSize; - static const LogViewXdrParser *m_Parser; + static const LogViewXdrParser* m_Parser; uint16_t m_ActOffset; QVector m_GpsFieldOffset; int m_TelId; - /** - * used for dyn. array in TETRA-Protocol - */ + + uint32_t m_LastUnsignedValue; - /** - * This value will be used for the dyn-array-method e_DynArrayMsgLength. This - * value will be subtracted from the message-length to get the size of the dynamic - * array. - */ + + uint16_t m_MaxArraySize; static const uint16_t START_OFFSET_CENTRAL; static const uint16_t POS_CENTRAL_COUNTER; @@ -335,14 +262,14 @@ namespace N_LogView QJsonObject m_json; N_CoPrtCnv::CoPrtCnvRadioTelegram *m_TetraTelegram; - NGL::INGLLogger &m_logger; - LogViewField *getFieldTree(const QString &a_type, - const QString &a_name, - uint16_t a_arraySize, - const LogViewXdrType *a_parentElement = nullptr, + LogViewField *getFieldTree(const QString& a_type, const QString& a_name, + uint16_t a_arraySize, const LogViewXdrType* a_parentElement = nullptr, const bool a_hasContent = true); - LogViewField *getFieldTreeJson(const QJsonValue &data, const QString &name, const StructInformation &si, const QStringList &objectPathBase); + LogViewField *getFieldTreeJson(const QJsonValue &data, + const QString &name, + const StructInformation &si, + const QStringList &objectPathBase); static void addFieldTreeStruct(const QJsonObject &parentObject, LogViewField *parent, @@ -374,108 +301,70 @@ namespace N_LogView static QString typeFromStructInformation(const StructInformation &si, const QString &name); static MemberInformation memberFromStructInformation(const StructInformation &si, const QString &name); - /** - * - * @param a_offset - */ + + uint16_t getUInt16(const uint16_t a_offset) const; - /** - * - * @param a_offset - */ + + uint32_t getUInt32(const uint16_t a_offset) const; - /** - * - * @param a_offset - */ + + int32_t getInt32(const uint16_t a_offset) const; - /** - * - * @param a_offset - * @param a_size - * @param a_byteOrder - */ - quint64 getUIntX(const uint16_t a_offset, - const uint8_t a_size, - const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const; + - /** - * - * @param a_offset - * @param a_size - * @param a_byteOrder - */ - int32_t getSIntX(const uint16_t a_offset, - const uint8_t a_size, - const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const; + quint64 getUIntX(const uint16_t a_offset, const uint8_t a_size, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const; + + + + int32_t getSIntX(const uint16_t a_offset, const uint8_t a_size, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const; + + - /** - * - * @param a_offset - * @param a_size - */ char getChar(const uint16_t a_offset, const uint8_t a_size) const; - /** - * - * @param a_standardType - * @param a_offset - * @param a_arraySize - */ - LogViewField *getContent(const LogViewXdrStandardType *a_standardType, uint16_t &a_offset, const uint16_t a_arraySize); + - /** - * - * @param a_xdrType - */ - bool isScalar(const LogViewXdrType *a_xdrType) const; + LogViewField* getContent(const LogViewXdrStandardType* a_standardType, uint16_t& a_offset, const uint16_t a_arraySize); - /** - * - * @param a_errorText - * @param a_title - */ - void showMessageBox(const QString &a_errorText, const QString &a_title = QObject::tr("Invalid telegram")) const; + - /** - * - * @param a_offset - */ - uint16_t getDynArraySize(uint16_t &a_offset) const; + bool isScalar(const LogViewXdrType* a_xdrType) const; - /** - * - * @param a_name - * @param a_value - */ - static QString formatToolTipLine(const QString &a_name, const uint32_t a_value) { return formatToolTipLine(a_name, QString::number(a_value), a_value); } + - /** - * - * @param a_name - * @param a_text - * @param a_value - */ - static QString formatToolTipLine(const QString &a_name, const QString &a_text, const uint32_t a_value); + void showMessageBox(const QString& a_errorText, const QString& a_title = QObject::tr("Invalid telegram")) const; - static QString formatToolTipLine(const QString &a_name, const std::string &a_text, const uint32_t a_value) + + + uint16_t getDynArraySize(uint16_t& a_offset) const; + + + + static QString formatToolTipLine(const QString& a_name, const uint32_t a_value) + { + return formatToolTipLine(a_name, QString::number(a_value), a_value); + } + + + + static QString formatToolTipLine(const QString& a_name, const QString& a_text, const uint32_t a_value); + + static QString formatToolTipLine(const QString& a_name, const std::string& a_text, const uint32_t a_value) { return formatToolTipLine(a_name, QString::fromStdString(a_text), a_value); } - /** - * returns the data-byte at a_offset. Returns 0 if a_offset is outside of range. - * - * @param a_offset - */ + + uint8_t getData(const uint16_t a_offset) const; private: NGL::INGLLogger &m_logger; friend class LogViewTabWidget; + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.cpp index 7600c28a2..e6cba4fc5 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.cpp @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * some models for LogViewGui - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #include "LogViewTelegramEditModel.hpp" #include @@ -12,155 +7,157 @@ namespace N_LogView { - // --------------------------------------------------------------- - int TelegramEditModel::rowCount(const QModelIndex &parent) const - { - return parent.isValid() ? 0 : m_telegrams.size(); - } - // --------------------------------------------------------------- - int TelegramEditModel::columnCount(const QModelIndex &parent) const - { - return parent.isValid() ? 0 : 3; - } +int TelegramEditModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : m_telegrams.size(); +} - // --------------------------------------------------------------- - QVariant TelegramEditModel::data(const QModelIndex &index, int role) const + +int TelegramEditModel::columnCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : 3; +} + + +QVariant TelegramEditModel::data(const QModelIndex &index, int role) const +{ + if (index.isValid() && index.row() < m_telegrams.size()) { - if (index.isValid() && index.row() < m_telegrams.size()) + if (role == Qt::DisplayRole) { - if (role == Qt::DisplayRole) + const QSharedPointer telegram = m_telegrams.at(index.row()); + switch (index.column()) { - const QSharedPointer telegram = m_telegrams.at(index.row()); - switch (index.column()) - { - case 0: - return telegram->getName(); - case 1: - return telegram->getParticipantId(); - case 2: - return telegram->getWaitTime(); - } - } - else if (role == Qt::ToolTipRole) - { - const QSharedPointer telegram = m_telegrams.at(index.row()); - if (telegram->isJsonTelegram()) - return telegram->getData(QJsonDocument::JsonFormat::Indented); + case 0: + return telegram->getName(); + case 1: + return telegram->getParticipantId(); + case 2: + return telegram->getWaitTime(); } } - return QVariant(); - } - - // --------------------------------------------------------------- - QVariant TelegramEditModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + else if (role == Qt::ToolTipRole) { - switch (section) - { - case 0: - return tr("Description"); - case 1: - return tr("Equip. No."); - case 2: - return tr("Wait Time"); - default: - break; - } - } - return QAbstractTableModel::headerData(section, orientation, role); - } - - // --------------------------------------------------------------- - void TelegramEditModel::clearTelegrams() - { - beginResetModel(); - m_telegrams.clear(); - endResetModel(); - } - - // --------------------------------------------------------------- - void TelegramEditModel::appendTelegrams(const QVector> &telegrams) - { - if (telegrams.isEmpty()) - return; - beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size() + telegrams.size() - 1); - m_telegrams += telegrams; - endInsertRows(); - } - - // --------------------------------------------------------------- - int TelegramEditModel::appendTelegram(const QSharedPointer &telegram) - { - beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size()); - m_telegrams.push_back(telegram); - telegram->rebuildJsonString(); - endInsertRows(); - return m_telegrams.size() - 1; // row - } - - // --------------------------------------------------------------- - QSharedPointer TelegramEditModel::telegram(int row) const - { - if (row >= 0 && row < m_telegrams.size()) - return m_telegrams.at(row); - return QSharedPointer(); - } - - // --------------------------------------------------------------- - bool TelegramEditModel::moveUp(int row) - { - if (row <= 0 || row >= m_telegrams.size()) - return false; - beginMoveRows(QModelIndex(), row, row, QModelIndex(), row - 1); - std::swap(m_telegrams[row], m_telegrams[row - 1]); - endMoveRows(); - return true; - } - - // --------------------------------------------------------------- - bool TelegramEditModel::moveDown(int row) - { - if (row >= (m_telegrams.size() - 1)) - return false; - beginMoveRows(QModelIndex(), row, row, QModelIndex(), row + 1); - std::swap(m_telegrams[row], m_telegrams[row + 1]); - endMoveRows(); - return true; - } - - // --------------------------------------------------------------- - void TelegramEditModel::emitDataChanged(int row) - { - QModelIndex top = createIndex(row, 0); - QModelIndex bottom = createIndex(row, columnCount() - 1); - emit dataChanged(top, bottom, {Qt::DisplayRole, Qt::ToolTipRole}); - } - - // --------------------------------------------------------------- - void TelegramEditModel::removeTelegrams(const QSet &rows) - { - QList rowList = rows.values(); - std::sort(rowList.begin(), rowList.end()); - // von oben her löschen um ein Verschieben der Indizes zu vermeiden - for (int i = rowList.size() - 1; i >= 0; --i) - { - int row = rowList.at(i); - beginRemoveRows(QModelIndex(), row, row); - m_telegrams.remove(row); - endRemoveRows(); + const QSharedPointer telegram = m_telegrams.at(index.row()); + if (telegram->isJsonTelegram()) + return telegram->getData(QJsonDocument::JsonFormat::Indented); } } + return QVariant(); +} - // --------------------------------------------------------------- - void TelegramEditModel::pasteRows(int row, const QSharedPointer &tele) + +QVariant TelegramEditModel::headerData(int section, + Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - if (row < 0 || row > m_telegrams.size()) - return; - beginInsertRows(QModelIndex(), row, row); - m_telegrams.insert(row, QSharedPointer(new LogViewTelegram(*tele.data()))); - endInsertRows(); + switch (section) + { + case 0: + return tr("Description"); + case 1: + return tr("Equip. No."); + case 2: + return tr("Wait Time"); + default: + break; + } } + return QAbstractTableModel::headerData(section, orientation, role); +} -} // namespace N_LogView + +void TelegramEditModel::clearTelegrams() +{ + beginResetModel(); + m_telegrams.clear(); + endResetModel(); +} + + +void TelegramEditModel::appendTelegrams(const QVector > &telegrams) +{ + if (telegrams.isEmpty()) + return; + beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size() + telegrams.size() - 1); + m_telegrams += telegrams; + endInsertRows(); +} + + +int TelegramEditModel::appendTelegram(const QSharedPointer &telegram) +{ + beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size()); + m_telegrams.push_back(telegram); + telegram->rebuildJsonString(); + endInsertRows(); + return m_telegrams.size() - 1; +} + + +QSharedPointer TelegramEditModel::telegram(int row) const +{ + if (row >= 0 && row < m_telegrams.size()) + return m_telegrams.at(row); + return QSharedPointer(); +} + + +bool TelegramEditModel::moveUp(int row) +{ + if (row <= 0 || row >= m_telegrams.size()) + return false; + beginMoveRows(QModelIndex(), row, row, QModelIndex(), row - 1); + std::swap(m_telegrams[row], m_telegrams[row - 1]); + endMoveRows(); + return true; +} + + +bool TelegramEditModel::moveDown(int row) +{ + if (row >= (m_telegrams.size() - 1)) + return false; + beginMoveRows(QModelIndex(), row, row, QModelIndex(), row + 1); + std::swap(m_telegrams[row], m_telegrams[row + 1]); + endMoveRows(); + return true; +} + + +void TelegramEditModel::emitDataChanged(int row) +{ + QModelIndex top = createIndex(row, 0); + QModelIndex bottom = createIndex(row, columnCount() - 1); + emit dataChanged(top, bottom, {Qt::DisplayRole, Qt::ToolTipRole}); +} + + +void TelegramEditModel::removeTelegrams(const QSet &rows) +{ + QList rowList = rows.values(); + std::sort(rowList.begin(), rowList.end()); + + for (int i = rowList.size() - 1 ; i >= 0; --i) + { + int row = rowList.at(i); + beginRemoveRows(QModelIndex(), row, row); + m_telegrams.remove(row); + endRemoveRows(); + } +} + + +void TelegramEditModel::pasteRows(int row, const QSharedPointer &tele) +{ + if (row < 0 || row > m_telegrams.size()) + return; + beginInsertRows(QModelIndex(), row, row); + m_telegrams.insert(row, QSharedPointer(new LogViewTelegram(*tele.data()))); + endInsertRows(); +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.hpp index a78efd3e9..ce650385c 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramEditModel.hpp @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * some models for LogViewGui - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #pragma once @@ -15,34 +10,35 @@ namespace N_LogView { - class TelegramEditModel final : public QAbstractTableModel - { - Q_OBJECT - public: - using QAbstractTableModel::QAbstractTableModel; +class TelegramEditModel final : public QAbstractTableModel +{ + Q_OBJECT +public: + using QAbstractTableModel::QAbstractTableModel; - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; - void clearTelegrams(); - void appendTelegrams(const QVector> &telegrams); - int appendTelegram(const QSharedPointer &telegram); - QSharedPointer telegram(int row) const; + void clearTelegrams(); + void appendTelegrams(const QVector > &telegrams); + int appendTelegram(const QSharedPointer &telegram); + QSharedPointer telegram(int row) const; - bool moveUp(int row); - bool moveDown(int row); + bool moveUp(int row); + bool moveDown(int row); - void emitDataChanged(int row); + void emitDataChanged(int row); - void removeTelegrams(const QSet &rows); + void removeTelegrams(const QSet &rows); - void pasteRows(int row, const QSharedPointer &tele); + void pasteRows(int row, const QSharedPointer &tele); +protected: + QVector > m_telegrams; - protected: - QVector> m_telegrams; - }; +}; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.cpp index 2acec770c..ba750ccab 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.cpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewTelegramSelectionDialog.hpp" #include #include @@ -22,40 +22,41 @@ namespace N_LogView { - static int s_currentRow = 0; - // --------------------------------------------------------------- - LogViewTelegramSelectionDialog::LogViewTelegramSelectionDialog(QWidget *a_parent) - : QDialog(a_parent) +static int s_currentRow = 0; + +LogViewTelegramSelectionDialog::LogViewTelegramSelectionDialog(QWidget* a_parent) + : QDialog(a_parent) +{ + setMinimumSize(QSize(600, 500)); + QVBoxLayout* layout = new QVBoxLayout; + layout->addWidget(new QLabel(tr("Select a telegram:"))); + m_TelegramList = new QListWidget(this); + const auto telegramMap = LogViewTelegram::jsonParser()->telegramsToCreate(); + for (auto it = telegramMap.cbegin(); it != telegramMap.cend(); ++it) { - setMinimumSize(QSize(600, 500)); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(new QLabel(tr("Select a telegram:"))); - m_TelegramList = new QListWidget(this); - const auto telegramMap = LogViewTelegram::jsonParser()->telegramsToCreate(); - for (auto it = telegramMap.cbegin(); it != telegramMap.cend(); ++it) - { - if (it.key() == 0) // ACK - continue; - auto lwi = new QListWidgetItem(it.value() + QStringLiteral(" (%1)").arg(it.key())); - lwi->setData(Qt::UserRole, it.key()); - m_TelegramList->addItem(lwi); - } - - m_TelegramList->sortItems(); - m_TelegramList->setCurrentRow(s_currentRow); - connect(m_TelegramList, &QListWidget::itemActivated, this, &LogViewTelegramSelectionDialog::selectTelegram); - layout->addWidget(m_TelegramList); - - setLayout(layout); + if (it.key() == 0) + continue; + auto lwi = new QListWidgetItem(it.value() + QStringLiteral(" (%1)").arg(it.key())); + lwi->setData(Qt::UserRole, it.key()); + m_TelegramList->addItem(lwi); } + m_TelegramList->sortItems(); + m_TelegramList->setCurrentRow(s_currentRow); + connect(m_TelegramList, &QListWidget::itemActivated, + this, &LogViewTelegramSelectionDialog::selectTelegram); + layout->addWidget(m_TelegramList); - // --------------------------------------------------------------- - void LogViewTelegramSelectionDialog::selectTelegram(QListWidgetItem *a_telegramItem) - { - s_currentRow = m_TelegramList->currentRow(); - m_SelectedTelegramId = a_telegramItem->data(Qt::UserRole).toInt(); - accept(); - } + setLayout(layout); +} -} // namespace N_LogView + + +void LogViewTelegramSelectionDialog::selectTelegram(QListWidgetItem* a_telegramItem) +{ + s_currentRow = m_TelegramList->currentRow(); + m_SelectedTelegramId = a_telegramItem->data(Qt::UserRole).toInt(); + accept(); +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.hpp index f955b8262..2befcb03e 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTelegramSelectionDialog.hpp @@ -1,15 +1,15 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once @@ -19,34 +19,28 @@ class QListWidgetItem; namespace N_LogView { - /** - * @author alois.wismer - * @version 1.0 - * @created 05-Mai-2010 17:24:14 - */ + + class LogViewTelegramSelectionDialog : public QDialog { Q_OBJECT public: - /** - * - * @param a_parent - */ - explicit LogViewTelegramSelectionDialog(QWidget *a_parent); + + + explicit LogViewTelegramSelectionDialog(QWidget* a_parent); int getSelectedTelegramId() const { return m_SelectedTelegramId; } protected slots: - /** - * - * @param a_telegramItem - */ - void selectTelegram(QListWidgetItem *a_telegramItem); + + + void selectTelegram(QListWidgetItem* a_telegramItem); protected: + QListWidget *m_TelegramList; int m_SelectedTelegramId; - }; +}; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.cpp index 93b4765f7..e21dedb07 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.cpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewTextEdit.hpp" #include "LogViewField.hpp" #include "LogViewTelegram.hpp" @@ -18,78 +18,79 @@ namespace N_LogView { - // --------------------------------------------------------------- - LogViewTextEdit::LogViewTextEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) - : QLineEdit(a_parent) - , LogViewWidget(a_field, this, a_parent, a_readonly) + +LogViewTextEdit::LogViewTextEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly) + : QLineEdit(a_parent) + , LogViewWidget(a_field, this, a_parent, a_readonly) +{ + const QString value = a_field->value(0); + setText(value); + + if (a_readonly) { - const QString value = a_field->value(0); - setText(value); + setReadOnly(true); + setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); + } - if (a_readonly) - { - setReadOnly(true); - setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); - } + + uint16_t maxArraySize = a_field->maxArraySize(); + setMaxLength(maxArraySize); + updateToolTip(value); - // set a validator for number of chars - uint16_t maxArraySize = a_field->maxArraySize(); - setMaxLength(maxArraySize); - updateToolTip(value); - - // make proper width of widget - QFontMetrics fm(font()); + + QFontMetrics fm(font()); #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - setMinimumWidth(fm.width(QLatin1Char(' ') + value + QLatin1Char(' '))); + setMinimumWidth(fm.width(QLatin1Char(' ') + value + QLatin1Char(' '))); #else - setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + value + QLatin1Char(' '))); + setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + value + QLatin1Char(' '))); #endif - // connect signals - connect(this, &LogViewTextEdit::editingFinished, this, &LogViewTextEdit::checkAndOvertakeContent); - } + + connect(this, &LogViewTextEdit::editingFinished, + this, &LogViewTextEdit::checkAndOvertakeContent); +} - // --------------------------------------------------------------- - void LogViewTextEdit::checkAndOvertakeContent() + +void LogViewTextEdit::checkAndOvertakeContent() +{ + updateToolTip(text()); + m_Valid = true; +} + + + + + +bool LogViewTextEdit::saveContent(LogViewTelegram* a_telegram) +{ + if (!isValid()) + return false; + if (a_telegram->isJsonTelegram()) { - updateToolTip(text()); // fixme nach jedem zeichen updaten - m_Valid = true; + a_telegram->setJsonValue(m_Field->jsonPath(), text()); } - - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewTextEdit::saveContent(LogViewTelegram *a_telegram) + else { - if (!isValid()) - return false; - if (a_telegram->isJsonTelegram()) + uint16_t size = getSize(); + QString content = text(); + uint16_t arraySize; + if (m_Field->isDynamicArray()) { - a_telegram->setJsonValue(m_Field->jsonPath(), text()); + arraySize = content.length(); + a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize); + } else { - uint16_t size = getSize(); - QString content = text(); - uint16_t arraySize; - if (m_Field->isDynamicArray()) - { - arraySize = content.length(); - a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize); - // fixme: bei vielen Telegrammen muss Länge auf die Länge des Textes gesetzt werden. Dies kann nicht automatisch gemacht werden. Aber vielleicht kann man schauen, ob vor dem dyn. Array ein Feld Länge vorkommt, oder hartcodieren, oder konfigurierbaren - } - else - { - arraySize = m_Field->maxArraySize(); - } - - // copy the text - for (int i = 0; i < arraySize; i++) - a_telegram->setUIntX(size, i < content.length() ? content[i].toLatin1() : 0); + arraySize = m_Field->maxArraySize(); } - return true; - } -} // namespace N_LogView + + for (int i = 0; i < arraySize; i++) + a_telegram->setUIntX(size, i < content.length() ? content[i].toLatin1() : 0); + } + return true; +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.hpp index 957ce6c44..725da7bd8 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewTextEdit.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewWidget.hpp" @@ -18,37 +18,23 @@ namespace N_LogView { - /** - * Used for arrays of char and string. - * - * @author alois.wismer - * @version 1.0 - * @created 21-Mai-2010 10:28:05 - */ - class LogViewTextEdit - : public QLineEdit - , public LogViewWidget + + + class LogViewTextEdit : public QLineEdit, public LogViewWidget { Q_OBJECT public: - /** - * - * @param a_field - * @param a_parent - * @param a_readonly - */ - LogViewTextEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly); + - /** - * Writes the content into telegram. - * Returns true if successful. - * - * @param a_telegram - */ - bool saveContent(LogViewTelegram *a_telegram) override; + LogViewTextEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly); + + + + bool saveContent(LogViewTelegram* a_telegram) override; protected slots: void checkAndOvertakeContent(); + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.cpp index 52f05bcdf..117211ef7 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.cpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewValueEdit.hpp" #include "LogViewField.hpp" #include "LogViewTelegram.hpp" @@ -18,117 +18,118 @@ namespace N_LogView { - // --------------------------------------------------------------- - LogViewValueEdit::LogViewValueEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) - : QLineEdit(a_parent) - , LogViewWidget(a_field, this, a_parent, a_readonly) - , m_IsFloat(false) - { - const LogViewXdrStandardType *stdType = static_cast(m_Field->xdrElement()); - m_IsFloat = (LogViewXdrStandardType::e_Float == stdType->getValueKind()); - const QString valueText = a_field->value(0); +LogViewValueEdit::LogViewValueEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly) + : QLineEdit(a_parent) + , LogViewWidget(a_field, this, a_parent, a_readonly) + , m_IsFloat(false) +{ + const LogViewXdrStandardType *stdType = static_cast(m_Field->xdrElement()); + m_IsFloat = (LogViewXdrStandardType::e_Float == stdType->getValueKind()); - setText(valueText); + const QString valueText = a_field->value(0); - // checkAndOvertakeContent(); - updateToolTip(valueText); + setText(valueText); - // make proper width of widget - QFontMetrics fm(font()); + + updateToolTip(valueText); + + + QFontMetrics fm(font()); #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - setMinimumWidth(fm.width(QLatin1Char(' ') + valueText + QLatin1Char(' '))); + setMinimumWidth(fm.width(QLatin1Char(' ') + valueText + QLatin1Char(' '))); #else - setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + valueText + QLatin1Char(' '))); + setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + valueText + QLatin1Char(' '))); #endif - if (a_readonly) - { - setReadOnly(true); - setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); - } - else - { - connect(this, &LogViewValueEdit::editingFinished, this, &LogViewValueEdit::checkAndOvertakeContent); - } + if (a_readonly) + { + setReadOnly(true); + setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); + } + else + { + connect(this, &LogViewValueEdit::editingFinished, + this, &LogViewValueEdit::checkAndOvertakeContent); + } +} + + + +void LogViewValueEdit::checkAndOvertakeContent() +{ + bool ok; + int64_t intValue = 0; + double floatValue = 0.0; + + + if (m_IsFloat) + floatValue = getFloat(text(), (uint64_t&)intValue, ok); + else + intValue = getInteger(text(), ok); + + + if (!ok) + { + setFocus(); + selectAll(); + return; } + + if (m_IsFloat) + setText(QString::number(floatValue)); + else + setText(QString::number(intValue)); - // --------------------------------------------------------------- - void LogViewValueEdit::checkAndOvertakeContent() + updateToolTip(text()); +} + + + + + + +bool LogViewValueEdit::saveContent(LogViewTelegram* a_telegram) +{ + if (m_Valid) { bool ok; - int64_t intValue = 0; - double floatValue = 0.0; - - // get the calculated and checked value if (m_IsFloat) - floatValue = getFloat(text(), (uint64_t &)intValue, ok); - else - intValue = getInteger(text(), ok); - - // handle errors - if (!ok) { - setFocus(); - selectAll(); - return; // abort - } - - // update - if (m_IsFloat) - setText(QString::number(floatValue)); - else - setText(QString::number(intValue)); - - updateToolTip(text()); - } - - - // --------------------------------------------------------------- - // Writes the content into telegram. - // Returns true if successful. - // --------------------------------------------------------------- - bool LogViewValueEdit::saveContent(LogViewTelegram *a_telegram) - { - if (m_Valid) - { - bool ok; - if (m_IsFloat) + + uint64_t valueAsUint64; + const double value = getFloat(text(), valueAsUint64, ok); + if (ok) { - // save the float or double-value - uint64_t valueAsUint64; - const double value = getFloat(text(), valueAsUint64, ok); - if (ok) + if (a_telegram->isJsonTelegram()) { - if (a_telegram->isJsonTelegram()) - { - a_telegram->setJsonValue(m_Field->jsonPath(), value); - } - else - { - const LogViewXdrStandardType *stdType = static_cast(m_Field->xdrElement()); - LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder(); - a_telegram->setUIntX(getSize(), valueAsUint64, byteOrder); - } - return true; + a_telegram->setJsonValue(m_Field->jsonPath(), value); } - } - else - { - // save the integer-value - qint64 intValue = getInteger(text(), ok); - if (ok) + else { - if (a_telegram->isJsonTelegram()) - a_telegram->setJsonValue(m_Field->jsonPath(), intValue); - else - a_telegram->setUIntX(getSize(), intValue); - return true; + const LogViewXdrStandardType *stdType = static_cast(m_Field->xdrElement()); + LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder(); + a_telegram->setUIntX(getSize(), valueAsUint64, byteOrder); } + return true; + } + } + else + { + + qint64 intValue = getInteger(text(), ok); + if (ok) + { + if (a_telegram->isJsonTelegram()) + a_telegram->setJsonValue(m_Field->jsonPath(), intValue); + else + a_telegram->setUIntX(getSize(), intValue); + return true; } } - return false; } + return false; +} -} // namespace N_LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.hpp index 5a61a3a1d..a9d4f1f9f 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewValueEdit.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewWidget.hpp" @@ -18,40 +18,27 @@ namespace N_LogView { - /** - * Used for scalar signed or unsigned values - * - * @author alois.wismer - * @version 1.0 - * @created 20-Mai-2010 14:47:50 - */ - class LogViewValueEdit - : public QLineEdit - , public LogViewWidget + + + class LogViewValueEdit : public QLineEdit, public LogViewWidget { Q_OBJECT public: - /** - * - * @param a_field - * @param a_parent - * @param a_readonly - */ - LogViewValueEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly); + - /** - * Writes the content into telegram. - * Returns true if successful. - * - * @param a_telegram - */ - bool saveContent(LogViewTelegram *a_telegram) override; + LogViewValueEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly); + + + + bool saveContent(LogViewTelegram* a_telegram) override; protected: + bool m_IsFloat; protected slots: void checkAndOvertakeContent(); + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.cpp index b964c2193..c2414c0fe 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.cpp @@ -1,61 +1,61 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewXdrElement.hpp" namespace N_LogView { - // --------------------------------------------------------------- - // Constructor of a struct or enum - // --------------------------------------------------------------- - LogViewXdrElement::LogViewXdrElement(const QString &a_name, const E_ElementKind a_kind, const char *loggerName) - : m_Name(a_name) - , m_Kind(a_kind) - , m_logger(getLogger(loggerName)) + + + +LogViewXdrElement::LogViewXdrElement(const QString& a_name, const E_ElementKind a_kind, const char *loggerName) + : m_Name(a_name) + , m_Kind(a_kind) + , m_logger(getLogger(loggerName)) +{ + if (a_name.indexOf(QLatin1Char('<')) >= 0 || a_name.indexOf(QLatin1Char('[')) >= 0) + ERROR_LOG(m_logger) << "Element \'" << a_name.toStdString() << "\' has a problem"; +} + + +void LogViewXdrElement::dump() const +{ + INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName(); +} + + + +QString LogViewXdrElement::getKindName() const +{ + switch (getKind()) { - if (a_name.indexOf(QLatin1Char('<')) >= 0 || a_name.indexOf(QLatin1Char('[')) >= 0) - ERROR_LOG(m_logger) << "Element \'" << a_name.toStdString() << "\' has a problem"; + case e_KindDefine: + return QLatin1String("Define"); + case e_KindEnum: + return QLatin1String("Enum"); + case e_KindEnumElement: + return QLatin1String("EnumElement"); + case e_KindStandardType: + return QLatin1String("StandardType"); + case e_KindStruct: + return QLatin1String("Struct"); + case e_KindStructElement: + return QLatin1String("StructElement"); + case e_KindTypedef: + return QLatin1String("Typedef"); } + return QStringLiteral("Unknown (%1)").arg(getKind()); +} - // --------------------------------------------------------------- - void LogViewXdrElement::dump() const - { - INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName(); - } - - - // --------------------------------------------------------------- - QString LogViewXdrElement::getKindName() const - { - switch (getKind()) - { - case e_KindDefine: - return QLatin1String("Define"); - case e_KindEnum: - return QLatin1String("Enum"); - case e_KindEnumElement: - return QLatin1String("EnumElement"); - case e_KindStandardType: - return QLatin1String("StandardType"); - case e_KindStruct: - return QLatin1String("Struct"); - case e_KindStructElement: - return QLatin1String("StructElement"); - case e_KindTypedef: - return QLatin1String("Typedef"); - } - return QStringLiteral("Unknown (%1)").arg(getKind()); - } - -} // namespace N_LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.hpp index dbef958c1..80228f21e 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrElement.hpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include @@ -18,19 +18,14 @@ namespace N_LogView { - /** - * @author alois.wismer - * @version 1.0 - * @created 05-Feb-2010 11:24:56 - */ + + class LogViewXdrElement { public: - /** - * @author alois.wismer - * @version 1.0 - * @created 10-Feb-2010 11:34:47 - */ + + + enum E_ElementKind { e_KindStandardType, @@ -45,16 +40,12 @@ namespace N_LogView virtual ~LogViewXdrElement() = default; protected: - /** - * Constructor of a struct or enum - * - * @param a_name - * @param a_kind - */ - LogViewXdrElement(const QString &a_name, const E_ElementKind a_kind, const char *loggerName); + + + LogViewXdrElement(const QString& a_name, const E_ElementKind a_kind, const char *loggerName); public: - const QString &getName() const { return m_Name; } + const QString& getName() const { return m_Name; } LogViewXdrElement::E_ElementKind getKind() const { return m_Kind; } virtual void dump() const; @@ -62,7 +53,6 @@ namespace N_LogView protected: QString m_Name; E_ElementKind m_Kind; - LOGGER_T m_logger; QString getKindName() const; NGL::INGLLogger &m_logger; diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.cpp index 79754c8e5..b5dd4bb3f 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.cpp @@ -1,83 +1,84 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** -// manual class headers + + + + + + + + + + + + + #include "LogViewXdrStandardType.hpp" namespace N_LogView { - // --------------------------------------------------------------- - // (a_valueKind must be Unsigned, if a_dynArraySizeMethod is - // e_DynArray...) - // --------------------------------------------------------------- - LogViewXdrStandardType::LogViewXdrStandardType(const QString &a_name, - const int a_valueSize, - const int a_editSize, - const E_ValueKind a_valueKind, - const E_DynArraySizeMethod a_dynArraySizeMethod, - E_ByteOrder a_byteOrder) - : LogViewXdrElement(a_name, e_KindStandardType, "LogViewXdrStandardType") - , m_ValueSize(a_valueSize) - , m_EditSize(a_editSize) - , m_ValueKind(a_valueKind) - , m_ByteOrder(a_byteOrder) - , m_DynArraySizeMethod(a_dynArraySizeMethod) - { - } - // --------------------------------------------------------------- - uint16_t LogViewXdrStandardType::getValueSize() const - { - return m_ValueSize; - } - - // --------------------------------------------------------------- - LogViewXdrStandardType::E_ValueKind LogViewXdrStandardType::getValueKind() const - { - return m_ValueKind; - } - // --------------------------------------------------------------- - void LogViewXdrStandardType::dump() const - { - INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " valueKind=" << getValueKind() << " valueSize=" << getValueSize() - << " editSize=" << getEditSize() << " dynArrSizeMethod=" << getDynArraySizeMethod() << " byteOrder=" << getByteOrder(); - } - - // --------------------------------------------------------------- - LogViewXdrStandardType::E_DynArraySizeMethod LogViewXdrStandardType::getDynArraySizeMethod() const - { - return m_DynArraySizeMethod; - } +LogViewXdrStandardType::LogViewXdrStandardType(const QString& a_name, const int a_valueSize, + const int a_editSize, const E_ValueKind a_valueKind, + const E_DynArraySizeMethod a_dynArraySizeMethod, E_ByteOrder a_byteOrder) + : LogViewXdrElement(a_name, e_KindStandardType, "LogViewXdrStandardType") + , m_ValueSize(a_valueSize) + , m_EditSize(a_editSize) + , m_ValueKind(a_valueKind) + , m_ByteOrder(a_byteOrder) + , m_DynArraySizeMethod(a_dynArraySizeMethod) +{} - // --------------------------------------------------------------- - LogViewXdrStandardType::E_ByteOrder LogViewXdrStandardType::getByteOrder() const - { - return m_ByteOrder; - } + +uint16_t LogViewXdrStandardType::getValueSize() const +{ + return m_ValueSize; +} - // --------------------------------------------------------------- - // The 'real' size of the value, which will be allowd when - // editing this value - // --------------------------------------------------------------- - uint16_t LogViewXdrStandardType::getEditSize() const - { - return m_EditSize; - } +LogViewXdrStandardType::E_ValueKind LogViewXdrStandardType::getValueKind() const +{ + return m_ValueKind; +} -} // namespace N_LogView + + +void LogViewXdrStandardType::dump() const +{ + INFO_LOG(m_logger) << "Element[" << getName() + << "]: kind=" << getKindName() + << " valueKind=" << getValueKind() + << " valueSize=" << getValueSize() + << " editSize=" << getEditSize() + << " dynArrSizeMethod=" << getDynArraySizeMethod() + << " byteOrder=" << getByteOrder(); +} + + +LogViewXdrStandardType::E_DynArraySizeMethod LogViewXdrStandardType::getDynArraySizeMethod() const +{ + return m_DynArraySizeMethod; +} + + + +LogViewXdrStandardType::E_ByteOrder LogViewXdrStandardType::getByteOrder() const +{ + return m_ByteOrder; +} + + + + + + +uint16_t LogViewXdrStandardType::getEditSize() const +{ + return m_EditSize; +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.hpp index a39a583d3..29a75ffa5 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStandardType.hpp @@ -1,106 +1,77 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewXdrElement.hpp" namespace N_LogView { - /** - * This class represents the standardtypes like int, char, ... - * It holds the the size of this type and its representation to user - * (signed/unsigned value or character) - * - * @author alois.wismer - * @version 1.0 - * @created 16-Feb-2010 14:22:20 - */ + + class LogViewXdrStandardType final : public LogViewXdrElement { public: - /** - * @author alois.wismer - * @version 1.0 - * @created 16-Feb-2010 14:34:38 - */ + + + enum E_ValueKind { - /** - * An unsigned 32-bit integer - */ + + e_Unsigned, - /** - * An signed 32-bit integer - */ + + e_Signed, - /** - * A floating-point number - */ + + e_Float, - /** - * A character or string - */ + + e_Character, - /** - * A boolean value - */ + + e_Boolean, - /** - * Hex-Data "0000: F7 A5 07 ..." - */ + + e_Data }; - /** - * @author alois.wismer - * @version 1.0 - * @created 31-Mrz-2010 10:27:31 - */ + + enum E_ByteOrder { e_ByteOrderBigEndian, e_ByteOrderLittleEndian }; - /** - * @author alois.wismer - * @version 1.0 - * @created 29-Mrz-2010 13:58:44 - */ + + enum E_DynArraySizeMethod { - /** - * Size of dyn array depends on message-size (size - m_DynArrayOffset) (or no dyn - * array) - * The value within <> in struct-element will be used for m_DynArrayOffset. - */ + + e_DynArrayMsgLength, - /** - * Size of dyn array is defined by a field (StandardType must be Unsigned) - */ + + e_DynArrayIndex, - /** - * Size of dyn array is defined by a field, which will be divided by 8 (used for - * bitfields) (StandardType must be Unsigned) - */ + + e_DynArrayIndexDiv8 }; - /** - * (a_valueKind must be Unsigned, if a_dynArraySizeMethod is e_DynArray...) - * - */ + + LogViewXdrStandardType(const QString &a_name, const int a_valueSize, const int a_editSize, @@ -123,25 +94,24 @@ namespace N_LogView LogViewXdrStandardType::E_ByteOrder getByteOrder() const; - /** - * The 'real' size of the value, which will be allowd when editing this value - */ + + uint16_t getEditSize() const; protected: - /** - * The size of this value as stored data. It may be bigger as the real (edit) size. - */ + + + int m_ValueSize; - /** - * The 'real' size of the value, which will be allowd when editing this value - */ + + int m_EditSize; E_ValueKind m_ValueKind; E_ByteOrder m_ByteOrder; E_DynArraySizeMethod m_DynArraySizeMethod; + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.cpp index e4c442880..b497f4222 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.cpp @@ -1,16 +1,16 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewXdrStruct.hpp" #include "LogViewXdrValue.hpp" #include "LogViewXdrType.hpp" @@ -18,94 +18,88 @@ namespace N_LogView { - // --------------------------------------------------------------- - LogViewXdrStruct::LogViewXdrStruct(const QString &a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize) - : LogViewXdrElement(a_name, a_kind, "LogViewXdrStruct") - , m_EnumSize(enumSize) + +LogViewXdrStruct::LogViewXdrStruct(const QString& a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize) + : LogViewXdrElement(a_name, a_kind, "LogViewXdrStruct") + , m_EnumSize(enumSize) +{ +} + +LogViewXdrStruct::~LogViewXdrStruct() +{ + for (auto ptr : m_ChildList) + delete ptr; +} + + + +void LogViewXdrStruct::addElement(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit, const int16_t a_lastBit, const bool a_isLast) +{ + m_ChildList.push_back(new LogViewXdrType(a_name, a_type, a_arraySize, a_dynArrayOffset, a_kind, a_firstBit, a_lastBit, a_isLast)); +} + + +void LogViewXdrStruct::addElement(const QString& a_name, const uint32_t a_value, const E_ElementKind a_kind) +{ + m_ChildList.push_back(new LogViewXdrValue(a_name, a_value, a_kind)); +} + + + +LogViewXdrElement* LogViewXdrStruct::getChild(const uint32_t a_childIndex) const +{ + if (m_ChildList.size() > a_childIndex) + return m_ChildList[a_childIndex]; + + return nullptr; +} + + + +LogViewXdrType* LogViewXdrStruct::getChildAsType(const uint32_t a_childIndex) const +{ + return static_cast(getChild(a_childIndex)); +} + + + +LogViewXdrValue* LogViewXdrStruct::getChildAsValue(const uint32_t a_childIndex) const +{ + return static_cast(getChild(a_childIndex)); +} + + + +void LogViewXdrStruct::dump() const +{ + INFO_LOG(m_logger) << "Element[" << getName().toStdString() << "]: kind=" << getKindName().toStdString() << " enumSize=" << getEnumSize(); + INFO_LOG(m_logger) << "-------------- childs start -----------------"; + + std::vector::const_iterator iter = m_ChildList.begin(); + while (iter != m_ChildList.end()) { + (*iter)->dump(); + ++iter; } + INFO_LOG(m_logger) << "-------------- childs end -----------------"; +} - LogViewXdrStruct::~LogViewXdrStruct() + +uint32_t LogViewXdrStruct::getChildValue(const QString& a_name, bool* a_error) const +{ + if (a_error) + *a_error = false; + std::vector::const_iterator iter = m_ChildList.begin(); + while (iter != m_ChildList.end()) { - for (auto ptr : m_ChildList) - delete ptr; + if ((*iter)->getName() == a_name) + return static_cast(*iter)->getValue(); + ++iter; } + if (a_error) + *a_error = true; + return 0; +} +} - // --------------------------------------------------------------- - void LogViewXdrStruct::addElement(const QString &a_name, - const QString &a_type, - const uint16_t a_arraySize, - const uint16_t a_dynArrayOffset, - const E_ElementKind a_kind, - const int16_t a_firstBit, - const int16_t a_lastBit, - const bool a_isLast) - { - m_ChildList.push_back(new LogViewXdrType(a_name, a_type, a_arraySize, a_dynArrayOffset, a_kind, a_firstBit, a_lastBit, a_isLast)); - } - - // --------------------------------------------------------------- - void LogViewXdrStruct::addElement(const QString &a_name, const uint32_t a_value, const E_ElementKind a_kind) - { - m_ChildList.push_back(new LogViewXdrValue(a_name, a_value, a_kind)); - } - - - // --------------------------------------------------------------- - LogViewXdrElement *LogViewXdrStruct::getChild(const uint32_t a_childIndex) const - { - if (m_ChildList.size() > a_childIndex) - return m_ChildList[a_childIndex]; - - return nullptr; - } - - - // --------------------------------------------------------------- - LogViewXdrType *LogViewXdrStruct::getChildAsType(const uint32_t a_childIndex) const - { - return static_cast(getChild(a_childIndex)); // fixme: check ob es wirklich ein XdrType ist - } - - - // --------------------------------------------------------------- - LogViewXdrValue *LogViewXdrStruct::getChildAsValue(const uint32_t a_childIndex) const - { - return static_cast(getChild(a_childIndex)); // fixme: check ob es wirklich ein XdrValue ist - } - - - // --------------------------------------------------------------- - void LogViewXdrStruct::dump() const - { - INFO_LOG(m_logger) << "Element[" << getName().toStdString() << "]: kind=" << getKindName().toStdString() << " enumSize=" << getEnumSize(); - INFO_LOG(m_logger) << "-------------- childs start -----------------"; - - std::vector::const_iterator iter = m_ChildList.begin(); - while (iter != m_ChildList.end()) - { - (*iter)->dump(); - ++iter; - } - INFO_LOG(m_logger) << "-------------- childs end -----------------"; - } - - // --------------------------------------------------------------- - uint32_t LogViewXdrStruct::getChildValue(const QString &a_name, bool *a_error) const - { - if (a_error) - *a_error = false; - std::vector::const_iterator iter = m_ChildList.begin(); - while (iter != m_ChildList.end()) - { - if ((*iter)->getName() == a_name) - return static_cast(*iter)->getValue(); - ++iter; - } - if (a_error) - *a_error = true; - return 0; - } - -} // namespace N_LogView diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.hpp index db34d102e..8faa4ed14 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrStruct.hpp @@ -1,23 +1,23 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include #include "LogViewXdrElement.hpp" #include -// forward declarations from stereotyped includes + namespace N_LogView { class LogViewXdrValue; @@ -29,42 +29,32 @@ namespace N_LogView namespace N_LogView { - /** - * This class represents elements which have childs. - * This are enum and struct. - * @author alois.wismer - * @version 1.0 - * @created 31-Mrz-2010 11:59:19 - */ + + class LogViewXdrStruct final : public LogViewXdrElement { public: - LogViewXdrStruct(const QString &a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize = 0); + LogViewXdrStruct(const QString& a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize = 0); ~LogViewXdrStruct(); - void addElement(const QString &a_name, - const QString &a_type, - const uint16_t a_arraySize, - const uint16_t a_dynArrayOffset, - const E_ElementKind a_kind, - const int16_t a_firstBit = -1, - const int16_t a_lastBit = -1, - const bool a_isLast = true); - void addElement(const QString &a_name, const uint32_t a_value, const E_ElementKind a_kind); + void addElement(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit = -1, const int16_t a_lastBit = -1, const bool a_isLast = true); + void addElement(const QString& a_name, const uint32_t a_value, const E_ElementKind a_kind); - LogViewXdrElement *getChild(const uint32_t a_childIndex) const; - LogViewXdrType *getChildAsType(const uint32_t a_childIndex) const; - LogViewXdrValue *getChildAsValue(const uint32_t a_childIndex) const; + LogViewXdrElement* getChild(const uint32_t a_childIndex) const; + LogViewXdrType* getChildAsType(const uint32_t a_childIndex) const; + LogViewXdrValue* getChildAsValue(const uint32_t a_childIndex) const; void dump() const override; - uint32_t getChildValue(const QString &a_name, bool *a_error = nullptr) const; + uint32_t getChildValue(const QString& a_name, bool* a_error = nullptr) const; uint16_t getEnumSize() const { return m_EnumSize; } protected: + uint16_t m_EnumSize; - std::vector m_ChildList; + std::vector m_ChildList; + }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.cpp index 82ae39dfd..c4a4b05c5 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.cpp @@ -1,104 +1,106 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewXdrType.hpp" namespace N_LogView { - // --------------------------------------------------------------- - LogViewXdrType::LogViewXdrType(const QString &a_name, const QString &a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind) - : LogViewXdrElement(a_name, a_kind, "LogViewXdrElement") - , m_Type(a_type) - , m_ArraySize(a_arraySize) - , m_MaxArraySize(a_dynArrayOffset) - , m_FirstBit(-1) - , m_LastBit(-1) - , m_IsLast(true) + +LogViewXdrType::LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind) + : LogViewXdrElement(a_name, a_kind, "LogViewXdrElement") + , m_Type(a_type) + , m_ArraySize(a_arraySize) + , m_MaxArraySize(a_dynArrayOffset) + , m_FirstBit(-1) + , m_LastBit(-1) + , m_IsLast(true) +{ +} + + + +LogViewXdrType::LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit, const int16_t a_lastBit, const bool a_isLast) + : LogViewXdrElement(a_name, a_kind, "LogViewXdrType") + , m_Type(a_type) + , m_ArraySize(a_arraySize) + , m_MaxArraySize(a_dynArrayOffset) + , m_FirstBit(a_firstBit) + , m_LastBit(a_lastBit) + , m_IsLast(a_isLast) +{ +} + + + +void LogViewXdrType::dump() const +{ + INFO_LOG(m_logger) << "Element[" << getName() + << "]: kind=" << getKindName() + << " type=" << getType() + << " arraySize=" << getArraySize() + << " maxArraySize=" << getMaxArraySize() + << " firstBit=" << m_FirstBit + << " lastBit=" << m_LastBit + << " isLast=" << m_IsLast; +} + + + +const QString& LogViewXdrType::getType() const +{ + return m_Type; +} + + + + + + +uint16_t LogViewXdrType::getArraySize() const +{ + return m_ArraySize; +} + + + +bool LogViewXdrType::maskValue(uint32_t& a_value, const uint16_t a_size, QString& a_tooltip) const +{ + + if (m_FirstBit != -1 && m_LastBit != -1) { + DEBUG_LOG(m_logger) << "MaskValue for Element " << m_Name + << " type: " << m_Type + << " size: " << m_ArraySize + << " first:last " << m_FirstBit << ":" << m_LastBit + << " isLast: " << m_IsLast; + uint16_t bitshift = (a_size*8)-m_LastBit-1; + uint32_t mask = (1<<(m_LastBit-m_FirstBit+1))-1; + + a_value = (a_value >> bitshift) & mask; + + a_tooltip.insert(a_tooltip.length()-(a_size*8)+m_FirstBit, QLatin1String("")); + a_tooltip.insert(a_tooltip.length()-(a_size*8)+m_LastBit+1, QLatin1String("")); + return m_IsLast; } + return true; +} - // --------------------------------------------------------------- - LogViewXdrType::LogViewXdrType(const QString &a_name, - const QString &a_type, - const uint16_t a_arraySize, - const uint16_t a_dynArrayOffset, - const E_ElementKind a_kind, - const int16_t a_firstBit, - const int16_t a_lastBit, - const bool a_isLast) - : LogViewXdrElement(a_name, a_kind, "LogViewXdrType") - , m_Type(a_type) - , m_ArraySize(a_arraySize) - , m_MaxArraySize(a_dynArrayOffset) - , m_FirstBit(a_firstBit) - , m_LastBit(a_lastBit) - , m_IsLast(a_isLast) - { - } +uint16_t LogViewXdrType::getMaxArraySize() const +{ + return m_MaxArraySize; +} - // --------------------------------------------------------------- - void LogViewXdrType::dump() const - { - INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " type=" << getType() << " arraySize=" << getArraySize() - << " maxArraySize=" << getMaxArraySize() << " firstBit=" << m_FirstBit << " lastBit=" << m_LastBit << " isLast=" << m_IsLast; - } - - - // --------------------------------------------------------------- - const QString &LogViewXdrType::getType() const - { - return m_Type; - } - - // --------------------------------------------------------------- - // 0 => opaque - // 1 => normal (scalar) element - // >1 => array - // --------------------------------------------------------------- - uint16_t LogViewXdrType::getArraySize() const - { - return m_ArraySize; - } - - - // --------------------------------------------------------------- - bool LogViewXdrType::maskValue(uint32_t &a_value, const uint16_t a_size, QString &a_tooltip) const - { - // INFO_LOG(m_logger) << "firstBit=" << m_FirstBit << " lastBit=" << m_LastBit << " isLast=" << m_IsLast; - if (m_FirstBit != -1 && m_LastBit != -1) - { - DEBUG_LOG(m_logger) << "MaskValue for Element " << m_Name << " type: " << m_Type << " size: " << m_ArraySize << " first:last " << m_FirstBit << ":" << m_LastBit - << " isLast: " << m_IsLast; - uint16_t bitshift = (a_size * 8) - m_LastBit - 1; - uint32_t mask = (1 << (m_LastBit - m_FirstBit + 1)) - 1; - // INFO_LOG(m_logger) << "value=" << a_value << " bitshift=" << bitshift << " mask=" << mask; - a_value = (a_value >> bitshift) & mask; - // make bold the corresponding bits in the bitfield - a_tooltip.insert(a_tooltip.length() - (a_size * 8) + m_FirstBit, QLatin1String("")); - a_tooltip.insert(a_tooltip.length() - (a_size * 8) + m_LastBit + 1, QLatin1String("")); - return m_IsLast; - } - return true; - } - - - // --------------------------------------------------------------- - uint16_t LogViewXdrType::getMaxArraySize() const - { - return m_MaxArraySize; - } - -} // namespace N_LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.hpp index 81fd83816..a189f3764 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrType.hpp @@ -1,115 +1,72 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewXdrElement.hpp" namespace N_LogView { - /** - * This class represents XDR-elements which have a type and an arraySize. This are - * typedefs and struct-elements. - * The arraySize has following possibilities: - * 0 => opaque - * 1 => scalar - * >1 => array - * - * @author alois.wismer - * @version 1.0 - * @created 16-Feb-2010 15:48:24 - */ + + class LogViewXdrType final : public LogViewXdrElement { public: - /** - * - * @param a_name - * @param a_type - * @param a_arraySize - * @param a_dynArrayOffset - * @param a_kind - */ - LogViewXdrType(const QString &a_name, const QString &a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind); - /** - * - * @param a_name - * @param a_type - * @param a_arraySize - * @param a_dynArrayOffset - * @param a_kind - * @param a_firstBit - * @param a_lastBit - * @param a_isLast - */ - LogViewXdrType(const QString &a_name, - const QString &a_type, - const uint16_t a_arraySize, - const uint16_t a_dynArrayOffset, - const E_ElementKind a_kind, - const int16_t a_firstBit, - const int16_t a_lastBit, - const bool a_isLast); + + + LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind); + + + + LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit, const int16_t a_lastBit, const bool a_isLast); void dump() const override; - const QString &getType() const; + const QString& getType() const; + + - /** - * 0 => opaque - * 1 => normal (scalar) element - * >1 => array - */ uint16_t getArraySize() const; - /** - * - * @param a_value - * @param a_size - * @param a_tooltip - */ - bool maskValue(uint32_t &a_value, const uint16_t a_size, QString &a_tooltip) const; + + + bool maskValue(uint32_t& a_value, const uint16_t a_size, QString& a_tooltip) const; uint16_t getMaxArraySize() const; protected: + QString m_Type; - /** - * 0 => opaque - * 1 => normal (scalar) element - * >1 => array - */ + + uint16_t m_ArraySize; - /** - * The maximum size of the array. Interesting for dynamic arrays. - */ + + uint16_t m_MaxArraySize; - /** - * The first relevant bit, if we have bitfield-enum - */ + + int16_t m_FirstBit; - /** - * The last relevant bit, if we have bitfield-enum - */ + + int16_t m_LastBit; - /** - * used to step to next values when reading out content-data of bit-fields - */ + + bool m_IsLast; }; } + diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.cpp index 26d27d244..70e8a2b93 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.cpp @@ -1,41 +1,40 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #include "LogViewXdrValue.hpp" namespace N_LogView { - // --------------------------------------------------------------- - LogViewXdrValue::LogViewXdrValue(const QString &a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind) - : LogViewXdrElement(a_name, a_kind, "LogViewXdrValue") - , m_Value(a_value) - { - } + +LogViewXdrValue::LogViewXdrValue(const QString& a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind) + : LogViewXdrElement(a_name, a_kind, "LogViewXdrValue") + , m_Value(a_value) +{} - // --------------------------------------------------------------- - void LogViewXdrValue::dump() const - { - INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " value=" << getValue(); - } + +void LogViewXdrValue::dump() const +{ + INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " value=" << getValue(); +} - // --------------------------------------------------------------- - int64_t LogViewXdrValue::getValue() const - { - return m_Value; - } -} // namespace N_LogView +int64_t LogViewXdrValue::getValue() const +{ + return m_Value; +} + +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.hpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.hpp index 3610f9924..db8eec061 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.hpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/LogViewXdrValue.hpp @@ -1,39 +1,34 @@ -// ************************************************************************** -// -// (C) Copyright 2009 Swiss SIMTEC AG -// -// ************************************************************************** -// -// $HeadURL$ -// $LastChangedBy$ -// $LastChangedDate$ -// $LastChangedRevision$ -// -// ************************************************************************** + + + + + + + + + + + + #pragma once #include "LogViewXdrElement.hpp" namespace N_LogView { - /** - * This class represents XDR-elements which have a value. This are #defines and - * enum-elements. - * - * @author alois.wismer - * @version 1.0 - * @created 17-Feb-2010 11:17:53 - */ + + class LogViewXdrValue final : public LogViewXdrElement { public: - LogViewXdrValue(const QString &a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind); + LogViewXdrValue(const QString& a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind); void dump() const override; int64_t getValue() const; protected: + int64_t m_Value; }; } diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.cpp b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.cpp index bbfbca317..8790cc277 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.cpp +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.cpp @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * Building Config - logging facility - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #include "logger.h" @@ -13,24 +8,25 @@ namespace N_LogView { - LOGGER_T getLogger(const char *name) +LOGGER_T getLogger(const char *name) +{ + static const char ns[] = "LogView."; + std::string loggerName; + const size_t len = strlen(name); + loggerName.reserve(sizeof(ns) + len); + loggerName.append(ns, sizeof(ns) - 1); + loggerName.append(name, len); + + try { - static const char ns[] = "LogView."; - std::string loggerName; - const size_t len = strlen(name); - loggerName.reserve(sizeof(ns) + len); - loggerName.append(ns, sizeof(ns) - 1); - loggerName.append(name, len); - - try - { - return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName); - } - catch (const std::exception &ex) - { - fprintf(stderr, "Error retrieving logger: %s", ex.what()); - abort(); - } + return NGL::NGLLoggerBootstrap::getNGLRootLogger(). + getNGLLogger(loggerName); } + catch (const std::exception &ex) + { + fprintf(stderr, "Error retrieving logger: %s", ex.what()); + abort(); + } +} -} // namespace LogView +} diff --git a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.h b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.h index c43a9c3db..8baf71f9f 100644 --- a/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.h +++ b/qt6-after/qt6-migrated-legatus/TetraIF/LogView/logger.h @@ -1,10 +1,5 @@ -/** - * @RDE_HEADER@ - * Logging for AudioVideoManagement - * $Id$ - * $HeadURL$ - * $Author$ - */ + + #pragma once @@ -12,11 +7,11 @@ namespace N_LogView { - typedef NGL::INGLLogger &LOGGER_T; +typedef NGL::INGLLogger &LOGGER_T; - LOGGER_T getLogger(const char *name); - inline LOGGER_T getLogger(const QString &loggerName) - { - return getLogger(loggerName.toUtf8().constData()); - } -} // namespace LogView +LOGGER_T getLogger(const char *name); +inline LOGGER_T getLogger(const QString &loggerName) +{ + return getLogger(loggerName.toUtf8().constData()); +} +}