/** * @RDE_HEADER@ * GUI Plugin for Evaluations * $Id$ * $HeadURL$ * $Author$ * * Created by Mike Wille, SLSE, 2017-03-15 */ #include "evl_edit_gui_plugin.h" #include "CriteriumEdit/evl_dialog.h" #include "CriteriumEdit/TopicEditor/topic_editor.h" #include "SchemaEdit/evl_edit_schema.h" #include "SchemaEdit/evl_comments.h" #include #include #include #include #include #include #include #include #include namespace Evaluations { std::shared_ptr GuiPlugin::createGuiInterface(LtsSession::LtsSession *session) { return std::make_shared(session); } InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session) : GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Evl.Edit")) {} QVector InterfaceImpl::getActions() { QVector ret; LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance(); const bool enableEvaluationsElements = ps->value(QStringLiteral("evl"), QStringLiteral("enableEvaluationsElements")).toBool(); const bool enableEvaluations = ps->value(QStringLiteral("evl"), QStringLiteral("enableEvaluations")).toBool(); if (appId() != LtsAppDescriptor::App::OC) { if (enableEvaluationsElements) { LtsWidgets::PluginData plData; plData.menuGroup = menuGroup(); plData.menuText = tr("Own Evaluation Criteria"); plData.menuIcon = QIcon(QStringLiteral("icon:evaluate.svg")); plData.identifier = QLatin1String("evlEditE"); plData.operatorRight = OperatorRights::EvaluationElementEdit; plData.exercisePart = LtsWidgets::ExercisePart::eExecution; plData.createWidgetFunc = [this](QWidget * parent) { bool ownEvlElements = true; return onEditCriteriumDialog(parent, ownEvlElements ); }; ret.append(plData); } if (enableEvaluations) { { LtsWidgets::PluginData plData; plData.menuGroup = menuGroup(); plData.menuText = tr("All Evaluation Criteria"); plData.menuIcon = QIcon(QStringLiteral("icon:evaluation_elements.svg")); plData.identifier = QLatin1String("evlEditCriteria"); plData.operatorRight = OperatorRights::EvaluationEdit; plData.exercisePart = LtsWidgets::ExercisePart::eExecution; plData.createWidgetFunc = [this](QWidget * parent) { bool ownEvlElements = false; return onEditCriteriumDialog(parent, ownEvlElements ); }; ret.append(plData); } { LtsWidgets::PluginData plData; plData.menuGroup = menuGroup(); plData.menuText = tr("O/C Evaluation Schemes"); plData.menuIcon = QIcon(QStringLiteral("icon:oc_evaluation_schemes.svg")); plData.identifier = QLatin1String("evlEditSchemes"); plData.operatorRight = OperatorRights::EvaluationEdit; plData.exercisePart = LtsWidgets::ExercisePart::eExecution; plData.createWidgetFunc = [this](QWidget * parent) { return onEditSchemaDialog(parent); }; ret.append(plData); } { LtsWidgets::PluginData plData; plData.menuGroup = menuGroup(); plData.menuText = tr("Display O/C Evaluations"); plData.menuIcon = QIcon(QStringLiteral("icon:display_oc_evaluations.svg")); plData.identifier = QLatin1String("evlDisplayOCEvaluations"); plData.operatorRight = OperatorRights::EvaluationShow; plData.exercisePart = LtsWidgets::ExercisePart::eExecution; plData.createWidgetFunc = [this](QWidget * parent) { return onCommentsDialog(parent); }; ret.append(plData); } } } // Provide possibility to test oc stuff on workstation #ifndef LTS_DEBUG if (appId() == LtsAppDescriptor::App::OC) #endif { if (enableEvaluations) { LtsWidgets::PluginData plData; plData.menuGroup = menuGroup(); plData.menuText = tr("O/C Evaluations"); plData.menuIcon = QIcon(QStringLiteral("icon:oc_evaluation_schemes.svg")); plData.identifier = QLatin1String("evlOCEvaluations"); plData.operatorRight = OperatorRights::EvaluationShow; plData.exercisePart = LtsWidgets::ExercisePart::eExecution; plData.createWidgetFunc = [this](QWidget * parent) { return onCreateCommentsDialog(parent, true); }; ret.append(plData); } } return ret; } bool InterfaceImpl::fetchInterfaces() { if (!m_session->getDtc(m_evlDtc)) { DEBUG_LOG(m_logger) << "getDtc for Evaluations::DataInterface failed."; return false; } if (!m_session->getFtc(m_evlFtc)) { DEBUG_LOG(m_logger) << "getFtc for Evaluations::DataInterface failed."; return false; } if (!m_session->getDtc(m_flmDtc)) { DEBUG_LOG(m_logger) << "m_flmDtc for FileManagement::DataInterface failed."; return false; } if (!m_session->getFtc(m_flmFtc)) { DEBUG_LOG(m_logger) << "getFtc for FileManagement::DataInterface failed."; return false; } if (!m_session->getForeignGuiInterface(m_flmGui)) { DEBUG_LOG(m_logger) << "getForeignGuiInterface for FileManagement failed."; return false; } if (!m_session->getDtc(m_opmDtc)) { DEBUG_LOG(m_logger) << "getDtc for OperatorManagement::DataInterface failed."; return false; } if (!m_session->getDtc(m_exmDtc)) { DEBUG_LOG(m_logger) << "getDtc for ExerciseManagement::DataInterface failed."; return false; } // optional, only needed in ElementEditDialog and checked there if available m_session->getForeignDataInterface_NEW(m_avmDataIfc); if (!m_session->getForeignGuiInterface(m_fltParticipantIfc)) { DEBUG_LOG(m_logger) << "getForeignGuiInterface for Filter Management Participan Gui failed."; return false; } if (!m_session->getForeignGuiInterface(m_fltAesIfc)) { DEBUG_LOG(m_logger) << "getForeignGuiInterface for Filter Management Aes Gui failed."; return false; } if (!m_session->getForeignGuiInterface(m_fltBuildingComponentfc)) { DEBUG_LOG(m_logger) << "getForeignGuiInterface for Filter Management BuildingComponent Gui failed."; // Nachtrag zu GUEZE-1769: since fltBuildingComponentIfc is optional: // return false; } if (!m_session->getForeignGuiInterface(m_opmCbxDtc)) { DEBUG_LOG(m_logger) << "getForeignGuiInterface for OperatorManagement failed."; return false; } if (!m_session->getFtc(m_ocFtc)) { DEBUG_LOG(m_logger) << "m_ocFtc for OcSituationClient::DataInterface failed."; return false; } DEBUG_LOG(m_logger) << "fetchInterfaces successful"; return true; } void InterfaceImpl::clearInterfaces() { m_opmDtc = nullptr; m_opmCbxDtc = nullptr; m_exmDtc = nullptr; m_avmDataIfc = nullptr; m_flmDtc = nullptr; m_flmFtc = nullptr; m_flmGui = nullptr; m_evlFtc = nullptr; m_evlDtc = nullptr; m_ocFtc = nullptr; m_fltParticipantIfc = nullptr; m_fltAesIfc = nullptr; m_fltBuildingComponentfc = nullptr; } TopicEditorBase::TopicEditor *InterfaceImpl::createTopicEditor(const TopicEditorBase::TopicData &data) { EvaluationTopicEditor *editor = new EvaluationTopicEditor(m_session); if (!editor->fetchInterfaces()) { delete editor; return nullptr; } editor->setTopicData(data); return editor; } QString InterfaceImpl::menuGroup() const { return tr("Evaluation"); } LtsWidgets::LtsDialog *InterfaceImpl::onEditCriteriumDialog(QWidget *parent, bool ownEvlElements) { CriteriumDialog *dialog = new CriteriumDialog(menuGroup(), m_session, ownEvlElements, parent); dialog->init(m_evlDtc, m_evlFtc, m_opmDtc, m_opmCbxDtc, m_exmDtc, m_avmDataIfc, m_fltParticipantIfc, m_fltAesIfc, m_fltBuildingComponentfc, m_session->exerciseId(), LtsSessionData::LtsSessionData::getInstance()->getOperatorId()); return dialog; } LtsWidgets::LtsDialog *InterfaceImpl::onEditSchemaDialog(QWidget *parent) { EditSchemaDialog *dialog = new EditSchemaDialog(false, false, m_session, parent); dialog->init(m_ocFtc, m_evlFtc, m_evlDtc, m_opmDtc, m_flmFtc, m_flmDtc, m_flmGui); return dialog; } LtsWidgets::LtsDialog *InterfaceImpl::onCreateCommentsDialog(QWidget *parent, bool runningOnTablet) { EditSchemaDialog *dialog = new EditSchemaDialog(true, runningOnTablet, m_session, parent); dialog->init(m_ocFtc, m_evlFtc, m_evlDtc, m_opmDtc, m_flmFtc, m_flmDtc, m_flmGui); return dialog; } LtsWidgets::LtsDialog *InterfaceImpl::onCommentsDialog(QWidget *parent) { EvlCommentsView *dialog = new EvlCommentsView(m_evlDtc, m_opmDtc, parent); return dialog; } } // namespace Evaluations