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,46 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-05-05
#
SET(pdm_combobox_gui_SRCS
pdm_combobox_foreign_gui_interface_impl.cpp
pdm_combobox_foreign_gui_interface_impl.h
pdm_combobox.cpp
pdm_combobox.h
pdm_charge_selector.cpp
pdm_charge_selector.h
)
NGL_WRAP_UI(pdm_combobox_gui_SRCS pdm_charge_selector.ui)
NGL_ADD_LIBRARY(WS PdmComboBoxGui STATIC ${pdm_combobox_gui_SRCS})
NGL_TARGET_INCLUDE_DIRECTORIES(PdmComboBoxGui
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../..
)
NGL_TARGET_LINK_LIBRARIES(PdmComboBoxGui
PRIVATE
Qt5::Widgets
LtsUtilsSettings
PUBLIC
PdmGuiPluginInterface
Qt5::Core
svcPdmClient
)
SET(pdm_combobox_gui_plugin_SRCS
pdm_combobox_gui_plugin.cpp
pdm_combobox_gui_plugin.h
)
NGL_ADD_LIBRARY(WS PdmComboBoxGuiPlugin MODULE ${pdm_combobox_gui_plugin_SRCS})
NGL_TARGET_LINK_LIBRARIES(PdmComboBoxGuiPlugin
LtsSession
NGLLogger
PdmComboBoxGui
PdmDataPluginInterface
)
NGL_INSTALL_TARGET(PdmComboBoxGuiPlugin)
@@ -0,0 +1,79 @@
/**
* @RDE_HEADER@
* A Frameless dialog to select parties
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2017-06-22
*/
#include "pdm_charge_selector.h"
#include <QCheckBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <ProjectDataManagement/pdm_translation.h>
#include <LtsUtils/LtsUtilsCore/json_object.h>
namespace ProjectDataManagement
{
ChargeSelector::ChargeSelector(QWidget *parent)
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
{
m_ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
}
ChargeSelector::~ChargeSelector()
{}
bool ChargeSelector::init(const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtc,
GearClass gearClass,
const QSet<int> &preselectedCharges)
{
QString title = tr("Select %1 Charges").arg(toString(gearClass));
m_ui.lblCharges->setText(title);
setWindowTitle(title);
qDeleteAll(findChildren<QCheckBox *>());
m_selectedCharges = preselectedCharges;
m_selectedChargesOriginal = preselectedCharges;
const auto cfgc = dtc->chargesForGearClass(gearClass);
for (const ChargeType &charge : cfgc)
{
if (LtsUtils::JsonObject::fromJson(charge.properties()).valueOr<bool>("suppressVisibility", false))
continue;
const int chargeId = charge.id();
QCheckBox *cb = new QCheckBox;
cb->setText(dtc->trChargeTypeShortName(chargeId, true));
cb->setChecked(preselectedCharges.contains(chargeId));
connect(cb, &QCheckBox::clicked, cb, [this, chargeId](bool checked) { chargeCheckBoxChanged(chargeId, checked); });
m_ui.layParties->addWidget(cb);
}
connect(m_ui.pbOk, &QPushButton::clicked,
this, &ChargeSelector::accept);
connect(m_ui.pbCancel, &QPushButton::clicked,
this, &ChargeSelector::reject);
return true;
}
void ChargeSelector::chargeCheckBoxChanged(int chargeId, bool bChecked)
{
if (bChecked)
m_selectedCharges += chargeId;
else
m_selectedCharges -= chargeId;
emit chargesSelected(m_selectedCharges);
}
void ChargeSelector::reject()
{
emit chargesSelected(m_selectedChargesOriginal);
LtsWidgets::LtsFramelessDialog::reject();
}
} // namespace ProjectDataManagement
@@ -0,0 +1,40 @@
/**
* @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 <ProjectDataManagement/logger.h>
#include <ProjectDataManagement/pdm_dtc.h>
#include <QSet>
#include "ui_pdm_charge_selector.h"
namespace ProjectDataManagement
{
class ChargeSelector final : public LtsWidgets::LtsFramelessDialog
{
Q_OBJECT
public:
explicit ChargeSelector(QWidget *parent = nullptr);
~ChargeSelector();
bool init(const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtc,
GearClass gearClass,
const QSet<int> &preselectedCharges);
Q_SIGNALS:
void chargesSelected(const QSet<int> &selectedCharges);
private:
void chargeCheckBoxChanged(int chargeId, bool bChecked);
void reject() override;
private:
QSet<int> m_selectedCharges;
QSet<int> m_selectedChargesOriginal;
Ui::ChargeSelector m_ui;
};
} // namespace ProjectDataManagement
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChargeSelector</class>
<widget class="QWidget" name="ChargeSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>127</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="lblCharges">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Select Charges</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>
<widget class="QPushButton" name="pbOk">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,343 @@
/**
* @RDE_HEADER@
* ProjectDataManagement - PdmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#include "pdm_combobox.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QSet>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <LtsUtilsSettings/settings.h>
#include <LtsWidgets/lts_combo_box.h>
#include <ProjectDataManagement/pdm_translation.h>
namespace ProjectDataManagement
{
namespace PdmComboBox
{
static QLatin1String emptyEntryComboBox = QLatin1String("--");
void ChargeTypeFilterProxyModel::setPropertyFilter(const QString &property, const QVariant &value)
{
if (m_property == property && m_value == value)
return;
m_property = property;
m_value = value;
invalidate();
}
void ChargeTypeFilterProxyModel::setSourceModel(QAbstractItemModel *model)
{
m_model = qobject_cast<QStandardItemModel *>(model);
QSortFilterProxyModel::setSourceModel(model);
}
bool ChargeTypeFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
if (!m_model || source_parent != QModelIndex())
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
if (m_property.isEmpty() || m_value.isNull())
return true;
QStandardItem *item = m_model->item(source_row);
QJsonObject obj = item->data(Qt::UserRole + 2).toJsonObject();
if (obj.isEmpty())
{
QJsonDocument doc(QJsonDocument::fromJson(item->data(Qt::UserRole + 1).toByteArray()));
if (doc.isObject())
obj = doc.object();
else
obj = QJsonObject();
if (obj.isEmpty())
obj[QStringLiteral("empty")] = 1;
item->setData(obj, Qt::UserRole + 2);
}
return obj.value(m_property) == m_value;
}
void fillGearClass(QComboBox *cbx, GearClass gearClass, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
ChargeTypeFilterProxyModel *fpm = new ChargeTypeFilterProxyModel(cbx);
fpm->setSourceModel(itemModel);
cbx->setModel(fpm);
// ULEIS codes 3000+ not actually omitted, but there are no (yet) defined.
const auto charges = dtc->chargesForGearClass(gearClass);
for (const ChargeType &charge : charges)
{
QStandardItem *item = new QStandardItem(dtc->trChargeTypeShortName(charge.id(), true));
item->setToolTip(dtc->trChargeTypeName(charge.id(), true));
item->setData(charge.id(), CBUserRoles::Id);
item->setData(QByteArray::fromStdString(charge.properties()), CBUserRoles::Properties);
itemModel->appendRow(item);
}
}
void fillIgniterType(QComboBox *cbx, int chargeTypeId, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
cbx->setModel(itemModel);
QStandardItem *itemEmpty = new QStandardItem(emptyEntryComboBox);
itemEmpty->setData(-1, CBUserRoles::Id);
itemModel->appendRow(itemEmpty);
const auto igniters = dtc->ignitersForChargeType(chargeTypeId);
for (const IgniterType &igniter : igniters)
{
QStandardItem *item = new QStandardItem(dtc->trIgniterTypeShortName(igniter.id()));
item->setToolTip(dtc->trIgniterTypeName(igniter.id()));
item->setData(igniter.id(), CBUserRoles::Id);
item->setData(QByteArray::fromStdString(igniter.properties()), CBUserRoles::Properties);
itemModel->appendRow(item);
}
itemModel->sort(0, Qt::AscendingOrder);
// Choose Option if only one option beside the empty entry exists
if (cbx->count() == 2)
cbx->setCurrentIndex(1);
}
void fillIgniterFunction(QComboBox *cbx, int chargeTypeId, int igniterTypeId, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
cbx->setModel(itemModel);
QStandardItem *itemEmpty = new QStandardItem(emptyEntryComboBox);
itemEmpty->setData(-1, CBUserRoles::Id);
itemModel->appendRow(itemEmpty);
const auto chargeTypeIgTypeIgFunMap = dtc->igniterFunctionsForChargeTypeIgniterType(chargeTypeId, igniterTypeId);
for (const ChargeTypeIgniterTypeIgniterFunction &chargeTypeIgTypeIgFun : chargeTypeIgTypeIgFunMap)
{
QStandardItem *item = new QStandardItem(dtc->trIgniterFunctionShortName(chargeTypeIgTypeIgFun.igniterFunctionId()));
item->setToolTip(dtc->trIgniterFunctionName(chargeTypeIgTypeIgFun.igniterFunctionId()));
item->setData(chargeTypeIgTypeIgFun.igniterFunctionId(), CBUserRoles::Id);
item->setData(QByteArray::fromStdString(chargeTypeIgTypeIgFun.properties()), CBUserRoles::Properties);
itemModel->appendRow(item);
}
itemModel->sort(0, Qt::AscendingOrder);
// Choose Option if only one option beside the empty entry exists
if (cbx->count() == 2)
cbx->setCurrentIndex(1);
}
void fillLoadType(QComboBox *cbx, int chargeTypeId, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
cbx->setModel(itemModel);
QStandardItem *itemEmpty = new QStandardItem(emptyEntryComboBox);
itemEmpty->setData(-1, CBUserRoles::Id);
itemModel->appendRow(itemEmpty);
const auto loads = dtc->loadsForChargeType(chargeTypeId);
for (const LoadType &load : loads)
{
QStandardItem *item = new QStandardItem(dtc->trLoadTypeShortName(load.id()));
item->setToolTip(dtc->trLoadTypeName(load.id()));
item->setData(load.id(), CBUserRoles::Id);
itemModel->appendRow(item);
}
itemModel->sort(0, Qt::AscendingOrder);
// Choose Option if only one option beside the empty entry exists
if (cbx->count() == 2)
cbx->setCurrentIndex(1);
}
void fillTargetType(QComboBox *cbx, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
cbx->setModel(itemModel);
QStandardItem *itemEmpty = new QStandardItem(emptyEntryComboBox);
itemEmpty->setData(-1, CBUserRoles::Id);
itemModel->appendRow(itemEmpty);
const auto targeTypes = dtc->targetTypes();
for (const TargetType &targetType : targeTypes)
{
QStandardItem *item = new QStandardItem(dtc->trTargetTypeName(targetType.id()));
item->setToolTip(dtc->trTargetTypeName(targetType.id()));
item->setData(targetType.id(), CBUserRoles::Id);
itemModel->appendRow(item);
}
itemModel->sort(0, Qt::AscendingOrder);
}
void fillTargetSubType(QComboBox *cbx, int targetTypeId, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
cbx->setModel(itemModel);
const auto targetSubTypeVec = dtc->targetSubTypesForTargetType(targetTypeId);
QStandardItem *itemEmpty = new QStandardItem(emptyEntryComboBox);
itemEmpty->setData(-1, TargetSubTypeRole::Id);
itemModel->appendRow(itemEmpty);
for (const TargetSubType &targetSubType : targetSubTypeVec)
{
QStandardItem *item = new QStandardItem(dtc->trTargetSubTypeName(targetSubType.id()));
item->setToolTip(dtc->trTargetSubTypeName(targetSubType.id()));
item->setData(targetSubType.id(), TargetSubTypeRole::Id);
item->setData(QString::fromStdString(targetSubType.abbreviation()), TargetSubTypeRole::Abbreviation);
itemModel->appendRow(item);
}
itemModel->sort(0, Qt::AscendingOrder);
}
void fillFirePurpose(QComboBox *cbx, const std::shared_ptr<Interface::Dtc> &dtc)
{
QStandardItemModel *itemModel = new QStandardItemModel(cbx);
cbx->setModel(itemModel);
QStandardItem *itemEmpty = new QStandardItem(emptyEntryComboBox);
itemEmpty->setData(-1, CBUserRoles::Id);
itemModel->appendRow(itemEmpty);
const auto &firePurposes = dtc->firePurposes();
for (const FirePurpose &firePurpose : firePurposes)
{
QStandardItem *item = new QStandardItem(dtc->trFirePurposeName(firePurpose.id()));
item->setToolTip(dtc->trFirePurposeName(firePurpose.id()));
item->setData(firePurpose.id(), CBUserRoles::Id);
item->setData(QByteArray::fromStdString(firePurpose.properties()), CBUserRoles::Properties);
itemModel->appendRow(item);
}
itemModel->sort(0, Qt::AscendingOrder);
}
bool fill(QComboBox *cbx, PdmComboBoxType type)
{
if (!cbx)
return false;
const QVariant curData = cbx->currentData();
QSignalBlocker block(cbx);
cbx->clear();
switch (type)
{
case PdmComboBoxType::CbLanguage:
{
const QString languages = LtsUtils::ProjectSettings::getInstance()->value(QStringLiteral("pdm"), QStringLiteral("EquipmentLanguages")).toString();
const QVector<QStringRef> slLang = languages.splitRef(QLatin1Char(','));
QSet<int> alreadySeen;
alreadySeen += LanguageConfiguration::NoChange;
cbx->addItem(toString(LanguageConfiguration::NoChange), LanguageConfiguration::NoChange);
for (const QStringRef &r : slLang)
{
const int langId = r.toInt();
if (alreadySeen.contains(langId))
continue;
alreadySeen += langId;
cbx->addItem(toString(static_cast<LanguageConfiguration_def::type>(langId)), static_cast<LanguageConfiguration_def::type>(langId));
}
break;
}
case PdmComboBoxType::CbOperationMode:
{
cbx->addItem(toString(OperationMode::NoChange), OperationMode::NoChange);
cbx->addItem(toString(OperationMode::Normal), OperationMode::Normal);
cbx->addItem(toString(OperationMode::BeStill), OperationMode::BeStill);
break;
}
case PdmComboBoxType::CbModeHelmet:
case PdmComboBoxType::CbModeVest:
{
cbx->addItem(toString(WphMode::NoChange), WphMode::NoChange);
cbx->addItem(toString(WphMode::Without), WphMode::Without);
cbx->addItem(toString(WphMode::With), WphMode::With);
break;
}
case PdmComboBoxType::CbPersonalProtection:
{
cbx->addItem(toString(PersonalProtection::NoChange), PersonalProtection::NoChange);
cbx->addItem(toString(PersonalProtection::Without), PersonalProtection::Without);
cbx->addItem(toString(PersonalProtection::Suit), PersonalProtection::Suit);
cbx->addItem(toString(PersonalProtection::SuitAndGloves), PersonalProtection::SuitAndGloves);
break;
}
case PdmComboBoxType::CbProtectionLevel:
{
cbx->addItem(toString(ProtectionLevel::NoChange), ProtectionLevel::NoChange);
cbx->addItem(toString(ProtectionLevel::IdzBs), ProtectionLevel::IdzBs);
cbx->addItem(toString(ProtectionLevel::IdzEs), ProtectionLevel::IdzEs);
cbx->addItem(toString(ProtectionLevel::Ksk), ProtectionLevel::Ksk);
cbx->addItem(toString(ProtectionLevel::SoldierWithBodyArmor), ProtectionLevel::SoldierWithBodyArmor);
cbx->addItem(toString(ProtectionLevel::SoldierActor), ProtectionLevel::SoldierActor);
break;
}
case PdmComboBoxType::CbHandgrenadeSearchMode:
{
cbx->addItem(toString(HandgrenadeSearchMode::NoChange), HandgrenadeSearchMode::NoChange);
cbx->addItem(toString(HandgrenadeSearchMode::On), HandgrenadeSearchMode::On);
cbx->addItem(toString(HandgrenadeSearchMode::Off), HandgrenadeSearchMode::Off);
break;
}
case PdmComboBoxType::CbInternationalMode:
{
cbx->addItem(toString(InternationalMode::NoChange), InternationalMode::NoChange);
cbx->addItem(toString(InternationalMode::On), InternationalMode::On);
cbx->addItem(toString(InternationalMode::Off), InternationalMode::Off);
break;
}
case PdmComboBoxType::CbABCProtectionMode:
{
cbx->addItem(toString(ABCProtectionMode::NoChange), ABCProtectionMode::NoChange);
cbx->addItem(toString(ABCProtectionMode::On), ABCProtectionMode::On);
cbx->addItem(toString(ABCProtectionMode::Off), ABCProtectionMode::Off);
break;
}
case PdmComboBoxType::CbUnkown:
break;
} // end switch
if (curData.isValid() && (cbx->findData(curData) != -1))
cbx->setCurrentIndex(cbx->findData(curData));
else if (cbx->count())
cbx->setCurrentIndex(0);
cbx->model()->sort(0, Qt::AscendingOrder);
return true;
}
bool fill(QComboBox *cbx, GearClass gearClass, const std::shared_ptr<Interface::Dtc> &dtc)
{
if (!cbx)
return false;
const QVariant curData = cbx->currentData();
QSignalBlocker block(cbx);
cbx->clear();
fillGearClass(cbx, gearClass, dtc);
if (curData.isValid() && (cbx->findData(curData) != -1))
cbx->setCurrentIndex(cbx->findData(curData));
else if (cbx->count())
cbx->setCurrentIndex(0);
return true;
}
bool setChargeTypePropertyFilter(QComboBox *cbx, const QString &property, const QVariant &value)
{
if (!cbx)
return false;
ChargeTypeFilterProxyModel *fpm = qobject_cast<ChargeTypeFilterProxyModel *>(cbx->model());
if (!fpm)
return false;
fpm->setPropertyFilter(property, value);
return true;
}
} // namespace PdmComboBox
} // namespace ProjectDataManagement
@@ -0,0 +1,86 @@
/**
* @RDE_HEADER@
* HMI Plugin for ProjectDataManagement - PDM ComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#pragma once
// DDS
#include <QSortFilterProxyModel>
#include <ProjectDataManagement/pdm_dtc.h>
class QComboBox;
class QStandardItemModel;
namespace ProjectDataManagement
{
enum class PdmComboBoxType
{
CbUnkown = 0,
CbLanguage,
CbOperationMode,
CbModeHelmet,
CbModeVest,
CbPersonalProtection,
CbProtectionLevel,
CbHandgrenadeSearchMode,
CbInternationalMode,
CbABCProtectionMode,
};
// --------------------------------------------------------
// ComboBox
// --------------------------------------------------------
namespace PdmComboBox
{
class ChargeTypeFilterProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
using QSortFilterProxyModel::QSortFilterProxyModel;
void setPropertyFilter(const QString &property, const QVariant &value);
void setSourceModel(QAbstractItemModel *model) override;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
private:
QStandardItemModel *m_model = nullptr;
QString m_property;
QVariant m_value;
};
namespace CBUserRoles
{
enum Role
{
Id = Qt::UserRole,
Properties
};
}
namespace TargetSubTypeRole
{
enum Role
{
Id = Qt::UserRole,
Abbreviation
};
}
bool fill(QComboBox *cbx, PdmComboBoxType type);
bool fill(QComboBox *cbx, GearClass gearClass, const std::shared_ptr<Interface::Dtc> &dtc);
void fillIgniterType(QComboBox *cbx, int chargeTypeId, const std::shared_ptr<Interface::Dtc> &dtc);
void fillIgniterFunction(QComboBox *cbx, int chargeTypeId, int igniterTypeId, const std::shared_ptr<Interface::Dtc> &dtc);
void fillLoadType(QComboBox *cbx, int chargeTypeId, const std::shared_ptr<Interface::Dtc> &dtc);
void fillTargetType(QComboBox *cbx, const std::shared_ptr<Interface::Dtc> &dtc);
void fillTargetSubType(QComboBox *cbx, int targetTypeId, const std::shared_ptr<Interface::Dtc> &dtc);
void fillFirePurpose(QComboBox *cbx, const std::shared_ptr<Interface::Dtc> &dtc);
bool setChargeTypePropertyFilter(QComboBox *cbx, const QString &property, const QVariant &value);
} // namespace PdmComboBox
} // namespace ProjectDataManagement
@@ -0,0 +1,181 @@
/**
* @RDE_HEADER@
* GUI Plugin for ProjectDataManagement - PdmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#include "pdm_combobox_foreign_gui_interface_impl.h"
#include "pdm_charge_selector.h"
#include "pdm_combobox.h"
namespace ProjectDataManagement
{
ForeignGuiInterfaceImpl::ForeignGuiInterfaceImpl()
: m_dtc(nullptr)
{}
bool ForeignGuiInterfaceImpl::init(const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtc)
{
m_dtc = dtc;
return m_dtc != nullptr;
}
void ForeignGuiInterfaceImpl::uninit()
{
m_dtc = nullptr;
}
bool ForeignGuiInterfaceImpl::fillBComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::Biological, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillCComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::Chemical, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillNComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::Nuclear, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillArtilleryComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::Artillery, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillMortarComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::Mortar, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillSingleMineComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::MineSingle, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillMineFieldComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::MineArea, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillBoobyTrapComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::BoobyTrap, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillOffRouteMineComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass_def::OffRouteMine, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillFunctionalAreaComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::FunctionalArea, m_dtc);
}
bool ForeignGuiInterfaceImpl::fillAirSupportComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, ProjectDataManagement::GearClass::AirSupport, m_dtc);
}
void ForeignGuiInterfaceImpl::fillIgniterComboBox(QComboBox *cbx, int chargeTypeId)
{
return PdmComboBox::fillIgniterType(cbx, chargeTypeId, m_dtc);
}
void ForeignGuiInterfaceImpl::fillIgniterFunctionComboBox(QComboBox *cbx, int chargeTypeId, int igniterTypeId)
{
return PdmComboBox::fillIgniterFunction(cbx, chargeTypeId, igniterTypeId, m_dtc);
}
void ForeignGuiInterfaceImpl::fillLoadComboBox(QComboBox *cbx, int chargeTypeId)
{
return PdmComboBox::fillLoadType(cbx, chargeTypeId, m_dtc);
}
void ForeignGuiInterfaceImpl::fillTargetTypeComboBox(QComboBox *cbx)
{
return PdmComboBox::fillTargetType(cbx, m_dtc);
}
void ForeignGuiInterfaceImpl::fillTargetSubTypeComboBox(QComboBox *cbx, int targetTypeId)
{
return PdmComboBox::fillTargetSubType(cbx, targetTypeId, m_dtc);
}
void ForeignGuiInterfaceImpl::fillFirePurposeComboBox(QComboBox *cbx)
{
return PdmComboBox::fillFirePurpose(cbx, m_dtc);
}
bool ForeignGuiInterfaceImpl::setChargeTypePropertyFilter(QComboBox *cbx, const QString &property, const QVariant &value)
{
return PdmComboBox::setChargeTypePropertyFilter(cbx, property, value);
}
void ForeignGuiInterfaceImpl::chargeSelector(const QSet<int> &preselectedCharges,
GearClass gearClass,
const std::function<void(const QSet<int>&)> &cb,
QWidget *parent)
{
ChargeSelector *ps(new ChargeSelector(parent));
ps->init(m_dtc, gearClass, preselectedCharges);
if (parent)
QObject::connect(ps, &ChargeSelector::chargesSelected, parent, cb);
ps->show();
}
bool ForeignGuiInterfaceImpl::fillPlayerLanguageComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbLanguage);
}
bool ForeignGuiInterfaceImpl::fillPlayerOperationModeComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbOperationMode);
}
bool ForeignGuiInterfaceImpl::fillPlayerModeHelmetComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbModeHelmet);
}
bool ForeignGuiInterfaceImpl::fillPlayerModeVestComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbModeVest);
}
bool ForeignGuiInterfaceImpl::fillPlayerPersonalProtectionComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbPersonalProtection);
}
bool ForeignGuiInterfaceImpl::fillPlayerProtectionLevelComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbProtectionLevel);
}
bool ForeignGuiInterfaceImpl::fillPlayerHandgrenadeSearchModeComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbHandgrenadeSearchMode);
}
bool ForeignGuiInterfaceImpl::fillPlayerInternationalModeComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbInternationalMode);
}
bool ForeignGuiInterfaceImpl::fillABCProtectionComboBox(QComboBox *cbx)
{
return PdmComboBox::fill(cbx, PdmComboBoxType::CbABCProtectionMode);
}
} // namespace ProjectDataManagement
@@ -0,0 +1,65 @@
/**
*@RDE_HEADER@
* Gui Plugin for ProjectDataManagement - PdmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#pragma once
#include <ProjectDataManagement/pdm_gui_plugin_interface.h>
#include <ProjectDataManagement/pdm_dtc.h>
namespace ProjectDataManagement
{
class ForeignGuiInterfaceImpl : public ForeignGuiInterface
{
public:
ForeignGuiInterfaceImpl();
bool init(const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &dtc);
void uninit();
bool fillBComboBox(QComboBox *cbx) override;
bool fillCComboBox(QComboBox *cbx) override;
bool fillNComboBox(QComboBox *cbx) override;
bool fillArtilleryComboBox(QComboBox *cbx) override;
bool fillMortarComboBox(QComboBox *cbx) override;
bool fillSingleMineComboBox(QComboBox *cbx) override;
bool fillMineFieldComboBox(QComboBox *cbx) override;
bool fillBoobyTrapComboBox(QComboBox *cbx) override;
bool fillOffRouteMineComboBox(QComboBox *cbx) override;
bool fillFunctionalAreaComboBox(QComboBox *cbx) override;
bool fillAirSupportComboBox(QComboBox *cbx) override;
bool setChargeTypePropertyFilter(QComboBox *cbx, const QString &property, const QVariant &value) override;
bool fillPlayerLanguageComboBox(QComboBox *cbx) override;
bool fillPlayerOperationModeComboBox(QComboBox *cbx) override;
bool fillPlayerModeHelmetComboBox(QComboBox *cbx) override;
bool fillPlayerModeVestComboBox(QComboBox *cbx) override;
bool fillPlayerPersonalProtectionComboBox(QComboBox *cbx) override;
bool fillPlayerProtectionLevelComboBox(QComboBox *cbx) override;
bool fillPlayerHandgrenadeSearchModeComboBox(QComboBox *cbx) override;
bool fillPlayerInternationalModeComboBox(QComboBox *cbx) override;
bool fillABCProtectionComboBox(QComboBox *cbx) override;
void fillIgniterComboBox(QComboBox *cbx, int chargeTypeId) override;
void fillIgniterFunctionComboBox(QComboBox *cbx, int chargeTypeId, int igniterTypeId) override;
void fillLoadComboBox(QComboBox *cbx, int chargeTypeId) override;
void fillTargetTypeComboBox(QComboBox *cbx) override;
void fillTargetSubTypeComboBox(QComboBox *cbx, int targetTypeId) override;
void fillFirePurposeComboBox(QComboBox *cbx) override;
void chargeSelector(const QSet<int> &preselectedCharges,
GearClass gearClass,
const std::function<void(const QSet<int>&)> &cb,
QWidget *parent) override;
private:
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_dtc;
};
} // namespace ProjectDataManagement
@@ -0,0 +1,37 @@
/**
* @RDE_HEADER@
* GUI Plugin for ProjectDataManagement - PdmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#include "pdm_combobox_gui_plugin.h"
namespace ProjectDataManagement
{
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.Pdm.PdmCombobox"))
{}
bool InterfaceImpl::fetchInterfaces()
{
std::shared_ptr<ProjectDataManagement::Interface::Dtc> dtc;
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(dtc))
return false;
return ForeignGuiInterfaceImpl::init(dtc);
}
void InterfaceImpl::clearInterfaces()
{
ForeignGuiInterfaceImpl::uninit();
}
} // namespace ProjectDataManagement
@@ -0,0 +1,54 @@
/**
*@RDE_HEADER@
* Gui Plugin for ProjectDataManagement - PdmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-09-12
*/
#pragma once
#include <LtsSession/lts_session.h>
#include <ProjectDataManagement/logger.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include "pdm_combobox_foreign_gui_interface_impl.h"
namespace ProjectDataManagement
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:pdm")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QLatin1String("ProjectDataManagementGuiPlugin"); }
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 QObject, public ForeignGuiInterfaceImpl, 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; }
};
} // namespace ProjectDataManagement