Files
qt5-legatus-legacy/Lts/Plugins/ParticipantManagement/Gui/MSDL/ppm_msdl_gui_plugin.cpp
T
2026-08-13 18:33:10 +02:00

101 lines
2.6 KiB
C++
Executable File

/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Last, SLSE, 2017-10-26
*/
#include "ppm_msdl_gui_plugin.h"
#include "ppm_msdl_edit.h"
#include <LtsSession/lts_session.h>
#include <Services/ParticipantManagement/ppm_operator_rights.h>
#include <LtsUtilsSettings/settings.h>
namespace ParticipantManagement
{
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
{
return std::make_shared<InterfaceImpl>(session);
}
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Ppm.msdl"))
, m_pSession(session)
, m_dtc(nullptr)
, m_ftc(nullptr)
, m_ppmGuiCbxIfc(nullptr)
{}
bool InterfaceImpl::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_dtc))
return false;
if (!m_session->getFtc<ParticipantManagement::DataInterface>(m_ftc))
return false;
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
return false;
return true;
}
void InterfaceImpl::clearInterfaces()
{
m_dtc = nullptr;
m_ftc = nullptr;
m_ppmGuiCbxIfc = nullptr;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Participants");
}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
/*
* Importing exercise data is only possible if
* the operator is actually operating within an exercise
*/
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
const bool enableMSDL_ImExport = ps->value(QStringLiteral("ppm"),
QStringLiteral("enableMSDL_ImExport")).toBool();
if ( (m_pSession->exerciseId() != 0) && enableMSDL_ImExport)
{
LtsWidgets::PluginData plData;
plData.menuGroup = menuGroup();
plData.menuText = tr("MSDL Import/Export");
plData.identifier = QLatin1String("ppmmsdlview");
plData.menuIcon = QIcon(QLatin1String("icon:import_msdl.svg"));
plData.operatorRight = OperatorRights::Msdl::MsdlImportExport; // OperatorRights::PartyEdit::PartiesShow
plData.exercisePart = LtsWidgets::ExercisePart::ePlanning;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowMSDLEdit(parent);
};
ret.append(plData);
}
return ret;
}
LtsWidgets::LtsDialog *InterfaceImpl::onShowMSDLEdit(QWidget *parent)
{
return LtsWidgets::initDialog(new ParticipantManagement::MSDLEdit(m_session, parent),
m_dtc, m_ftc, m_ppmGuiCbxIfc);
}
} // namespace ParticipantManagement