Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,44 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-05-05
#
SET(ppm_combobox_gui_SRCS
ppm_combobox_foreign_gui_interface_impl.cpp
ppm_combobox_foreign_gui_interface_impl.h
ppm_combobox.cpp
ppm_combobox.h
ppm_party_selector.cpp
ppm_party_selector.h
)
NGL_WRAP_UI(ppm_combobox_gui_SRCS ppm_party_selector.ui)
NGL_ADD_LIBRARY(WS PpmComboBoxGui STATIC ${ppm_combobox_gui_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(PpmComboBoxGui
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../..
)
NGL_TARGET_LINK_LIBRARIES(PpmComboBoxGui
PRIVATE
LtsWidgets
PUBLIC
LtsSession
PpmGuiComboboxPluginInterface
Qt5::Core
svcPpmClient
)
SET(ppm_combobox_gui_plugin_SRCS
ppm_combobox_gui_plugin.cpp
ppm_combobox_gui_plugin.h
)
NGL_ADD_LIBRARY(WS PpmComboBoxGuiPlugin MODULE ${ppm_combobox_gui_plugin_SRCS})
NGL_TARGET_LINK_LIBRARIES(PpmComboBoxGuiPlugin
LtsSessionData
NGLLogger
PpmComboBoxGui
PpmDataPluginInterface
)
NGL_INSTALL_TARGET(PpmComboBoxGuiPlugin)
@@ -0,0 +1,104 @@
/**
* @RDE_HEADER@
* ParticipantManagement - PpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#include "ppm_combobox.h"
#include <QComboBox>
#include <ParticipantManagement/ppm_translation.h>
namespace ParticipantManagement
{
bool PpmComboBox::fill(QComboBox *cbx, ComboBoxType type,
const std::shared_ptr<Interface::Dtc> &dtc)
{
const QVariant curData = cbx->currentData();
QSignalBlocker block(cbx);
cbx->clear();
switch (type)
{
case ComboBoxType::EquipmentType:
{
cbx->addItem(QObject::tr("NONE"), 0);
const QMap<qint32, EquipmentType> eqTypes = dtc->equipmentTypes();
for (const EquipmentType &eqType : eqTypes)
{
if (eqType.id() <= 0)
continue;
if (eqType.deletedInWms())
cbx->addItem(QString::fromStdString(eqType.name()) + QObject::tr("(deleted)"), eqType.id());
else
cbx->addItem(QString::fromStdString(eqType.name()), eqType.id());
}
break;
}
case ComboBoxType::Role:
{
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::Unknown), ParticipantManagement::Role::Unknown);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::Friend), ParticipantManagement::Role::Friend);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::Neutral), ParticipantManagement::Role::Neutral);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::Enemy), ParticipantManagement::Role::Enemy);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::Pending), ParticipantManagement::Role::Pending);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::AssumedFriend), ParticipantManagement::Role::AssumedFriend);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::Role::Suspect), ParticipantManagement::Role::Suspect);
break;
}
case ComboBoxType::HlaForceIdentifier:
{
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Other), ParticipantManagement::HlaForceIdentifierEnum::Other);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_1), ParticipantManagement::HlaForceIdentifierEnum::Friendly_1);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_1), ParticipantManagement::HlaForceIdentifierEnum::Opposing_1);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_1), ParticipantManagement::HlaForceIdentifierEnum::Neutral_1);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_2), ParticipantManagement::HlaForceIdentifierEnum::Friendly_2);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_2), ParticipantManagement::HlaForceIdentifierEnum::Opposing_2);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_2), ParticipantManagement::HlaForceIdentifierEnum::Neutral_2);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_3), ParticipantManagement::HlaForceIdentifierEnum::Friendly_3);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_3), ParticipantManagement::HlaForceIdentifierEnum::Opposing_3);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_3), ParticipantManagement::HlaForceIdentifierEnum::Neutral_3);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_4), ParticipantManagement::HlaForceIdentifierEnum::Friendly_4);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_4), ParticipantManagement::HlaForceIdentifierEnum::Opposing_4);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_4), ParticipantManagement::HlaForceIdentifierEnum::Neutral_4);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_5), ParticipantManagement::HlaForceIdentifierEnum::Friendly_5);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_5), ParticipantManagement::HlaForceIdentifierEnum::Opposing_5);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_5), ParticipantManagement::HlaForceIdentifierEnum::Neutral_5);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_6), ParticipantManagement::HlaForceIdentifierEnum::Friendly_6);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_6), ParticipantManagement::HlaForceIdentifierEnum::Opposing_6);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_6), ParticipantManagement::HlaForceIdentifierEnum::Neutral_6);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_7), ParticipantManagement::HlaForceIdentifierEnum::Friendly_7);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_7), ParticipantManagement::HlaForceIdentifierEnum::Opposing_7);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_7), ParticipantManagement::HlaForceIdentifierEnum::Neutral_7);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_8), ParticipantManagement::HlaForceIdentifierEnum::Friendly_8);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_8), ParticipantManagement::HlaForceIdentifierEnum::Opposing_8);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_8), ParticipantManagement::HlaForceIdentifierEnum::Neutral_8);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_9), ParticipantManagement::HlaForceIdentifierEnum::Friendly_9);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_9), ParticipantManagement::HlaForceIdentifierEnum::Opposing_9);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_9), ParticipantManagement::HlaForceIdentifierEnum::Neutral_9);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Friendly_10), ParticipantManagement::HlaForceIdentifierEnum::Friendly_10);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Opposing_10), ParticipantManagement::HlaForceIdentifierEnum::Opposing_10);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::HlaForceIdentifierEnum::Neutral_10), ParticipantManagement::HlaForceIdentifierEnum::Neutral_10);
break;
}
}
if (curData.isValid() && (cbx->findData(curData) != -1))
{
cbx->setCurrentIndex(cbx->findData(curData));
}
else if(cbx->count())
cbx->setCurrentIndex(0);
return cbx->count() > 0;
}
} // namespace ParticipantManagement
@@ -0,0 +1,37 @@
/**
* @RDE_HEADER@
* HMI Plugin for ParticipantManagement - PpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#pragma once
//DDS
#include <ParticipantManagement/ppm_dtc.h>
class QComboBox;
namespace ParticipantManagement
{
enum class ComboBoxType
{
EquipmentType,
Role,
HlaForceIdentifier
};
// --------------------------------------------------------
// ComboBox
// --------------------------------------------------------
namespace PpmComboBox
{
Q_REQUIRED_RESULT bool fill(QComboBox *cbx,
ComboBoxType type,
const std::shared_ptr<Interface::Dtc> &dtc);
}
} // namespace ParticipantManagement
@@ -0,0 +1,245 @@
/**
* @RDE_HEADER@
* GUI Plugin for ParticipantManagement - PpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#include "ppm_combobox_gui_plugin.h"
#include "ppm_combobox.h"
#include "ppm_party_selector.h"
#include <ParticipantManagement/ppm_translation.h>
#include <LtsWidgets/lts_combo_box.h>
#include <QPainter>
#include <QPainterPath>
namespace ParticipantManagement
{
ForeignGuiComboboxInterfaceImpl::ForeignGuiComboboxInterfaceImpl()
: m_dtc(nullptr)
{}
bool ForeignGuiComboboxInterfaceImpl::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc)
{
m_dtc = dtc;
return m_dtc != nullptr;
}
void ForeignGuiComboboxInterfaceImpl::uninit()
{
m_dtc = nullptr;
}
void ForeignGuiComboboxInterfaceImpl::autoRefill(QComboBox *cbx, int ect)
{
LtsWidgets::LtsComboBox *ltsCbx = qobject_cast<LtsWidgets::LtsComboBox*>(cbx);
if (!ltsCbx)
return;
ltsCbx->setExternalContentType(ect);
connect(m_dtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged,
ltsCbx, &LtsWidgets::LtsComboBox::signalExternallyChanged, Qt::UniqueConnection);
// <= sig on sig (to fetch cbx as sender) =>
connect(ltsCbx, &LtsWidgets::LtsComboBox::signalRefill,
this, &ForeignGuiComboboxInterfaceImpl::slotExternallyChanged, Qt::UniqueConnection);
}
template<typename T>
static inline bool isBitSet(T &bits, T value)
{
const int intBits = static_cast<int>(bits);
const int intValue = static_cast<int>(value);
return ((intBits & intValue) == intValue);
}
bool ForeignGuiComboboxInterfaceImpl::fillPartyComboBox(QComboBox *cbx, CbxPartyFilter filter)
{
const QVariant curData = cbx->currentData();
QSignalBlocker block(cbx);
cbx->clear();
QMap<qint32, Party> parties;
if (!m_dtc->visibleParties(parties, visibleParties()))
{
cbx->setCurrentIndex(0);
return false;
}
for (const Party &party : qAsConst(parties))
{
if (party.id() < 0)
continue;
if (party.id() == 0 && isBitSet(filter, CbxPartyFilter::Pool))
cbx->addItem(pixmapFromParty(QColor::fromRgb(QRgb(party.color()))),
ParticipantManagement::trPartyName(party.name()), party.id());
else if (party.id() == 1 && isBitSet(filter, CbxPartyFilter::Oc))
cbx->addItem(pixmapFromParty(QColor::fromRgb(QRgb(party.color()))),
ParticipantManagement::trPartyName(party.name()), party.id());
else if (party.id() > 1 && isBitSet(filter, CbxPartyFilter::Normal))
cbx->addItem(pixmapFromParty(QColor::fromRgb(QRgb(party.color()))),
ParticipantManagement::trPartyName(party.name()), party.id());
}
if (curData.isValid() && (cbx->findData(curData) != -1))
{
cbx->setCurrentIndex(cbx->findData(curData));
}
else if(cbx->count())
{
cbx->setCurrentIndex(0);
}
autoRefill(cbx, (int)filter);
return true;
}
bool ForeignGuiComboboxInterfaceImpl::fillTypeClassComboBox(QComboBox *cbx, int filter)
{
return fillTypeClassPpmComboBox(cbx, filter);
}
bool ForeignGuiComboboxInterfaceImpl::fillEquipmentTypeComboBox(QComboBox *cbx)
{
return fillPpmComboBox(cbx, ComboBoxType::EquipmentType);
}
bool ForeignGuiComboboxInterfaceImpl::fillTypeComboBox(QComboBox *cbx, TypeClass typeClass)
{
const QVariant curData = cbx->currentData();
QSignalBlocker block(cbx);
cbx->clear();
const auto cb = [this, cbx, typeClass](const Type &type)
{
if (type.typeClass() == typeClass && !type.isDeleted())
{
if (!m_dtc->isEditable(type.id()))
return;
cbx->addItem(ParticipantManagement::trTypeName(type.name()), type.id());
}
};
m_dtc->types(cb);
cbx->model()->sort(0);
const int idx = (cbx->count() && curData.isValid()) ? cbx->findData(curData) : -1;
if (idx >= 0)
cbx->setCurrentIndex(idx);
else if (cbx->count())
{
cbx->setCurrentIndex(0);
}
return true;
}
bool ForeignGuiComboboxInterfaceImpl::fillRoleComboBox(QComboBox *cbx)
{
return fillPpmComboBox(cbx, ComboBoxType::Role);
}
bool ForeignGuiComboboxInterfaceImpl::fillHlaForceIdentifierComboBox(QComboBox *cbx)
{
return fillPpmComboBox(cbx, ComboBoxType::HlaForceIdentifier);
}
void ForeignGuiComboboxInterfaceImpl::partySelector(const QSet<int> &preselectedParties,
const std::function<void(const QSet<int> &)> &cb,
QWidget *parent)
{
PartySelector *ps(new PartySelector(parent));
ps->init(m_dtc, preselectedParties, visibleParties());
if (parent)
connect(ps, &PartySelector::partiesSelected, parent, cb);
ps->show();
}
QPixmap ForeignGuiComboboxInterfaceImpl::pixmapFromParty(const QColor &partyColor) const
{
static const int pmSize = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pm(pmSize, pmSize);
pm.fill(Qt::transparent);
QPainterPath pp;
pp.addRoundedRect(QRectF(1, 1, pmSize - 2, pmSize - 2), 20, 20, Qt::RelativeSize);
QPainter painter(&pm);
QRadialGradient rad(QPointF(pmSize / 2., pmSize / 2.), pmSize);
rad.setColorAt(1, partyColor.lighter());
rad.setColorAt(0, partyColor);
QBrush brush(rad);
painter.setRenderHint(QPainter::Antialiasing);
painter.fillPath(pp, brush);
painter.end();
return pm;
}
void ForeignGuiComboboxInterfaceImpl::slotExternallyChanged()
{
LtsWidgets::LtsComboBox *cbx = qobject_cast<LtsWidgets::LtsComboBox *>(sender());
if (!cbx)
return;
fillPartyComboBox(cbx, static_cast<CbxPartyFilter>(cbx->externalContentType()));
}
//private
bool ForeignGuiComboboxInterfaceImpl::fillPpmComboBox(QComboBox *cbx, ComboBoxType type)
{
return PpmComboBox::fill(cbx, type, m_dtc);
}
bool ForeignGuiComboboxInterfaceImpl::fillTypeClassPpmComboBox(QComboBox *cbx, int filter)
{
const QVariant curData = cbx->currentData();
QSignalBlocker block(cbx);
cbx->clear();
if ((filter & eParticipants) == eParticipants)
{
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::Human), ParticipantManagement::TypeClass::Human);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::VehicleWithGear), ParticipantManagement::TypeClass::VehicleWithGear);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::GroundVehicle), ParticipantManagement::TypeClass::GroundVehicle);
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::WeaponSystem), ParticipantManagement::TypeClass::WeaponSystem);
if ((filter & eParticipantsWithCtaEquipment) != eParticipantsWithCtaEquipment)
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::Aircraft), ParticipantManagement::TypeClass::Aircraft);
}
if ((filter & eUnits) == eUnits)
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::Unit), ParticipantManagement::TypeClass::Unit);
if ((filter & eOcUnits) == eOcUnits)
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::SupportUnit), ParticipantManagement::TypeClass::SupportUnit);
if ((filter & eOc) == eOc)
cbx->addItem(ParticipantManagement::toString(ParticipantManagement::TypeClass::SupportEntity), ParticipantManagement::TypeClass::SupportEntity);
cbx->model()->sort(0);
if (curData.isValid() && (cbx->findData(curData) != -1))
{
cbx->setCurrentIndex(cbx->findData(curData));
}
else if (cbx->count())
{
cbx->setCurrentIndex(0);
}
return true;
}
QVector<int> ForeignGuiComboboxInterfaceImpl::visibleParties() const
{
return {-1}; // == all
}
} // namespace ParticipantManagement
@@ -0,0 +1,53 @@
/**
*@RDE_HEADER@
* Gui Plugin for ParticipantManagement - PpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#pragma once
#include <ParticipantManagement/ppm_dtc.h>
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
namespace ParticipantManagement
{
enum class ComboBoxType;
class ForeignGuiComboboxInterfaceImpl : public QObject, public ForeignGuiComboboxInterface
{
Q_OBJECT
public:
ForeignGuiComboboxInterfaceImpl();
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc);
void uninit();
bool fillPartyComboBox(QComboBox *cbx, CbxPartyFilter filter = CbxPartyFilter::Normal) override;
bool fillTypeClassComboBox(QComboBox *cbx, int filter) override;
bool fillEquipmentTypeComboBox(QComboBox *cbx) override;
bool fillTypeComboBox(QComboBox *cbx, TypeClass typeClass) override;
bool fillRoleComboBox(QComboBox *cbx) override;
bool fillHlaForceIdentifierComboBox(QComboBox *cbx) override;
void partySelector(const QSet<int> &preselectedParties,
const std::function<void(const QSet<int>&)> &cb,
QWidget *parent) override;
QPixmap pixmapFromParty(const QColor &partyColor) const override;
protected:
virtual QVector<int> visibleParties() const;
private slots:
void slotExternallyChanged();
private:
bool fillTypeClassPpmComboBox(QComboBox *cbx, int filter);
bool fillPpmComboBox(QComboBox *cbx, ComboBoxType type);
void autoRefill(QComboBox *cbx, int ect);
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtc;
};
} // namespace ParticipantManagement
@@ -0,0 +1,46 @@
/**
* @RDE_HEADER@
* GUI Plugin for ParticipantManagement - PpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#include "ppm_combobox_gui_plugin.h"
#include "ppm_party_selector.h"
#include <ParticipantManagement/logger.h>
#include <ParticipantManagement/ppm_translation.h>
#include <LtsSession/lts_session_data.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.PpmCombobox"))
{}
bool InterfaceImpl::fetchInterfaces()
{
std::shared_ptr<ParticipantManagement::Interface::Dtc> dtc;
if (!m_session->getDtc<ParticipantManagement::DataInterface>(dtc))
return false;
return ForeignGuiComboboxInterfaceImpl::init(dtc);
}
void InterfaceImpl::clearInterfaces()
{
ForeignGuiComboboxInterfaceImpl::uninit();
}
QVector<int> InterfaceImpl::visibleParties() const
{
return LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_session->exerciseId());
}
} // namespace ProjectDataManagement
@@ -0,0 +1,56 @@
/**
*@RDE_HEADER@
* Gui Plugin for ParticipantManagement - PpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#pragma once
#include <LtsSession/lts_session.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include "ppm_combobox_foreign_gui_interface_impl.h"
namespace ParticipantManagement
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:ppm.combobox")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("ParticipantManagement.GuiPlugin.ComboBox"); }
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return (partition == IDL::PartitionType::Global ||
partition == IDL::PartitionType::Exercise ||
partition == IDL::PartitionType::Replay);
}
};
class InterfaceImpl final : public ForeignGuiComboboxInterfaceImpl, public GuiPluginBase::Interface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
bool fetchInterfaces() override;
void clearInterfaces() override;
QString menuGroup() const override { return QString(); }
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Global; }
protected:
QVector<int> visibleParties() const override;
};
} // namespace ParticipantManagement
@@ -0,0 +1,77 @@
/**
* @RDE_HEADER@
* A Frameless dialog to select parties
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2017-06-22
*/
#include "ppm_party_selector.h"
#include <QCheckBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <ParticipantManagement/ppm_translation.h>
namespace ParticipantManagement
{
PartySelector::PartySelector(QWidget *parent)
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
{
m_ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
}
PartySelector::~PartySelector()
{}
bool PartySelector::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc,
const QSet<int> &preselectedParties,
const QVector<int> &visibleParties)
{
qDeleteAll(findChildren<QCheckBox *>());
m_selectedParties = preselectedParties;
m_selectedPartiesOriginal = preselectedParties;
QMap<qint32, Party> parties;
if (!dtc->visibleParties(parties, visibleParties))
return false;
for (const Party &party : qAsConst(parties))
{
// TODO: add color
QCheckBox *cb = new QCheckBox;
cb->setText(ParticipantManagement::trPartyName(party.name()));
cb->setChecked(preselectedParties.contains(party.id()));
const int partyId = party.id();
connect(cb, &QCheckBox::clicked,
cb, [this, partyId](bool checked) {partyCheckBoxChanged(partyId, checked);});
m_ui.layParties->addWidget(cb);
}
connect(m_ui.pbOk, &QPushButton::clicked,
this, &PartySelector::accept);
connect(m_ui.pbCancel, &QPushButton::clicked,
this, &PartySelector::reject);
return true;
}
void PartySelector::partyCheckBoxChanged(int partyId, bool bChecked)
{
if (bChecked)
m_selectedParties += partyId;
else
m_selectedParties -= partyId;
emit partiesSelected(m_selectedParties);
}
void PartySelector::reject()
{
emit partiesSelected(m_selectedPartiesOriginal);
LtsWidgets::LtsFramelessDialog::reject();
}
} // namespace ParticipantManagement
@@ -0,0 +1,39 @@
/**
* @RDE_HEADER@
* A Frameless dialog to select parties
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2017-06-22
*/
#pragma once
#include <LtsWidgets/lts_frameless_dialog.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <QSet>
#include "ui_ppm_party_selector.h"
namespace ParticipantManagement
{
class PartySelector final : public LtsWidgets::LtsFramelessDialog
{
Q_OBJECT
public:
explicit PartySelector(QWidget *parent = nullptr);
~PartySelector();
bool init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc,
const QSet<int> &preselectedParties,
const QVector<int> &visibleParties);
Q_SIGNALS:
void partiesSelected(const QSet<int> &selectedParties);
private:
void partyCheckBoxChanged(int partyId, bool bChecked);
void reject() override;
private:
QSet<int> m_selectedParties;
QSet<int> m_selectedPartiesOriginal;
Ui::PartySelector m_ui;
};
} // namespace ParticipantManagement
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartySelector</class>
<widget class="QWidget" name="PartySelector">
<property name="windowTitle">
<string>Select Parties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Select Parties</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="layParties"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbOk">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>