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,28 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Astrid Mueller, SGAS, 2017-10-11
#
SET(opm_combobox_gui_SRCS
opm_combobox_gui_plugin.cpp
opm_combobox_gui_plugin.h
)
NGL_ADD_LIBRARY(WS OpmComboBoxGuiPlugin MODULE ${opm_combobox_gui_SRCS})
NGL_TARGET_LINK_LIBRARIES(OpmComboBoxGuiPlugin
NGLLogger
OpmGuiComboboxPluginInterface
OpmDataPluginInterface
PpmDataPluginInterface
LtsUtilsGuiDds
Qt5::Widgets
LtsWidgets
LtsSession
LtsSessionData
)
NGL_INSTALL_TARGET(OpmComboBoxGuiPlugin)
@@ -0,0 +1,142 @@
/**
* @RDE_HEADER@
* GUI Plugin for OperatorManagement - OpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Astrid Mueller, SGAS, 201-10-11
*/
#include "opm_combobox_gui_plugin.h"
#include <OperatorManagement/opm_translation.h>
namespace OperatorManagement
{
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.Opm.OpmCombobox"))
, m_dtc(nullptr)
, m_ppmDtc(nullptr)
{}
bool InterfaceImpl::fetchInterfaces()
{
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_dtc))
return false;
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
return false;
return true;
}
void InterfaceImpl::clearInterfaces()
{
m_dtc = nullptr;
m_ppmDtc = nullptr;
}
bool InterfaceImpl::fillOperatorComboBox(LtsWidgets::LtsComboBox *cbx, CbxOperatorFilter filter)
{
cbx->clear();
if ((filter & eOperators) == eOperators)
{
auto cbUser = [cbx](const User &user)
{
if (user.isDeleted() || user.id() <= 0)
return;
cbx->addItem(QString::fromStdString(user.name()), user.id());
};
m_dtc->users(cbUser);
}
if ((filter & eOc) == eOc)
{
auto cbPlayer = [this, cbx] (const ParticipantManagement::Participant &oc)
{
if (oc.isDeleted() || !oc.equipmentNumber().is_set())
return;
ParticipantManagement::TypeClass typeClass = m_ppmDtc->type(oc.typeId()).typeClass();
if ((typeClass != ParticipantManagement::TypeClass::SupportEntity) ||
(oc.id() <= 0))
return;
int participantId = oc.id();
QString hierarchy = m_ppmDtc->hierarchyFromParticipant(participantId);
cbx->addItem(hierarchy + QStringLiteral(" - ") + QString::fromStdString(oc.tacticalIdentifier()) + QStringLiteral(" - ")+ QString::number(oc.equipmentNumber().get()), 0 - oc.id());
};
m_ppmDtc->participants(cbPlayer);
}
cbx->model()->sort(0);
return cbx->count() > 0;
}
bool InterfaceImpl::fillActiveAppOperatorComboBox(LtsWidgets::LtsComboBox *cbx, int appId, int exerciseId, int preSelectedOperatorId)
{
m_dtc->enableActiveApp();
cbx->clear();
QSet<int> operatorIds;
auto cbActiveApp = [this, &operatorIds, appId, exerciseId](const ActiveApp &activeApp)
{
DEBUG_LOG(m_logger) << "activeApp = " << activeApp
<< ", appId = " << appId;
if ((activeApp.operatorId() <= 0) ||
// (activeApp.appId() != appId) || // GUEZE-1771
(activeApp.exerciseId() != exerciseId))
return;
operatorIds += activeApp.operatorId();
};
m_dtc->activeApps(cbActiveApp);
for (int opId : qAsConst(operatorIds))
{
const User &user = m_dtc->user(opId);
DEBUG_LOG(m_logger) << "activeApp = addItem: " << user;
cbx->addItem(QString::fromStdString(user.name()), user.id());
}
cbx->model()->sort(0);
if ((preSelectedOperatorId > 0) && (cbx->model()->rowCount() > 0))
{
int idx = cbx->findData(preSelectedOperatorId);
if (idx >= 0)
cbx->setCurrentIndex(idx);
}
return cbx->count() > 0;
}
bool InterfaceImpl::fillActiveAppScreenComboBox(LtsWidgets::LtsComboBox *cbx, int appId, int operatorId, int exerciseId, bool preSelectTopmost)
{
cbx->clear();
auto cbActiveApp = [this, cbx, appId, operatorId, exerciseId](const ActiveApp &activeApp)
{
DEBUG_LOG(m_logger) << " activeApp = " << activeApp;
if ((activeApp.operatorId() == operatorId) &&
// (activeApp.appId() == appId) && // GUEZE-1771
(activeApp.exerciseId() == exerciseId))
{
const int screenId = activeApp.screenId();
const QString &activeAppAsString = LtsSession::LtsSession::appToString(static_cast<LtsAppDescriptor::App>(activeApp.appId()));
cbx->addItem(tr("Screen '%1' ('%2')").arg(screenId).arg(activeAppAsString),
screenId);
}
};
m_dtc->activeApps(cbActiveApp);
cbx->model()->sort(0);
if (preSelectTopmost && (cbx->model()->rowCount() > 0))
cbx->setCurrentIndex(0);
return cbx->count() > 0;
}
} // namespace OperatorManagement
@@ -0,0 +1,71 @@
/**
*@RDE_HEADER@
* Gui Plugin for OperatorManagement - OpmComboBox
* $Id$
* $HeadURL$
* $Author$
* Created by Astrid Mueller, SGAS, 2017-10-11
*/
#pragma once
#include <LtsSession/lts_session.h>
#include <LtsWidgets/lts_combo_box.h>
#include <OperatorManagement/logger.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/OperatorManagement/opm_gui_combobox_plugin_interface.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
namespace OperatorManagement
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:opm.combobox")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("OperatorManagement.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 QObject, public ForeignGuiComboboxInterface, 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 || partition == IDL::PartitionType::Replay; }
// ForeignDataInterface
virtual bool fillOperatorComboBox(LtsWidgets::LtsComboBox *cbx, CbxOperatorFilter filter = eOperators) override;
// ActiveApps:
virtual bool fillActiveAppOperatorComboBox(LtsWidgets::LtsComboBox *cbx, int appId, int exerciseId, int preSelectedOperatorId) override;
virtual bool fillActiveAppScreenComboBox(LtsWidgets::LtsComboBox *cbx, int appId, int operatorId, int exerciseId, bool preSelectTopmost = false) override;
private:
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
};
} // namespace ParticipantManagement