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

157 lines
5.6 KiB
C++
Executable File

/**
* @RDE_HEADER@
* GUI Plugin for ParticipantManagement - ParticipantEdit
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-17
*/
#include "participant_edit_gui_plugin.h"
#include "participant_organisation.h"
#include "participant_edit.h"
#include "tactical_organisation.h"
#include <ParticipantManagement/ppm_operator_rights.h>
#include <Plugins/AdvancedSymbology/asb_data_plugin_interface.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.ParticipantTemplates"))
, m_dtc(nullptr)
, m_ftc(nullptr)
, m_ppmGuiTemplateIfc(nullptr)
, m_ppmGuiCbxIfc(nullptr)
{}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
QVector<LtsWidgets::PluginData> ret;
//were are in Exercise so only use exercise participants
LtsWidgets::PluginData pd;
pd.menuGroup = menuGroup();
pd.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
pd.menuText = tr("Organise Participants");
pd.identifier = QStringLiteral("organiseParticipants");
pd.menuIcon = QIcon(QLatin1String("icon:force_organization.svg"));
pd.createWidgetFunc = [this](QWidget *parent) { return onParticipantOrganisation(parent, false); };
pd.operatorRight = OperatorRights::ParticipantEdit::ParticipantsOrganise;
pd.exercisePart = LtsWidgets::ExercisePart::ePlanning;
ret.append(pd);
pd.menuText = tr("Edit Participants");
pd.identifier = QStringLiteral("editParticipants");
pd.menuIcon = QIcon(QLatin1String("icon:force_player_configuration.svg"));
pd.createWidgetFunc = [this](QWidget *parent) { return onParticipantEdit(parent, false); };
pd.operatorRight = OperatorRights::ParticipantEdit::ParticipantsEdit;
pd.exercisePart = LtsWidgets::ExercisePart::ePlanning;
pd.exerciseStates = LtsWidgets::ExcState::eCreated | LtsWidgets::ExcState::eStarted | LtsWidgets::ExcState::ePaused;
ret.append(pd);
pd.menuText = tr("Tactical Organisation");
pd.identifier = QStringLiteral("tacticalParticipantOrganisation");
pd.menuIcon = QIcon(QLatin1String("icon:tactical_organization.svg"));
pd.createWidgetFunc = [this](QWidget *parent) { return onTacticalParticipantOrganisation(parent); };
pd.operatorRight = OperatorRights::ParticipantEdit::TacticalParticipantOrganisation;
pd.exercisePart = LtsWidgets::ExercisePart::eExecution;
ret.append(pd);
if (ps->value(QStringLiteral("ppm"),
QStringLiteral("enableSupportParticipantsOrganise")).toBool())
{
pd.menuText = tr("Organise Support Participants");
pd.identifier = QStringLiteral("organiseSupParticipants");
pd.menuIcon = QIcon(QLatin1String("icon:oc_composition.svg"));
pd.createWidgetFunc = [this](QWidget *parent) { return onParticipantOrganisation(parent, true); };
pd.operatorRight = OperatorRights::ParticipantEdit::SupportParticipantsOrganise;
pd.exercisePart = LtsWidgets::ExercisePart::ePlanning;
ret.append(pd);
}
if (ps->value(QStringLiteral("ppm"),
QStringLiteral("enableSupportParticipantsEdit")).toBool())
{
pd.menuText = tr("Edit Support Participants");
pd.identifier = QStringLiteral("editSupportParticipants");
pd.menuIcon = QIcon(QLatin1String("icon:oc_player_configuration.svg"));
pd.createWidgetFunc = [this](QWidget *parent) { return onParticipantEdit(parent, true); };
pd.operatorRight = OperatorRights::ParticipantEdit::SupportParticipantsEdit;
pd.exercisePart = LtsWidgets::ExercisePart::ePlanning;
pd.exerciseStates = LtsWidgets::ExcState::eCreated | LtsWidgets::ExcState::eStarted | LtsWidgets::ExcState::ePaused;
ret.append(pd);
}
return ret;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Participants");
}
QString InterfaceImpl::menuGroupSup() const // TODO: UNUSED!
{
return tr("Support");
}
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::ForeignGuiTemplatesInterface>(m_ppmGuiTemplateIfc))
return false;
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
return false;
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(m_asb);
return true;
}
void InterfaceImpl::clearInterfaces()
{
m_ppmGuiTemplateIfc = nullptr;
m_ppmGuiCbxIfc = nullptr;
m_dtc = nullptr;
m_ftc = nullptr;
m_asb = nullptr;
}
LtsWidgets::LtsDialog *InterfaceImpl::onParticipantEdit(QWidget *parent, bool asSupportService)
{
return LtsWidgets::initDialog(new ParticipantEdit(m_session, asSupportService, parent),
m_dtc, m_ftc, m_ppmGuiCbxIfc, m_asb);
}
LtsWidgets::LtsDialog *InterfaceImpl::onParticipantOrganisation(QWidget *parent, bool asSupportService)
{
return LtsWidgets::initDialog(new ParticipantOrganisationDialog(m_session, asSupportService, parent),
m_dtc, m_ftc, m_ppmGuiTemplateIfc, m_ppmGuiCbxIfc, m_asb);
}
LtsWidgets::LtsDialog *InterfaceImpl::onTacticalParticipantOrganisation(QWidget *parent)
{
return LtsWidgets::initDialog(new TacticalOrganisation(m_session, parent),
m_dtc, m_ftc, m_ppmGuiCbxIfc, m_asb);
}
} // namespace ParticipantManagement