diff --git a/doc/manual/file_formats.md b/doc/manual/file_formats.md index e23a3088..964277aa 100644 --- a/doc/manual/file_formats.md +++ b/doc/manual/file_formats.md @@ -38,9 +38,6 @@ to be used. Notes for the paths: -- "application" should contain the path of your executable relative to the path - of the ConfigGUI binary - it is recommended to place all executables in the - `./bin` directory. - Results will be stored in the directory from which the call is made. ## Result File (`*.xqar`) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7adab0b9..3a47b7c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,6 @@ set(CMAKE_INSTALL_RPATH $ORIGIN/../lib) add_subdirectory(common) add_subdirectory(report_modules) add_subdirectory(result_pooling) -add_subdirectory(runtime) # FIXME: install()? ## copy common lib @@ -40,4 +39,4 @@ file( PATTERN "*.svn" EXCLUDE ) -file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/plugin) \ No newline at end of file +file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/plugin) diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt deleted file mode 100644 index 009733c6..00000000 --- a/src/runtime/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - -set(RUNTIME_PROJECT "ConfigGUI") -project(${RUNTIME_PROJECT}) - -set(CMAKE_AUTOMOC ON) - -add_executable(${RUNTIME_PROJECT} - src/c_configuration_validator.cpp - src/c_configuration_validator.h - src/runtime.cpp - src/runtime.h - src/stdafx.cpp - src/stdafx.h - src/ui/c_checker_dialog.cpp - src/ui/c_param_dialog.cpp - src/ui/c_local_param_dialog.cpp - src/ui/c_global_param_dialog.cpp - src/ui/c_process_view.cpp - src/ui/c_runtime_window.cpp -) - -target_link_libraries(${RUNTIME_PROJECT} PRIVATE - qc4openx-common - Qt5::Gui - Qt5::Widgets - $<$:stdc++fs> -) - -if (WIN32) - # FIXME: We need some adaptions that this is usable in Linux - install(TARGETS ${RUNTIME_PROJECT} DESTINATION bin) - qc4openx_install_qt(bin ${RUNTIME_PROJECT}${CMAKE_EXECUTABLE_SUFFIX}) -endif(WIN32) - -set_target_properties(${RUNTIME_PROJECT} PROPERTIES FOLDER runtime) diff --git a/src/runtime/src/c_configuration_validator.cpp b/src/runtime/src/c_configuration_validator.cpp deleted file mode 100644 index d96cde15..00000000 --- a/src/runtime/src/c_configuration_validator.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_configuration_validator.h" - -#include "common/config_format/c_configuration.h" - -bool cConfigurationValidator::ValidateConfiguration(cConfiguration *const configuration, std::string &message) -{ - message = "Unknown failure"; - - bool success = true; - - success = CheckNecessaryParametersExist(configuration, message); - if (!success) - return false; - - success = CheckParameterNotEmpty(configuration, PARAM_INPUT_FILE, message); - if (!success) - return false; - - return true; -} - -bool cConfigurationValidator::CheckNecessaryParametersExist(cConfiguration *const configuration, std::string &message) -{ - if (!configuration->HasParam(PARAM_INPUT_FILE)) - { - message = "Configuration needs a parameter '" + PARAM_INPUT_FILE + "' for running."; - return false; - } - - return true; -} - -bool cConfigurationValidator::CheckParameterNotEmpty(cConfiguration *const configuration, const std::string ¶mName, - std::string &message) -{ - if (configuration->HasParam(paramName)) - { - const std::string paramValue = configuration->GetParam(paramName); - - if (paramValue.empty()) - { - message = "Parameter '" + paramName + "' is empty. Please specify a value."; - return false; - } - } - - return true; -} diff --git a/src/runtime/src/c_configuration_validator.h b/src/runtime/src/c_configuration_validator.h deleted file mode 100644 index 478ddd53..00000000 --- a/src/runtime/src/c_configuration_validator.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef cConfigurationValidator_h__ -#define cConfigurationValidator_h__ - -#include - -class cConfiguration; - -// Validator for the configuration file -class cConfigurationValidator -{ - - public: - // Checks a Configuration for consistency - static bool ValidateConfiguration(cConfiguration *config, std::string &message); - - protected: - // Check if at least one of the necessary parameters exists - static bool CheckNecessaryParametersExist(cConfiguration *const configuration, std::string &message); - - // Check if parameter is valid (is not empty) - static bool CheckParameterNotEmpty(cConfiguration *const configuration, const std::string ¶mName, - std::string &message); -}; - -#endif diff --git a/src/runtime/src/runtime.cpp b/src/runtime/src/runtime.cpp deleted file mode 100644 index a7c46606..00000000 --- a/src/runtime/src/runtime.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "runtime.h" -#include "stdafx.h" - -#include "ui/c_runtime_window.h" - -XERCES_CPP_NAMESPACE_USE - -// Main program entry point -int main(int argc, char *argv[]) -{ - std::string strToolpath = argv[0]; - - std::string strConfigurationFilepath = ""; - std::string strInputFilepath = ""; - - std::cout << std::endl << std::endl; - - for (int i = 1; i < argc; i++) - { - if (strcmp(argv[i], "-config") == 0) - { - if (argc >= i + 1) - { - strConfigurationFilepath = argv[i + 1]; - std::cout << "Configuration: " << strConfigurationFilepath << std::endl; - } - } - else if (strcmp(argv[i], "-input") == 0) - { - if (argc >= i + 1) - { - strInputFilepath = argv[i + 1]; - std::cout << "Input: " << strInputFilepath << std::endl; - } - } - else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) - { - ShowHelp(strToolpath); - return 0; - } - } - - // Handle open of configuration with only one parameter - if (argc == 2) - strConfigurationFilepath = argv[1]; - - QApplication app(argc, argv); - RunConfigGUI(strConfigurationFilepath, strInputFilepath, app); - return 0; -} - -void ShowHelp(const std::string &toolPath) -{ - std::string applicationName = toolPath; - std::string applicationNameWithoutExt = toolPath; - GetFileName(&applicationName, false); - GetFileName(&applicationNameWithoutExt, true); - - std::cout << "\nUsage of " << applicationNameWithoutExt << ":" << std::endl; - std::cout << "\nOpen the application with DefaultConfiguration.xml: \n" - << applicationName << " myConfiguration.xml" << std::endl; - std::cout << "\nOpen the application with myConfiguration.xml and a given input file which is under " - "test. \n" - << applicationName << " -config myConfiguration.xml -input myTrack.xodr " << std::endl; - std::cout << "\n\n"; -} - -void RunConfigGUI(const std::string &strConfigurationFilepath, const std::string &strInputFilepath, - const QApplication &app) -{ - cRuntimeWindow mainWindow(strConfigurationFilepath, strInputFilepath); - mainWindow.show(); - - app.processEvents(); - - app.exec(); -} diff --git a/src/runtime/src/runtime.h b/src/runtime/src/runtime.h deleted file mode 100644 index bcfe818e..00000000 --- a/src/runtime/src/runtime.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "common/util.h" - -#include - -/** - * Main function for application - * - * @param [in] argc Number of arguments in shell - * @param [in] argv Pointer to arguments - * - * @return The standard return value - */ -int main(int argc, char *argv[]); - -/** - * Shows the help for the application - * @param [in] applicationName The name of the application - */ -void ShowHelp(const std::string &applicationName); - -/** - * Runs the config gui - */ -void RunConfigGUI(const std::string &strConfigurationFilepath, const std::string &strInputFilepath, - const QApplication &app); diff --git a/src/runtime/src/stdafx.cpp b/src/runtime/src/stdafx.cpp deleted file mode 100644 index 4a0e5a70..00000000 --- a/src/runtime/src/stdafx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "stdafx.h" diff --git a/src/runtime/src/stdafx.h b/src/runtime/src/stdafx.h deleted file mode 100644 index 370fd954..00000000 --- a/src/runtime/src/stdafx.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef _STD_INCLUDE_HEADER_ -#define _STD_INCLUDE_HEADER_ - -#include -#include -#include -#include - -#include "common/util.h" - -#endif // _STD_INCLUDE_HEADER_ diff --git a/src/runtime/src/ui/c_checker_dialog.cpp b/src/runtime/src/ui/c_checker_dialog.cpp deleted file mode 100644 index 4dea8fd4..00000000 --- a/src/runtime/src/ui/c_checker_dialog.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_checker_dialog.h" -#include - -cCheckerDialog::cCheckerDialog(eIssueLevel minLevel, eIssueLevel maxLevel, QWidget *parent) : QDialog(parent) -{ - QVBoxLayout *layout = new QVBoxLayout; - - QWidget *paramWidget = new QWidget(this); - QVBoxLayout *paramWidgetLayout = new QVBoxLayout; - - QLabel *minLevelLabel = new QLabel(paramWidget); - minLevelLabel->setText("Minimal warn level of issues"); - - _minLevelEdit = new QComboBox(this); - _minLevelEdit->setEditable(false); - - _minLevelEdit->addItem("Information", INFO_LVL); - _minLevelEdit->addItem("Warning", WARNING_LVL); - _minLevelEdit->addItem("Error", ERROR_LVL); - - int index = _minLevelEdit->findData(minLevel); - if (index != -1) - { - _minLevelEdit->setCurrentIndex(index); - } - - QLabel *maxLevelLabel = new QLabel(paramWidget); - maxLevelLabel->setText("Maximal warn level of issues"); - - _maxLevelEdit = new QComboBox(this); - _maxLevelEdit->setEditable(false); - - _maxLevelEdit->addItem("Error", ERROR_LVL); - _maxLevelEdit->addItem("Warning", WARNING_LVL); - _maxLevelEdit->addItem("Information", INFO_LVL); - - index = _maxLevelEdit->findData(maxLevel); - if (index != -1) - { - _maxLevelEdit->setCurrentIndex(index); - } - - paramWidgetLayout->setContentsMargins(3, 3, 3, 3); - paramWidgetLayout->addWidget(minLevelLabel, 0); - paramWidgetLayout->addWidget(_minLevelEdit, 0); - paramWidgetLayout->addWidget(maxLevelLabel, 0); - paramWidgetLayout->addWidget(_maxLevelEdit, 0); - paramWidget->setLayout(paramWidgetLayout); - - QPushButton *okay = new QPushButton(this); - okay->setText("Set"); - - connect(okay, SIGNAL(clicked()), this, SLOT(SaveAndClose())); - - layout->addWidget(paramWidget, 2); - layout->addWidget(okay, 0); - layout->setContentsMargins(2, 3, 2, 3); - - setLayout(layout); - setWindowFlags(Qt::Tool); - setMinimumWidth(250); - - setWindowTitle("Checker"); -} - -void cCheckerDialog::SaveAndClose() -{ - accept(); -} - -// Returns the min level -eIssueLevel cCheckerDialog::GetMinLevel() const -{ - assert(_minLevelEdit != nullptr); - return static_cast(_minLevelEdit->currentData().toInt()); -} - -// Returns the max level -eIssueLevel cCheckerDialog::GetMaxLevel() const -{ - assert(_maxLevelEdit != nullptr); - return static_cast(_maxLevelEdit->currentData().toInt()); -} diff --git a/src/runtime/src/ui/c_checker_dialog.h b/src/runtime/src/ui/c_checker_dialog.h deleted file mode 100644 index 6fac185a..00000000 --- a/src/runtime/src/ui/c_checker_dialog.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef CCHECKER_DIALOG_H -#define CCHECKER_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include - -#include "common/result_format/c_issue.h" - -class cCheckerDialog : public QDialog -{ - Q_OBJECT - - public: - cCheckerDialog(eIssueLevel minLevel, eIssueLevel maxLevel, QWidget *parent); - - // Returns the min level - eIssueLevel GetMinLevel() const; - - // Returns the max level - eIssueLevel GetMaxLevel() const; - - protected: - QComboBox *_minLevelEdit{nullptr}; - QComboBox *_maxLevelEdit{nullptr}; - - public slots: - void SaveAndClose(); -}; - -#endif diff --git a/src/runtime/src/ui/c_global_param_dialog.cpp b/src/runtime/src/ui/c_global_param_dialog.cpp deleted file mode 100644 index d975c061..00000000 --- a/src/runtime/src/ui/c_global_param_dialog.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_global_param_dialog.h" -#include "common/util.h" - -#include "c_process_view.h" - -#include "common/config_format/c_configuration.h" - -cGlobalParamDialog::cGlobalParamDialog(const QString &initalParamName, const QString &initalParamValue, - const bool paramNameEditable, cProcessView *parent, - const cConfiguration *currentConfig) - : cParamDialog(initalParamName, initalParamValue, paramNameEditable, parent) -{ - _processView = parent; - InitUIElements(initalParamName, initalParamValue, paramNameEditable, currentConfig); - AddWidgetsToLayout(initalParamName); -} - -void cGlobalParamDialog::InitUIElements(const QString &initalParamName, const QString &initalParamValue, - const bool paramNameEditable, const cConfiguration *currentConfig) -{ - InitBasicUIElements(initalParamName, initalParamValue); - - _paramNameComboBox = new QComboBox(this); - QStringList items; - - // Add default parameters - items << QString::fromStdString(PARAM_INPUT_FILE); - - // Add parameters, which are in current config - std::vector params = currentConfig->GetParams().GetParams(); - for (size_t i = 0; i < params.size(); ++i) - items << QString::fromStdString(params[i]); - - // Add initial parameter (just for safety) - items << initalParamName; - - items.removeDuplicates(); - _paramNameComboBox->addItems(items); - _paramNameComboBox->setCurrentText(initalParamName); - _paramNameComboBox->setEditable(true); - _paramNameComboBox->setEnabled(paramNameEditable); - - connect(_paramNameComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(SwitchCall(const QString &))); - connect(_paramNameComboBox, SIGNAL(editTextChanged(const QString &)), this, SLOT(SwitchCall(const QString &))); -} - -void cGlobalParamDialog::AddWidgetsToLayout(const QString &initalParamName) -{ - _paramWidgetLayout->addWidget(_paramNameComboBox, 2); - AddBasicWidgetsToLayout(); - - SwitchCall(initalParamName); -} - -void cGlobalParamDialog::SwitchCall(const QString ¶mName) -{ - RemoveFileOpenButton(); - - if (paramName.toLower() == QString::fromStdString(PARAM_INPUT_FILE).toLower()) - AddFileOpenButton(SLOT(OpenInputFile())); -} - -void cGlobalParamDialog::AddFileOpenButton(const char *slot) -{ - _fileOpenButton = new QPushButton(this); - _fileOpenButton->setText("..."); - - connect(_fileOpenButton, SIGNAL(clicked()), this, slot); - _paramWidgetLayout->addWidget(_fileOpenButton, 0); -} - -void cGlobalParamDialog::RemoveFileOpenButton() -{ - if (_fileOpenButton != 0) - { - _paramWidgetLayout->removeWidget(_fileOpenButton); - delete _fileOpenButton; - _fileOpenButton = nullptr; - } -} - -void cGlobalParamDialog::SaveAndClose() -{ - _paramName = _paramNameComboBox->currentText(); - _paramValue = _paramValueEdit->text(); - - accept(); -} - -void cGlobalParamDialog::OpenInputFile() -{ - QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"), "", ""); - - if (!filePath.isEmpty()) - _paramValueEdit->setText(filePath); -} diff --git a/src/runtime/src/ui/c_global_param_dialog.h b/src/runtime/src/ui/c_global_param_dialog.h deleted file mode 100644 index 10888dfc..00000000 --- a/src/runtime/src/ui/c_global_param_dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef CGLOBAL_PARAM_DIALOG_H -#define CGLOBAL_PARAM_DIALOG_H - -#include "c_param_dialog.h" - -// Forward declaration to avoid problems with circular dependencies (especially under Linux) -class cConfiguration; -class cProcessView; - -class cGlobalParamDialog : public cParamDialog -{ - Q_OBJECT - - public: - cGlobalParamDialog(const QString &initalParamName, const QString &initalParamValue, const bool paramNameEditable, - cProcessView *parent, const cConfiguration *currentConfig); - - protected: - cProcessView *_processView{nullptr}; - QComboBox *_paramNameComboBox{nullptr}; - QPushButton *_fileOpenButton{nullptr}; - - void InitUIElements(const QString &initalParamName, const QString &initalParamValue, const bool paramNameEditable, - const cConfiguration *currentConfig); - void AddWidgetsToLayout(const QString &initalParamName); - - private: - void AddFileOpenButton(const char *slot); - void RemoveFileOpenButton(); - - public slots: - void SwitchCall(const QString ¶mName); - void SaveAndClose(); - void OpenInputFile(); -}; - -#endif diff --git a/src/runtime/src/ui/c_local_param_dialog.cpp b/src/runtime/src/ui/c_local_param_dialog.cpp deleted file mode 100644 index ee272b49..00000000 --- a/src/runtime/src/ui/c_local_param_dialog.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_local_param_dialog.h" - -cLocalParamDialog::cLocalParamDialog(const QString &initalParamName, const QString &initalParamValue, - const bool paramNameEditable, QWidget *parent) - : cParamDialog(initalParamName, initalParamValue, paramNameEditable, parent) -{ - InitUIElements(initalParamName, initalParamValue, paramNameEditable); - AddWidgetsToLayout(); -} - -void cLocalParamDialog::InitUIElements(const QString &initalParamName, const QString &initalParamValue, - const bool paramNameEditable) -{ - InitBasicUIElements(initalParamName, initalParamValue); - - _paramNameEdit = new QLineEdit(this); - _paramNameEdit->setText(initalParamName); - _paramNameEdit->setEnabled(paramNameEditable); -} - -void cLocalParamDialog::AddWidgetsToLayout() -{ - _paramWidgetLayout->addWidget(_paramNameEdit, 2); - AddBasicWidgetsToLayout(); -} - -void cLocalParamDialog::SaveAndClose() -{ - _paramName = _paramNameEdit->text(); - _paramValue = _paramValueEdit->text(); - - accept(); -} diff --git a/src/runtime/src/ui/c_local_param_dialog.h b/src/runtime/src/ui/c_local_param_dialog.h deleted file mode 100644 index 747ae4fb..00000000 --- a/src/runtime/src/ui/c_local_param_dialog.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef CLOCAL_PARAM_DIALOG_H -#define CLOCAL_PARAM_DIALOG_H - -#include "c_param_dialog.h" - -class cLocalParamDialog : public cParamDialog -{ - Q_OBJECT - - public: - cLocalParamDialog(const QString &initalParamName, const QString &initalParamValue, const bool paramNameEditable, - QWidget *parent); - - protected: - QLineEdit *_paramNameEdit{nullptr}; - - void InitUIElements(const QString &initalParamName, const QString &initalParamValue, const bool paramNameEditable); - void AddWidgetsToLayout(); - - public slots: - void SaveAndClose(); -}; - -#endif diff --git a/src/runtime/src/ui/c_param_dialog.cpp b/src/runtime/src/ui/c_param_dialog.cpp deleted file mode 100644 index f69230cb..00000000 --- a/src/runtime/src/ui/c_param_dialog.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_param_dialog.h" - -cParamDialog::cParamDialog(const QString & /*initalParamName*/, const QString & /*initalParamValue*/, - const bool /*paramNameEditable*/, QWidget *parent) - : QDialog(parent) -{ -} - -void cParamDialog::InitBasicUIElements(const QString &initalParamName, const QString &initalParamValue) -{ - _paramName = initalParamName; - _paramValue = initalParamValue; - - QVBoxLayout *layout = new QVBoxLayout; - - QWidget *paramWidget = new QWidget(this); - _paramWidgetLayout = new QHBoxLayout; - _paramWidgetLayout->setContentsMargins(3, 3, 3, 3); - paramWidget->setLayout(_paramWidgetLayout); - - _paramLabel = new QLabel(this); - _paramLabel->setText(" = "); - _paramLabel->setStyleSheet("font-weight: bold;"); - - _paramValueEdit = new QLineEdit(this); - _paramValueEdit->setText(initalParamValue); - - QPushButton *okayButton = new QPushButton(this); - okayButton->setText("Set"); - connect(okayButton, SIGNAL(clicked()), this, SLOT(SaveAndClose())); - - layout->addWidget(paramWidget, 2); - layout->addWidget(okayButton, 0); - layout->setContentsMargins(2, 3, 2, 3); - - setLayout(layout); - setWindowFlags(Qt::Tool); - setMinimumWidth(350); - - _paramValueEdit->setFocus(); - - setWindowTitle("Parameters"); -} - -void cParamDialog::AddBasicWidgetsToLayout() -{ - _paramWidgetLayout->addWidget(_paramLabel, 0); - _paramWidgetLayout->addWidget(_paramValueEdit, 3); -} - -// Returns the name of the param -QString cParamDialog::GetParamName() const -{ - return _paramName; -} - -// Returns the value of the param -QString cParamDialog::GetParamValue() const -{ - return _paramValue; -} diff --git a/src/runtime/src/ui/c_param_dialog.h b/src/runtime/src/ui/c_param_dialog.h deleted file mode 100644 index 4165cae5..00000000 --- a/src/runtime/src/ui/c_param_dialog.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef CPARAM_DIALOG_H -#define CPARAM_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include - -class cParamDialog : public QDialog -{ - Q_OBJECT - - public: - cParamDialog(const QString &initalParamName, const QString &initalParamValue, const bool paramNameEditable, - QWidget *parent); - - // Returns the name of the param - QString GetParamName() const; - - // Returns the value of the param - QString GetParamValue() const; - - protected: - QString _paramName; - QString _paramValue; - - QHBoxLayout *_paramWidgetLayout{nullptr}; - QLabel *_paramLabel{nullptr}; - QLineEdit *_paramValueEdit{nullptr}; - - void InitBasicUIElements(const QString &initalParamName, const QString &initalParamValue); - void AddBasicWidgetsToLayout(); - - public slots: - virtual void SaveAndClose() = 0; -}; - -#endif diff --git a/src/runtime/src/ui/c_process_view.cpp b/src/runtime/src/ui/c_process_view.cpp deleted file mode 100644 index 7129b532..00000000 --- a/src/runtime/src/ui/c_process_view.cpp +++ /dev/null @@ -1,700 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_process_view.h" - -#include "common/result_format/c_checker_bundle.h" -#include "common/result_format/c_parameter_container.h" -#include "common/result_format/c_result_container.h" - -#include "common/config_format/c_configuration.h" -#include "common/config_format/c_configuration_checker.h" -#include "common/config_format/c_configuration_checker_bundle.h" -#include "common/config_format/c_configuration_report_module.h" - -#include "c_checker_dialog.h" -#include "c_global_param_dialog.h" -#include "c_local_param_dialog.h" -#include "c_param_dialog.h" - -cProcessView::cProcessView(QWidget *parent) : QTreeWidget(parent) -{ - setContextMenuPolicy(Qt::CustomContextMenu); - - setSortingEnabled(false); - - connect(this, &QTreeWidget::customContextMenuRequested, this, &cProcessView::showContextMenu); -} - -const QString cProcessView::GetApplicationDir() -{ - return QCoreApplication::applicationDirPath() + "/"; -} - -void cProcessView::LoadConfiguration(cConfiguration *const configuration) -{ - _currentConfiguration = configuration; - clear(); - - cParameterContainer configParams = configuration->GetParams(); - std::vector paramNames = configParams.GetParams(); - - // Add Configuration Params - for (std::vector::const_iterator paramIt = paramNames.cbegin(); paramIt != paramNames.cend(); - paramIt++) - { - AddParamItemToRoot(*paramIt, configParams.GetParam(*paramIt)); - } - - // Add CheckerBundles - std::vector checkerBundle = configuration->GetCheckerBundles(); - for (std::vector::const_iterator bundleIt = checkerBundle.cbegin(); - bundleIt != checkerBundle.cend(); bundleIt++) - { - AddCheckerBundleItemToRoot(*bundleIt); - } - - // Add ReportModules - std::vector reportModules = configuration->GetReportModules(); - for (std::vector::const_iterator reportModuleIt = reportModules.cbegin(); - reportModuleIt != reportModules.cend(); reportModuleIt++) - { - AddReportModuleItemToRoot(*reportModuleIt); - } - - expandAll(); -} - -void cProcessView::AddConfiguration(cConfiguration *const configurationToAdd) -{ - if (nullptr == configurationToAdd) - return; - - // Add CheckerBundles - std::vector checkerBundle = configurationToAdd->GetCheckerBundles(); - for (std::vector::const_iterator bundleIt = checkerBundle.cbegin(); - bundleIt != checkerBundle.cend(); bundleIt++) - { - AddCheckerBundleItemToRoot(*bundleIt, true); - } - - // Add ReportModules - std::vector reportModules = configurationToAdd->GetReportModules(); - for (std::vector::const_iterator reportModuleIt = reportModules.cbegin(); - reportModuleIt != reportModules.cend(); reportModuleIt++) - { - AddReportModuleItemToRoot(*reportModuleIt, true); - } -} - -void cProcessView::showContextMenu(const QPoint &pos) -{ - QTreeWidgetItem *currentItem = itemAt(pos); - QMenu menu(this); - - if (nullptr != currentItem) - { - QVariant itemType = currentItem->data(0, ITEM_TYPE_ID); - - switch (itemType.toInt()) - { - case ITEM_PARAM: { - QAction *editAction = new QAction("Edit"); - menu.addAction(editAction); - QAction *deleteAction = new QAction("Delete"); - menu.addAction(deleteAction); - - connect(editAction, SIGNAL(triggered(void)), this, SLOT(EditParam())); - connect(deleteAction, SIGNAL(triggered(void)), this, SLOT(DeleteParam())); - break; - } - case ITEM_CHECKER_BUNDLE: { - QAction *addParameterAction = new QAction("Add Parameter"); - menu.addAction(addParameterAction); - menu.addSeparator(); - QAction *deleteAction = new QAction("Delete"); - menu.addAction(deleteAction); - - menu.addSeparator(); - QAction *moveUpAction = new QAction("Move Up"); - menu.addAction(moveUpAction); - QAction *moveDownAction = new QAction("Move Down"); - menu.addAction(moveDownAction); - - connect(addParameterAction, SIGNAL(triggered(void)), this, SLOT(AddLocalParam())); - connect(deleteAction, SIGNAL(triggered(void)), this, SLOT(DeleteCheckerBundle())); - connect(moveUpAction, SIGNAL(triggered(void)), this, SLOT(MoveUp())); - connect(moveDownAction, SIGNAL(triggered(void)), this, SLOT(MoveDown())); - - break; - } - case ITEM_CHECKER: { - QAction *addParameterAction = new QAction("Add Parameter"); - menu.addAction(addParameterAction); - - QAction *editAction = new QAction("Edit"); - menu.addAction(editAction); - QAction *deleteAction = new QAction("Delete"); - menu.addAction(deleteAction); - - connect(addParameterAction, SIGNAL(triggered(void)), this, SLOT(AddLocalParam())); - connect(editAction, SIGNAL(triggered(void)), this, SLOT(EditChecker())); - connect(deleteAction, SIGNAL(triggered(void)), this, SLOT(DeleteChecker())); - - break; - } - case ITEM_REPORT_MODULE: { - QAction *addParameterAction = new QAction("Add Parameter"); - menu.addAction(addParameterAction); - - menu.addSeparator(); - QAction *editAction = new QAction("Edit"); - menu.addAction(editAction); - QAction *deleteAction = new QAction("Delete"); - menu.addAction(deleteAction); - - menu.addSeparator(); - QAction *moveUpAction = new QAction("Move Up"); - menu.addAction(moveUpAction); - QAction *moveDownAction = new QAction("Move Down"); - menu.addAction(moveDownAction); - - connect(addParameterAction, SIGNAL(triggered(void)), this, SLOT(AddLocalParam())); - connect(deleteAction, SIGNAL(triggered(void)), this, SLOT(DeleteReportModule())); - connect(moveUpAction, SIGNAL(triggered(void)), this, SLOT(MoveUp())); - connect(moveDownAction, SIGNAL(triggered(void)), this, SLOT(MoveDown())); - - break; - } - } - } - else - { - QAction *addModuleAction = new QAction("Add Module"); - menu.addAction(addModuleAction); - - connect(addModuleAction, SIGNAL(triggered(void)), this, SLOT(AddModule())); - } - - menu.exec(mapToGlobal(pos)); -}; - -void cProcessView::mouseDoubleClickEvent(QMouseEvent *event) -{ - QTreeWidgetItem *clickedItem = itemAt(event->pos()); - - if (nullptr != clickedItem) - { - QVariant itemType = clickedItem->data(0, ITEM_TYPE_ID); - - if (itemType == ITEM_PARAM) - EditParam(clickedItem); - else if (itemType == ITEM_CHECKER) - EditChecker(clickedItem); - } -} - -cParamData cProcessView::GetParamDataFromItem(const QTreeWidgetItem *item) -{ - QVariant data = item->data(0, ITEM_DATA_ID); - cParamData paramData = data.value(); - return paramData; -} - -cCheckerBundleData cProcessView::GetCheckerBundleDataFromItem(const QTreeWidgetItem *item) -{ - QVariant data = item->data(0, ITEM_DATA_ID); - cCheckerBundleData checkerBundleData = data.value(); - return checkerBundleData; -} - -cCheckerData cProcessView::GetCheckerDataFromItem(const QTreeWidgetItem *item) -{ - QVariant data = item->data(0, ITEM_DATA_ID); - cCheckerData checkerData = data.value(); - return checkerData; -} - -cReportModuleData cProcessView::GetReportModuleDataFromItem(const QTreeWidgetItem *item) -{ - QVariant data = item->data(0, ITEM_DATA_ID); - cReportModuleData reportModuleData = data.value(); - return reportModuleData; -} - -void cProcessView::AddCheckerBundleItemToRoot(cConfigurationCheckerBundle *const checkerBundle, const bool expand) -{ - QTreeWidgetItem *newCheckerBundleItem = new QTreeWidgetItem(invisibleRootItem()); - - newCheckerBundleItem->setBackgroundColor(0, QColor(0, 120, 250, 128)); - newCheckerBundleItem->setText( - 0, QString("CheckerBundle %1").arg(checkerBundle->GetCheckerBundleApplication().c_str())); - newCheckerBundleItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); - newCheckerBundleItem->setData(0, ITEM_TYPE_ID, ITEM_CHECKER_BUNDLE); - - cCheckerBundleData newData; - newData.applicationName = checkerBundle->GetCheckerBundleApplication(); - newData.enabled = true; - - QVariant data; - data.setValue(newData); - - newCheckerBundleItem->setData(0, ITEM_DATA_ID, data); - - // Add Bundle Params - cParameterContainer configParams = checkerBundle->GetParams(); - std::vector paramNames = configParams.GetParams(); - - for (std::vector::const_iterator paramIt = paramNames.cbegin(); paramIt != paramNames.cend(); - paramIt++) - { - AddParamItem(newCheckerBundleItem, *paramIt, configParams.GetParam(*paramIt)); - } - - // Add Checkers - std::vector checkers = checkerBundle->GetCheckers(); - for (std::vector::const_iterator checkerIt = checkers.cbegin(); - checkerIt != checkers.cend(); checkerIt++) - { - AddCheckerItem(newCheckerBundleItem, *checkerIt); - } - - if (expand) - newCheckerBundleItem->setExpanded(true); - - addTopLevelItem(newCheckerBundleItem); -} - -void cProcessView::AddCheckerItem(QTreeWidgetItem *parentCheckerBundleItem, cConfigurationChecker *const checker) -{ - QTreeWidgetItem *newCheckerItem = new QTreeWidgetItem(parentCheckerBundleItem); - - newCheckerItem->setBackgroundColor(0, QColor(0, 120, 250, 32)); - - std::stringstream ssCheckerName; - ssCheckerName << checker->GetCheckerId().c_str() << " [" << PrintIssueLevel(checker->GetMinLevel()) << ", " - << PrintIssueLevel(checker->GetMaxLevel()) << "]"; - - newCheckerItem->setText(0, ssCheckerName.str().c_str()); - newCheckerItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); - newCheckerItem->setData(0, ITEM_TYPE_ID, ITEM_CHECKER); - - cCheckerData newData; - newData.checkerId = checker->GetCheckerId(); - newData.minLevel = checker->GetMinLevel(); - newData.maxLevel = checker->GetMaxLevel(); - - QVariant data; - data.setValue(newData); - - newCheckerItem->setData(0, ITEM_DATA_ID, data); - - // Add Checker Params - cParameterContainer configParams = checker->GetParams(); - std::vector paramNames = configParams.GetParams(); - - for (std::vector::const_iterator paramIt = paramNames.cbegin(); paramIt != paramNames.cend(); - paramIt++) - { - AddParamItem(newCheckerItem, *paramIt, configParams.GetParam(*paramIt)); - } - - parentCheckerBundleItem->addChild(newCheckerItem); -} - -void cProcessView::AddReportModuleItemToRoot(cConfigurationReportModule *const reportModule, const bool expand) -{ - QTreeWidgetItem *newReportModuleItem = new QTreeWidgetItem(invisibleRootItem()); - - newReportModuleItem->setBackgroundColor(0, QColor(0, 113, 77, 91)); - newReportModuleItem->setText(0, QString("ReportModule %1").arg(reportModule->GetReportModuleApplication().c_str())); - newReportModuleItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); - newReportModuleItem->setData(0, ITEM_TYPE_ID, ITEM_REPORT_MODULE); - - cReportModuleData newData; - newData.applicationName = reportModule->GetReportModuleApplication(); - newData.enabled = true; - - QVariant data; - data.setValue(newData); - - newReportModuleItem->setData(0, ITEM_DATA_ID, data); - - // Add Report Params - cParameterContainer configParams = reportModule->GetParams(); - std::vector paramNames = configParams.GetParams(); - for (std::vector::const_iterator paramIt = paramNames.cbegin(); paramIt != paramNames.cend(); - paramIt++) - { - AddParamItem(newReportModuleItem, *paramIt, configParams.GetParam(*paramIt)); - } - - if (expand) - newReportModuleItem->setExpanded(true); - - addTopLevelItem(newReportModuleItem); -} - -void cProcessView::AddParamItem(QTreeWidgetItem *parentItem, const std::string &name, const std::string &value) -{ - QTreeWidgetItem *newParamItem = new QTreeWidgetItem(parentItem); - - AddParamToItem(newParamItem, name, value); - - parentItem->addChild(newParamItem); -} - -void cProcessView::AddParamItemToRoot(const std::string &name, const std::string &value, const bool setAsFirstItem) -{ - QTreeWidgetItem *newParamItem = new QTreeWidgetItem(invisibleRootItem()); - - AddParamToItem(newParamItem, name, value); - - addTopLevelItem(newParamItem); - - if (setAsFirstItem) - { - int index = invisibleRootItem()->indexOfChild(newParamItem); - QTreeWidgetItem *child = invisibleRootItem()->takeChild(index); - invisibleRootItem()->insertChild(0, child); - } -} - -void cProcessView::AddParamToItem(QTreeWidgetItem *newItem, const std::string &name, const std::string &value) -{ - newItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); - newItem->setData(0, ITEM_TYPE_ID, ITEM_PARAM); - - SetParamDataOnItem(newItem, name, value); -} - -void cProcessView::SetParamDataOnItem(QTreeWidgetItem *item, const std::string &name, const std::string &value) -{ - cParamData newData; - newData.paramName = name; - newData.paramValue = value; - - QVariant data; - data.setValue(newData); - - item->setData(0, ITEM_DATA_ID, data); - - item->setText(0, QString("%1=\"%2\"").arg(name.c_str(), value.c_str())); -} - -QTreeWidgetItem *cProcessView::HasParamItem(const QTreeWidgetItem *parentItem, const std::string &name) -{ - QTreeWidgetItem *foundItem = nullptr; - for (int i = 0; i < parentItem->childCount(); i++) - { - QTreeWidgetItem *child = parentItem->child(i); - - cParamData paramData = GetParamDataFromItem(child); - if (paramData.paramName == name) - { - foundItem = child; - break; - } - } - - return foundItem; -} - -void cProcessView::AddLocalParam() -{ - if (selectedItems().count() > 0) - { - QTreeWidgetItem *selected = selectedItems().first(); - - cLocalParamDialog newDlg("newParameter", "", true, this); - - if (newDlg.exec() == QDialog::Accepted) - { - std::string paramName = newDlg.GetParamName().toLocal8Bit().data(); - std::string paramValue = newDlg.GetParamValue().toLocal8Bit().data(); - - QTreeWidgetItem *existingItem = HasParamItem(selected, paramName); - if (existingItem) - { - QMessageBox::StandardButton reply = QMessageBox::question( - this, "Overwrite Parameter", - "Do you want to overwrite\nthe parameter '" + QString::fromStdString(paramName) + "'\nwith '" + - QString::fromStdString(paramValue) + "'?", - QMessageBox::Yes | QMessageBox::No); - - if (reply == QMessageBox::Yes) - { - SetParamDataOnItem(existingItem, paramName, paramValue); - emit ChangeConfiguration(); - } - } - else - { - AddParamItem(selected, paramName, paramValue); - emit ChangeConfiguration(); - } - } - } -} - -void cProcessView::AddGlobalParam() -{ - cConfiguration currentConfig; - GetConfigurationFromView(¤tConfig); - - cGlobalParamDialog newDlg("InputFile", "", true, this, ¤tConfig); - - if (newDlg.exec() == QDialog::Accepted) - { - std::string paramName = newDlg.GetParamName().toLocal8Bit().data(); - std::string paramValue = newDlg.GetParamValue().toLocal8Bit().data(); - - QTreeWidgetItem *existingItem = HasParamItem(invisibleRootItem(), paramName); - if (existingItem) - { - QMessageBox::StandardButton reply = - QMessageBox::question(this, "Overwrite Parameter", - "Do you want to overwrite\nthe parameter '" + QString::fromStdString(paramName) + - "'\nwith '" + QString::fromStdString(paramValue) + "'?", - QMessageBox::Yes | QMessageBox::No); - - if (reply == QMessageBox::Yes) - { - SetParamDataOnItem(existingItem, paramName, paramValue); - emit ChangeConfiguration(); - } - } - else - { - AddParamItemToRoot(paramName, paramValue, true); - emit ChangeConfiguration(); - } - } -} - -void cProcessView::EditParam() -{ - if (selectedItems().count() > 0) - EditParam(selectedItems().first()); -} - -void cProcessView::EditParam(QTreeWidgetItem *item) -{ - cParamData paramData = GetParamDataFromItem(item); - - cParamDialog *newDlg; - if (item->parent() == nullptr) - { - cConfiguration currentConfig; - GetConfigurationFromView(¤tConfig); - newDlg = new cGlobalParamDialog(paramData.paramName.c_str(), paramData.paramValue.c_str(), false, this, - ¤tConfig); - } - else - newDlg = new cLocalParamDialog(paramData.paramName.c_str(), paramData.paramValue.c_str(), false, this); - - if (newDlg->exec() == QDialog::Accepted) - { - SetParamDataOnItem(item, newDlg->GetParamName().toLocal8Bit().data(), - newDlg->GetParamValue().toLocal8Bit().data()); - emit ChangeConfiguration(); - } -} - -void cProcessView::GetConfigurationFromView(cConfiguration *newConfiguration) -{ - QTreeWidgetItem *rootItem = invisibleRootItem(); - newConfiguration->Clear(); - - for (int i = 0; i < rootItem->childCount(); ++i) - { - QTreeWidgetItem *configurationItem = rootItem->child(i); - - // Params... - if (configurationItem->data(0, ITEM_TYPE_ID) == ITEM_PARAM) - { - cParamData paramData = GetParamDataFromItem(configurationItem); - newConfiguration->SetParam(paramData.paramName, paramData.paramValue); - } - // CheckerBundles... - else if (configurationItem->data(0, ITEM_TYPE_ID) == ITEM_CHECKER_BUNDLE) - { - cCheckerBundleData bundleData = GetCheckerBundleDataFromItem(configurationItem); - cConfigurationCheckerBundle *newBundle = newConfiguration->AddCheckerBundle(bundleData.applicationName); - - for (int j = 0; j < configurationItem->childCount(); ++j) - { - QTreeWidgetItem *checkerBundleItem = configurationItem->child(j); - - if (checkerBundleItem->data(0, ITEM_TYPE_ID) == ITEM_PARAM) - { - cParamData paramData = GetParamDataFromItem(checkerBundleItem); - newBundle->SetParam(paramData.paramName, paramData.paramValue); - } - // Checker... - else if (checkerBundleItem->data(0, ITEM_TYPE_ID) == ITEM_CHECKER) - { - cCheckerData checkerData = GetCheckerDataFromItem(checkerBundleItem); - cConfigurationChecker *newChecker = - newBundle->AddChecker(checkerData.checkerId, checkerData.minLevel, checkerData.maxLevel); - - for (int p = 0; p < checkerBundleItem->childCount(); ++p) - { - QTreeWidgetItem *checkerItem = checkerBundleItem->child(p); - - if (checkerItem->data(0, ITEM_TYPE_ID) == ITEM_PARAM) - { - cParamData paramData = GetParamDataFromItem(checkerItem); - newChecker->SetParam(paramData.paramName, paramData.paramValue); - } - } - } - } - } - else if (configurationItem->data(0, ITEM_TYPE_ID) == ITEM_REPORT_MODULE) - { - cReportModuleData moduleData = GetReportModuleDataFromItem(configurationItem); - cConfigurationReportModule *newModule = newConfiguration->AddReportModule(moduleData.applicationName); - - // Params for reportModules... - for (int j = 0; j < configurationItem->childCount(); ++j) - { - QTreeWidgetItem *reportModuleItem = configurationItem->child(j); - - if (reportModuleItem->data(0, ITEM_TYPE_ID) == ITEM_PARAM) - { - cParamData paramData = GetParamDataFromItem(reportModuleItem); - newModule->SetParam(paramData.paramName, paramData.paramValue); - } - } - } - } -} - -void cProcessView::DeleteParam() -{ - if (selectedItems().count() > 0) - DeleteItem(selectedItems().first(), false); -} - -void cProcessView::EditChecker() -{ - if (selectedItems().count() > 0) - EditChecker(selectedItems().first()); -} -void cProcessView::EditChecker(QTreeWidgetItem *item) -{ - QVariant data = item->data(0, ITEM_DATA_ID); - - cCheckerData moduleData = data.value(); - cCheckerDialog newDlg(moduleData.minLevel, moduleData.maxLevel, this); - - if (newDlg.exec() == QDialog::Accepted) - { - moduleData.minLevel = newDlg.GetMinLevel(); - moduleData.maxLevel = newDlg.GetMaxLevel(); - data.setValue(moduleData); - - std::stringstream ssIconName; - ssIconName << moduleData.checkerId << " [" << PrintIssueLevel(moduleData.minLevel) << ", " - << PrintIssueLevel(moduleData.maxLevel) << "]"; - - item->setData(0, ITEM_DATA_ID, data); - item->setText(0, ssIconName.str().c_str()); - - emit ChangeConfiguration(); - } -} - -void cProcessView::DeleteChecker() -{ - if (selectedItems().count() > 0) - DeleteItem(selectedItems().first(), true); -} - -void cProcessView::DeleteReportModule() -{ - if (selectedItems().count() > 0) - DeleteItem(selectedItems().first(), true); -} - -void cProcessView::SelectModuleFromFileSystem() -{ - QString pathToNewModule = QFileDialog::getOpenFileName(this, tr("Add module to configuration"), GetApplicationDir(), - tr("CheckerBundles, ReportModules (*.exe);;All files (*)")); - - if (pathToNewModule.length() > 0) - { - emit ExecuteProcessAndAddConfiguration(pathToNewModule); - } -} - -void cProcessView::MoveUp() -{ - QTreeWidgetItem *item = currentItem(); - int row = currentIndex().row(); - - if (item && row > 0) - { - QTreeWidgetItem *parent = item->parent(); - - if (nullptr == parent) - parent = invisibleRootItem(); - - int index = parent->indexOfChild(item); - QTreeWidgetItem *child = parent->takeChild(index); - - parent->insertChild((index > 1) ? index - 1 : 1, child); - } - - emit ChangeConfiguration(); -} - -void cProcessView::MoveDown() -{ - QTreeWidgetItem *item = currentItem(); - int row = currentIndex().row(); - - if (item && row > 0) - { - QTreeWidgetItem *parent = item->parent(); - - if (nullptr == parent) - parent = invisibleRootItem(); - - int index = parent->indexOfChild(item); - QTreeWidgetItem *child = parent->takeChild(index); - - parent->insertChild((index < topLevelItemCount()) ? index + 1 : index, child); - } - - emit ChangeConfiguration(); -} - -void cProcessView::DeleteCheckerBundle() -{ - if (selectedItems().count() > 0) - DeleteItem(selectedItems().first(), true); -} - -void cProcessView::DeleteItem(QTreeWidgetItem *item, bool deleteChilds) -{ - if (deleteChilds) - { - // Delete childs - for (int i = 0; i < item->childCount(); ++i) - { - QTreeWidgetItem *childItem = item->child(i); - - DeleteItem(childItem, deleteChilds); - } - } - - delete item; - - emit ChangeConfiguration(); -} diff --git a/src/runtime/src/ui/c_process_view.h b/src/runtime/src/ui/c_process_view.h deleted file mode 100644 index 14f2b9bf..00000000 --- a/src/runtime/src/ui/c_process_view.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef CPROCESS_VIEW_H -#define CPROCESS_VIEW_H - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "common/result_format/c_issue.h" -#include "common/result_format/c_result_container.h" - -class cParamDialog; -class cCheckerDialog; -class cLocalParamDialog; -class cGlobalParamDialog; - -class cConfiguration; -class cConfigurationChecker; -class cConfigurationCheckerBundle; -class cConfigurationReportModule; - -// Container for parameters -struct cParamData -{ - std::string paramName; - std::string paramValue; -}; - -// Container for parameters -struct cCheckerBundleData -{ - std::string applicationName; - bool enabled; -}; - -// Container for parameters -struct cCheckerData -{ - std::string checkerId; - eIssueLevel minLevel; - eIssueLevel maxLevel; -}; - -// Container for parameters -struct cReportModuleData -{ - std::string applicationName; - bool enabled; -}; - -class cProcessView : public QTreeWidget -{ - Q_OBJECT - - protected: - static const unsigned int ITEM_TYPE_ID = Qt::UserRole + 1; - static const unsigned int ITEM_DATA_ID = Qt::UserRole + 10; - static const unsigned int ITEM_PARAM = 0; - static const unsigned int ITEM_CHECKER_BUNDLE = 1; - static const unsigned int ITEM_CHECKER = 2; - static const unsigned int ITEM_REPORT_MODULE = 3; - - // Pointer to current configuration which is hold in cRuntimeWindow - const cConfiguration *_currentConfiguration{nullptr}; - - public: - cProcessView(QWidget *parent = nullptr); - - /** - * Loads a configuration in the processView - **/ - void LoadConfiguration(cConfiguration *const configuration); - - /*! - * Adds a configuration - * - * \param configurationToAdd - */ - void AddConfiguration(cConfiguration *const configurationToAdd); - - void GetConfigurationFromView(cConfiguration *newConfiguration); - - private: - // Add checker bundle item to invisible root item - void AddCheckerBundleItemToRoot(cConfigurationCheckerBundle *const checkerBundle, const bool expand = false); - - // Add checker item to checker bundle item - void AddCheckerItem(QTreeWidgetItem *parentCheckerBundleItem, cConfigurationChecker *const checker); - - // Add report module item to invisible root item - void AddReportModuleItemToRoot(cConfigurationReportModule *const reportModule, const bool expand = false); - - // Add param item to parent item - void AddParamItem(QTreeWidgetItem *parentItem, const std::string &name, const std::string &value); - - // Add param item to invisible root item - void AddParamItemToRoot(const std::string &name, const std::string &value, const bool setAsFirstItem = false); - - void AddParamToItem(QTreeWidgetItem *newItem, const std::string &name, const std::string &value); - - // Set param data and text - void SetParamDataOnItem(QTreeWidgetItem *item, const std::string &name, const std::string &value); - - // Evaluates, if the parent item has a param item with the given name as child - // Returns the found param item or nullptr - QTreeWidgetItem *HasParamItem(const QTreeWidgetItem *parentItem, const std::string &name); - - cParamData GetParamDataFromItem(const QTreeWidgetItem *item); - cCheckerBundleData GetCheckerBundleDataFromItem(const QTreeWidgetItem *item); - cCheckerData GetCheckerDataFromItem(const QTreeWidgetItem *item); - cReportModuleData GetReportModuleDataFromItem(const QTreeWidgetItem *item); - - public slots: - // Add a local parameter - void AddLocalParam(); - - // Add a global parameter - void AddGlobalParam(); - - // Calls the dialog for the current selected item - void EditParam(); - - // Calls the dialog for a special item - void EditParam(QTreeWidgetItem *item); - - // Deletes the current selected item - void DeleteParam(); - - // Opens the dialog to add a new Module to the configuration - void SelectModuleFromFileSystem(); - - // Deletes the current selected item - void DeleteCheckerBundle(); - - // Calls the dialog for a special item - void EditChecker(); - - // Calls the dialog for a special item - void EditChecker(QTreeWidgetItem *item); - - // Deletes the current selected item - void DeleteChecker(); - - // Deletes the current selected item - void DeleteReportModule(); - - void DeleteItem(QTreeWidgetItem *item, bool deleteChilds = true); - - // Moves an item up - void MoveUp(); - - // Moves an item down - void MoveDown(); - - signals: - void ChangeConfiguration(); - - int ExecuteProcessAndAddConfiguration(QString processPath); - - private: - virtual void mouseDoubleClickEvent(QMouseEvent *event); - - protected: - void showContextMenu(const QPoint &pos); - - /** - * Get application directory - * - * @return directory, where the application is installed - */ - const QString GetApplicationDir(); -}; - -Q_DECLARE_METATYPE(cParamData) -Q_DECLARE_METATYPE(cCheckerBundleData) -Q_DECLARE_METATYPE(cCheckerData) -Q_DECLARE_METATYPE(cReportModuleData) - -#endif diff --git a/src/runtime/src/ui/c_runtime_window.cpp b/src/runtime/src/ui/c_runtime_window.cpp deleted file mode 100644 index dd918bee..00000000 --- a/src/runtime/src/ui/c_runtime_window.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "c_runtime_window.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common/result_format/c_result_container.h" - -#include "../c_configuration_validator.h" -#include "c_process_view.h" - -const QString cRuntimeWindow::DEFAULT_CONFIG = "DefaultConfiguration.xml"; - -cRuntimeWindow::cRuntimeWindow(const std::string &strConfigurationFilepath, const std::string &inputFile, - QWidget *parent) - : QMainWindow(parent) -{ - - QAction *newAction = new QAction(tr("&New"), this); - newAction->setShortcuts(QKeySequence::New); - newAction->setStatusTip(tr("New configuration")); - connect(newAction, &QAction::triggered, this, &cRuntimeWindow::NewConfiguration); - - QAction *openAction = new QAction(tr("&Open..."), this); - openAction->setShortcuts(QKeySequence::Open); - openAction->setStatusTip(tr("Open configuration")); - connect(openAction, &QAction::triggered, this, &cRuntimeWindow::OpenConfigurationFile); - - QAction *saveAction = new QAction(tr("&Save..."), this); - saveAction->setShortcuts(QKeySequence::Save); - saveAction->setStatusTip(tr("Save configuration")); - connect(saveAction, &QAction::triggered, this, &cRuntimeWindow::SaveConfigurationFile); - - QAction *saveAsAction = new QAction(tr("&Save As..."), this); - saveAsAction->setStatusTip(tr("Save configuration")); - connect(saveAsAction, &QAction::triggered, this, &cRuntimeWindow::SaveAsConfigurationFile); - - auto fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(newAction); - fileMenu->addAction(openAction); - fileMenu->addAction(saveAction); - fileMenu->addAction(saveAsAction); - - QSplitter *splitter = new QSplitter(Qt::Horizontal); - - QWidget *processWidget = new QWidget(this); - QVBoxLayout *processLayout = new QVBoxLayout; - - QWidget *processButtonBar = new QWidget(this); - QHBoxLayout *processButtonBarLayout = new QHBoxLayout; - - QPushButton *addModule = new QPushButton(this); - addModule->setText("Add Module"); - QPushButton *addParameter = new QPushButton(this); - addParameter->setText("Add global Parameter"); - - processButtonBarLayout->addWidget(addParameter); - processButtonBarLayout->addWidget(addModule); - processButtonBarLayout->setContentsMargins(2, 2, 2, 2); - processButtonBar->setLayout(processButtonBarLayout); - - QLabel *processLabel = new QLabel(processWidget); - processLabel->setText("Runtime Configuration"); - processLabel->setStyleSheet("font-weight: bold;"); - _processView = new cProcessView(this); - _processView->setSortingEnabled(false); - _processView->setContentsMargins(QMargins(0, 0, 0, 0)); - _processView->setAlternatingRowColors(true); - _processView->setSelectionBehavior(QAbstractItemView::SelectRows); - _processView->setRootIsDecorated(true); - _processView->setHeaderHidden(true); - - processLayout->addWidget(processLabel); - processLayout->addWidget(_processView, 2); - processLayout->addWidget(processButtonBar, 0); - processLayout->setContentsMargins(3, 6, 3, 3); - processWidget->setLayout(processLayout); - splitter->addWidget(processWidget); - - QWidget *outputWidget = new QWidget(this); - QVBoxLayout *outputLayout = new QVBoxLayout; - outputLayout->setContentsMargins(3, 6, 3, 3); - outputWidget->setLayout(outputLayout); - splitter->addWidget(outputWidget); - - _currentConfiguration = cConfiguration(); - - setCentralWidget(splitter); - - connect(addModule, SIGNAL(pressed()), _processView, SLOT(SelectModuleFromFileSystem())); - connect(addParameter, SIGNAL(pressed()), _processView, SLOT(AddGlobalParam())); - - connect(_processView, SIGNAL(ChangeConfiguration()), this, SLOT(OnChangeConfiguration())); - connect(_processView, SIGNAL(ExecuteProcessAndAddConfiguration(QString)), this, - SLOT(ExecuteProcessAndAddConfiguration(QString))); - - // Set the size of the application of the half size of desktop - QSize quarterDesktopSize = QDesktopWidget().availableGeometry(this).size() * 0.5f; - resize(quarterDesktopSize); - - if (!strConfigurationFilepath.empty()) - { - LoadConfiguration(&_currentConfiguration, strConfigurationFilepath.c_str()); - } - else - { - // Standardkonfiguration laden - QString defaultConfigPath = GetApplicationDir() + "/" + DEFAULT_CONFIG; - if (CheckIfFileExists(defaultConfigPath.toStdString())) - { - LoadConfiguration(&_currentConfiguration, defaultConfigPath); - } - // Neue Konfiguration erstellen - else - { - CreateNewConfiguration(&_currentConfiguration); - } - } - - // Apply input file settings from command line - if (!inputFile.empty()) - { - _currentConfiguration.SetParam(PARAM_INPUT_FILE, inputFile); - OnChangeConfiguration(); - } - - ShowConfiguration(&_currentConfiguration); -} - -const QString cRuntimeWindow::GetApplicationDir() -{ - return QCoreApplication::applicationDirPath(); -} - -const QString cRuntimeWindow::GetWorkingDir() -{ - return QString::fromStdString(fs::current_path().string()); -} - -bool cRuntimeWindow::ValidateAndWrite(cConfiguration &configuration, const std::string &filePath) -{ - std::string message = ""; - if (!cConfigurationValidator::ValidateConfiguration(&configuration, message)) - { - std::stringstream ssDetails; - - ssDetails << "Configuration is invalid." << std::endl << std::endl; - ssDetails << "Message: " << std::endl; - ssDetails << message; - ssDetails << std::endl << std::endl; - ssDetails << "Please fix it before saving configuration file"; - - QMessageBox::warning(this, tr("Error"), tr(ssDetails.str().c_str()), QMessageBox::Ok); - return false; - } - configuration.WriteConfigurationToFile(filePath); - return true; -} - -void cRuntimeWindow::OpenConfigurationFile() -{ - QString filePath = - QFileDialog::getOpenFileName(this, tr("Open Configuration"), GetWorkingDir(), tr("configurations (*.xml)")); - - LoadConfiguration(&_currentConfiguration, filePath); - ShowConfiguration(&_currentConfiguration); -} - -bool cRuntimeWindow::SaveConfigurationFile() -{ - if (!_currentConfigurationPath.isEmpty()) - { - if (_configurationChanged) - { - QFileInfo fileInfo(_currentConfigurationPath); - - // If we opened a default configuration the user cannot overwrite this - if (fileInfo.fileName().toLower() == DEFAULT_CONFIG.toLower()) - { - // Open Dialog - return SaveAsConfigurationFile(); - } - else - { - QMessageBox::StandardButton reply = QMessageBox::NoButton; - reply = QMessageBox::question(this, "Overwrite Configuration", - "Do you want to overwrite:\n" + fileInfo.fileName(), - QMessageBox::Yes | QMessageBox::No); - - if (reply == QMessageBox::Yes) - { - UpdateConfiguration(); - bool validation_result = false; - validation_result = - ValidateAndWrite(_currentConfiguration, _currentConfigurationPath.toLocal8Bit().data()); - if (!validation_result) - { - return false; - } - _configurationChanged = false; - SetupWindowTitle(); - return true; - } - else - { - // Open Dialog - return SaveAsConfigurationFile(); - } - } - } - else - return true; - } - // Open Dialog - return SaveAsConfigurationFile(); -} - -bool cRuntimeWindow::SaveAsConfigurationFile() -{ - QString filePath = - QFileDialog::getSaveFileName(this, tr("Save Configuration"), GetWorkingDir(), tr("configurations (*.xml)")); - - if (!filePath.isEmpty()) - { - QFileInfo fileInfo(filePath); - - if (fileInfo.fileName().toLower() == DEFAULT_CONFIG.toLower()) - { - QMessageBox::information( - this, "Save Configuration", - "It is not possible to overwrite a default configuration.\nPlease enter a different file name.", - QMessageBox::Ok); - - // Open Dialog - bool saved = SaveAsConfigurationFile(); - return saved; - } - - UpdateConfiguration(); - - _currentConfigurationPath = filePath; - bool validation_result = false; - validation_result = ValidateAndWrite(_currentConfiguration, filePath.toLocal8Bit().data()); - if (!validation_result) - { - return false; - } - - _configurationChanged = false; - SetupWindowTitle(); - - return true; - } - - return false; -} - -void cRuntimeWindow::SetupWindowTitle() -{ - std::string build_version = BUILD_VERSION; - std::string build_date = BUILD_DATE; - std::string config_ui_name = "ConfigGUI (v" + build_version + ", " + build_date + ")"; - if (!_currentConfigurationPath.isEmpty()) - { - QFileInfo fileInfo(_currentConfigurationPath); - QString applicationTitle = - QString(" - %1.xml%2").arg(fileInfo.baseName()).arg(_configurationChanged ? "*" : ""); - applicationTitle = QString::fromStdString(config_ui_name) + applicationTitle; - setWindowTitle(applicationTitle); - } - else - { - config_ui_name += " - New Configuration*"; - setWindowTitle(QString::fromStdString(config_ui_name)); - } -} - -void cRuntimeWindow::UpdateConfiguration() -{ - _processView->GetConfigurationFromView(&_currentConfiguration); -} - -void cRuntimeWindow::LoadConfiguration(cConfiguration *const configuration, const QString &strConfigurationFilepath) -{ - if (!strConfigurationFilepath.isNull()) - { - _currentConfiguration.Clear(); - - if (!cConfiguration::ParseFromXML(configuration, strConfigurationFilepath.toLocal8Bit().data())) - { - std::stringstream ssError; - ssError << "Couldn't load the configuration '" << strConfigurationFilepath.toLocal8Bit().data() - << "'. It occured a problem while parsing. Abort."; - - QMessageBox::warning(this, tr("Load Configuration"), ssError.str().c_str(), QMessageBox::Ok); - } - else - { - _currentConfigurationPath = strConfigurationFilepath; - } - } -} - -void cRuntimeWindow::CreateNewConfiguration(cConfiguration *const configuration) -{ - _currentConfigurationPath = ""; - - configuration->Clear(); - configuration->SetParam(PARAM_INPUT_FILE, ""); - - OnChangeConfiguration(); -} - -void cRuntimeWindow::ShowConfiguration(cConfiguration *const configurationToBeShown) -{ - - _processView->LoadConfiguration(configurationToBeShown); - - SetupWindowTitle(); -} - -void cRuntimeWindow::NewConfiguration() -{ - CreateNewConfiguration(&_currentConfiguration); - ShowConfiguration(&_currentConfiguration); -} - -void cRuntimeWindow::OnChangeConfiguration() -{ - _configurationChanged = true; - - SetupWindowTitle(); -} - -int cRuntimeWindow::ExecuteProcessAndAddConfiguration(const QString &processPath) -{ - QProcess process; - QFileInfo fileInfo(processPath); - - QString processName = fileInfo.fileName(); - QString processDir = fileInfo.absoluteDir().absolutePath(); - - std::string processExec = processName.toLocal8Bit().data(); - - std::cout << "-----" << std::endl; - std::cout << "Start to read default configuration from: " << std::endl; - std::cout << processPath.toLocal8Bit().data() << std::endl; - - emit Log(QString("-------------------------------------------------------------")); - emit Log(QString("---- Start to read default configuration")); - emit Log(QString("-------------------------------------------------------------")); - - if (!StringEndsWith(processExec, ".exe")) - processExec = processExec.append(".exe"); - - if (!CheckIfFileExists(processPath.toStdString())) - { - emit Log(QString("> Application '%1' does not exist. Abort.").arg(processPath.toStdString().c_str())); - return -1; - } - - process.start(processName, {"--defaultConfig"}); - process.setWorkingDirectory(processDir); - process.waitForStarted(); - - emit Log(QString("> Start application '%1' to generate report...").arg(processExec.c_str())); - - double dTimePassedToGenerateDefaultReport = 0; - - // Check if process is still running or we waited too long.... - while (process.state() == QProcess::Running && dTimePassedToGenerateDefaultReport < 100.0) - { - process.waitForFinished(300); - dTimePassedToGenerateDefaultReport += 3.0f; - - QString stdOut = QString(process.readAllStandardOutput()); - QString stdErr = QString(process.readAllStandardError()); - - std::cout << stdOut.toLocal8Bit().data() << std::endl; - std::cout << stdErr.toLocal8Bit().data() << std::endl; - } - - QString reportFile = processExec.c_str(); - reportFile = reportFile.replace(".exe", ".xqar"); - QString confgurationFile = processExec.c_str(); - confgurationFile = confgurationFile.replace(".exe", ".xml"); - - cConfiguration newConfigurationToAdd; - - if (CheckIfFileExists(confgurationFile.toLocal8Bit().data(), false)) - { - emit Log(QString("> Configuration '%1' found.").arg(confgurationFile.toLocal8Bit().data())); - emit Log(QString("> Extract configuration.")); - - cConfiguration::ParseFromXML(&newConfigurationToAdd, confgurationFile.toLocal8Bit().data()); - } - else if (CheckIfFileExists(reportFile.toLocal8Bit().data(), false)) - { - emit Log(QString("> Report '%1' found.").arg(reportFile.toLocal8Bit().data())); - emit Log(QString("> Extract configuration...")); - - cResultContainer report; - report.AddResultsFromXML(reportFile.toLocal8Bit().data()); - - report.ConvertReportToConfiguration(&newConfigurationToAdd); - } - else - { - emit Log(QString("> Report '%1' or configuration '%2' does not exist. Abort.") - .arg(reportFile.toLocal8Bit().data(), confgurationFile.toLocal8Bit().data())); - return -1; - } - - UpdateConfiguration(); - - _currentConfiguration.AddConfiguration(&newConfigurationToAdd); - - if (nullptr != _processView) - { - _processView->LoadConfiguration(&_currentConfiguration); - emit Log(QString("> Configuration added.")); - OnChangeConfiguration(); - } - - return 0; -} diff --git a/src/runtime/src/ui/c_runtime_window.h b/src/runtime/src/ui/c_runtime_window.h deleted file mode 100644 index 53287dc5..00000000 --- a/src/runtime/src/ui/c_runtime_window.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#ifndef CRUNTIME_WINDOW_H -#define CRUNTIME_WINDOW_H - -#include - -#include "common/config_format/c_configuration.h" -#include "common/qc4openx_filesystem.h" - -class cProcessView; -class cProcessLog; -class cRuntimeControl; - -// Implementation of the main window -class cRuntimeWindow : public QMainWindow -{ - Q_OBJECT - - protected: - cProcessView *_processView{nullptr}; - - cConfiguration _currentConfiguration; - QString _currentConfigurationPath; - - bool _configurationChanged{false}; - - public: - cRuntimeWindow(const std::string &configurationFilePath, const std::string &inputFile, QWidget *parent = 0); - - /* - * Loads a configuration from file to datastructure - * \param strConfigurationFilepath: File path of the configuration which should be loaded - */ - void LoadConfiguration(cConfiguration *const configuration, const QString &strConfigurationFilepath); - - /* - * Shows a configuration to the user - * \param currentConfiguration: Configuration which should be shown - */ - void ShowConfiguration(cConfiguration *const currentConfiguration); - - // Updates the internal configuration - void UpdateConfiguration(); - - private slots: - // Open result file - void OpenConfigurationFile(); - - // SaveAs configuration file - bool SaveAsConfigurationFile(); - - bool ValidateAndWrite(cConfiguration &, const std::string &); - - // Save configuration file - bool SaveConfigurationFile(); - - // Creates a new Configuration - void NewConfiguration(); - - // Called if a confuration was changed. - void OnChangeConfiguration(); - - /*! - * Execute process and read default configuration - * - * \param processPath - * \return Positive number if everything is okay - */ - int ExecuteProcessAndAddConfiguration(const QString &processPath); - - signals: - void Finished(); - - void Log(QString log); - - private: - // Filename of the default configuration - static const QString DEFAULT_CONFIG; - - /** - * Get application directory - * - * @return directory, where the application is installed - */ - const QString GetApplicationDir(); - - /** - * Get working directory - * - * @return directory, from where the application is started - */ - const QString GetWorkingDir(); - - // Changes the window title of the application - void SetupWindowTitle(); - - // Creates an empty configuration - void CreateNewConfiguration(cConfiguration *const configuration); -}; - -#endif diff --git a/test/function/CMakeLists.txt b/test/function/CMakeLists.txt index d63cec33..d5291155 100644 --- a/test/function/CMakeLists.txt +++ b/test/function/CMakeLists.txt @@ -9,11 +9,6 @@ add_subdirectory(report_modules) add_subdirectory(result_pooling/src) add_subdirectory(result_format/src) -if (WIN32) - # FIXME: We need some adaptions that this works in Linux - add_subdirectory(runtime/src) -endif(WIN32) - add_custom_target(INSTALL_TEST_REFERENCES ALL) add_custom_command( @@ -30,10 +25,6 @@ add_custom_command( ${CMAKE_CURRENT_SOURCE_DIR}/result_pooling/files ${REFERENCE_FILES_INSTALL_DIR}/function/result_pooling - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/runtime/files - ${REFERENCE_FILES_INSTALL_DIR}/function/runtime - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../doc/schema ${REFERENCE_FILES_INSTALL_DIR}/doc/schema diff --git a/test/function/runtime/files/DemoCheckerBundle_config.xml b/test/function/runtime/files/DemoCheckerBundle_config.xml deleted file mode 100644 index fc533a59..00000000 --- a/test/function/runtime/files/DemoCheckerBundle_config.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - diff --git a/test/function/runtime/files/XodrSchemaChecker_config.xml b/test/function/runtime/files/XodrSchemaChecker_config.xml deleted file mode 100644 index 98824132..00000000 --- a/test/function/runtime/files/XodrSchemaChecker_config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/test/function/runtime/files/XoscSchemaChecker_config.xml b/test/function/runtime/files/XoscSchemaChecker_config.xml deleted file mode 100644 index e7f96f90..00000000 --- a/test/function/runtime/files/XoscSchemaChecker_config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/test/function/runtime/src/CMakeLists.txt b/test/function/runtime/src/CMakeLists.txt deleted file mode 100644 index e2056d58..00000000 --- a/test/function/runtime/src/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2023 CARIAD SE. -# -# This Source Code Form is subject to the terms of the Mozilla -# Public License, v. 2.0. If a copy of the MPL was not distributed -# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - - -set(TEST_NAME runtime_tester) - -set_property(GLOBAL PROPERTY USE_FOLDERS true) - -find_package(XercesC REQUIRED) - -include_directories(${TEST_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../../_common - ${XercesC_INCLUDE_DIRS}) - -add_executable(${TEST_NAME} - ${CMAKE_CURRENT_SOURCE_DIR}/../../_common/helper.cpp - ${TEST_NAME}.cpp) - -add_test(NAME ${TEST_NAME} - COMMAND ${TEST_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../ -) - -target_link_libraries(${TEST_NAME} - PRIVATE - GTest::gtest_main - $<$:pthread> - $<$:stdc++fs> - ${XercesC_LIBRARIES} -) - -target_compile_definitions(${TEST_NAME} - PRIVATE QC4OPENX_DBQA_BIN_DIR="${QC4OPENX_DBQA_DIR}/bin" - PRIVATE QC4OPENX_DBQA_RUNTIME_TEST_WORK_DIR="${CMAKE_CURRENT_BINARY_DIR}/../.." - PRIVATE QC4OPENX_DBQA_RUNTIME_TEST_REF_DIR="${REFERENCE_FILES_INSTALL_DIR}/function/runtime") - -set_target_properties(${TEST_NAME} PROPERTIES FOLDER test/function) diff --git a/test/function/runtime/src/runtime_tester.cpp b/test/function/runtime/src/runtime_tester.cpp deleted file mode 100644 index 7c2fd7f8..00000000 --- a/test/function/runtime/src/runtime_tester.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 CARIAD SE. - * - * This Source Code Form is subject to the terms of the Mozilla - * Public License, v. 2.0. If a copy of the MPL was not distributed - * with this file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "gtest/gtest.h" - -#include "helper.h" - -#define MODULE_NAME "ConfigGUI" - -class cTesterRuntime : public ::testing::Test -{ - public: - std::string strTestFilesDir = std::string(QC4OPENX_DBQA_RUNTIME_TEST_REF_DIR); - std::string strWorkingDir = std::string(QC4OPENX_DBQA_RUNTIME_TEST_WORK_DIR); -}; - -TEST_F(cTesterRuntime, CmdHelp) -{ - std::string strResultMessage; - - TestResult nRes = ExecuteCommand(strResultMessage, MODULE_NAME, "-h"); - ASSERT_TRUE_EXT(nRes == TestResult::ERR_NOERROR, strResultMessage.c_str()); - - nRes |= ExecuteCommand(strResultMessage, MODULE_NAME, "--help"); - ASSERT_TRUE_EXT(nRes == TestResult::ERR_NOERROR, strResultMessage.c_str()); -} -