Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+56
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-03-01
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Info Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(OpmGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opm_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# ComboBox Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(OpmGuiComboboxPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opm_gui_combobox_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# Settings Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(OpmSettingsGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opm_settings_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Overview Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(OpmOverviewGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opm_overview_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../
|
||||
GuiPluginInterface
|
||||
)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(OpmDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opm_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcOpmCommon
|
||||
)
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-09-06
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY(WS OpmDataPlugin MODULE opm_data_plugin.cpp opm_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(OpmDataPlugin
|
||||
Qt5::Core
|
||||
OpmDataPluginInterface
|
||||
svcOpmClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
LtsUtilsSettings # user-settings
|
||||
LtsUtilsGuiDds # dds-vec => QByteArray
|
||||
LtsSessionData
|
||||
ddsconnector
|
||||
)
|
||||
NGL_INSTALL_TARGET(OpmDataPlugin)
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for ExerciseManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "opm_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/OperatorManagement/opm_gui_plugin_interface.h>
|
||||
#include <Services/OperatorManagement/logger.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<Interface::Dtc> dtc;
|
||||
std::shared_ptr<Interface::Ftc> ftc;
|
||||
if (!session->createTopicClient(dtc, ftc, false, true))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc, session);
|
||||
}
|
||||
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSessionDataDds *session)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
, m_foreignInterface(std::make_shared<ForeignInterfaceImpl>(dtc, ftc, session))
|
||||
{}
|
||||
|
||||
|
||||
ForeignInterfaceImpl::ForeignInterfaceImpl(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSessionDataDds *session)
|
||||
: m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
, m_session(session)
|
||||
, m_timer(nullptr)
|
||||
{
|
||||
// bleibt Global immer geladen? Wenn nein, IDL::PartitionType::Exercise auch noch nötig
|
||||
if (m_session->partitionType() == IDL::PartitionType::Global)
|
||||
{
|
||||
auto ddsConnector = m_session->ddsConnector();
|
||||
m_dtsOperatorWorkstationAlive.reset(ddsConnector->createDTS<DTS::OperatorWorkstationAliveImpl>());
|
||||
|
||||
// send KeepAlive - Messages every n seconds
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, &QTimer::timeout, this, &ForeignInterfaceImpl::onSendKeepAlive);
|
||||
m_timer->setSingleShot(false);
|
||||
onSendKeepAlive();
|
||||
}
|
||||
}
|
||||
|
||||
ForeignInterfaceImpl::~ForeignInterfaceImpl()
|
||||
{
|
||||
if (m_dtsOperatorWorkstationAlive)
|
||||
{
|
||||
const auto inst = LtsSessionData::LtsSessionData::getInstance();
|
||||
if (inst->getWorkstationId() > 0)
|
||||
{
|
||||
const OperatorWorkstationAlive alive(inst->getWorkstationId(), 0, 0);
|
||||
m_dtsOperatorWorkstationAlive->remove(alive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ForeignInterfaceImpl::onSendKeepAlive()
|
||||
{
|
||||
if (!m_timer)
|
||||
return;
|
||||
|
||||
m_timer->start(30 * 1000); // every 30s
|
||||
|
||||
if (!m_dtsOperatorWorkstationAlive)
|
||||
return;
|
||||
|
||||
const auto inst = LtsSessionData::LtsSessionData::getInstance();
|
||||
if (inst->getWorkstationId() <= 0)
|
||||
return;
|
||||
const OperatorWorkstationAlive alive(inst->getWorkstationId(),
|
||||
inst->getOperatorId(),
|
||||
QDateTime::currentMSecsSinceEpoch());
|
||||
m_dtsOperatorWorkstationAlive->write(alive);
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <OperatorManagement/opm_dts_types.h>
|
||||
#include <DDS/DTS/generic_dts_impl.h>
|
||||
|
||||
class QTimer;
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:opm")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("OperatorManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global ||
|
||||
partition == IDL::PartitionType::Exercise ||
|
||||
partition == IDL::PartitionType::Replay;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
DataInterfaceImpl(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSessionDataDds *session);
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
std::shared_ptr<ForeignDataInterface> getForeignDataInterface() override { return m_foreignInterface; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ForeignDataInterface> m_foreignInterface;
|
||||
};
|
||||
|
||||
class ForeignInterfaceImpl final : public QObject, public ForeignDataInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ForeignInterfaceImpl(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSessionDataDds *session);
|
||||
~ForeignInterfaceImpl();
|
||||
|
||||
void onSendKeepAlive() override;
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
std::unique_ptr<DTS::OperatorWorkstationAlive> m_dtsOperatorWorkstationAlive;
|
||||
LtsSession::LtsSessionDataDds *m_session;
|
||||
QTimer *m_timer;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(Common)
|
||||
ADD_SUBDIRECTORY(OperatorOverview)
|
||||
ADD_SUBDIRECTORY(OperatorSettings)
|
||||
ADD_SUBDIRECTORY(OperatorEdit)
|
||||
ADD_SUBDIRECTORY(Login)
|
||||
ADD_SUBDIRECTORY(OpmComboBox)
|
||||
#ADD_SUBDIRECTORY(NewLogin)
|
||||
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Diers, SLSE, 2017-10-23
|
||||
#
|
||||
|
||||
SET(opm_change_pw_gui_SRCS
|
||||
operator_change_password.cpp
|
||||
operator_change_password.h
|
||||
|
||||
operator_dialog_model.cpp
|
||||
operator_dialog_model.h
|
||||
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(opm_change_pw_gui_SRCS
|
||||
operator_change_password.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS OpmChangePasswordGui SHARED ${opm_change_pw_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(OpmChangePasswordGui
|
||||
OpmDataPluginInterface
|
||||
OpmGuiPluginInterface
|
||||
PpmDataPluginInterface
|
||||
ExmDataPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSessionData
|
||||
LtsUtilsGuiDds
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Change Password (Frameless) Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, SLSE, 2017-10-11
|
||||
*/
|
||||
|
||||
#include "operator_change_password.h"
|
||||
#include "ui_operator_change_password.h"
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <OperatorManagement/opm_operator_rights.h>
|
||||
|
||||
OperatorChangePassword::OperatorChangePassword(QWidget *parent, int operatorId)
|
||||
: LtsWidgets::LtsFramelessDialog(parent)
|
||||
, m_session(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_operatorId(operatorId)
|
||||
, m_ui(new Ui::OperatorChangePassword)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->pbDisplay, &QPushButton::toggled, this, &OperatorChangePassword::onViewPasswordToggled);
|
||||
|
||||
connect(m_ui->pbCancel, &QPushButton::clicked, this, &OperatorChangePassword::reject);
|
||||
connect(m_ui->pbOk, &QPushButton::clicked, this, &OperatorChangePassword::onOkay);
|
||||
|
||||
connect(m_ui->leOldPassword, &QLineEdit::textChanged, m_ui->lblError, &QLabel::clear);
|
||||
connect(m_ui->leNewPassword, &QLineEdit::textChanged, m_ui->lblError, &QLabel::clear);
|
||||
connect(m_ui->leConfirmPassword, &QLineEdit::textChanged, m_ui->lblError, &QLabel::clear);
|
||||
}
|
||||
|
||||
OperatorChangePassword::~OperatorChangePassword()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void OperatorChangePassword::onOperatorChangePasswordReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (replyObject.error())
|
||||
m_ui->lblError->setText(replyObject.translated());
|
||||
else
|
||||
accept();
|
||||
}
|
||||
|
||||
bool OperatorChangePassword::init(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
m_session = session;
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<OperatorManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
if (m_operatorId == LtsSessionData::LtsSessionData::getInstance()->getOperatorId())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Organizer Or Admin Mode. No Need to know old Password.
|
||||
m_ui->leOldPassword->hide();
|
||||
m_ui->lblOldPassword->hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OperatorChangePassword::onViewPasswordToggled(bool checked)
|
||||
{
|
||||
m_ui->leNewPassword->setEchoMode(checked ? QLineEdit::EchoMode::Normal : QLineEdit::EchoMode::Password);
|
||||
m_ui->leConfirmPassword->setEchoMode(checked ? QLineEdit::EchoMode::Normal : QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
void OperatorChangePassword::onOkay()
|
||||
{
|
||||
if (m_ui->leNewPassword->text().length() < 4)
|
||||
{
|
||||
m_ui->lblError->setText(tr("New password is too short"));
|
||||
return;
|
||||
}
|
||||
if (m_ui->leNewPassword->text() != m_ui->leConfirmPassword->text())
|
||||
{
|
||||
m_ui->lblError->setText(tr("New password and confirmation do not match"));
|
||||
return;
|
||||
}
|
||||
|
||||
OperatorManagement::OperatorChangePasswordRequest req;
|
||||
req.id(m_operatorId);
|
||||
// Transmit anyways. If ForceSet is true, it doesn't matter if set or not.
|
||||
req.oldPassword(m_ui->leOldPassword->text().toStdString());
|
||||
req.password(m_ui->leNewPassword->text().toStdString());
|
||||
req.forceSet(m_ui->leOldPassword->isHidden());
|
||||
m_requestHelper->addRequest([this,req]()
|
||||
{
|
||||
return m_ftc->operatorChangePasswordRequest(req, this);
|
||||
});
|
||||
m_requestHelper->startRequests();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Change Password (Frameless) Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Malte Diers, SLSE, 2017-10-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <Plugins/OperatorManagement/Gui/Common/opmchangepasswordgui_export.h>
|
||||
|
||||
namespace Ui {
|
||||
class OperatorChangePassword;
|
||||
}
|
||||
namespace LtsSession {
|
||||
class LtsSessionDataDds;
|
||||
}
|
||||
|
||||
class OPMCHANGEPASSWORDGUI_EXPORT OperatorChangePassword : public LtsWidgets::LtsFramelessDialog,
|
||||
protected OperatorManagement::Interface::Ftc::OperatorChangePasswordReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OperatorChangePassword(QWidget *parent = nullptr, int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
~OperatorChangePassword();
|
||||
void onOperatorChangePasswordReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
bool init(LtsSession::LtsSessionDataDds *session);
|
||||
|
||||
private slots:
|
||||
void onViewPasswordToggled(bool checked);
|
||||
void onOkay();
|
||||
|
||||
private:
|
||||
LtsSession::LtsSessionDataDds *m_session;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
int m_operatorId;
|
||||
Ui::OperatorChangePassword *m_ui;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OperatorChangePassword</class>
|
||||
<widget class="LtsWidgets::LtsFramelessDialog" name="OperatorChangePassword">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>369</width>
|
||||
<height>196</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</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>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblOldPassword">
|
||||
<property name="text">
|
||||
<string>Old Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leOldPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leNewPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leConfirmPassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblPasswordConfirmation">
|
||||
<property name="text">
|
||||
<string>Confirm Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblPassword">
|
||||
<property name="text">
|
||||
<string>New Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="lblError">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" rowspan="2">
|
||||
<widget class="QPushButton" name="pbDisplay">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsFramelessDialog</class>
|
||||
<extends>QDialog</extends>
|
||||
<header>LtsWidgets/lts_frameless_dialog.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,290 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManangement - Operator Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "operator_dialog_model.h"
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <LtsUtilsCore/dds_vector_to_pixmap.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// OperatorManagementDialogModel
|
||||
//---------------------------------
|
||||
OperatorManagementDialogModel::OperatorManagementDialogModel(QObject *parent, int exerciseId )
|
||||
: LtsWidgets::LtsAbstractTableModel<OperatorManagement::User>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Info"),
|
||||
tr("Effective ACLs"),
|
||||
tr("Visible Parties"),
|
||||
tr("Primary Group Id"),
|
||||
tr("Projection Priority"),
|
||||
tr("Audio Channel Priority"),
|
||||
tr("Image"),
|
||||
tr("Workstation"),
|
||||
tr("Exercises"),
|
||||
tr("Preset Role")},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_exmDtc(nullptr)
|
||||
, m_logger(getLogger("OpeartorManagementDialogModel"))
|
||||
, m_exerciseId(exerciseId)
|
||||
{}
|
||||
|
||||
OperatorManagementDialogModel::~OperatorManagementDialogModel()
|
||||
{}
|
||||
|
||||
bool OperatorManagementDialogModel::initModel(LtsSession::LtsSession *session, const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc);
|
||||
session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc);
|
||||
|
||||
connect(m_dtc.get(), &OperatorManagement::Interface::Dtc::userChanged,
|
||||
this, &OperatorManagementDialogModel::onDataChanged);
|
||||
m_dtc->users([this](const OperatorManagement::User &op) { insertRow(op); });
|
||||
|
||||
if (m_ppmDtc)
|
||||
{
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged,
|
||||
this, &OperatorManagementDialogModel::onPartyChanged);
|
||||
// Get 'static' data for all parties
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Party & party)
|
||||
{
|
||||
onPartyChanged(party, DataModification::eAdded);
|
||||
};
|
||||
if (!m_ppmDtc->partys(cb))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_exmDtc)
|
||||
{
|
||||
connect(m_exmDtc.get(), &ExerciseManagement::Interface::Dtc::exerciseChanged,
|
||||
this, &OperatorManagementDialogModel::onExerciseChanged);
|
||||
// Get 'static' data for all exercises
|
||||
{
|
||||
auto cb = [this](const ExerciseManagement::Exercise &exercise)
|
||||
{
|
||||
onExerciseChanged(exercise, DataModification::eAdded);
|
||||
};
|
||||
if (!m_exmDtc->exercises(cb))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const Group &group)
|
||||
{
|
||||
if (group.type() == GroupType_def::PresetGroup)
|
||||
m_roles[group.id()] = QString::fromStdString(group.name());
|
||||
};
|
||||
dtc->groups(cb);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OperatorManagementDialogModel::onPartyChanged(const ParticipantManagement::Party &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
m_parties.remove(data.id());
|
||||
else
|
||||
m_parties[data.id()] = ParticipantManagement::trPartyName(data.name());
|
||||
for (int row = 0; row < m_vecData.size(); ++row)
|
||||
{
|
||||
const QModelIndex idx(index(row, VisibleParties));
|
||||
emit dataChanged(idx, idx);
|
||||
}
|
||||
}
|
||||
|
||||
void OperatorManagementDialogModel::onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
m_exercises.remove(data.id());
|
||||
else
|
||||
m_exercises[data.id()] = QString::fromStdString(data.name());
|
||||
for (int row = 0; row < m_vecData.size(); ++row)
|
||||
{
|
||||
const QModelIndex idx(index(row, Exercises));
|
||||
emit dataChanged(idx, idx);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant OperatorManagementDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole && role != Qt::DecorationRole)
|
||||
return QVariant();
|
||||
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DecorationRole && index.column() == Name)
|
||||
return QIcon(QLatin1String("icon:list-add-user.svg"));
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
const OperatorManagement::User &op = m_vecData.at(index.row());
|
||||
std::vector<OperatorManagement::PartiesByExercise> pbe = op.visiblePartiesByExercise();
|
||||
switch (index.column())
|
||||
{
|
||||
case Name:
|
||||
return QString::fromStdString(op.name());
|
||||
case Description:
|
||||
return QString::fromStdString(op.description());
|
||||
case VisibleParties:
|
||||
return hasVisibleParties(pbe);
|
||||
case RolePreset:
|
||||
return rolePreset(op.rolePresetId());
|
||||
case Id:
|
||||
return QString::number(op.id());
|
||||
case EffectiveAcls:
|
||||
return effectiveAcls(op.effectiveAcls());
|
||||
case PrimaryGroupId:
|
||||
return QString::number(op.primaryGroupId());
|
||||
case ProjectionPriority:
|
||||
return priority(op.projectionPriority());
|
||||
case AudioChannelPriority:
|
||||
return priority(op.audioChannelPriority());
|
||||
case Image:
|
||||
return LtsUtils::getPixmap(op.image());
|
||||
case Workstation:
|
||||
return workstation(op.workstationId(), op.workstationIp());
|
||||
case Exercises:
|
||||
return exercises(op.exerciseIds());
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QString OperatorManagementDialogModel::workstation(int wsId, int wsIp) const
|
||||
{
|
||||
if (!wsId)
|
||||
return QString();
|
||||
|
||||
quint8 oct1,oct2,oct3,oct4;
|
||||
oct1 = (wsIp >> 24) & 0xFF;
|
||||
oct2 = (wsIp >> 16) & 0xFF;
|
||||
oct3 = (wsIp >> 8) & 0xFF;
|
||||
oct4 = (wsIp >> 0) & 0xFF;
|
||||
QString ip = tr("%1.%2.%3.%4").arg(oct1).arg(oct2).arg(oct3).arg(oct4);
|
||||
|
||||
return tr("ID: %1, IP: %2").arg(wsId).arg(ip);
|
||||
|
||||
}
|
||||
|
||||
QString OperatorManagementDialogModel::rolePreset(const dds::core::optional<int32_t> &rolePresetId) const
|
||||
{
|
||||
if (!rolePresetId.is_set())
|
||||
return tr("---");
|
||||
|
||||
int32_t id = rolePresetId.get();
|
||||
|
||||
if (id <= 0)
|
||||
return tr("---");
|
||||
|
||||
return m_roles.value(id, tr("Id: %1").arg(id));
|
||||
}
|
||||
|
||||
QString OperatorManagementDialogModel::hasVisibleParties(const std::vector<OperatorManagement::PartiesByExercise> &vpbe) const
|
||||
{
|
||||
int exerciseId = (m_exerciseId != -1) ? m_exerciseId
|
||||
: 0 /*new exercise*/;
|
||||
std::vector<int32_t> parties = {};
|
||||
|
||||
for (const auto &pbe : vpbe)
|
||||
{
|
||||
if (pbe.exerciseId() != exerciseId)
|
||||
continue;
|
||||
|
||||
std::vector<int32_t> hiddenParties = {};
|
||||
if (pbe.hiddenParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
hiddenParties = pbe.hiddenParties().get();
|
||||
|
||||
if(!pbe.visibleParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
return {};
|
||||
|
||||
for (const auto &partyId : pbe.visibleParties().get())
|
||||
{
|
||||
bool isHidden = false;
|
||||
for (const int &hiddenId : hiddenParties)
|
||||
{
|
||||
if (hiddenId != partyId)
|
||||
continue;
|
||||
isHidden = true;
|
||||
}
|
||||
|
||||
if(!isHidden)
|
||||
parties.push_back(partyId);
|
||||
}
|
||||
return visibleParties(parties);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QString OperatorManagementDialogModel::visibleParties(const std::vector<int32_t> &parties) const
|
||||
{
|
||||
QStringList result;
|
||||
result.reserve(parties.size());
|
||||
for (const int partyId : parties)
|
||||
result.append(m_parties.value(partyId, tr("Id: %1").arg(partyId)));
|
||||
|
||||
return result.join(QStringLiteral(", "));
|
||||
}
|
||||
|
||||
|
||||
QString OperatorManagementDialogModel::exercises(const std::vector<int32_t> &exercises) const
|
||||
{
|
||||
QStringList result;
|
||||
result.reserve(exercises.size());
|
||||
for (const int exerciseId : exercises)
|
||||
result.append(m_exercises.value(exerciseId, tr("Id: %1").arg(exerciseId)));
|
||||
|
||||
return result.join(QStringLiteral(", "));
|
||||
}
|
||||
|
||||
QString OperatorManagementDialogModel::effectiveAcls(std::vector<int32_t> acls) const
|
||||
{
|
||||
std::sort(acls.begin(), acls.end());
|
||||
QStringList sl;
|
||||
sl.reserve(acls.size());
|
||||
for (const int32_t acl : acls)
|
||||
sl.append(QString::number(acl));
|
||||
return sl.join(QStringLiteral(", "));
|
||||
}
|
||||
|
||||
QString OperatorManagementDialogModel::priority(int16_t prio) const
|
||||
{
|
||||
// Todo: Names?
|
||||
return QString::number(prio);
|
||||
}
|
||||
|
||||
bool OperatorManagementDialogModel::isFiltered(const OperatorManagement::User &data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
|
||||
if (m_exerciseId == 0)
|
||||
return false; // no operator filtered out
|
||||
for (auto exId : data.exerciseIds())
|
||||
if (exId == m_exerciseId)
|
||||
return false; // operator not filtered out
|
||||
|
||||
return true; // operator filtered out
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Operator Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <Plugins/OperatorManagement/Gui/Common/opmchangepasswordgui_export.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// OperatorManagementModel
|
||||
// --------------------------------------------------------
|
||||
class OPMCHANGEPASSWORDGUI_EXPORT OperatorManagementDialogModel final : public LtsWidgets::LtsAbstractTableModel<OperatorManagement::User>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Name,
|
||||
Description,
|
||||
EffectiveAcls,
|
||||
VisibleParties,
|
||||
PrimaryGroupId,
|
||||
ProjectionPriority,
|
||||
AudioChannelPriority,
|
||||
Image,
|
||||
Workstation,
|
||||
Exercises,
|
||||
RolePreset
|
||||
};
|
||||
|
||||
explicit OperatorManagementDialogModel(QObject *parent = nullptr, int exerciseId = 0);
|
||||
~OperatorManagementDialogModel();
|
||||
|
||||
bool initModel(LtsSession::LtsSession *session, const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
|
||||
bool isFiltered( const OperatorManagement::User &data, DataModification modType ) const override;
|
||||
|
||||
private:
|
||||
QString hasVisibleParties(const std::vector<PartiesByExercise> &vpbe) const;
|
||||
QString visibleParties(const std::vector<int32_t> &parties) const;
|
||||
QString effectiveAcls(std::vector<int32_t> acls) const;
|
||||
QString priority(int16_t prio) const;
|
||||
QString exercises(const std::vector<int32_t> &exercises) const;
|
||||
QString rolePreset(const dds::core::optional<int32_t> &rolePresetId) const;
|
||||
QString workstation(int wsId, int wsIp) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPartyChanged(const ParticipantManagement::Party &data, DataModification modType);
|
||||
void onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
QMap<int,QString> m_parties;
|
||||
QMap<int,QString> m_exercises;
|
||||
QMap<int,QString> m_roles;
|
||||
LOGGER_T m_logger;
|
||||
int m_exerciseId;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Mike Wille, SLSE, 2016-05-12
|
||||
#
|
||||
|
||||
SET(opm_login_gui_SRCS
|
||||
opm_login_dialog_gui_plugin.cpp
|
||||
opm_login_dialog_gui_plugin.h
|
||||
opm_login_dialog.cpp
|
||||
opm_login_dialog.h
|
||||
opm_login_operator_dialog.cpp
|
||||
opm_login_operator_dialog.h
|
||||
opm_login_remote_shutdown_dialog.cpp
|
||||
opm_login_remote_shutdown_dialog.h
|
||||
opm_login_workstation_model.cpp
|
||||
opm_login_workstation_model.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(opm_login_gui_SRCS
|
||||
opm_login_dialog.ui
|
||||
opm_login_operator_dialog.ui
|
||||
opm_login_remote_shutdown_dialog.ui
|
||||
)
|
||||
|
||||
IF(UNIX)
|
||||
SET(X11_LIB X11)
|
||||
ENDIF()
|
||||
|
||||
NGL_ADD_LIBRARY(WS OpmLoginGuiPlugin MODULE ${opm_login_gui_SRCS})
|
||||
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16.0 AND BOTAN_FOUND) # botan doesn't use cmake
|
||||
target_include_directories(OpmLoginGuiPlugin SYSTEM PRIVATE ${BOTAN_INCLUDE_DIRS})
|
||||
set(LTS_BOTAN ${BOTAN_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(OpmLoginGuiPlugin
|
||||
NGLLogger
|
||||
OpmDataPluginInterface
|
||||
AsmDataPluginInterface # workstation id
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
LtsWidgets
|
||||
LtsSessionData
|
||||
LtsSession
|
||||
LtsUtilsGuiDds # RequestHelper
|
||||
LtsUtilsSettings # user-settings
|
||||
LtsUtilsGuiConnectDialog
|
||||
LtsMultiMonitor
|
||||
LtsUtilsGuiStyleManager
|
||||
LtsProjectionWorkstation
|
||||
LtsPluginManager
|
||||
LtsAppManager
|
||||
#LtsTranslator
|
||||
ngltranslator
|
||||
ngltools
|
||||
nglsettings
|
||||
${X11_LIB} # focus test, debug
|
||||
|
||||
ExmDataPluginInterface
|
||||
ddscore # srm dtc
|
||||
|
||||
${LTS_BOTAN} # only if available
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(OpmLoginGuiPlugin)
|
||||
|
||||
|
||||
@@ -0,0 +1,576 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-05-05
|
||||
*/
|
||||
|
||||
#include "opm_login_dialog.h"
|
||||
#include "ui_opm_login_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Services/OperatorManagement/opm_ftc.h>
|
||||
#include <LtsMultiMonitor/lts_multi_monitor.h>
|
||||
#include <StyleManager/style_manager.h>
|
||||
#include <LtsWidgets/lts_base.h>
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QStyle>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QProcess>
|
||||
#include <QMenu>
|
||||
#include <QFile>
|
||||
#include <QUdpSocket>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
LoginWindow::LoginWindow(QWidget *parent, bool isAAR)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::LoginWindow)
|
||||
, m_done(false)
|
||||
, m_isAAR(isAAR)
|
||||
{
|
||||
setWindowFlag(Qt::WindowMinimizeButtonHint, false);
|
||||
setWindowFlag(Qt::WindowCloseButtonHint, false);
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
m_ui->setupUi(this);
|
||||
#ifdef Q_OS_LINUX
|
||||
QTimer *t = new QTimer(this);
|
||||
t->setInterval(1000);
|
||||
connect(t, &QTimer::timeout,
|
||||
this, [this]()
|
||||
{
|
||||
#ifndef LTS_DEBUG
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->debugFlagValue(QStringLiteral("Login.ShowFocus")) == QVariant(true))
|
||||
#endif
|
||||
{
|
||||
Display *dp = XOpenDisplay(nullptr);
|
||||
|
||||
if (dp == nullptr)
|
||||
{
|
||||
m_ui->lbLoginText->setText(QStringLiteral("Unable to get screen!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Window focused;
|
||||
int revert = 0;
|
||||
|
||||
XGetInputFocus(dp, &focused, &revert);
|
||||
XCloseDisplay(dp);
|
||||
|
||||
m_ui->lbLoginText->setText(QStringLiteral("Focused window id: 0x%1").arg(QString::number(focused, 16)));
|
||||
}
|
||||
});
|
||||
t->start();
|
||||
#endif
|
||||
setWindowTitle(tr("Login"));
|
||||
setMouseTracking(true); // register mouse movement
|
||||
|
||||
bool mmm = LtsMultiMonitor::LtsMultiMonitor::getInstance()->isActive();
|
||||
|
||||
if (mmm)
|
||||
{
|
||||
setWindowFlags(windowFlags() | /*Qt::WindowStaysOnTopHint | */Qt::FramelessWindowHint); // hints..
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
}
|
||||
|
||||
m_hideTimer.setInterval(30000);
|
||||
if(!LtsSessionData::LtsSessionData::getInstance()->isTablet())
|
||||
connect(&m_hideTimer, &QTimer::timeout, this, &LoginWindow::slotHide);
|
||||
|
||||
connect(m_ui->leOperatorName, &QLineEdit::textChanged, this, [this]()
|
||||
{
|
||||
if (m_hideTimer.isActive())
|
||||
m_hideTimer.start();
|
||||
});
|
||||
|
||||
QList<QLabel *> labels = findChildren<QLabel *>();
|
||||
|
||||
for (QList<QLabel *>::const_iterator i = labels.constBegin(); i != labels.constEnd(); ++i)
|
||||
{
|
||||
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); // cannot copy this..
|
||||
shadow->setOffset(0, 0);
|
||||
shadow->setBlurRadius(22);
|
||||
shadow->setColor(QColor("white"));
|
||||
|
||||
(*i)->setGraphicsEffect(shadow);
|
||||
}
|
||||
|
||||
LtsSessionData::LtsSessionData *sessionData = LtsSessionData::LtsSessionData::getInstance();
|
||||
|
||||
if (sessionData->isTablet())
|
||||
{
|
||||
setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignHCenter | Qt::AlignTop,
|
||||
size(),
|
||||
QGuiApplication::primaryScreen()->geometry()));
|
||||
}
|
||||
else
|
||||
{
|
||||
setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter,
|
||||
size(),
|
||||
QGuiApplication::primaryScreen()->geometry()));
|
||||
}
|
||||
|
||||
QMenu *shutdownMenu = new QMenu(m_ui->pbShutdown);
|
||||
QAction *action = shutdownMenu->addAction(tr("Shutdown"), this, &LoginWindow::slotShutdown );
|
||||
QFont font = action->font();
|
||||
#ifdef TABLET_MODE
|
||||
font.setPointSizeF(font.pointSizeF()*1.5);
|
||||
#endif
|
||||
action->setFont(font);
|
||||
action = shutdownMenu->addAction(tr("Reboot"), this, &LoginWindow::slotReboot );
|
||||
action->setFont(font);
|
||||
|
||||
|
||||
#ifndef GUEZ_MODE
|
||||
#ifdef TABLET_MODE
|
||||
if (PROJECTBUILD == "ahtc")
|
||||
{
|
||||
action = shutdownMenu->addAction(tr("Logout"), this, &LoginWindow::slotOperatorLogout );
|
||||
action->setFont(font);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
m_ui->pbShutdown->setMenu(shutdownMenu);
|
||||
#ifdef TABLET_MODE
|
||||
// m_ui->pbExit->setFont(font);
|
||||
// m_ui->pbShutdown->setFont(font);
|
||||
#endif
|
||||
|
||||
|
||||
connect(m_ui->pbGo, &QPushButton::clicked,
|
||||
this, &LoginWindow::slotLogin, Qt::QueuedConnection); // TODO: can be direct (?)
|
||||
connect(m_ui->pbExit, &QPushButton::clicked,
|
||||
this, &LoginWindow::slotExit);
|
||||
// connect(m_ui->pbShutdown, &QPushButton::clicked,
|
||||
// this, &LoginWindow::slotShutdown);
|
||||
|
||||
connect(m_ui->pbDe_DE, &QPushButton::clicked,
|
||||
this, &LoginWindow::onLanguageChange);
|
||||
connect(m_ui->pbEn_GB, &QPushButton::clicked,
|
||||
this, &LoginWindow::onLanguageChange);
|
||||
connect(m_ui->pbEn_US, &QPushButton::clicked,
|
||||
this, &LoginWindow::onLanguageChange);
|
||||
|
||||
m_ui->pbDe_DE->hide();
|
||||
m_ui->pbEn_GB->hide();
|
||||
m_ui->pbEn_US->hide();
|
||||
const QString languages = LtsUtils::ProjectSettings::getInstance()->value(QStringLiteral("pdm"), QStringLiteral("SystemLanguages")).toString();
|
||||
const QVector<QStringRef> slLang = languages.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
|
||||
|
||||
if (slLang.isEmpty())
|
||||
{
|
||||
qWarning() << "LoginWindow::c_tor: Missing 'SystemLanguages' entry in project settings file!";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slLang.size() > 1)
|
||||
{
|
||||
for (QStringRef lang : slLang)
|
||||
{
|
||||
lang = lang.trimmed();
|
||||
// qWarning() << "available language:" << lang.toString();
|
||||
if (lang == QLatin1String("de_DE"))
|
||||
m_ui->pbDe_DE->show();
|
||||
if (lang == QLatin1String("en_GB"))
|
||||
m_ui->pbEn_GB->show();
|
||||
if (lang == QLatin1String("en_US"))
|
||||
m_ui->pbEn_US->show();
|
||||
}
|
||||
|
||||
if (NGL::translationLocale() == "de_DE")
|
||||
m_ui->pbDe_DE->click();
|
||||
if (NGL::translationLocale() == "en_GB")
|
||||
m_ui->pbEn_GB->click();
|
||||
if (NGL::translationLocale() == "en_US")
|
||||
m_ui->pbEn_US->click();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString lang = slLang.at(0).toString().trimmed();
|
||||
// qWarning() << "available language:" << slLang.at(0).toString();
|
||||
if (lang.toLatin1() == "de_DE")
|
||||
m_ui->pbDe_DE->click();
|
||||
if (lang.toLatin1() == "en_GB")
|
||||
m_ui->pbEn_GB->click();
|
||||
if (lang.toLatin1() == "en_US")
|
||||
m_ui->pbEn_US->click();
|
||||
}
|
||||
}
|
||||
QMenu *styleMenu = new QMenu(m_ui->pbStyle);
|
||||
styleMenu->addAction(tr("Light"), this, &LoginWindow::slotLightStyle);
|
||||
styleMenu->addAction(tr("Dark"), this, &LoginWindow::slotDarkStyle);
|
||||
m_ui->pbStyle->setMenu(styleMenu);
|
||||
slotLightStyle();
|
||||
|
||||
|
||||
// PROJECT LOGO
|
||||
QString projectLogoFilename(QStringLiteral(":project/login_logo.png"));
|
||||
if (!QFile(projectLogoFilename).exists())
|
||||
projectLogoFilename = QStringLiteral(":/project/logo.png");
|
||||
|
||||
QPixmap pixmap(projectLogoFilename);
|
||||
|
||||
if (pixmap.isNull())
|
||||
{
|
||||
qWarning() << "LoginWindow::c_tor: (PROJECT LOGO) file missing or is not an valid image '" << projectLogoFilename << "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
pixmap = pixmap.scaled(m_ui->lbRDELogo->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
m_ui->lbRDELogo->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
|
||||
auto setFocusCb = [this]()
|
||||
{
|
||||
QApplication::setActiveWindow(this);
|
||||
};
|
||||
QTimer::singleShot(50, this, setFocusCb);
|
||||
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->isTablet())
|
||||
m_ui->leOperatorName->setFocusPolicy(Qt::ClickFocus);
|
||||
else if (mmm && !LtsSessionData::LtsSessionData::getInstance()->isTablet())
|
||||
m_hideTimer.start();
|
||||
setMinimumSize(sizeHint());
|
||||
m_ui->leOperatorName->setFocus();
|
||||
}
|
||||
|
||||
LoginWindow::~LoginWindow()
|
||||
{
|
||||
delete m_ui;
|
||||
// qCritical() << "~LoginWindow";
|
||||
}
|
||||
|
||||
QString LoginWindow::getOperatorName() const
|
||||
{
|
||||
return m_ui->leOperatorName->text();
|
||||
}
|
||||
|
||||
void LoginWindow::setAARLabel(bool isAAR, bool connectedLocal)
|
||||
{
|
||||
if (!isAAR)
|
||||
m_ui->lblConnectedTo->hide();
|
||||
else
|
||||
{
|
||||
m_ui->lblConnectedTo->setStyleSheet(QStringLiteral("background-color: white;"));
|
||||
if (connectedLocal)
|
||||
m_ui->lblConnectedTo->setText(tr("Connected to local database"));
|
||||
else
|
||||
m_ui->lblConnectedTo->setText(tr("Connected to network"));
|
||||
}
|
||||
}
|
||||
|
||||
void LoginWindow::setStyle(const QString &name)
|
||||
{
|
||||
#ifdef TABLET_MODE
|
||||
LtsUtils::StyleManager::getInstance()->loadStyle(name, true);
|
||||
#else
|
||||
LtsUtils::StyleManager::getInstance()->loadStyle(name, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void LoginWindow::slotLightStyle()
|
||||
{
|
||||
setStyle(QStringLiteral("rme.light"));
|
||||
}
|
||||
|
||||
|
||||
void LoginWindow::slotDarkStyle()
|
||||
{
|
||||
setStyle(QStringLiteral("rme.dark"));
|
||||
}
|
||||
|
||||
void LoginWindow::slotExit()
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait(tr("Shutting down ..."));
|
||||
|
||||
//QMetaObject::invokeMethod
|
||||
QTimer::singleShot(500, this, [this]()
|
||||
{
|
||||
m_ui->pbExit->setText(tr("exiting ..."));
|
||||
m_ui->pbExit->setEnabled(false);
|
||||
m_ui->pbDe_DE->setEnabled(false);
|
||||
m_ui->pbEn_GB->setEnabled(false);
|
||||
m_ui->pbEn_US->setEnabled(false);
|
||||
m_ui->pbGo->setEnabled(false);
|
||||
m_ui->pbShutdown->setEnabled(false);
|
||||
m_ui->leOperatorName->setEnabled(false);
|
||||
|
||||
if (m_isAAR)
|
||||
{
|
||||
QStringList args;
|
||||
QString cmd = QStringLiteral("openbox");
|
||||
args << QStringLiteral("--exit");
|
||||
|
||||
qWarning() << "start openbox --exit";
|
||||
QProcess::startDetached(cmd, args);
|
||||
}
|
||||
|
||||
//QCoreApplication::processEvents();
|
||||
QCoreApplication::quit(); // simply exit event loop, cleanup is done by main() automatically (THIS is the only way to exit the application! via the Login Dialog)
|
||||
|
||||
});//, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void LoginWindow::slotShutdown()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
QFont font = msgBox.font();
|
||||
#ifdef TABLET_MODE
|
||||
font.setPointSizeF(font.pointSizeF()*1.5);
|
||||
#endif
|
||||
|
||||
msgBox.setWindowTitle(tr("Shutdown"));
|
||||
msgBox.setText(tr("Are you sure you want to shut down the system?"));
|
||||
|
||||
QAbstractButton* pButtonYes = msgBox.addButton(QMessageBox::Yes);
|
||||
pButtonYes->setMinimumWidth(150);
|
||||
pButtonYes->setFont(font);
|
||||
|
||||
QAbstractButton* pButtonNo = msgBox.addButton(QMessageBox::No);
|
||||
pButtonNo->setMinimumWidth(150);
|
||||
pButtonNo->setFont(font);
|
||||
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
#ifdef TABLET_MODE
|
||||
if (strcmp(PROJECTBUILD, "commaster") == 0) // may add a new plugin or projectBuild for that? demotablet for now
|
||||
{
|
||||
QByteArray queryTimeline("$IIXDR,S,1,,SERVICE_CONTROL_PRESHUTDOWN*79");
|
||||
QUdpSocket *socket = new QUdpSocket(this);
|
||||
socket->writeDatagram(queryTimeline, QHostAddress(QStringLiteral("172.16.255.255")), 10110);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
QString cmd;
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
cmd = QStringLiteral("xeyes");
|
||||
#else
|
||||
#ifdef Q_OS_WIN
|
||||
cmd = QStringLiteral("shutdown /s /t 0"); // s = shutdown t = time in seconds
|
||||
#else
|
||||
cmd = QStringLiteral("systemctl poweroff");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QProcess::startDetached(cmd);
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
}
|
||||
|
||||
void LoginWindow::slotReboot()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
QFont font = msgBox.font();
|
||||
#ifdef TABLET_MODE
|
||||
font.setPointSizeF(font.pointSizeF()*1.5);
|
||||
#endif
|
||||
|
||||
msgBox.setWindowTitle(tr("Reboot"));
|
||||
msgBox.setText(tr("Are you sure you want to reboot the system?"));
|
||||
|
||||
QAbstractButton* pButtonYes = msgBox.addButton(QMessageBox::Yes);
|
||||
pButtonYes->setMinimumWidth(150);
|
||||
pButtonYes->setFont(font);
|
||||
QAbstractButton* pButtonNo = msgBox.addButton(QMessageBox::No);
|
||||
pButtonNo->setMinimumWidth(150);
|
||||
pButtonNo->setFont(font);
|
||||
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
QString cmd;
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
cmd = QStringLiteral("xeyes");
|
||||
#else
|
||||
#ifdef Q_OS_WIN
|
||||
cmd = QStringLiteral("shutdown /r /t 0"); // s = shutdown t = time in seconds
|
||||
#else
|
||||
cmd = QStringLiteral("systemctl reboot");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QProcess::startDetached(cmd);
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
}
|
||||
|
||||
void LoginWindow::slotOperatorLogout()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
QFont font = msgBox.font();
|
||||
#ifdef TABLET_MODE
|
||||
font.setPointSizeF(font.pointSizeF()*1.5);
|
||||
#endif
|
||||
|
||||
msgBox.setWindowTitle(tr("Shutdown"));
|
||||
msgBox.setText(tr("Are you sure you want to shut down the system?"));
|
||||
|
||||
QAbstractButton* pButtonYes = msgBox.addButton(QMessageBox::Yes);
|
||||
pButtonYes->setMinimumWidth(150);
|
||||
pButtonYes->setFont(font);
|
||||
QAbstractButton* pButtonNo = msgBox.addButton(QMessageBox::No);
|
||||
pButtonNo->setMinimumWidth(150);
|
||||
pButtonNo->setFont(font);
|
||||
|
||||
int ret = msgBox.exec();
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
QString cmd;
|
||||
/*
|
||||
#ifdef LTS_DEBUG
|
||||
cmd = QStringLiteral("xeyes");
|
||||
#else
|
||||
*/
|
||||
#ifdef Q_OS_WIN
|
||||
cmd = QStringLiteral("logoff"); // logoff
|
||||
#else
|
||||
cmd = QStringLiteral("loginctl terminate-user ctc_ws");
|
||||
#endif
|
||||
/*
|
||||
#endif
|
||||
*/
|
||||
|
||||
QProcess::startDetached(cmd);
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoginWindow::slotOperatorAction() // TODO: can re-show already finished dialog when some there is NO modal window that inactivates the main background ???
|
||||
{
|
||||
if (m_done) // do NOT reshow after login (as window is hidden then) and the return key will be processed again, as we did not return from slotOperatorAction.... holy shit!
|
||||
return;
|
||||
|
||||
//qWarning() << "slotOperatorAction";
|
||||
if (LtsMultiMonitor::LtsMultiMonitor::getInstance()->isActive() && !LtsSessionData::LtsSessionData::getInstance()->isTablet())
|
||||
m_hideTimer.start(); // restarts timer (hides window on timeout)
|
||||
|
||||
if (!isVisible()) // do not use isHidden (see F1)
|
||||
{
|
||||
// windows (linux ignores that and centers the dialog automatically):
|
||||
setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter,
|
||||
size(),
|
||||
QGuiApplication::primaryScreen()->geometry()));
|
||||
|
||||
// m_ui->leOperatorName->setFocus();
|
||||
show();
|
||||
}
|
||||
|
||||
//raise();
|
||||
QApplication::setActiveWindow(this);
|
||||
m_ui->leOperatorName->setFocus();
|
||||
}
|
||||
|
||||
bool LoginWindow::event(QEvent *event)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
#undef KeyPress // X.h defines it
|
||||
case QEvent::KeyPress: // respect typing into textfields
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove:
|
||||
{
|
||||
slotOperatorAction();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return QDialog::event(event);
|
||||
}
|
||||
|
||||
|
||||
void LoginWindow::closeEvent(QCloseEvent *event) // TODO: override reject()
|
||||
{
|
||||
#ifdef DEVEL
|
||||
(void)event;
|
||||
// event->accept();
|
||||
// emit signalSuccess(); // pretend we have chosen an exercise ..
|
||||
// deleteLater(); // .. end don't come back
|
||||
#else
|
||||
event->ignore();
|
||||
exit(0); // do not allow access to the opapp without login on NON-DEVEL
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoginWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange)
|
||||
m_ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void LoginWindow::slotHide()
|
||||
{
|
||||
m_hideTimer.stop(); // window hidden, no need to hide it by timeout
|
||||
hide();
|
||||
}
|
||||
|
||||
void LoginWindow::slotCancel() // TODO: override reject()
|
||||
{
|
||||
//#ifdef DEVEL
|
||||
// emit signalQuit();
|
||||
// //QCoreApplication::quit(); // end main event loop so that the applications ends when main() ends !
|
||||
// //exit(0);
|
||||
//#else
|
||||
// slotHide();
|
||||
//#endif
|
||||
}
|
||||
|
||||
void LoginWindow::slotLogin()
|
||||
{
|
||||
if (m_ui->leOperatorName->text().isEmpty())
|
||||
return;
|
||||
|
||||
onLanguageChange(); // not really needed
|
||||
hide();
|
||||
emit signalOperatorSelected(m_ui->leOperatorName->text());
|
||||
}
|
||||
|
||||
void LoginWindow::onLanguageChange()
|
||||
{
|
||||
if (m_ui->pbDe_DE->isChecked())
|
||||
NGL::setTranslationLocale(QByteArray("de_DE"));
|
||||
if (m_ui->pbEn_GB->isChecked())
|
||||
NGL::setTranslationLocale(QByteArray("en_GB"));
|
||||
if (m_ui->pbEn_US->isChecked())
|
||||
NGL::setTranslationLocale(QByteArray("en_US"));
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-05-05
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTimer>
|
||||
#define DEVEL
|
||||
|
||||
class QProcess;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LoginWindow;
|
||||
}
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsProgressDialogHelper;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class LoginWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoginWindow(QWidget *parent, bool isAAR);
|
||||
~LoginWindow();
|
||||
|
||||
QString getOperatorName() const;
|
||||
void setAARLabel(bool isAAR, bool connectedLocal);
|
||||
|
||||
signals:
|
||||
void signalOperatorSelected(const QString &operatorName);
|
||||
void signalExit();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
bool event(QEvent *event) override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
public slots:
|
||||
void slotOperatorAction();
|
||||
|
||||
private slots:
|
||||
void slotHide();
|
||||
void slotCancel();
|
||||
void slotLogin();
|
||||
void onLanguageChange();
|
||||
void slotExit();
|
||||
void slotShutdown();
|
||||
void slotReboot();
|
||||
void slotOperatorLogout();
|
||||
void slotLightStyle();
|
||||
void slotDarkStyle();
|
||||
|
||||
private:
|
||||
void setStyle(const QString &name);
|
||||
|
||||
Ui::LoginWindow *m_ui;
|
||||
QTimer m_hideTimer;
|
||||
bool m_done;
|
||||
bool m_isAAR;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,305 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoginWindow</class>
|
||||
<widget class="QWidget" name="LoginWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>350</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>350</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Login</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbRDELogo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbLoginText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">Login</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblConnectedTo">
|
||||
<property name="text">
|
||||
<string>Connected to:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leOperatorName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Operator Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbGo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbDe_DE">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Deutsch - German</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Germany-Flag.png</normaloff>:/Germany-Flag.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbEn_GB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>English - Englisch (GB)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/Great-Britain-Flag.png</normaloff>:/Great-Britain-Flag.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbEn_US">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>English - Englisch (US)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/US-Flag.png</normaloff>:/US-Flag.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="languageLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbStyle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>13</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbShutdown">
|
||||
<property name="text">
|
||||
<string>Shutdown</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbExit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for SessionManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-05-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_gui_plugin_interface.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <Plugins/SituationReplayManagement/srm_data_plugin_interface.h>
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace LtsPluginManager { class LtsPluginManager; }
|
||||
namespace LtsWidgets { class LtsBackgroundWidget;}
|
||||
class QProcess;
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class LoginWindow;
|
||||
class LoginOperatorWindow;
|
||||
//class LogoutInformationDialog;
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:opm.login")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("OperatorManagement.Login"); }
|
||||
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); // TODO: from global only?
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class LastStateLoader;
|
||||
|
||||
|
||||
class LastStateLoaderApp
|
||||
{
|
||||
public:
|
||||
LastStateLoaderApp(LastStateLoader *lsl, LtsAppDescriptor::App appId, const QVector<QJsonObject> &sessions)
|
||||
: m_appId(appId)
|
||||
, m_sessions(sessions)
|
||||
, m_lsl(lsl)
|
||||
{
|
||||
|
||||
}
|
||||
LastStateLoaderApp() = default;
|
||||
|
||||
bool sessionsLeft() const { return !m_sessions.isEmpty(); }
|
||||
void next();
|
||||
|
||||
//private:
|
||||
LtsAppDescriptor::App m_appId;
|
||||
QVector<QJsonObject> m_sessions;
|
||||
LastStateLoader *m_lsl;
|
||||
|
||||
LtsPluginManager::LtsPluginManager *m_app { nullptr };
|
||||
};
|
||||
|
||||
|
||||
class LastStateLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
friend class LastStateLoaderApp;
|
||||
|
||||
LastStateLoader(const QVector<QJsonObject> &appStates, LtsSession::LtsSession *session, ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
//~LastStateLoader();
|
||||
const QStringList &errorList() const { return m_errorList; }
|
||||
|
||||
private:
|
||||
bool go(LastStateLoaderApp &app);
|
||||
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
//QVector<QJsonObject> m_appStates;
|
||||
QStringList m_errorList;
|
||||
|
||||
QVector<LastStateLoaderApp> m_apps;
|
||||
|
||||
private slots:
|
||||
void next();
|
||||
|
||||
signals:
|
||||
void done();
|
||||
};
|
||||
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public OperatorManagement::ForeignGuiInterface
|
||||
, protected OperatorManagement::Interface::Ftc::OperatorLoginReplyHandler
|
||||
, protected OperatorManagement::Interface::Ftc::OperatorGetSetSettingsReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
~InterfaceImpl();
|
||||
|
||||
QString menuGroup() const override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
|
||||
// be able to show login dialog
|
||||
int executionPriority() const override { return 0; /* first payload to execute */ }
|
||||
void executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground) override;
|
||||
|
||||
bool isLocalDatabase();
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<OperatorManagement::ForeignDataInterface> m_opmIfc;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
|
||||
//std::shared_ptr<Core::Interface::Dtc> m_srmDtc;
|
||||
|
||||
private:
|
||||
LoginWindow *m_loginOperatorName;
|
||||
LoginOperatorWindow *m_loginPassword;
|
||||
LtsWidgets::LtsBackgroundWidget *m_mainBackground;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
//LogoutInformationDialog *m_dialog;
|
||||
QProcess* m_sdProcess;
|
||||
int m_workstationId;
|
||||
int32_t m_operatorId;
|
||||
bool m_loggedIn;
|
||||
QWidget *m_hiddenWidget { nullptr };
|
||||
//bool m_stopLoginWindow { false };
|
||||
|
||||
int getOperatorId(const QString &operatorName); // also fully prepares the password dialog ! TODO: so 'get' does not fit 100% shows operator dialog on unknown operator - BUT does NOT show password dialog (to prevent redundancies in code)
|
||||
AssetManagement::Asset findWorkstation(const QString &wsName);
|
||||
void trySendKeepAlive();
|
||||
void onOperatorLoginReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onOperatorGetSetSettingsReply(const OperatorGetSetSettingsReply &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void go(QWidget *parent);
|
||||
void loadLastState();
|
||||
void tryLogin();
|
||||
void executePayloadDone();
|
||||
|
||||
signals:
|
||||
void signalLogin();
|
||||
void signalLogout();
|
||||
//void signalSuccessXXX();
|
||||
|
||||
private slots:
|
||||
void slotOperatorSelected(const QString &operatorName); // checks wether operator exists, otherwise shows error and then after acknowledgement it reshows loginOperatorName, if operator exists: loginOperatorName profile picture is set and loginPassword is shown
|
||||
void slotLoginNonForce(int operatorId /* to provide fail safe guranteed existing operator id */, const QString &password);
|
||||
void slotLogin(int operatorId /* to provide fail safe guranteed existing operator id */, const QString &password, bool force = false); // called by loginPassword (operatorId from loginOperatorName)
|
||||
void slotSetPresetsFromProjectionLogin();
|
||||
void onOperatorChanged(const OperatorManagement::User &data, DataModification modType);
|
||||
void slotPasswordBack();
|
||||
void slotLoginStep();
|
||||
void waitForHistoricalOperatorData(QWidget *parent);
|
||||
void waitForHistoricalAssetData(QWidget *parent);
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-05-05
|
||||
*/
|
||||
|
||||
#include "opm_login_operator_dialog.h"
|
||||
#include "ui_opm_login_operator_dialog.h"
|
||||
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QStyle>
|
||||
#include <QDebug>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QPushButton>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
LoginOperatorWindow::LoginOperatorWindow(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::LoginOperatorWindow)
|
||||
, m_operatorId(-1)
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(false);
|
||||
|
||||
setWindowTitle(tr("Password"));
|
||||
setWindowFlags(windowFlags() | /*Qt::WindowStaysOnTopHint | */Qt::FramelessWindowHint); // hints..
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->profileButton->setMenuEnabled(false); // dont allow the operator to click the profile button
|
||||
|
||||
// shadow labels
|
||||
QList<QLabel *> labels = findChildren<QLabel *>();
|
||||
|
||||
for (QList<QLabel *>::const_iterator i = labels.constBegin(); i != labels.constEnd(); ++i)
|
||||
{
|
||||
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); // cannot copy this..
|
||||
shadow->setOffset(0, 0);
|
||||
shadow->setBlurRadius(22);
|
||||
shadow->setColor(QColor("white"));
|
||||
|
||||
(*i)->setGraphicsEffect(shadow);
|
||||
}
|
||||
|
||||
LtsSessionData::LtsSessionData *sessionData = LtsSessionData::LtsSessionData::getInstance();
|
||||
|
||||
if (sessionData->isTablet())
|
||||
{
|
||||
setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignHCenter | Qt::AlignTop,
|
||||
size(),
|
||||
QGuiApplication::primaryScreen()->geometry()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// center widget
|
||||
setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter,
|
||||
size(),
|
||||
QGuiApplication::primaryScreen()->geometry()));
|
||||
}
|
||||
|
||||
|
||||
connect(m_ui->pbGo, &QPushButton::clicked,
|
||||
this, &LoginOperatorWindow::slotGo);
|
||||
connect(m_ui->pbCancel, &QPushButton::clicked,
|
||||
this, &LoginOperatorWindow::signalPasswordBack, Qt::QueuedConnection);
|
||||
connect(m_ui->lePassword, &QLineEdit::returnPressed,
|
||||
this, &LoginOperatorWindow::slotGo);
|
||||
setMinimumSize(sizeHint());
|
||||
#ifdef TABLET_MODE
|
||||
m_ui->lePassword->setFocusPolicy(Qt::ClickFocus);
|
||||
#endif
|
||||
}
|
||||
|
||||
LoginOperatorWindow::~LoginOperatorWindow()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void LoginOperatorWindow::closeEvent(QCloseEvent *)
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
}
|
||||
|
||||
// TODO: back to operator selection on ESC, etc.
|
||||
|
||||
void LoginOperatorWindow::setOperatorData(const int operatorId, const QString &operatorName)
|
||||
{
|
||||
m_operatorId = operatorId;
|
||||
m_operatorName = operatorName; // m_operatorName is not really used
|
||||
|
||||
m_ui->lbOperatorName->setText(operatorName);
|
||||
}
|
||||
|
||||
|
||||
void LoginOperatorWindow::setProfilePicture(const QPixmap &pixmap)
|
||||
{
|
||||
m_ui->profileButton->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
void LoginOperatorWindow::showEvent(QShowEvent *e)
|
||||
{
|
||||
QDialog::showEvent(e);
|
||||
m_ui->lePassword->clear();
|
||||
m_ui->lePassword->setFocus();
|
||||
}
|
||||
|
||||
void LoginOperatorWindow::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange)
|
||||
m_ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void LoginOperatorWindow::slotGo()
|
||||
{
|
||||
if (isHidden())
|
||||
return;
|
||||
|
||||
QString pw = m_ui->lePassword->text();
|
||||
m_ui->lePassword->clear();
|
||||
|
||||
if (pw.length()) // password entered
|
||||
{
|
||||
hide();
|
||||
emit signalLogin(m_operatorId, pw); // block!
|
||||
}
|
||||
|
||||
// do nothing when the operator did not enter a password (or has already been entered)
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-05-05
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTimer>
|
||||
#include <QMoveEvent>
|
||||
|
||||
|
||||
#define DEVEL
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LoginOperatorWindow;
|
||||
}
|
||||
|
||||
class QCloseEvent;
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class LoginOperatorWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LoginOperatorWindow(QWidget *parent);
|
||||
~LoginOperatorWindow();
|
||||
|
||||
void setOperatorData(const int operatorId, const QString &operatorName);
|
||||
void setProfilePicture(const QPixmap &pixmap);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
|
||||
signals:
|
||||
void signalLogin(const int operatorId, const QString &password);
|
||||
void signalPasswordBack();
|
||||
|
||||
|
||||
private slots:
|
||||
void slotGo();
|
||||
|
||||
private:
|
||||
Ui::LoginOperatorWindow *m_ui;
|
||||
int m_operatorId;
|
||||
QString m_operatorName;
|
||||
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoginOperatorWindow</class>
|
||||
<widget class="QWidget" name="LoginOperatorWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>470</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Login</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="mainLayout" stretch="0,0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>25</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>24</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Welcome</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="lbOperatorName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>28</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">%USERNAME%</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="LtsWidgets::LtsProfileButton" name="profileButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lePassword">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbGo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QPushButton" name="pbCancel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Back</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsProfileButton</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_profile_button.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-01-18
|
||||
*/
|
||||
|
||||
#include "opm_login_remote_shutdown_dialog.h"
|
||||
#include "ui_opm_login_remote_shutdown_dialog.h"
|
||||
#include "opm_login_workstation_model.h"
|
||||
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
RemoteShutdownDialog::RemoteShutdownDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::RemoteShutdownDialog)
|
||||
, m_logger(getLogger("ShutdownDialog"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_trvWorkstations(nullptr)
|
||||
, m_trvModel(nullptr)
|
||||
, m_trvSelectionModel(nullptr)
|
||||
, m_thisWsId(0)
|
||||
, m_iterChildren(true)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->cbSelectAction->insertItem(int(AssetManagement::ShutdownAction::NoAction), tr("- No Action -"));
|
||||
m_ui->cbSelectAction->insertItem(int(AssetManagement::ShutdownAction::Logout), tr("Logout"));
|
||||
m_ui->cbSelectAction->insertItem(int(AssetManagement::ShutdownAction::Shutdown), tr("Shutdown"));
|
||||
m_ui->cbSelectAction->insertItem(int(AssetManagement::ShutdownAction::Reboot), tr("Reboot"));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Function_Group_User_Management"));
|
||||
}
|
||||
|
||||
RemoteShutdownDialog::~RemoteShutdownDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool RemoteShutdownDialog::init(const std::shared_ptr<AssetManagement::Interface::Ftc> &asmFtc,
|
||||
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc)
|
||||
{
|
||||
int thisWsId = LtsSessionData::LtsSessionData::getInstance()->getWorkstationId();
|
||||
DEBUG_LOG(m_logger) << "ws id = " << thisWsId;
|
||||
|
||||
if (thisWsId <= 0 || asmFtc == nullptr)
|
||||
return false;
|
||||
|
||||
m_asmFtc = asmFtc;
|
||||
m_thisWsId = thisWsId;
|
||||
|
||||
QMultiMap<QString, WorkstationModel::WorkstationInfo> wsMap;
|
||||
|
||||
asmDtc->assets([this, &asmDtc, &wsMap](const AssetManagement::Asset & data)
|
||||
{
|
||||
if (data.assetTypeId() == AssetManagement::AssetType_def::Workstation && m_thisWsId != data.id())
|
||||
{
|
||||
wsMap.insert(QString::fromStdString(asmDtc->location(data.locationId()).description()),
|
||||
WorkstationModel::WorkstationInfo(data.id(), QString::fromStdString(data.name()), data.subLocation()));
|
||||
}
|
||||
});
|
||||
|
||||
m_ui->trvWorkstations->setModel(new WorkstationModel(wsMap, this));
|
||||
m_ui->trvWorkstations->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->trvWorkstations->hideColumn(1);
|
||||
m_ui->trvWorkstations->setHeaderHidden(true);
|
||||
|
||||
m_trvWorkstations = m_ui->trvWorkstations;
|
||||
m_trvModel = m_ui->trvWorkstations->model();
|
||||
m_trvSelectionModel = m_ui->trvWorkstations->selectionModel();
|
||||
|
||||
connect(m_trvSelectionModel, &QItemSelectionModel::selectionChanged, this, &RemoteShutdownDialog::onTreeViewSelectionChanged);
|
||||
connect(m_ui->pbConfirmAction, &QPushButton::clicked, this, &RemoteShutdownDialog::onConfirmActionClicked);
|
||||
|
||||
expandFirstLevel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoteShutdownDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Shutdown Workstations"));
|
||||
}
|
||||
|
||||
void RemoteShutdownDialog::expandFirstLevel()
|
||||
{
|
||||
int rows = m_trvModel->rowCount();
|
||||
for (int count = 0; count < rows; count++)
|
||||
m_trvWorkstations->expand(m_trvModel->index(count, 0));
|
||||
}
|
||||
|
||||
void RemoteShutdownDialog::onTreeViewSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{
|
||||
QItemSelection newSelection;
|
||||
|
||||
QItemSelection mergedSelection;
|
||||
mergedSelection.merge(selected, QItemSelectionModel::Select);
|
||||
mergedSelection.merge(deselected, QItemSelectionModel::Select);
|
||||
|
||||
QItemSelectionModel::SelectionFlag flag = QItemSelectionModel::NoUpdate;
|
||||
|
||||
if (!selected.isEmpty())
|
||||
flag = QItemSelectionModel::Select;
|
||||
else if (!deselected.isEmpty())
|
||||
flag = QItemSelectionModel::Deselect;
|
||||
|
||||
const auto indexes = mergedSelection.indexes();
|
||||
for (const QModelIndex &index : indexes)
|
||||
{
|
||||
int childRows = m_trvModel->rowCount(index);
|
||||
|
||||
if (childRows > 0 && m_iterChildren)
|
||||
{
|
||||
newSelection.select(m_trvModel->index(0, 0, index),
|
||||
m_trvModel->index(childRows - 1, 1, index));
|
||||
}
|
||||
|
||||
if (index.parent().isValid())
|
||||
{
|
||||
if ( (flag == QItemSelectionModel::Select
|
||||
&& !m_trvSelectionModel->isSelected(index.parent())
|
||||
&& testAllSiblingsSelected(index.parent(), m_trvWorkstations))
|
||||
|| flag == QItemSelectionModel::Deselect )
|
||||
{
|
||||
newSelection.merge(QItemSelection(index.parent(), index.parent()), QItemSelectionModel::Select);
|
||||
m_iterChildren = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_trvSelectionModel->select(newSelection, flag);
|
||||
m_iterChildren = true;
|
||||
}
|
||||
|
||||
bool RemoteShutdownDialog::testAllSiblingsSelected(const QModelIndex &index, QAbstractItemView *view)
|
||||
{
|
||||
bool result = true;
|
||||
int siblings = view->model()->rowCount(index);
|
||||
for (int count = 0; count < siblings; ++count)
|
||||
{
|
||||
QModelIndex sibling = view->model()->index(count, index.column(), index);
|
||||
if (!view->selectionModel()->isSelected(sibling))
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int> RemoteShutdownDialog::parseCurrentSelection() const
|
||||
{
|
||||
std::vector<int> result;
|
||||
const QModelIndexList list = m_trvSelectionModel->selectedIndexes();
|
||||
result.reserve(std::floor(list.size() / 2));
|
||||
for (const QModelIndex &index : list)
|
||||
{
|
||||
QVariant idxData = m_trvModel->data(index);
|
||||
if (idxData.isValid() && idxData.canConvert(QVariant::Int))
|
||||
{
|
||||
int id = idxData.toInt();
|
||||
if (id > 0)
|
||||
result.push_back(id);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void RemoteShutdownDialog::onConfirmActionClicked()
|
||||
{
|
||||
AssetManagement::ShutdownAction shutdownAction =
|
||||
static_cast<AssetManagement::ShutdownAction_def::type>(m_ui->cbSelectAction->currentIndex());
|
||||
if (shutdownAction == AssetManagement::ShutdownAction::NoAction)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("An Action has to be selected!"), tr("Error"));
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<int> idVector = parseCurrentSelection();
|
||||
if (idVector.size() > 0)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, &shutdownAction, &idVector]()
|
||||
{
|
||||
AssetManagement::WorkstationLogout logout;
|
||||
logout.shutdownAction(shutdownAction);
|
||||
logout.ids(idVector);
|
||||
logout.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
logout.originatorId(m_thisWsId);
|
||||
|
||||
return m_asmFtc->workstationLogoutRequest(logout, this);
|
||||
});
|
||||
}
|
||||
else
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("At least one workstation has to be selected!"), tr("Error"));
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-01-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <Plugins/AssetManagement/Data/asm_data_plugin.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
class QTreeView;
|
||||
class QItemSelection;
|
||||
class QItemSelectionModel;
|
||||
|
||||
namespace Ui { class RemoteShutdownDialog; }
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class RemoteShutdownDialog : public LtsWidgets::LtsDialog
|
||||
, protected AssetManagement::Interface::Ftc::WorkstationLogoutReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RemoteShutdownDialog(QWidget *parent = nullptr);
|
||||
bool init(const std::shared_ptr<AssetManagement::Interface::Ftc> &asmFtc,
|
||||
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc);
|
||||
|
||||
|
||||
~RemoteShutdownDialog();
|
||||
|
||||
// LtsDialog interface
|
||||
void retranslate() override final;
|
||||
|
||||
// WorkstationLogoutReplyHandler interface
|
||||
void onWorkstationLogoutReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
|
||||
private:
|
||||
void expandFirstLevel();
|
||||
std::vector<int> parseCurrentSelection() const;
|
||||
bool testAllSiblingsSelected(const QModelIndex &index, QAbstractItemView *view);
|
||||
|
||||
Ui::RemoteShutdownDialog *m_ui;
|
||||
LOGGER_T &m_logger;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
QTreeView *m_trvWorkstations;
|
||||
QAbstractItemModel *m_trvModel;
|
||||
QItemSelectionModel *m_trvSelectionModel;
|
||||
int m_thisWsId;
|
||||
bool m_iterChildren;
|
||||
std::shared_ptr<AssetManagement::Interface::Ftc> m_asmFtc;
|
||||
|
||||
private slots:
|
||||
void onConfirmActionClicked();
|
||||
void onTreeViewSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
};
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RemoteShutdownDialog</class>
|
||||
<widget class="QWidget" name="RemoteShutdownDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>901</width>
|
||||
<height>469</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbRemote">
|
||||
<property name="title">
|
||||
<string>Remote:</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeView" name="trvWorkstations"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Choose an action for the selected workstations:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbSelectAction"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbConfirmAction">
|
||||
<property name="text">
|
||||
<string>Confirm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-01-18
|
||||
*/
|
||||
|
||||
#include "opm_login_workstation_model.h"
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
WorkstationModel::WorkstationModel(const QMultiMap<QString, WorkstationInfo> &data, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_rootItem(new WorkstationModelItem({QStringLiteral("root"), -1}, nullptr))
|
||||
{
|
||||
setupModelData(data);
|
||||
}
|
||||
|
||||
WorkstationModel::~WorkstationModel()
|
||||
{
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
QModelIndex WorkstationModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
WorkstationModelItem *parentItem;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = m_rootItem;
|
||||
else
|
||||
parentItem = static_cast<WorkstationModelItem *>(parent.internalPointer());
|
||||
|
||||
WorkstationModelItem *childItem = parentItem->child(row);
|
||||
if (childItem)
|
||||
return createIndex(row, column, childItem);
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex WorkstationModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
WorkstationModelItem *childItem = static_cast<WorkstationModelItem *>(index.internalPointer());
|
||||
WorkstationModelItem *parentItem = childItem->parentItem();
|
||||
|
||||
if (parentItem == m_rootItem)
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentItem->row(), 0, parentItem);
|
||||
}
|
||||
|
||||
int WorkstationModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
WorkstationModelItem *parentItem;
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
|
||||
if (!parent.isValid())
|
||||
parentItem = m_rootItem;
|
||||
else
|
||||
parentItem = static_cast<WorkstationModelItem *>(parent.internalPointer());
|
||||
|
||||
return parentItem->childCount();
|
||||
}
|
||||
|
||||
int WorkstationModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return static_cast<WorkstationModelItem *>(parent.internalPointer())->columnCount();
|
||||
else
|
||||
return m_rootItem->columnCount();
|
||||
}
|
||||
|
||||
QVariant WorkstationModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
WorkstationModelItem *item = static_cast<WorkstationModelItem *>(index.internalPointer());
|
||||
|
||||
return item->data(index.column());
|
||||
}
|
||||
|
||||
Qt::ItemFlags WorkstationModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
|
||||
return QAbstractItemModel::flags(index);
|
||||
}
|
||||
|
||||
void WorkstationModel::setupModelData(const QMultiMap<QString, WorkstationInfo> &data)
|
||||
{
|
||||
const auto keys = data.uniqueKeys();
|
||||
for (const QString &key : keys)
|
||||
{
|
||||
WorkstationModelItem *locationItem = new WorkstationModelItem({{key, -1}}, m_rootItem);
|
||||
WorkstationModelItem *grpItem1 = new WorkstationModelItem({{tr("Group 1"), -1}}, locationItem);
|
||||
WorkstationModelItem *grpItem2 = new WorkstationModelItem({{tr("Group 2"), -1}}, locationItem);
|
||||
QMultiMap<QString, WorkstationInfo>::const_iterator it = data.find(key);
|
||||
while (it != data.end() && it.key() == key)
|
||||
{
|
||||
if (0 == it.value().m_group)
|
||||
grpItem1->appendChild(new WorkstationModelItem({{it.value().m_name, it.value().m_id}}, grpItem1));
|
||||
else if (1 == it.value().m_group)
|
||||
grpItem2->appendChild(new WorkstationModelItem({{it.value().m_name, it.value().m_id}}, grpItem2));
|
||||
|
||||
++it;
|
||||
}
|
||||
if (grpItem1->childCount())
|
||||
locationItem->appendChild(grpItem1);
|
||||
else
|
||||
delete grpItem1;
|
||||
if (grpItem2->childCount())
|
||||
locationItem->appendChild(grpItem2);
|
||||
else
|
||||
delete grpItem2;
|
||||
if (locationItem->childCount())
|
||||
m_rootItem->appendChild(locationItem);
|
||||
else
|
||||
delete locationItem;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// -------- WorkstatioModel --------
|
||||
|
||||
WorkstationModelItem::WorkstationModelItem(const QVector<QVariant> &data, WorkstationModelItem *parentItem)
|
||||
: m_itemData(data)
|
||||
, m_parentItem(parentItem)
|
||||
{}
|
||||
|
||||
WorkstationModelItem::~WorkstationModelItem()
|
||||
{
|
||||
qDeleteAll(m_childItems);
|
||||
}
|
||||
|
||||
void WorkstationModelItem::appendChild(WorkstationModelItem *child)
|
||||
{
|
||||
m_childItems.append(child);
|
||||
}
|
||||
|
||||
WorkstationModelItem *WorkstationModelItem::child(int row)
|
||||
{
|
||||
return m_childItems.value(row);
|
||||
}
|
||||
|
||||
int WorkstationModelItem::childCount() const
|
||||
{
|
||||
return m_childItems.count();
|
||||
}
|
||||
|
||||
int WorkstationModelItem::columnCount() const
|
||||
{
|
||||
return m_itemData.count();
|
||||
}
|
||||
|
||||
QVariant WorkstationModelItem::data(int column) const
|
||||
{
|
||||
return m_itemData.value(column);
|
||||
}
|
||||
|
||||
int WorkstationModelItem::row() const
|
||||
{
|
||||
if (m_parentItem)
|
||||
return m_parentItem->m_childItems.indexOf(const_cast<WorkstationModelItem *>(this));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
WorkstationModelItem *WorkstationModelItem::parentItem()
|
||||
{
|
||||
return m_parentItem;
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Chrsitian Roeskens, NLSE, 2018-01-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class WorkstationModelItem;
|
||||
|
||||
class WorkstationModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct WorkstationInfo
|
||||
{
|
||||
WorkstationInfo(int id, const QString &name, int group)
|
||||
: m_name(name), m_id(id), m_group(group) {}
|
||||
QString m_name;
|
||||
int m_id = 0;
|
||||
int m_group = 0;
|
||||
};
|
||||
|
||||
explicit WorkstationModel(const QMultiMap<QString, WorkstationInfo> &data, QObject *parent);
|
||||
~WorkstationModel();
|
||||
|
||||
public:
|
||||
// QAbstractItemModel interface
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const override final;
|
||||
QModelIndex parent(const QModelIndex &index) const override final;
|
||||
int rowCount(const QModelIndex &parent) const override final;
|
||||
int columnCount(const QModelIndex &parent) const override final;
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override final;
|
||||
|
||||
void setupModelData(const QMultiMap<QString, WorkstationInfo> &data);
|
||||
private:
|
||||
WorkstationModelItem *m_rootItem;
|
||||
};
|
||||
|
||||
class WorkstationModelItem
|
||||
{
|
||||
public:
|
||||
explicit WorkstationModelItem(const QVector<QVariant> &data, WorkstationModelItem *parentItem = nullptr);
|
||||
~WorkstationModelItem();
|
||||
|
||||
void appendChild(WorkstationModelItem *child);
|
||||
|
||||
WorkstationModelItem *child(int row);
|
||||
int childCount() const;
|
||||
int columnCount() const;
|
||||
QVariant data(int column) const;
|
||||
int row() const;
|
||||
WorkstationModelItem *parentItem();
|
||||
|
||||
private:
|
||||
QVector<WorkstationModelItem *> m_childItems;
|
||||
QVector<QVariant> m_itemData;
|
||||
WorkstationModelItem *m_parentItem;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
#
|
||||
|
||||
SET(opm_edit_gui_SRCS
|
||||
acl_dialog.cpp
|
||||
acl_dialog.h
|
||||
acl_dialog_model.cpp
|
||||
acl_dialog_model.h
|
||||
|
||||
operator_dialog.cpp
|
||||
operator_dialog.h
|
||||
operator_edit_dialog.cpp
|
||||
operator_edit_dialog.h
|
||||
operator_edit_visible_parties_model.cpp
|
||||
operator_edit_visible_parties_model.h
|
||||
|
||||
group_model.cpp
|
||||
group_model.h
|
||||
group_edit_dialog.cpp
|
||||
group_edit_dialog.h
|
||||
group_edit_member_of_model.cpp
|
||||
group_edit_member_of_model.h
|
||||
|
||||
preset_dialog.cpp
|
||||
preset_dialog.h
|
||||
|
||||
opm_edit_gui_plugin.cpp
|
||||
opm_edit_gui_plugin.h
|
||||
|
||||
CustomViews/opm_group.cpp
|
||||
CustomViews/opm_group.h
|
||||
CustomViews/opm_operator.cpp
|
||||
CustomViews/opm_operator.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(opm_edit_gui_SRCS
|
||||
acl_dialog.ui
|
||||
operator_dialog.ui
|
||||
operator_edit_dialog.ui
|
||||
preset_dialog.ui
|
||||
group_edit_dialog.ui
|
||||
CustomViews/opm_group.ui
|
||||
CustomViews/opm_operator.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS OpmEditGuiPlugin MODULE ${opm_edit_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(OpmEditGuiPlugin
|
||||
OpmChangePasswordGui
|
||||
NGLLogger
|
||||
nglwidgets
|
||||
ExmDataPluginInterface
|
||||
OpmDataPluginInterface
|
||||
PpmDataPluginInterface
|
||||
FlmDataPluginInterface
|
||||
OpmGuiPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
LtsPrinting
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(OpmEditGuiPlugin)
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for OPM Group
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "opm_group.h"
|
||||
#include "ui_opm_group.h"
|
||||
|
||||
#include "group_model.h"
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
CustomViewGroup::CustomViewGroup(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewGroup)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewGroup::~CustomViewGroup()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewGroup::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, OperatorManagement::GroupModel::Name).toString());
|
||||
m_ui->lbInfo->setText(rowData(idx, OperatorManagement::GroupModel::Info).toString());
|
||||
return true;
|
||||
}
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for OPM Group
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewGroup;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class CustomViewGroup final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewGroup(QWidget *parent = nullptr);
|
||||
~CustomViewGroup();
|
||||
bool init(const QModelIndex &idx) override;
|
||||
|
||||
private:
|
||||
Ui::CustomViewGroup* m_ui;
|
||||
|
||||
};
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewGroup</class>
|
||||
<widget class="QWidget" name="CustomViewGroup">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>74</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbInfo">
|
||||
<property name="text">
|
||||
<string notr="true">Info</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for OPM Operator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "opm_operator.h"
|
||||
#include "ui_opm_operator.h"
|
||||
|
||||
#include "operator_dialog.h"
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
CustomViewOperator::CustomViewOperator(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewOperator)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->lbImage->setScaledContents(true);
|
||||
}
|
||||
|
||||
CustomViewOperator::~CustomViewOperator()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewOperator::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, OperatorManagement::OperatorManagementDialogModel::Name).toString());
|
||||
m_ui->lbInfo->setText(rowData(idx, OperatorManagement::OperatorManagementDialogModel::Description).toString());
|
||||
QPixmap pm(rowData(idx, OperatorManagement::OperatorManagementDialogModel::Image).value<QPixmap>());
|
||||
m_ui->lbImage->setPixmap(pm.scaled(m_ui->lbImage->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
return true;
|
||||
}
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for OPM Operator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewOperator;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class CustomViewOperator final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewOperator(QWidget *parent = nullptr);
|
||||
~CustomViewOperator();
|
||||
bool init(const QModelIndex &idx) override;
|
||||
|
||||
private:
|
||||
Ui::CustomViewOperator* m_ui;
|
||||
|
||||
};
|
||||
} // namespace OperatorManagement
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewOperator</class>
|
||||
<widget class="QWidget" name="CustomViewOperator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>319</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<widget class="QLabel" name="lbImage">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Image</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbInfo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Info</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Operator/User Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-04-20
|
||||
*/
|
||||
|
||||
#include "acl_dialog.h"
|
||||
#include "ui_acl_dialog.h"
|
||||
|
||||
|
||||
namespace OperatorManagement {
|
||||
|
||||
AclDialog::AclDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::AclDialog)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_logger(getLogger("AclDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
AclDialog::~AclDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void AclDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("ACL Edit"));
|
||||
}
|
||||
|
||||
bool AclDialog::init(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
m_model = new AclDialogModel(this);
|
||||
m_model->initModel(dtc, ftc);
|
||||
m_ui->tvACL->setModel(m_model);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OpeartorManagement - ACL Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-04-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "acl_dialog_model.h"
|
||||
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
namespace Ui {
|
||||
class AclDialog;
|
||||
}
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class AclDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AclDialog(QWidget *parent = nullptr);
|
||||
~AclDialog();
|
||||
bool init(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
AclDialogModel *m_model;
|
||||
Ui::AclDialog *m_ui;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AclDialog</class>
|
||||
<widget class="QWidget" name="AclDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>674</width>
|
||||
<height>285</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Show ACL</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="tvACL">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - ACL Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-04-20
|
||||
*/
|
||||
|
||||
|
||||
#include "acl_dialog_model.h"
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// AclDialogModel
|
||||
//---------------------------------
|
||||
AclDialogModel::AclDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<OperatorManagement::AccessControlLevel>({tr("Name"),
|
||||
tr("Info")},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_logger(getLogger("AccessControlLevelDialogModel"))
|
||||
{}
|
||||
|
||||
AclDialogModel::~AclDialogModel()
|
||||
{}
|
||||
|
||||
bool AclDialogModel::initModel(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
connect(m_dtc.get(), &OperatorManagement::Interface::Dtc::accessControlLevelChanged,
|
||||
this, &AclDialogModel::onDataChanged);
|
||||
m_dtc->accessControlLevels([this](const OperatorManagement::AccessControlLevel &acl) { insertRow(acl); });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant AclDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const OperatorManagement::AccessControlLevel &acl = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return QString::fromStdString(acl.name());
|
||||
case 1:
|
||||
return QString::fromStdString(acl.description());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - ACL Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-04-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// AclDialogModel
|
||||
// --------------------------------------------------------
|
||||
class AclDialogModel final : public LtsWidgets::LtsAbstractTableModel<OperatorManagement::AccessControlLevel>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AclDialogModel(QObject *parent = nullptr);
|
||||
~AclDialogModel();
|
||||
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "group_edit_dialog.h"
|
||||
#include "ui_group_edit_dialog.h"
|
||||
|
||||
#include "group_edit_member_of_model.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <OperatorManagement/opm_translation.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
GroupEditDialog::GroupEditDialog(QWidget *parent)
|
||||
: LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::GroupEditDialog)
|
||||
, m_operatorId(0)
|
||||
, m_rolePresetId(0)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_model(nullptr)
|
||||
, m_logger(getLogger("GroupEditDialog"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
void GroupEditDialog::init(const Group &group,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
const int operatorId)
|
||||
{
|
||||
m_group = group;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_operatorId = operatorId;
|
||||
|
||||
m_ui->leName->setText(QString::fromStdString(group.name()));
|
||||
m_ui->leDescription->setText(QString::fromStdString(group.description()));
|
||||
|
||||
m_ui->cbRoles->addItem(tr("---"), 0);
|
||||
auto cbGroup = [this](const Group &group)
|
||||
{
|
||||
if (group.type() == GroupType_def::PresetGroup)
|
||||
m_ui->cbRoles->addItem(OperatorManagement::trGroupName(group.name()), group.id());
|
||||
};
|
||||
dtc->groups(cbGroup);
|
||||
|
||||
User user(m_dtc->user(m_operatorId));
|
||||
int rolePresetId = user.rolePresetId().is_set() ? user.rolePresetId().get() : m_rolePresetId;
|
||||
m_ui->cbRoles->setCurrentIndex(m_ui->cbRoles->findData(rolePresetId));
|
||||
|
||||
if (m_group.type() == GroupType_def::OperatorGroup)
|
||||
{
|
||||
m_ui->leName->setEnabled(false);
|
||||
m_ui->leDescription->setEnabled(false);
|
||||
}
|
||||
|
||||
if (m_group.type() == GroupType_def::PresetGroup && m_group.id() != 0)
|
||||
m_ui->leName->setEnabled(false);
|
||||
|
||||
connect(m_ui->pbLoadPreset, &QPushButton::clicked, this, &GroupEditDialog::onPbPresetClicked);
|
||||
|
||||
// create model, as its only needed for editable groups
|
||||
m_model = new MembershipModel(this, m_dtc);
|
||||
m_model->init(group.isMemberOf());
|
||||
connect(m_model, &MembershipModel::dataChanged, this, &GroupEditDialog::slotChangesMade);
|
||||
m_ui->dvMemberOf->setModel(m_model);
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
m_ui->dvMemberOf->setRootIsDecorated(true);
|
||||
m_ui->dvMemberOf->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_ui->dvMemberOf, &LtsDataView::LtsDataView::customContextMenuRequested, this, &GroupEditDialog::onContextMenuRequested);
|
||||
#endif
|
||||
|
||||
if (m_group.type() == GroupType_def::PresetGroup) // Preset
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Presets"));
|
||||
else if (m_group.type() == GroupType_def::OperatorGroup) // Privileges
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Operators"));
|
||||
}
|
||||
|
||||
void GroupEditDialog::setRolePresetId(int presetGroupId)
|
||||
{
|
||||
m_rolePresetId = presetGroupId;
|
||||
m_ui->cbRoles->setCurrentIndex(m_ui->cbRoles->findData(presetGroupId));
|
||||
}
|
||||
|
||||
void GroupEditDialog::onGroupChangeMembershipsReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
// Update m_group with new values
|
||||
// the reply arrives after the LTS_User is updated
|
||||
m_group = m_dtc->group(replyObject.id());
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void GroupEditDialog::onGroupCreateReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_group = m_dtc->group(replyObject.id());
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
GroupEditDialog::~GroupEditDialog() { delete m_ui; }
|
||||
|
||||
void GroupEditDialog::retranslate()
|
||||
{
|
||||
if (m_group.type() == GroupType_def::PresetGroup)
|
||||
translate(m_ui, OperatorManagement::trGroupName(m_group.name()), m_group.id() < 1, tr("Preset"));
|
||||
else if (m_group.type() == GroupType_def::OperatorGroup)
|
||||
translate(m_ui, OperatorManagement::trGroupName(m_group.name()), m_group.id() < 1, tr("Privileges"));
|
||||
}
|
||||
|
||||
// SLOTS:
|
||||
bool GroupEditDialog::apply()
|
||||
{
|
||||
std::vector<int> memberOf = m_model->checkStateForGroups(Qt::Checked);
|
||||
|
||||
if (memberOf.empty())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("An operator must have at least one right"));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::sort(memberOf.begin(), memberOf.end());
|
||||
|
||||
std::vector<int> oldGroups = m_group.isMemberOf();
|
||||
std::sort(oldGroups.begin(), oldGroups.end());
|
||||
|
||||
const User &user(m_dtc->user(m_operatorId));
|
||||
const int rolePresetId = user.rolePresetId().is_set() ? user.rolePresetId().get() : 0;
|
||||
|
||||
if (oldGroups == memberOf && m_ui->cbRoles->currentData().toInt() == rolePresetId)
|
||||
return true;
|
||||
|
||||
if (m_group.id() == 0)
|
||||
{
|
||||
if (m_group.type() == GroupType_def::OperatorGroup)
|
||||
{
|
||||
emit newGroups(memberOf, m_ui->cbRoles->currentData().toInt());
|
||||
return true;
|
||||
}
|
||||
else // Preset Group
|
||||
{
|
||||
const std::string name = m_ui->leName->text().toStdString();
|
||||
const std::string description = m_ui->leDescription->text().toStdString();
|
||||
GroupCreateRequest req(name, description, GroupType_def::PresetGroup, false, memberOf);
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->groupCreateRequest(req, this); });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_group.description() != m_ui->leDescription->text().toStdString())
|
||||
{
|
||||
m_requestHelper->addRequest(
|
||||
[this]()
|
||||
{
|
||||
const std::string name = m_ui->leName->text().toStdString();
|
||||
const std::string description = m_ui->leDescription->text().toStdString();
|
||||
GroupChangeNameRequest req(m_group.id(), name, description);
|
||||
return m_ftc->groupChangeNameRequest(req, this);
|
||||
});
|
||||
}
|
||||
const int rolePresetId = m_operatorId ? m_ui->cbRoles->currentData().toInt() : 0;
|
||||
GroupChangeMembersRequest req(m_group.id(), memberOf, LtsUtils::toOptional(rolePresetId), LtsUtils::toOptional(m_operatorId));
|
||||
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->groupChangeMembershipsRequest(req, this); });
|
||||
}
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void GroupEditDialog::onPbPresetClicked()
|
||||
{
|
||||
int contextGroupId = m_ui->cbRoles->currentData().toInt();
|
||||
m_model->setCheckStateForGroups(m_dtc->group(contextGroupId).isMemberOf());
|
||||
}
|
||||
|
||||
void GroupEditDialog::onContextMenuRequested(const QPoint &position)
|
||||
{
|
||||
QMenu menu(m_ui->dvMemberOf);
|
||||
menu.addAction(tr("Select All"), this, &GroupEditDialog::onSelectAllRights);
|
||||
menu.addAction(tr("Unselect All"), this, &GroupEditDialog::onUnselectAllRights);
|
||||
menu.exec(m_ui->dvMemberOf->mapToGlobal(position));
|
||||
}
|
||||
|
||||
void GroupEditDialog::onSelectAllRights() { m_model->selectAll(); }
|
||||
|
||||
void GroupEditDialog::onUnselectAllRights() { m_model->unselectAll(); }
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Operator Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
|
||||
#include <QVector>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class GroupEditDialog;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class MembershipModel;
|
||||
|
||||
class GroupEditDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::GroupChangeMembershipsReplyHandler
|
||||
, protected Interface::Ftc::GroupCreateReplyHandler
|
||||
, protected Interface::Ftc::GroupChangeNameReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GroupEditDialog(QWidget *parent = nullptr);
|
||||
~GroupEditDialog();
|
||||
|
||||
// If initialized with a group that has id==0, this class will emit the new Groups as a signal. Otherwise
|
||||
// it will call the groupChangeMembership-FTC itself
|
||||
void init(const Group &group, const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<Interface::Ftc> &ftc, const int operatorId = 0);
|
||||
void setRolePresetId(int presetGroupId);
|
||||
|
||||
void onGroupChangeMembershipsReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
void onGroupCreateReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onGroupChangeNameReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
private slots:
|
||||
void onPbPresetClicked();
|
||||
void onContextMenuRequested(const QPoint &position);
|
||||
void onSelectAllRights();
|
||||
void onUnselectAllRights();
|
||||
|
||||
signals:
|
||||
void newGroups(const std::vector<int> &groupIds, const int presetGroupId);
|
||||
|
||||
private:
|
||||
Ui::GroupEditDialog *m_ui;
|
||||
Group m_group;
|
||||
int m_operatorId;
|
||||
int m_rolePresetId;
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
MembershipModel *m_model;
|
||||
LOGGER_T m_logger;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GroupEditDialog</class>
|
||||
<widget class="QWidget" name="GroupEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>886</width>
|
||||
<height>685</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Group Edit</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbxName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leName"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QPushButton" name="pbLoadPreset">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbxInfo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Info:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leDescription"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblMemberOf">
|
||||
<property name="text">
|
||||
<string>Member Of:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="6">
|
||||
<widget class="LtsDataView::LtsDataView" name="dvMemberOf">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="lbxPreset">
|
||||
<property name="text">
|
||||
<string>Preset:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbRoles"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>leName</tabstop>
|
||||
<tabstop>leDescription</tabstop>
|
||||
<tabstop>pbLoadPreset</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+452
@@ -0,0 +1,452 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Group Edit member of model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-26
|
||||
*/
|
||||
|
||||
#include "group_edit_member_of_model.h"
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <QCoreApplication>
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
QDataStream &operator<<(QDataStream &ds, const Group &gp)
|
||||
{
|
||||
ds << gp.id()
|
||||
<< QString::fromStdString(gp.name())
|
||||
<< QString::fromStdString(gp.description())
|
||||
<< LtsUtils::convert<QVector<int32_t>>(gp.aclAllow())
|
||||
<< LtsUtils::convert<QVector<int32_t>>(gp.aclDeny())
|
||||
<< gp.type().underlying()
|
||||
<< gp.isDeleted()
|
||||
<< gp.isHidden()
|
||||
<< LtsUtils::convert<QVector<int32_t>>(gp.isMemberOf());
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &ds, Group &gp)
|
||||
{
|
||||
int id;
|
||||
QString name, description;
|
||||
bool isDeleted, isHidden, isOperatorGroup;
|
||||
int type;
|
||||
QVector<int32_t> aclAllow, aclDeny, isMemberOf;
|
||||
ds >> id
|
||||
>> name
|
||||
>> description
|
||||
>> aclAllow
|
||||
>> aclDeny
|
||||
>> type
|
||||
>> isDeleted
|
||||
>> isHidden
|
||||
>> isMemberOf
|
||||
>> isOperatorGroup;
|
||||
|
||||
gp.id(id);
|
||||
gp.name(name.toStdString());
|
||||
gp.description(description.toStdString());
|
||||
LtsUtils::convert(aclAllow, gp.aclAllow());
|
||||
LtsUtils::convert(aclDeny, gp.aclDeny());
|
||||
gp.type(static_cast<GroupType::inner_enum>(type));
|
||||
gp.isDeleted(isDeleted);
|
||||
gp.isHidden(isHidden);
|
||||
LtsUtils::convert(isMemberOf, gp.isMemberOf());
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
class CheckedTreeItem final : public NGLTreeItem
|
||||
{
|
||||
public:
|
||||
using NGLTreeItem::NGLTreeItem;
|
||||
|
||||
bool bIsChecked = false;
|
||||
};
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
MembershipModel::MembershipModel(QObject *parent,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc)
|
||||
: NGLTreeModel(parent,
|
||||
new CheckedTreeItem(QVariant()),
|
||||
{tr("Name"), tr("Description"), tr("Is Hidden"), tr("Type")}
|
||||
)
|
||||
, m_dtc(dtc)
|
||||
, m_bRowsAreCheckable(true)
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<Group>();
|
||||
|
||||
QSet<int> disabledFunctionality;
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
|
||||
//--- aes ---
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableAirSupport")).toBool())
|
||||
disabledFunctionality += 0x20b0000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableBiologicalContamination")).toBool())
|
||||
disabledFunctionality += 0x2010000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableChemicalContamination")).toBool())
|
||||
disabledFunctionality += 0x2010100;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableBorderlines")).toBool())
|
||||
disabledFunctionality += 0x2090000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableChargeAdministration")).toBool())
|
||||
disabledFunctionality += 0x2060000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableDangerAreas")).toBool())
|
||||
disabledFunctionality += 0x2050000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableAreaExplosionArtillery")).toBool())
|
||||
disabledFunctionality += 0x2020000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableAreaExplosionMortar")).toBool())
|
||||
disabledFunctionality += 0x2020100;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableSingleExplosionArtillery")).toBool())
|
||||
disabledFunctionality += 0x2020200;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableSingleExplosionMortar")).toBool())
|
||||
disabledFunctionality += 0x2020300;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableExplosionCluster")).toBool())
|
||||
disabledFunctionality += 0x2020600;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableFunctionalAreas")).toBool())
|
||||
disabledFunctionality += 0x2070000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableMineAreas")).toBool())
|
||||
disabledFunctionality += 0x2040000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableMineAreasResetDusMines")).toBool())
|
||||
disabledFunctionality += 0x2040003;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableMineCorridors")).toBool())
|
||||
disabledFunctionality += 0x2080000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableNuclearContaminations")).toBool())
|
||||
disabledFunctionality += 0x2030000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableTechnicalAreas")).toBool())
|
||||
disabledFunctionality += 0x20a0000;
|
||||
if (!ps->value(QStringLiteral("aes"), QStringLiteral("enableGasPipes")).toBool())
|
||||
disabledFunctionality += 0x2100000;
|
||||
|
||||
|
||||
//--- avm ---
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableAudioVideoManagement")).toBool())
|
||||
disabledFunctionality += 0x5010000;
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableVideoImport")).toBool())
|
||||
disabledFunctionality += 0x5010100;
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableAudioVideoPlaybacks")).toBool())
|
||||
disabledFunctionality += 0x5010003;
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableCombatNetRadioEdit")).toBool())
|
||||
disabledFunctionality += 0x5020000;
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableCombatNetRadioFrequencyPlanningEdit")).toBool())
|
||||
disabledFunctionality += 0x5020100;
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableElectronicWarfareMeasures")).toBool())
|
||||
disabledFunctionality += 0x5030000;
|
||||
if (!ps->value(QStringLiteral("avm"), QStringLiteral("enableMobileVideoSystem")).toBool())
|
||||
disabledFunctionality += 0x5040000;
|
||||
|
||||
//--- cod ---
|
||||
if (!ps->value(QStringLiteral("cod"), QStringLiteral("enableCodificationTables")).toBool())
|
||||
disabledFunctionality += 0x8010000;
|
||||
if (!ps->value(QStringLiteral("cod"), QStringLiteral("enableShowCodificationTableBLUFOR")).toBool())
|
||||
disabledFunctionality += 0x8010100;
|
||||
if (!ps->value(QStringLiteral("cod"), QStringLiteral("enableShowCodificationTableOPFOR")).toBool())
|
||||
disabledFunctionality += 0x8010200;
|
||||
|
||||
//--- esm ---
|
||||
if (!ps->value(QStringLiteral("esm"), QStringLiteral("enableEffectShowManagement")).toBool())
|
||||
disabledFunctionality += 0x31010000;
|
||||
|
||||
//--- evl ---
|
||||
if (!ps->value(QStringLiteral("evl"), QStringLiteral("enableEvaluationsElements")).toBool())
|
||||
disabledFunctionality += 0xa010000;
|
||||
if (!ps->value(QStringLiteral("evl"), QStringLiteral("enableEvaluations")).toBool())
|
||||
disabledFunctionality += 0xa010100;
|
||||
|
||||
//--- exm ---
|
||||
if (!ps->value(QStringLiteral("exm"), QStringLiteral("enableEditPhases")).toBool())
|
||||
disabledFunctionality += 0xc010200;
|
||||
|
||||
//--- flt ---
|
||||
if (!ps->value(QStringLiteral("flt"), QStringLiteral("enableAES_FilterEdit")).toBool())
|
||||
disabledFunctionality += 0x31010000;
|
||||
|
||||
//--- gim ---
|
||||
if (!ps->value(QStringLiteral("gim"), QStringLiteral("enableIED_Pairing")).toBool())
|
||||
disabledFunctionality += 0x3010000;
|
||||
|
||||
//--- gna ---
|
||||
if (!ps->value(QStringLiteral("gna"), QStringLiteral("enableGuezNasat")).toBool())
|
||||
disabledFunctionality += 0x33010000;
|
||||
|
||||
//--- mdm ---
|
||||
if (!ps->value(QStringLiteral("mdm"), QStringLiteral("enableEditStaticMeteoData")).toBool())
|
||||
disabledFunctionality += 0x16020000;
|
||||
if (!ps->value(QStringLiteral("mdm"), QStringLiteral("enableShowMeteoDataStations")).toBool())
|
||||
disabledFunctionality += 0x16010000;
|
||||
|
||||
//--- msg ---
|
||||
if (!ps->value(QStringLiteral("msg"), QStringLiteral("enableMessages")).toBool())
|
||||
disabledFunctionality += 0x15010000;
|
||||
|
||||
//--- opm ---
|
||||
if (!ps->value(QStringLiteral("opm"), QStringLiteral("enableShutdownWorkstations")).toBool())
|
||||
disabledFunctionality += 0x19020002;
|
||||
|
||||
//--- ore ---
|
||||
if (!ps->value(QStringLiteral("ore"), QStringLiteral("enableOnlineReports")).toBool())
|
||||
disabledFunctionality += 0x2e010000;
|
||||
|
||||
//--- ppm ---
|
||||
if (!ps->value(QStringLiteral("ppm"), QStringLiteral("enableSupportParticipantsOrganise")).toBool())
|
||||
disabledFunctionality += 0x1b010002;
|
||||
if (!ps->value(QStringLiteral("ppm"), QStringLiteral("enableSupportParticipantsEdit")).toBool())
|
||||
disabledFunctionality += 0x1b010003;
|
||||
if (!ps->value(QStringLiteral("ppm"), QStringLiteral("enableMSDL_ImExport")).toBool())
|
||||
disabledFunctionality += 0x1b060000;
|
||||
|
||||
//--- rep ---
|
||||
if (!ps->value(QStringLiteral("rep"), QStringLiteral("enableReports")).toBool())
|
||||
disabledFunctionality += 0x1f010000;
|
||||
|
||||
//--- pws ---
|
||||
if (!ps->value(QStringLiteral("pws"), QStringLiteral("enableProjection")).toBool())
|
||||
disabledFunctionality += 0x32010000;
|
||||
|
||||
//--- smo ---
|
||||
if (!ps->value(QStringLiteral("smo"), QStringLiteral("enableEquipmentErrorRegistration")).toBool())
|
||||
disabledFunctionality += 0x2c010006;
|
||||
if (!ps->value(QStringLiteral("smo"), QStringLiteral("enableHandgrenadeAndMineSearchShow")).toBool())
|
||||
disabledFunctionality += 0x2c010006;
|
||||
|
||||
NGLTreeModel::resetModel();
|
||||
|
||||
// Insert All visible Groups
|
||||
auto cbGroup = [this, disabledFunctionality](const Group &group)
|
||||
{
|
||||
if (group.type() == GroupType_def::StandardGroup)
|
||||
{
|
||||
if (disabledFunctionality.contains(group.id()) || group.isHidden())
|
||||
return;
|
||||
CheckedTreeItem *item = static_cast<CheckedTreeItem *>(createItem(QVariant::fromValue(group), QIcon()));
|
||||
getRootItem()->appendChild(item);
|
||||
}
|
||||
};
|
||||
dtc->groups(cbGroup);
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
const auto children = getRootItem()->children();
|
||||
for (NGLTreeItem *opGroupItem : children)
|
||||
{
|
||||
const std::vector<int32_t> isMemberOf = opGroupItem->data().value<Group>().isMemberOf();
|
||||
auto cbGroup2 = [this, &isMemberOf, opGroupItem] (const Group &group)
|
||||
{
|
||||
if (group.type() == GroupType_def::AclGroup && contains(isMemberOf, group.id()))
|
||||
opGroupItem->appendChild(createItem(QVariant::fromValue(group), QIcon()));
|
||||
};
|
||||
dtc->groups(cbGroup2);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
bool MembershipModel::contains(const std::vector<int32_t>&isMemberOf, int grpId)
|
||||
{
|
||||
for (int id : isMemberOf)
|
||||
{
|
||||
if (id == grpId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant MembershipModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole && role != Qt::CheckStateRole)
|
||||
return NGLTreeModel::data(index, role);
|
||||
|
||||
CheckedTreeItem *item = static_cast<CheckedTreeItem *>(privateData(index));
|
||||
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
Group group = getGroupData(index);
|
||||
if (!m_bRowsAreCheckable || index.column() != 0 || group.type() != GroupType_def::StandardGroup)
|
||||
return NGLTreeModel::data(index, role);
|
||||
|
||||
return item->bIsChecked ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
|
||||
if (item->data().canConvert<Group>())
|
||||
{
|
||||
Group grp = item->data().value<Group>();
|
||||
switch (index.column())
|
||||
{
|
||||
case ColName:
|
||||
return QCoreApplication::translate("OperatorRights", grp.name().c_str());
|
||||
case ColDescription:
|
||||
return QCoreApplication::translate("OperatorRights", grp.description().c_str());
|
||||
case ColIsAclGroup:
|
||||
return grp.type().underlying();
|
||||
case ColIsHidden:
|
||||
return grp.isHidden() ? tr("Yes") : tr("No");
|
||||
}
|
||||
}
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
void MembershipModel::init(int groupId)
|
||||
{
|
||||
init(m_dtc->group(groupId).isMemberOf());
|
||||
}
|
||||
|
||||
void MembershipModel::init(const std::vector<int> &groupIds)
|
||||
{
|
||||
setCheckStateForGroups(groupIds);
|
||||
}
|
||||
|
||||
bool MembershipModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (role != Qt::CheckStateRole || index.column() != 0 || !index.isValid())
|
||||
return NGLTreeModel::setData(index, value, role);
|
||||
if (!value.canConvert<bool>())
|
||||
return false;
|
||||
CheckedTreeItem *item = static_cast<CheckedTreeItem *>(privateData(index));
|
||||
if (item->bIsChecked != value.toBool())
|
||||
{
|
||||
item->bIsChecked = value.toBool();
|
||||
emit dataChanged(index, index, {role});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::ItemFlags MembershipModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Group group = getGroupData(index);
|
||||
auto ret = NGLTreeModel::flags(index);
|
||||
if (m_bRowsAreCheckable && index.column() == 0 && group.type() == GroupType_def::StandardGroup)
|
||||
ret |= Qt::ItemIsUserCheckable;
|
||||
|
||||
// // can not drag the whole tree, also we allow only dragging the first column
|
||||
// if (index.column() != 0 || !index.parent().isValid())
|
||||
// ret &= ~Qt::ItemIsDragEnabled;
|
||||
// // drop also only on first column
|
||||
// if (index.column() != 0)
|
||||
// ret &= ~Qt::ItemIsDropEnabled;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int MembershipModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
int count = NGLTreeModel::columnCount(parent);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
count -= 2;
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
Group MembershipModel::getGroupData(const QModelIndex &idx) const
|
||||
{
|
||||
return privateData(idx)->data().value<Group>();
|
||||
}
|
||||
|
||||
void MembershipModel::setRowsCheckable(bool bCheckable)
|
||||
{
|
||||
if (m_bRowsAreCheckable == bCheckable)
|
||||
return;
|
||||
m_bRowsAreCheckable = bCheckable;
|
||||
// onReinitModel(m_partyId); // TODO: not really needed, only invalidate first column
|
||||
}
|
||||
|
||||
|
||||
std::vector<int> MembershipModel::checkStateForGroups(Qt::CheckState cs)
|
||||
{
|
||||
if (m_rootItem->childCount() < 1)
|
||||
return {};
|
||||
|
||||
CheckedTreeItem *item = static_cast<CheckedTreeItem *>(m_rootItem);
|
||||
return checkState(item, cs);
|
||||
}
|
||||
|
||||
bool MembershipModel::setCheckStateForGroups(const std::vector<int> &groupIds)
|
||||
{
|
||||
if (m_rootItem->childCount() < 1)
|
||||
return false;
|
||||
setChecked(static_cast<CheckedTreeItem *>(m_rootItem),groupIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<int> MembershipModel::checkState(CheckedTreeItem *parentItem, Qt::CheckState cs) const
|
||||
{
|
||||
std::vector<int> ret;
|
||||
if ((parentItem->bIsChecked && cs == Qt::Checked) ||
|
||||
(!parentItem->bIsChecked && cs == Qt::Unchecked))
|
||||
ret.push_back(groupIdFromItem(parentItem));
|
||||
|
||||
for (int i = 0; i < parentItem->childCount(); ++i)
|
||||
{
|
||||
const auto c = checkState(static_cast<CheckedTreeItem *>(parentItem->child(i)), cs);
|
||||
ret.insert(ret.end(), c.begin(), c.end());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MembershipModel::setChecked(CheckedTreeItem *parentItem, const std::vector<int> &checkedGroups)
|
||||
{
|
||||
for (int i = 0; i < parentItem->childCount(); ++i)
|
||||
{
|
||||
CheckedTreeItem *item = static_cast<CheckedTreeItem *>(parentItem->child(i));
|
||||
const auto newState = LtsUtils::isInVector(checkedGroups, groupIdFromItem(item));
|
||||
if (item->bIsChecked != newState)
|
||||
{
|
||||
item->bIsChecked = newState;
|
||||
const QModelIndex idx = indexFromItem(item);
|
||||
emit dataChanged(idx, idx, {Qt::CheckStateRole});
|
||||
}
|
||||
setChecked(item, checkedGroups);
|
||||
}
|
||||
}
|
||||
|
||||
int MembershipModel::groupIdFromItem(NGLTreeItem *item) const
|
||||
{
|
||||
return item->data().value<Group>().id();
|
||||
}
|
||||
|
||||
NGLTreeItem *MembershipModel::createItem(const QVariant &data, const QIcon &icon) const
|
||||
{
|
||||
return new CheckedTreeItem(data, icon);
|
||||
}
|
||||
|
||||
void MembershipModel::selectAll()
|
||||
{
|
||||
if (m_rootItem->childCount() < 1)
|
||||
return;
|
||||
select(static_cast<CheckedTreeItem *>(m_rootItem), true);
|
||||
return;
|
||||
}
|
||||
|
||||
void MembershipModel::select(CheckedTreeItem *parentItem, bool selectValue)
|
||||
{
|
||||
for (int i = 0; i < parentItem->childCount(); ++i)
|
||||
{
|
||||
CheckedTreeItem *item = static_cast<CheckedTreeItem *>(parentItem->child(i));
|
||||
if (item->bIsChecked != selectValue)
|
||||
{
|
||||
item->bIsChecked = selectValue;
|
||||
const QModelIndex idx = indexFromItem(item);
|
||||
emit dataChanged(idx, idx, {Qt::CheckStateRole});
|
||||
}
|
||||
select(item, selectValue);
|
||||
}
|
||||
}
|
||||
|
||||
void MembershipModel::unselectAll()
|
||||
{
|
||||
if (m_rootItem->childCount() < 1)
|
||||
return;
|
||||
select(static_cast<CheckedTreeItem *>(m_rootItem), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Group Edit member of model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-09-26
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/OperatorManagement/Data/opm_data_plugin.h>
|
||||
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class CheckedTreeItem;
|
||||
|
||||
class MembershipModel : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum Columns
|
||||
{
|
||||
ColName,
|
||||
ColDescription,
|
||||
ColIsHidden,
|
||||
ColIsAclGroup
|
||||
};
|
||||
|
||||
public:
|
||||
explicit MembershipModel(QObject *parent,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc
|
||||
);
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
|
||||
Group getGroupData(const QModelIndex &idx) const;
|
||||
|
||||
void setRowsCheckable(bool bCheckable);
|
||||
bool rowsCheckable() const { return m_bRowsAreCheckable; }
|
||||
|
||||
std::vector<int> checkStateForGroups(Qt::CheckState cs);
|
||||
bool setCheckStateForGroups(const std::vector<int> &groupIds);
|
||||
void selectAll();
|
||||
void unselectAll();
|
||||
|
||||
void init(int groupId);
|
||||
void init(const std::vector<int> &groupIds);
|
||||
private:
|
||||
std::vector<int> checkState(CheckedTreeItem *parentItem, Qt::CheckState cs) const;
|
||||
void setChecked(CheckedTreeItem *parentItem, const std::vector<int> &checkedGroups);
|
||||
void select(CheckedTreeItem *parentItem, bool selectValue);
|
||||
int groupIdFromItem(NGLTreeItem *item) const;
|
||||
|
||||
NGLTreeItem *createItem(const QVariant &data, const QIcon &icon) const override;
|
||||
|
||||
private:
|
||||
const std::shared_ptr<Interface::Dtc> &m_dtc;
|
||||
bool m_bRowsAreCheckable;
|
||||
static bool contains(const std::vector<int32_t>&isMemberOf, int grpId);
|
||||
};
|
||||
}
|
||||
Q_DECLARE_METATYPE(OperatorManagement::Group)
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Group Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "group_model.h"
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <OperatorManagement/opm_translation.h>
|
||||
#include <QIcon>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// GroupModel
|
||||
//---------------------------------
|
||||
GroupModel::GroupModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<OperatorManagement::Group>({tr("Name"),
|
||||
tr("Info"),
|
||||
tr("Id")},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_hideHidden(false)
|
||||
, m_logger(getLogger("GroupManagementDialogModel"))
|
||||
{}
|
||||
|
||||
GroupModel::~GroupModel()
|
||||
{}
|
||||
|
||||
bool GroupModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
bool hideHidden)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_hideHidden = hideHidden;
|
||||
|
||||
connect(m_dtc.get(), &OperatorManagement::Interface::Dtc::groupChanged,
|
||||
this, &GroupModel::onDataChanged);
|
||||
m_dtc->groups([this](const OperatorManagement::Group &group) {
|
||||
if (group.type() == GroupType_def::PresetGroup)
|
||||
insertRow(group);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant GroupModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole && role != Qt::DecorationRole)
|
||||
return QVariant();
|
||||
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const OperatorManagement::Group &group = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::DecorationRole && index.column() == 0)
|
||||
{
|
||||
if (group.type() == GroupType::OperatorGroup)
|
||||
return QIcon(QLatin1String("icon:list-add-user.svg"));
|
||||
if (group.type() == GroupType::AclGroup)
|
||||
return QIcon(QLatin1String("icon:define_teams.svg"));
|
||||
return QIcon(QLatin1String("icon:display_oc_evaluations.svg"));
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Name:
|
||||
return OperatorManagement::trGroupName(group.name());
|
||||
case Info:
|
||||
return OperatorManagement::trGroupDescription(group.description());
|
||||
case Id:
|
||||
return group.id();
|
||||
//return QVariant(DTG::toStringMSec(group.lastChanged()));
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Group Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// GroupModel
|
||||
// --------------------------------------------------------
|
||||
class GroupModel final : public LtsWidgets::LtsAbstractTableModel<OperatorManagement::Group>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Name,
|
||||
Info,
|
||||
Id
|
||||
};
|
||||
|
||||
explicit GroupModel(QObject *parent = nullptr);
|
||||
~GroupModel();
|
||||
|
||||
bool initModel(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
bool hideHidden = true);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
protected:
|
||||
bool isFiltered(const Group &data, DataModification modType) const override
|
||||
{
|
||||
if (m_hideHidden && data.isHidden())
|
||||
return true;
|
||||
return LtsWidgets::LtsAbstractTableModel<OperatorManagement::Group>::isFiltered(data, modType);
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
bool m_hideHidden;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Operator/User Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "operator_dialog.h"
|
||||
#include "ui_operator_dialog.h"
|
||||
|
||||
#include "operator_edit_dialog.h"
|
||||
#include "CustomViews/opm_operator.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
OperatorDialog::OperatorDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::OperatorDialog)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("OperatorDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &OperatorDialog::onAddOperator);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &OperatorDialog::onEditOperator);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &OperatorDialog::onRemoveOperator);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &OperatorDialog::onPrint);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &OperatorDialog::onEditOperator);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &OperatorDialog::onEditOperator);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Operators"));
|
||||
}
|
||||
|
||||
OperatorDialog::~OperatorDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void OperatorDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Operators"));
|
||||
}
|
||||
|
||||
void OperatorDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool OperatorDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> dtc;
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<OperatorManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
m_model = new OperatorManagementDialogModel(this);
|
||||
m_model->initModel(m_session, dtc);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewOperator(this); });
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &OperatorDialog::enaDisa);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::clicked,
|
||||
this, &OperatorDialog::onTvItemClicked);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::Id);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::EffectiveAcls);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::PrimaryGroupId);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::Image);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::Workstation);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(OperatorManagementDialogModel::Columns::Name, Qt::AscendingOrder);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OperatorDialog::enaDisa()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows == 1);
|
||||
}
|
||||
|
||||
void OperatorDialog::onRemoveOperator()
|
||||
{
|
||||
QModelIndex idx = m_ui->widget->currentIndex();
|
||||
Core::RemoveElementRequest req(m_model->getRowData(idx.row()).id());
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->operatorRemoveRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void OperatorDialog::onAddOperator()
|
||||
{
|
||||
OperatorEditDialog *dialog = new OperatorEditDialog(-1, m_session, m_menuGroup, this);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("NewOperator"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void OperatorDialog::onEditOperator()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const OperatorManagement::User op = m_model->getRowData(idx.row());
|
||||
|
||||
if (op.id() <= 0)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "current Operator Id: " << op.id();
|
||||
|
||||
OperatorEditDialog *dialog = new OperatorEditDialog(op.id(), m_session, m_menuGroup, this);
|
||||
const QString identifier = QLatin1String("EditOperator") + QString::number(op.id());
|
||||
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void OperatorDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void OperatorDialog::onTvItemClicked(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
auto user = m_model->getRowData(idx.row());
|
||||
if (user.id() == 99) // Id 99 -> Organisator
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setEnabled(false);
|
||||
else
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setEnabled(true);
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OpeartorManagement - Operator/User Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/Gui/Common/operator_dialog_model.h>
|
||||
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OperatorDialog;
|
||||
}
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class OperatorDialog : public LtsWidgets::LtsDialog
|
||||
, protected OperatorManagement::Interface::Ftc::OperatorRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OperatorDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~OperatorDialog();
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void onOperatorRemoveReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
QString m_menuGroup;
|
||||
OperatorManagementDialogModel *m_model;
|
||||
Ui::OperatorDialog *m_ui;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onRemoveOperator();
|
||||
void onAddOperator();
|
||||
void onEditOperator();
|
||||
void onPrint();
|
||||
void onTvItemClicked(const QModelIndex &idx);
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OperatorDialog</class>
|
||||
<widget class="QWidget" name="OperatorDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>674</width>
|
||||
<height>328</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Operator Edit</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,514 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "operator_edit_dialog.h"
|
||||
#include "ui_operator_edit_dialog.h"
|
||||
|
||||
#include <OperatorManagement/Gui/Common/operator_change_password.h>
|
||||
#include "operator_edit_visible_parties_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsUtilsCore/dds_vector_to_pixmap.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <Plugins/ParticipantManagement/Data/ppm_data_plugin.h>
|
||||
#include <Plugins/ExerciseManagement/Data/exm_data_plugin.h>
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QImage>
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
#include <QFileDialog>
|
||||
#include <QMenu>
|
||||
|
||||
#include "group_edit_dialog.h"
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
OperatorEditDialog::OperatorEditDialog(const int operatorId,
|
||||
LtsSession::LtsSession *session,
|
||||
const QString &menuGroup,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_operatorId(operatorId)
|
||||
, m_pictureChanged(false)
|
||||
, m_visiblePartiesChanged(false)
|
||||
, m_projectionPriorityChanged(false)
|
||||
, m_audioChannelPriorityChanged(false)
|
||||
, m_presetGroupId(0)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_visiblePartiesModel(nullptr)
|
||||
, m_session(session)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_ui(new Ui::OperatorEditDialog)
|
||||
, m_logger(getLogger("operatorManangementEditDialog"))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_effectiveACls.clear();
|
||||
|
||||
// Todo: Init
|
||||
m_session->getDtc<OperatorManagement::DataInterface>(m_dtc);
|
||||
m_session->getFtc<OperatorManagement::DataInterface>(m_ftc);
|
||||
m_session->getDtc<FileManagement::DataInterface>(m_flmDtc);
|
||||
m_session->getFtc<FileManagement::DataInterface>(m_flmFtc);
|
||||
|
||||
OperatorManagement::User op = m_dtc->user(m_operatorId);
|
||||
|
||||
m_effectiveACls = op.effectiveAcls();
|
||||
|
||||
if (m_operatorId < 1)
|
||||
{
|
||||
m_ui->pbChangePassword->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_ui->leOperator->setEnabled(false);
|
||||
m_ui->lePassword->setVisible(false);
|
||||
m_ui->lePasswordConfirmation->setVisible(false);
|
||||
m_ui->lblPassword->setVisible(false);
|
||||
m_ui->lblPasswordConfirmation->setVisible(false);
|
||||
m_ui->pbDisplay->setVisible(false);
|
||||
}
|
||||
|
||||
m_ui->leOperator->setText(QString::fromStdString(op.name()));
|
||||
m_ui->leInfo->setText(QString::fromStdString(op.description()));
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
{
|
||||
|
||||
m_visiblePartiesModel = new OperatorEditVisiblePartiesModel(m_dtc, ppmDtc, m_operatorId, this);
|
||||
m_ui->tvVisibleParties->setModel(m_visiblePartiesModel);
|
||||
m_ui->tvVisibleParties->resizeColumnsToContent();
|
||||
m_ui->tvVisibleParties->setSortIndicator(OperatorEditVisiblePartiesModel::Columns::ColId, Qt::SortOrder::AscendingOrder);
|
||||
m_ui->tvVisibleParties->setSortingEnabled(false);
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->tvVisibleParties->hideColumn(OperatorEditVisiblePartiesModel::Columns::ColId);
|
||||
#endif
|
||||
|
||||
connect(m_ui->tvVisibleParties, &LtsDataView::LtsDataView::doubleClicked, m_visiblePartiesModel, &OperatorEditVisiblePartiesModel::switchCheckbox);
|
||||
connect(m_visiblePartiesModel, &OperatorEditVisiblePartiesModel::dataChanged, this, [=]() {
|
||||
m_visiblePartiesChanged = true; slotChangesMade();});
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
m_ui->tvVisibleParties->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_ui->tvVisibleParties, &LtsDataView::LtsDataView::customContextMenuRequested, this, &OperatorEditDialog::onContextMenuRequested);
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->layParties->setEnabled(false);
|
||||
}
|
||||
getProfilePicture();
|
||||
|
||||
connect(m_ui->profileButton, &LtsWidgets::LtsProfileButton::signalClicked,
|
||||
this, &OperatorEditDialog::slotProfileButtonClicked);
|
||||
|
||||
connect(m_ui->pbACL, &QPushButton::clicked,
|
||||
this, &OperatorEditDialog::showACLs);
|
||||
|
||||
connect(m_ui->pbDisplay, &QPushButton::toggled,
|
||||
this, &OperatorEditDialog::onViewPasswordToggled);
|
||||
|
||||
connect(m_ui->pbFolders, &QPushButton::clicked,
|
||||
this, &OperatorEditDialog::createFolders);
|
||||
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
if (m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc))
|
||||
connect(m_ui->pbExercises, &QPushButton::clicked, this, &OperatorEditDialog::showExercises);
|
||||
else
|
||||
m_ui->pbExercises->hide();
|
||||
|
||||
// new password needs to be minimum 4 chars
|
||||
m_uiRequirements->addRequirement({m_ui->lblPassword, [this]()
|
||||
{
|
||||
return (m_operatorId > 0 || m_ui->lblPassword->text().size() >= 4); }
|
||||
});
|
||||
// new password and confirm password need to be equal
|
||||
m_uiRequirements->addRequirement({m_ui->lblPasswordConfirmation, [this]()
|
||||
{
|
||||
return (m_operatorId > 0 || (m_ui->lePassword->text() == m_ui->lePasswordConfirmation->text())); }
|
||||
});
|
||||
|
||||
connect(m_ui->pbChangePassword, &QPushButton::clicked, this, &OperatorEditDialog::slotPasswordChangedClicked);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lblOperator, [this]() { return (!m_ui->leOperator->text().isEmpty()); }});
|
||||
|
||||
QString priorities = QStringLiteral("1 (%1),2,3,4,5 (%2)").arg(tr("Least"), tr("Highest"));
|
||||
|
||||
m_ui->cbProjectionPriority->addItems(priorities.split(QLatin1Char(',')));
|
||||
m_ui->cbAudioChannelPriority->addItems(priorities.split(QLatin1Char(',')));
|
||||
|
||||
m_ui->cbProjectionPriority->setCurrentIndex(clamp(op.projectionPriority() - 1, 0, 4));
|
||||
m_ui->cbAudioChannelPriority->setCurrentIndex(clamp(op.audioChannelPriority() - 1, 0, 4));
|
||||
|
||||
connect<void(QComboBox::*)(int)>(m_ui->cbProjectionPriority, &QComboBox::currentIndexChanged,
|
||||
this, [this] () { m_projectionPriorityChanged = true; });
|
||||
connect<void(QComboBox::*)(int)>(m_ui->cbAudioChannelPriority, &QComboBox::currentIndexChanged,
|
||||
this, [this] () { m_audioChannelPriorityChanged = true; });
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Operators"));
|
||||
}
|
||||
|
||||
int OperatorEditDialog::clamp(int v, int lower, int upper)
|
||||
{
|
||||
return std::min(upper, std::max(v, lower));
|
||||
}
|
||||
|
||||
bool OperatorEditDialog::operatorCreateModify(const OperatorCreateModifyRequest &req)
|
||||
{
|
||||
// If it's an existing Operator, "req.operatorRights().is_set()" is false.
|
||||
// We assume, groups are set.
|
||||
// If it's a new Operator, we need one privilege
|
||||
if (req.operatorRights().is_set() && req.operatorRights().get().size() == 0)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("An operator must have at least one right"));
|
||||
return false;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "req.name: " << req.name();
|
||||
return m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_ftc->operatorCreateModifyRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void OperatorEditDialog::onViewPasswordToggled(bool checked)
|
||||
{
|
||||
m_ui->lePassword->setEchoMode(checked ? QLineEdit::EchoMode::Normal : QLineEdit::EchoMode::Password);
|
||||
m_ui->lePasswordConfirmation->setEchoMode(checked ? QLineEdit::EchoMode::Normal : QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
void OperatorEditDialog::onNewGroups(const std::vector<int> &groupIds, const int presetGroupId)
|
||||
{
|
||||
m_groups = groupIds;
|
||||
m_presetGroupId = presetGroupId;
|
||||
}
|
||||
|
||||
|
||||
void OperatorEditDialog::getProfilePicture()
|
||||
{
|
||||
OperatorManagement::User op = m_dtc->user(m_operatorId);
|
||||
m_ui->profileButton->setPixmap(LtsUtils::getPixmap(op.image()));
|
||||
}
|
||||
|
||||
void OperatorEditDialog::slotProfileButtonClicked()
|
||||
{
|
||||
if (!m_ui->profileButton->pixmap().isNull())
|
||||
{
|
||||
if (LtsWidgets::LtsMessageDialog::showMessage(this, tr("Yes - overwrite image.<br>"
|
||||
"No - do not overwrite image.<br>"),
|
||||
tr("Do you really want to overwrite the current image?"),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes | LtsWidgets::Button::No) != LtsWidgets::Button::Yes)
|
||||
return; // do nothing if not ack by user
|
||||
}
|
||||
|
||||
const QStringList filter ({
|
||||
tr("Images (*.jpg *.jpeg *.png)")
|
||||
});
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select new image to replace profile picture"),
|
||||
QString(), // last wd
|
||||
filter.join(QStringLiteral(";;")));
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!pixmap.load(fileName))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Cannot load image '%1'").arg(fileName));
|
||||
return;
|
||||
}
|
||||
if (pixmap.width() > 100 || pixmap.height() > 100)
|
||||
pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
m_ui->profileButton->setPixmap(pixmap);
|
||||
|
||||
m_pictureChanged = true;
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
void OperatorEditDialog::slotPasswordChangedClicked()
|
||||
{
|
||||
OperatorChangePassword *dialog = new OperatorChangePassword(this, m_operatorId);
|
||||
if (!dialog->init(m_session))
|
||||
return;
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
OperatorEditDialog::~OperatorEditDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void OperatorEditDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dtc->user(m_operatorId), tr("Operator"));
|
||||
}
|
||||
|
||||
//Private Slots
|
||||
|
||||
void OperatorEditDialog::showACLs()
|
||||
{
|
||||
// Todo: MenuGroup!
|
||||
GroupEditDialog *dlg = new GroupEditDialog(this);
|
||||
if (m_operatorId < 1)
|
||||
{
|
||||
Group grp;
|
||||
grp.id(0);
|
||||
grp.name(m_ui->leOperator->text().toStdString());
|
||||
grp.description(m_ui->leInfo->text().toStdString());
|
||||
grp.type(GroupType_def::OperatorGroup);
|
||||
grp.isMemberOf(m_groups);
|
||||
connect(dlg, &GroupEditDialog::newGroups, this, &OperatorEditDialog::onNewGroups);
|
||||
dlg->init(grp, m_dtc, m_ftc);
|
||||
dlg->setRolePresetId(m_presetGroupId);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto grpInit = m_dtc->group(m_dtc->user(m_operatorId).primaryGroupId());
|
||||
dlg->init(grpInit, m_dtc, m_ftc, m_operatorId);
|
||||
}
|
||||
|
||||
|
||||
addDialog ( dlg, m_menuGroup, QLatin1String("EditGroups") + QString::number(m_operatorId));
|
||||
}
|
||||
|
||||
void OperatorEditDialog::showExercises()
|
||||
{
|
||||
LtsWidgets::LtsFramelessDialog *exercisesPopup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
||||
|
||||
QListWidget *wid = new QListWidget(exercisesPopup);
|
||||
wid->setFrameShape(QFrame::NoFrame);
|
||||
wid->viewport()->setAutoFillBackground(false);
|
||||
|
||||
QLabel *lblTitle = new QLabel(tr("Exercises"),exercisesPopup);
|
||||
|
||||
std::vector<int> exercises = m_dtc->user(m_operatorId).exerciseIds();
|
||||
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(exmDtc);
|
||||
|
||||
for (int exercise : exercises)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(wid);
|
||||
item->setData(Qt::DisplayRole, exmDtc ? QString::fromStdString(exmDtc->exercise(exercise).name()) : tr("Exercise Id: <%1> (name unknown)").arg(exercise));
|
||||
item->setData(Qt::UserRole, exercise);
|
||||
wid->addItem(item);
|
||||
}
|
||||
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(exercisesPopup);
|
||||
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, exercisesPopup, &LtsWidgets::LtsFramelessDialog::accept); // TODO: undo workaround !
|
||||
btnBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
|
||||
//buildUI
|
||||
QVBoxLayout *lay = new QVBoxLayout(exercisesPopup);
|
||||
lay->addWidget(lblTitle);
|
||||
lay->addWidget(line);
|
||||
lay->addWidget(wid);
|
||||
lay->addWidget(btnBox);
|
||||
exercisesPopup->setLayout(lay);
|
||||
|
||||
//exec
|
||||
exercisesPopup->show();
|
||||
//delete aclPopup; <= not needed, see parenting
|
||||
}
|
||||
|
||||
|
||||
bool OperatorEditDialog::apply()
|
||||
{
|
||||
const std::string name = m_ui->leOperator->text().toStdString();
|
||||
const std::string description = m_ui->leInfo->text().toStdString();
|
||||
const std::string password = m_ui->lePassword->text().toStdString();
|
||||
|
||||
//bool isAdmin = false; // TODO: check if session operator is in admin role - admins can change passwords without entering the old one
|
||||
|
||||
if (m_operatorId > 0) // user exists
|
||||
{
|
||||
OperatorManagement::User op = m_dtc->user(m_operatorId);
|
||||
|
||||
//updateData
|
||||
bool bNeedUpdate = false;
|
||||
OperatorCreateModifyRequest req;
|
||||
req.id(m_operatorId);
|
||||
|
||||
if (m_pictureChanged)
|
||||
{
|
||||
bNeedUpdate = true;
|
||||
req.image(LtsUtils::fromPixmap(m_ui->profileButton->pixmap()));
|
||||
}
|
||||
|
||||
if (name != op.name())
|
||||
{
|
||||
bNeedUpdate = true;
|
||||
req.name(name);
|
||||
}
|
||||
|
||||
if (description != op.description())
|
||||
{
|
||||
bNeedUpdate = true;
|
||||
req.description(description);
|
||||
}
|
||||
|
||||
if (m_visiblePartiesChanged)
|
||||
{
|
||||
bNeedUpdate = true;
|
||||
const QVector<int> visiblePartyIds = m_visiblePartiesModel->getCheckedIds();
|
||||
std::vector<OperatorManagement::PartiesByExercise> vpbe;
|
||||
PartiesByExercise pbe;
|
||||
DEBUG_LOG(m_logger) << "----------------- m_session.exerciseId:" << m_session->exerciseId();
|
||||
pbe.exerciseId(0);
|
||||
pbe.visibleParties().set({});
|
||||
std::copy(visiblePartyIds.begin(), visiblePartyIds.end(), std::back_inserter(pbe.visibleParties().get()));
|
||||
vpbe.push_back(pbe);
|
||||
req.visiblePartiesByExercise() = vpbe;
|
||||
}
|
||||
|
||||
if (m_projectionPriorityChanged)
|
||||
{
|
||||
bNeedUpdate = true;
|
||||
req.projectionPriority(m_ui->cbProjectionPriority->currentIndex() + 1);
|
||||
}
|
||||
|
||||
if (m_audioChannelPriorityChanged)
|
||||
{
|
||||
bNeedUpdate = true;
|
||||
req.audioChannelPriority(m_ui->cbAudioChannelPriority->currentIndex() + 1);
|
||||
}
|
||||
|
||||
return bNeedUpdate && operatorCreateModify(req);
|
||||
}
|
||||
else // create new user
|
||||
{
|
||||
OperatorCreateModifyRequest req;
|
||||
req.name(name);
|
||||
req.description(description);
|
||||
req.password(password);
|
||||
req.projectionPriority(dds::core::optional<int16_t>(m_ui->cbProjectionPriority->currentIndex() + 1));
|
||||
req.audioChannelPriority(m_ui->cbAudioChannelPriority->currentIndex() + 1);
|
||||
if (m_pictureChanged)
|
||||
req.image(LtsUtils::fromPixmap(m_ui->profileButton->pixmap()));
|
||||
if (m_visiblePartiesChanged)
|
||||
{
|
||||
const QVector<int> visiblePartyIds = m_visiblePartiesModel->getCheckedIds();
|
||||
std::vector<OperatorManagement::PartiesByExercise> vpbe;
|
||||
PartiesByExercise pbe;
|
||||
DEBUG_LOG (m_logger) << "----------------- m_session.exerciseId:" << m_session->exerciseId();
|
||||
pbe.exerciseId(0);
|
||||
pbe.visibleParties().set({});
|
||||
std::copy(visiblePartyIds.begin(), visiblePartyIds.end(), std::back_inserter(pbe.visibleParties().get()));
|
||||
vpbe.push_back(pbe);
|
||||
req.visiblePartiesByExercise() = vpbe;
|
||||
}
|
||||
req.operatorRights(m_groups);
|
||||
req.rolePresetId(m_presetGroupId);
|
||||
|
||||
return operatorCreateModify(req);
|
||||
}
|
||||
}
|
||||
|
||||
void OperatorEditDialog::onContextMenuRequested(const QPoint &position)
|
||||
{
|
||||
QMenu menu(m_ui->tvVisibleParties);
|
||||
menu.addAction(tr("Select All"), this, &OperatorEditDialog::onSelectAllParties);
|
||||
menu.addAction(tr("Unselect All"), this, &OperatorEditDialog::onUnselectAllParties);
|
||||
menu.exec(m_ui->tvVisibleParties->mapToGlobal(position));
|
||||
}
|
||||
|
||||
void OperatorEditDialog::onSelectAllParties()
|
||||
{
|
||||
m_visiblePartiesModel->selectAll();
|
||||
m_visiblePartiesModel->update();
|
||||
}
|
||||
|
||||
void OperatorEditDialog::onUnselectAllParties()
|
||||
{
|
||||
m_visiblePartiesModel->unselectAll();
|
||||
m_visiblePartiesModel->update();
|
||||
}
|
||||
|
||||
void OperatorEditDialog::createFolders()
|
||||
{
|
||||
// User folder
|
||||
OperatorManagement::User op = m_dtc->user(m_operatorId);
|
||||
QString folderName = QString::fromStdString(op.name());
|
||||
int userId = op.id();
|
||||
|
||||
// check if folder already exists
|
||||
int folderId = m_flmDtc->findFolder(0,folderName);
|
||||
if (folderId > 0)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("User folders already created"));
|
||||
return;
|
||||
}
|
||||
|
||||
// folder does not exists, we create it
|
||||
folderId = createFolder(FileManagement::MainFolder::UserDocuments, folderName, userId);
|
||||
|
||||
if (folderId <= 0)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Could not create user folders"));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "User Folder created with id = " << folderId;
|
||||
|
||||
#ifdef GUEZ_MODE
|
||||
// Sub-folder z.B. AuswtGrp/LtgDst/AusbDst_<username>
|
||||
folderName = QStringLiteral("AuswtGrp/LtgDst/AusbDst_") + folderName ;
|
||||
int subFolderId = createFolder(folderId, folderName, userId);
|
||||
|
||||
if (subFolderId <= 0)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Could not create user sub-folders"));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "User Subfolder created with id = " << subFolderId;
|
||||
#endif
|
||||
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("User folders successfully created"));
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
int OperatorEditDialog::createFolder(int parentFolderId, const QString &folderName, int userId, bool isHidden)
|
||||
{
|
||||
FileManagement::Folder parentFolder = m_flmDtc->folder(parentFolderId);
|
||||
const std::vector<int32_t> &parentPath = parentFolder.path();
|
||||
|
||||
FileManagement::FolderModifyRequest req;
|
||||
req.name(folderName.toStdString());
|
||||
req.path(parentPath);
|
||||
req.isEditable(true);
|
||||
req.isHidden(isHidden);
|
||||
req.parentId(parentFolderId);
|
||||
req.operatorId(userId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_flmFtc->folderModifyRequest(req, this);
|
||||
});
|
||||
|
||||
DEBUG_LOG(m_logger) << "Created folder id = " << m_requestHelper->getRepliedId();
|
||||
|
||||
return m_requestHelper->getRepliedId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManangement - Operator Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OperatorEditDialog;
|
||||
}
|
||||
|
||||
namespace LtsSession {
|
||||
class LtsSession;
|
||||
}
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class OperatorEditVisiblePartiesModel;
|
||||
// --------------------------------------------------------
|
||||
// OperatorManagementEditDialog
|
||||
// --------------------------------------------------------
|
||||
class OperatorEditDialog : public LtsWidgets::LtsDialog
|
||||
, protected OperatorManagement::Interface::Ftc::OperatorCreateModifyReplyHandler
|
||||
, protected OperatorManagement::Interface::Ftc::GroupChangeMembershipsReplyHandler
|
||||
, protected FileManagement::Interface::Ftc::FolderModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OperatorEditDialog(int operatorId,
|
||||
LtsSession::LtsSession *session,
|
||||
const QString &menuGroup,
|
||||
QWidget *parent = nullptr);
|
||||
~OperatorEditDialog();
|
||||
|
||||
|
||||
void onOperatorCreateModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onGroupChangeMembershipsReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onFolderModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
int createFolder(int parentFolderId, const QString &folderName, int userId, bool isHidden = false);
|
||||
|
||||
private slots:
|
||||
void showACLs();
|
||||
void showExercises();
|
||||
void slotPasswordChangedClicked();
|
||||
void slotProfileButtonClicked();
|
||||
void onViewPasswordToggled(bool checked);
|
||||
void onNewGroups(const std::vector<int> &groupIds, const int presetGroupId);
|
||||
void onContextMenuRequested(const QPoint &position);
|
||||
void onSelectAllParties();
|
||||
void onUnselectAllParties();
|
||||
void createFolders();
|
||||
|
||||
signals:
|
||||
void sendData(const OperatorManagement::User &data);
|
||||
|
||||
private:
|
||||
int m_operatorId;
|
||||
bool m_pictureChanged;
|
||||
bool m_visiblePartiesChanged;
|
||||
bool m_projectionPriorityChanged;
|
||||
bool m_audioChannelPriorityChanged;
|
||||
std::vector<int> m_groups;
|
||||
int m_presetGroupId;
|
||||
QString m_menuGroup;
|
||||
|
||||
std::vector<int> m_effectiveACls;
|
||||
OperatorEditVisiblePartiesModel *m_visiblePartiesModel;
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
|
||||
//std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
Ui::OperatorEditDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
void getProfilePicture();
|
||||
int clamp(int v, int lower, int upper);
|
||||
bool operatorCreateModify(const OperatorCreateModifyRequest &req);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OperatorEditDialog</class>
|
||||
<widget class="QWidget" name="OperatorEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>687</width>
|
||||
<height>571</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Operator Edit</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblOperator">
|
||||
<property name="text">
|
||||
<string>Operator:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leOperator">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lblProjectionPriority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Projection Priority:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="cbProjectionPriority"/>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pbACL">
|
||||
<property name="text">
|
||||
<string>Privileges</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5" rowspan="2">
|
||||
<widget class="LtsWidgets::LtsProfileButton" name="profileButton" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblInfo">
|
||||
<property name="text">
|
||||
<string>Info:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leInfo">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lblAudioChannelPriority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Audio Channel Priority:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="cbAudioChannelPriority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QPushButton" name="pbExercises">
|
||||
<property name="text">
|
||||
<string>Exercises</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblPassword">
|
||||
<property name="text">
|
||||
<string>New Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lePassword">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="pbChangePassword">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change Password</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblPasswordConfirmation">
|
||||
<property name="text">
|
||||
<string>Confirm Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lePasswordConfirmation">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="pbDisplay">
|
||||
<property name="text">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="pbFolders">
|
||||
<property name="text">
|
||||
<string>Create Folders</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<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 row="1" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="layParties">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblVisibleParties">
|
||||
<property name="text">
|
||||
<string>Available Parties:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="tvVisibleParties" native="true">
|
||||
<property name="showColumnCount" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolButtonsVisible" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsProfileButton</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_profile_button.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>leOperator</tabstop>
|
||||
<tabstop>leInfo</tabstop>
|
||||
<tabstop>lePassword</tabstop>
|
||||
<tabstop>lePasswordConfirmation</tabstop>
|
||||
<tabstop>cbProjectionPriority</tabstop>
|
||||
<tabstop>cbAudioChannelPriority</tabstop>
|
||||
<tabstop>pbACL</tabstop>
|
||||
<tabstop>pbExercises</tabstop>
|
||||
<tabstop>pbChangePassword</tabstop>
|
||||
<tabstop>pbDisplay</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Edit Visible Parties Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2019-09-18
|
||||
*/
|
||||
|
||||
#include "operator_edit_visible_parties_model.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
OperatorEditVisiblePartiesModel::OperatorEditVisiblePartiesModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
int operatorId,
|
||||
QObject *parent)
|
||||
: LtsWidgets::LtsCheckableTableModel<QPair<bool, ParticipantManagement::Party>>({tr("Id"), tr("Name")}, ColName, parent)
|
||||
, m_dtc (dtc)
|
||||
, m_ppmDtc(ppmDtc)
|
||||
, m_operatorId (operatorId)
|
||||
{
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::partyChanged,
|
||||
this, &OperatorEditVisiblePartiesModel::onPartiesChanged, Qt::UniqueConnection);
|
||||
|
||||
auto cb = [this](const ParticipantManagement::Party &party)
|
||||
{
|
||||
onPartiesChanged(party, DataModification::eAdded);
|
||||
};
|
||||
m_ppmDtc->partys(cb);
|
||||
}
|
||||
|
||||
OperatorEditVisiblePartiesModel::~OperatorEditVisiblePartiesModel()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant OperatorEditVisiblePartiesModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return LtsCheckableTableModel::data(index, role);
|
||||
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const ParticipantManagement::Party &party = m_vecData.at(index.row()).second;
|
||||
switch (index.column())
|
||||
{
|
||||
case ColId:
|
||||
return party.id();
|
||||
case ColName:
|
||||
return ParticipantManagement::trPartyName(party.name());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void OperatorEditVisiblePartiesModel::onPartiesChanged(const ParticipantManagement::Party &data, DataModification mod)
|
||||
{
|
||||
switch(mod)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
insertRow(qMakePair(hasParty(data), data));
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).second.id() == data.id())
|
||||
{
|
||||
removeRow(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
{
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
if (m_vecData.at(i).second.id() == data.id())
|
||||
{
|
||||
m_vecData[i].second = data;
|
||||
const QModelIndex idx(index(i, ColName, QModelIndex()));
|
||||
emit dataChanged(idx, idx, {Qt::DisplayRole});
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool OperatorEditVisiblePartiesModel::hasParty(const ParticipantManagement::Party &party) const
|
||||
{
|
||||
const auto visiblePartiesByExercise = m_dtc->user(m_operatorId).visiblePartiesByExercise();
|
||||
|
||||
for (const auto &exerciseParties : visiblePartiesByExercise)
|
||||
{
|
||||
if (exerciseParties.exerciseId() != 0)
|
||||
continue;
|
||||
// Now we are definetelay in exId == 0 --> Template!
|
||||
if (!exerciseParties.visibleParties().is_set()) //has_value not support on windows yet so we need depricated is_set
|
||||
return false;
|
||||
for (const auto &partyId : exerciseParties.visibleParties().get())
|
||||
if (partyId == party.id())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Operator Edit Visible Parties Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2019-09-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/OperatorManagement/Data/opm_data_plugin.h>
|
||||
#include <Plugins/ParticipantManagement/Data/ppm_data_plugin.h>
|
||||
|
||||
#include <LtsWidgets/lts_checkable_table_model.h>
|
||||
|
||||
#include <QPair>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class OperatorEditVisiblePartiesModel : public LtsWidgets::LtsCheckableTableModel<QPair<bool, ParticipantManagement::Party>>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
ColId,
|
||||
ColName
|
||||
};
|
||||
|
||||
explicit OperatorEditVisiblePartiesModel(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
int operatorId = 0,
|
||||
QObject *parent = nullptr);
|
||||
~OperatorEditVisiblePartiesModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
public slots:
|
||||
void onPartiesChanged(const ParticipantManagement::Party &data, DataModification mod);
|
||||
|
||||
private:
|
||||
bool hasParty(const ParticipantManagement::Party &party) const;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
int m_operatorId;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "opm_edit_gui_plugin.h"
|
||||
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include "operator_dialog.h"
|
||||
#include "acl_dialog.h"
|
||||
#include "preset_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/OperatorManagement/opm_operator_rights.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.Edit"))
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<OperatorManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
// Todo: Check if necessary
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> ppmDtc;
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(ppmDtc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Operators");
|
||||
plData.identifier = QLatin1String("opmOperatorEdit");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:list-add-user.svg"));
|
||||
plData.operatorRight = OperatorRights::OperatorsEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowOperatorDialog(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
plData.menuText = tr("Presets");
|
||||
plData.identifier = QLatin1String("opmGroupEdit");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:operator_rights.svg"));
|
||||
plData.closable = true;
|
||||
plData.operatorRight = OperatorRights::GroupEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowGroupDialog(parent, false);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
plData.menuText = tr("Show ACLs");
|
||||
plData.identifier = QLatin1String("openShowAcls");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:access_rights.svg"));
|
||||
plData.closable = true;
|
||||
plData.operatorRight = OperatorRights::GroupShow;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowAclDialog(parent);
|
||||
};
|
||||
// ret.append(plData);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//private
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowOperatorDialog(QWidget *parent)
|
||||
{
|
||||
OperatorDialog *dialog = new OperatorDialog(menuGroup(), parent);
|
||||
dialog->init(m_session);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowGroupDialog(QWidget *parent, bool hideHidden)
|
||||
{
|
||||
PresetDialog *dialog = new PresetDialog(menuGroup(), parent);
|
||||
dialog->init(m_dtc, m_ftc, hideHidden);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAclDialog(QWidget *parent)
|
||||
{
|
||||
AclDialog *dialog = new AclDialog(parent);
|
||||
dialog->init(m_dtc, m_ftc);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
} //namespace OperatorManagement
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_gui_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")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("OperatorManagementGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Global;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
QString menuGroup() const override { return tr("Operators"); }
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Global; } // global only, not in exercise mode
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowOperatorDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowGroupDialog(QWidget *parent, bool hideHidden = true);
|
||||
LtsWidgets::LtsDialog *onShowAclDialog(QWidget *parent);
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManangement - Group Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "preset_dialog.h"
|
||||
#include "ui_preset_dialog.h"
|
||||
|
||||
#include "group_edit_dialog.h"
|
||||
#include "CustomViews/opm_group.h"
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
PresetDialog::PresetDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::PresetDialog)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("PresetDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &PresetDialog::onAddGroup);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &PresetDialog::onEditGroup);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &PresetDialog::onRemoveGroup);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &PresetDialog::onEditGroup);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &PresetDialog::onEditGroup);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Presets"));
|
||||
}
|
||||
|
||||
PresetDialog::~PresetDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void PresetDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Presets"));
|
||||
}
|
||||
|
||||
void PresetDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool PresetDialog::init(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
bool hideHidden)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
m_model = new GroupModel(this);
|
||||
m_model->initModel(dtc, hideHidden);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewGroup(this); });
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->setColumnHidden(GroupModel::Id, true);
|
||||
#endif
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &PresetDialog::enaDisa);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PresetDialog::enaDisa()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1 );
|
||||
|
||||
bool deletable = cntSelectedRows > 0 &&
|
||||
(m_model->getRowData(selectedRows.at(0).row()).type() == GroupType_def::PresetGroup);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, deletable );
|
||||
}
|
||||
|
||||
void PresetDialog::onRemoveGroup()
|
||||
{
|
||||
QModelIndex idx = m_ui->widget->currentIndex();
|
||||
Core::RemoveElementRequest req(m_model->getRowData(idx.row()).id());
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->groupRemoveRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void PresetDialog::onAddGroup()
|
||||
{
|
||||
GroupEditDialog *dialog = new GroupEditDialog(this);
|
||||
Group grp;
|
||||
grp.type(GroupType_def::PresetGroup);
|
||||
dialog->init(grp, m_dtc, m_ftc);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("NewPreset"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void PresetDialog::onEditGroup()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const OperatorManagement::Group group = m_model->getRowData(idx.row());
|
||||
|
||||
if (group.id() <= 0)
|
||||
return;
|
||||
|
||||
GroupEditDialog *dialog = new GroupEditDialog(this);
|
||||
dialog->init(group, m_dtc, m_ftc);
|
||||
const QString identifier = QLatin1String("editPreset") + QString::number(group.id());
|
||||
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Group Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "group_model.h"
|
||||
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PresetDialog;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class PresetDialog : public LtsWidgets::LtsDialog
|
||||
, protected OperatorManagement::Interface::Ftc::GroupRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PresetDialog(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~PresetDialog();
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
bool hideHidden = true);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void onGroupRemoveReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
QString m_menuGroup;
|
||||
GroupModel *m_model;
|
||||
Ui::PresetDialog *m_ui;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void enaDisa();
|
||||
void onRemoveGroup();
|
||||
void onAddGroup();
|
||||
void onEditGroup();
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PresetDialog</class>
|
||||
<widget class="QWidget" name="PresetDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>674</width>
|
||||
<height>328</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Group Edit</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Diers, SLSE, 2017-08-22
|
||||
#
|
||||
|
||||
SET(opm_overview_gui_SRCS
|
||||
opm_overview_gui_plugin.cpp
|
||||
opm_overview_gui_plugin.h
|
||||
|
||||
CustomViews/opm_operator.cpp
|
||||
CustomViews/opm_operator.h
|
||||
|
||||
operator_overview_dialog.cpp
|
||||
operator_overview_dialog.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(opm_overview_gui_SRCS
|
||||
operator_overview_dialog.ui
|
||||
CustomViews/opm_operator.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS OpmOverviewGuiPlugin MODULE ${opm_overview_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(OpmOverviewGuiPlugin
|
||||
NGLLogger
|
||||
OpmDataPluginInterface
|
||||
OpmGuiPluginInterface
|
||||
OpmChangePasswordGui
|
||||
Qt5::Widgets
|
||||
LtsPrinting
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(OpmOverviewGuiPlugin)
|
||||
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for OPM Operator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
|
||||
#include "opm_operator.h"
|
||||
#include "ui_opm_operator.h"
|
||||
|
||||
#include <OperatorManagement/Gui/Common/operator_dialog_model.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
CustomViewOperator::CustomViewOperator(QWidget *parent)
|
||||
: AbstractDisplayWidget(parent)
|
||||
, m_ui(new Ui::CustomViewOperator)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
CustomViewOperator::~CustomViewOperator()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool CustomViewOperator::init(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return false;
|
||||
|
||||
m_ui->lbName->setText(rowData(idx, OperatorManagement::OperatorManagementDialogModel::Name).toString());
|
||||
m_ui->lbInfo->setText(rowData(idx, OperatorManagement::OperatorManagementDialogModel::Description).toString());
|
||||
return true;
|
||||
}
|
||||
} // namespace OperatorManagement
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CustomView for OPM Operator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-04-08
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Viewer/LtsDataView/abstract_display_widget.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CustomViewOperator;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class CustomViewOperator final : public LtsDataView::AbstractDisplayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomViewOperator(QWidget *parent = nullptr);
|
||||
~CustomViewOperator();
|
||||
bool init(const QModelIndex &idx) override;
|
||||
|
||||
private:
|
||||
Ui::CustomViewOperator* m_ui;
|
||||
|
||||
};
|
||||
} // namespace OperatorManagement
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CustomViewOperator</class>
|
||||
<widget class="QWidget" name="CustomViewOperator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>74</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbInfo">
|
||||
<property name="text">
|
||||
<string notr="true">Info</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement - Operator/User Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "operator_overview_dialog.h"
|
||||
#include "ui_operator_overview_dialog.h"
|
||||
|
||||
#include "operator_overview_dialog.h"
|
||||
#include "CustomViews/opm_operator.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
namespace OperatorManagement
|
||||
{
|
||||
OperatorOverviewDialog::OperatorOverviewDialog(const QString &windowTitle, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_windowTitle(windowTitle)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::OperatorOverviewDialog)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("OperatorDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &OperatorOverviewDialog::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Function_Group_User_Management"));
|
||||
}
|
||||
|
||||
OperatorOverviewDialog::~OperatorOverviewDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void OperatorOverviewDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, m_windowTitle);
|
||||
}
|
||||
|
||||
void OperatorOverviewDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool OperatorOverviewDialog::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> dtc;
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<OperatorManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
m_model = new OperatorManagementDialogModel(this, m_session->exerciseId());
|
||||
m_model->initModel(m_session, dtc);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewOperator(this); });
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::Id);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::EffectiveAcls);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::PrimaryGroupId);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::Image);
|
||||
m_ui->widget->hideColumn(OperatorManagementDialogModel::Columns::Workstation);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OperatorOverviewDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
}
|
||||
|
||||
} // namespace OperatorManagement
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OpeartorManagement - Operator/User Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/Gui/Common/operator_dialog_model.h>
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OperatorOverviewDialog;
|
||||
}
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class OperatorOverviewDialog : public LtsWidgets::LtsDialog
|
||||
, protected OperatorManagement::Interface::Ftc::OperatorRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OperatorOverviewDialog(const QString &windowTitle, QWidget *parent = nullptr);
|
||||
~OperatorOverviewDialog();
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void onOperatorRemoveReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
QString m_windowTitle;
|
||||
OperatorManagementDialogModel *m_model;
|
||||
Ui::OperatorOverviewDialog *m_ui;
|
||||
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPrint();
|
||||
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OperatorOverviewDialog</class>
|
||||
<widget class="QWidget" name="OperatorOverviewDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>674</width>
|
||||
<height>328</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Operator Overview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "opm_overview_gui_plugin.h"
|
||||
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include "operator_overview_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/OperatorManagement/opm_operator_rights.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.Overview"))
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<OperatorManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
}
|
||||
|
||||
void InterfaceImpl::showOperators(const QString &windowTitle)
|
||||
{
|
||||
m_session->addWidget(LtsWidgets::initDialog(new OperatorOverviewDialog(windowTitle),
|
||||
m_session),
|
||||
menuGroup(), QStringLiteral("OperatorOverview"));
|
||||
DEBUG_LOG(m_logger)<<"showOperators";
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Overview");
|
||||
plData.identifier = QLatin1String("_OpmShowOperatorOveriew");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:operator.svg"));
|
||||
plData.operatorRight = OperatorRights::OperatorSettingsRead;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onShowOperatorOverviewDialog(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//private
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowOperatorOverviewDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new OperatorOverviewDialog(tr("Overview"), parent), m_session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //namespace OperatorManagement
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_overview_gui_plugin_interface.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:opm.overview")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("OperatorOverviewGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return (partition == IDL::PartitionType::Exercise);
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public OperatorManagement::OverviewForeignGuiInterface
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override { return tr("Operators"); }
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override {return ( partition == IDL::PartitionType::Exercise );}
|
||||
|
||||
void showOperators(const QString &windowTitle) override final;
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowOperatorOverviewDialog(QWidget *parent);
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Malte Diers, SLSE, 2017-08-22
|
||||
#
|
||||
|
||||
SET(opm_settings_gui_SRCS
|
||||
operator_settings_dialog.cpp
|
||||
operator_settings_dialog.h
|
||||
|
||||
operator_settings_create_new_dialog.cpp
|
||||
operator_settings_create_new_dialog.h
|
||||
|
||||
opm_settings_gui_plugin.cpp
|
||||
opm_settings_gui_plugin.h
|
||||
|
||||
SettingsGroup/opm_settings_group.cpp
|
||||
SettingsGroup/opm_settings_group.h
|
||||
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(opm_settings_gui_SRCS
|
||||
operator_settings_dialog.ui
|
||||
operator_settings_create_new_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS OpmSettingsGuiPlugin MODULE ${opm_settings_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(OpmSettingsGuiPlugin
|
||||
NGLLogger
|
||||
OpmDataPluginInterface
|
||||
OpmGuiPluginInterface
|
||||
OpmChangePasswordGui
|
||||
FltDataPluginInterface
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsDataView
|
||||
LtsUtilsSettings
|
||||
LtsUtilsGuiDds
|
||||
nglwidgets
|
||||
ngltools
|
||||
FltAesGuiCommon
|
||||
LtsProjectionWorkstation
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(OpmSettingsGuiPlugin)
|
||||
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "opm_settings_group.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
SettingsGroup::SettingsGroup(const QString &group, const QString &id, SubSetHandler *handler, LtsUtils::OperatorSettings *opSettings)
|
||||
: m_group(group)
|
||||
, m_id(id)
|
||||
, m_subSetHandler(handler)
|
||||
, m_opSettings(opSettings)
|
||||
, m_logger(getLogger("SettingsGroup"))
|
||||
{
|
||||
m_logger.setNoSpace(false);
|
||||
}
|
||||
|
||||
bool SettingsGroup::init()
|
||||
{
|
||||
if (!m_subSetHandler || !m_opSettings)
|
||||
{
|
||||
// MQS-474 Crash beim Öffnen des Script-Editors:
|
||||
ERROR_LOG(m_logger) << " SettingsGroup::init() failed. this=" << this
|
||||
<< ", typeid.name='" << typeid(*this).name()
|
||||
<< ", m_id='" << m_id
|
||||
<< ", m_group='" << m_group;
|
||||
#ifdef LTS_DEBUG
|
||||
abort(); // Bitte Hinweis an Norbert
|
||||
#else
|
||||
return false;
|
||||
#endif // LTS_DEBUG
|
||||
}
|
||||
|
||||
m_data = jsonObjectFromSettings(m_group, m_id);
|
||||
return !m_data.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
QJsonValue SettingsGroup::value(const QString &key)
|
||||
{
|
||||
return m_data.value(key);
|
||||
}
|
||||
|
||||
|
||||
void SettingsGroup::setValue(const QString &key, const QJsonValue &value)
|
||||
{
|
||||
m_data.insert(key, value);
|
||||
}
|
||||
|
||||
|
||||
void SettingsGroup::registerSubset(const SubSet &subset)
|
||||
{
|
||||
m_subsets.append(subset);
|
||||
}
|
||||
|
||||
|
||||
void SettingsGroup::startLoad()
|
||||
{
|
||||
if (!aboutToLoad())
|
||||
return;
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
// MQS-474 Crash beim Öffnen des Script-Editors:
|
||||
if (!m_subSetHandler)
|
||||
abort(); // Bitte Hinweis an Norbert
|
||||
#else
|
||||
if (!m_subSetHandler)
|
||||
{
|
||||
ERROR_LOG(m_logger) << " SettingsGroup::startLoad() : no m_subSetHandler. this=" << this
|
||||
<< ", typeid.name='" << typeid(*this).name()
|
||||
<< ", m_id='" << m_id
|
||||
<< ", m_group='" << m_group;
|
||||
return;
|
||||
}
|
||||
#endif // LTS_DEBUG
|
||||
|
||||
for (SubSet &subset : m_subsets)
|
||||
{
|
||||
subset.data = m_data.value(subset.name); //.toObject();
|
||||
m_subSetHandler->loadSubSet(subset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SettingsGroup::startSave() // NOTE: saves settings from the workspaceId it gets from m_session->workspaceId, not the workspaceId it was given in the constructor !
|
||||
{
|
||||
if (!aboutToSave())
|
||||
return;
|
||||
for (SubSet &subset : m_subsets)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "saving11 subset for group: " << m_group
|
||||
<< ", id:" << m_id
|
||||
<< ", subset.name=" << subset.name
|
||||
<< ", subset.data=" << subset.data.toString();
|
||||
|
||||
bool saveSubSetOk = m_subSetHandler->saveSubSet(subset); // saveSubSet fills .data
|
||||
if (!saveSubSetOk)
|
||||
WARNING_LOG(m_logger) << "saving22 subset failed for group: " << m_group
|
||||
<< ", id:" << m_id
|
||||
<< ", subset.name=" << subset.name
|
||||
<< ", subset.data=" << subset.data.toString();
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "saving22 subset for group: " << m_group
|
||||
<< ", id:" << m_id
|
||||
<< ", subset.name=" << subset.name
|
||||
<< ", subset.data=" << subset.data.toString();
|
||||
|
||||
m_data.insert(subset.name, subset.data);
|
||||
}
|
||||
m_opSettings->setValue(m_group, m_id, QJsonDocument(m_data).toJson(QJsonDocument::Compact));
|
||||
}
|
||||
|
||||
|
||||
void SettingsGroup::startDelete()
|
||||
{
|
||||
if (!aboutToDelete())
|
||||
return;
|
||||
m_opSettings->removeValue(m_group, m_id);
|
||||
}
|
||||
|
||||
|
||||
QJsonObject SettingsGroup::jsonObjectFromSettings(const QString &group, const QString &id) const
|
||||
{
|
||||
QString settingsString = m_opSettings->value(group, id, QString()).toString();
|
||||
if (settingsString.isEmpty())
|
||||
return QJsonObject();
|
||||
|
||||
QJsonParseError err;
|
||||
QJsonDocument doc(QJsonDocument::fromJson(settingsString.toUtf8(), &err));
|
||||
|
||||
if (err.error != QJsonParseError::NoError)
|
||||
return QJsonObject();
|
||||
|
||||
return doc.object();
|
||||
}
|
||||
|
||||
|
||||
} //namespace OperatorManagement
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QVector>
|
||||
#include <OperatorManagement/logger.h>
|
||||
|
||||
namespace LtsUtils { class OperatorSettings; }
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
|
||||
enum class SubSetType
|
||||
{
|
||||
SS_UNKNOWN = -1,
|
||||
SS_MAP_SETTINGS,
|
||||
SS_FUNCTION_BARS,
|
||||
SS_FUNCTION_KEYS,
|
||||
SS_SYMBOL_FILTER,
|
||||
SS_BUILDING_COMPONENT_FILTER,
|
||||
SS_AES_FILTER
|
||||
};
|
||||
|
||||
|
||||
struct SubSet final
|
||||
{
|
||||
SubSet() = default;
|
||||
SubSet(const QString &_name, SubSetType _type = SubSetType::SS_UNKNOWN)
|
||||
: name(_name), type(_type), bIsSystemDefault(false) {}
|
||||
|
||||
void markAsSystemDefault(bool mark = true) { bIsSystemDefault = mark; }
|
||||
bool isMarkedAsSystemDefault() const { return bIsSystemDefault; }
|
||||
|
||||
QString name;
|
||||
SubSetType type = SubSetType::SS_UNKNOWN;
|
||||
QJsonValue data;
|
||||
bool bIsSystemDefault;
|
||||
};
|
||||
|
||||
|
||||
class SubSetHandler // OPM Setting's InterfaceImpl, which is a QObject, inherites this
|
||||
{
|
||||
public:
|
||||
SubSetHandler() = default;
|
||||
virtual ~SubSetHandler() = default;
|
||||
|
||||
virtual bool saveSubSet(SubSet &subset) = 0;
|
||||
virtual bool loadSubSet(SubSet &subset) = 0;
|
||||
};
|
||||
|
||||
|
||||
class SettingsGroup
|
||||
{
|
||||
public:
|
||||
SettingsGroup(const QString &group, const QString &id, SubSetHandler *handler, LtsUtils::OperatorSettings *opSettings);
|
||||
virtual ~SettingsGroup() = default;
|
||||
|
||||
bool init();
|
||||
|
||||
const QString &id() const { return m_id; }
|
||||
const QJsonObject &data() const { return m_data; }
|
||||
const QString &group() const { return m_group; }
|
||||
|
||||
void markSubsetAsSystemDefault(bool mark = true)
|
||||
{
|
||||
for (SubSet &itemRef : m_subsets)
|
||||
itemRef.markAsSystemDefault(mark);
|
||||
}
|
||||
bool isSubsetMarkedAsSystemDefault()
|
||||
{
|
||||
if (m_subsets.isEmpty())
|
||||
return false;
|
||||
return m_subsets.first().isMarkedAsSystemDefault();
|
||||
}
|
||||
|
||||
|
||||
QJsonValue value(const QString &key);
|
||||
void setValue(const QString &key, const QJsonValue &value);
|
||||
|
||||
void startLoad();
|
||||
void startSave();
|
||||
void startDelete();
|
||||
void registerSubset(const SubSet &subset);
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool aboutToLoad() { return true; }
|
||||
virtual bool aboutToSave() { return true; }
|
||||
virtual bool aboutToDelete() { return true; }
|
||||
|
||||
QJsonObject jsonObjectFromSettings(const QString &group, const QString &id) const;
|
||||
|
||||
QString m_group;
|
||||
QString m_id;
|
||||
SubSetHandler *m_subSetHandler; //not owning
|
||||
QJsonObject m_data;
|
||||
QVector<SubSet> m_subsets;
|
||||
LtsUtils::OperatorSettings *m_opSettings; //not owning
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
|
||||
} // namespace OperatorManagement
|
||||
Executable
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Create a new preset entry
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "operator_settings_create_new_dialog.h"
|
||||
#include "ui_operator_settings_create_new_dialog.h"
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <QComboBox>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
OperatorSettingsCreateNewDialog::OperatorSettingsCreateNewDialog(CreationType type,
|
||||
QComboBox *cbxNames,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_ui(new Ui::OperatorSettingsCreateNewDialog)
|
||||
, m_type(type)
|
||||
, m_cbxNames(cbxNames)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// hmpf
|
||||
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked,
|
||||
this, &OperatorSettingsCreateNewDialog::apply);
|
||||
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked,
|
||||
this, &OperatorSettingsCreateNewDialog::close);
|
||||
connect(m_ui->cbAsDefault, &QCheckBox::toggled,
|
||||
this, &OperatorSettingsCreateNewDialog::onToggled);
|
||||
|
||||
QString title;
|
||||
QString label;
|
||||
switch (m_type)
|
||||
{
|
||||
case CreationType::Workspace:
|
||||
title = tr("Workspace");
|
||||
label = tr("Workspace Name:");
|
||||
break;
|
||||
case CreationType::FilterPreset:
|
||||
title = tr("Filter Preset");
|
||||
label = tr("Filter Preset Name:");
|
||||
}
|
||||
m_ui->lbxName->setText(label);
|
||||
setWindowTitle(tr("Create New %1").arg(title));
|
||||
|
||||
// how is this done for LtsFramelessDialog?
|
||||
//setOnlineHelpFilename(QStringLiteral("Situation-Settings"));
|
||||
}
|
||||
|
||||
OperatorSettingsCreateNewDialog::~OperatorSettingsCreateNewDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void OperatorSettingsCreateNewDialog::onToggled(bool toggled)
|
||||
{
|
||||
if (toggled)
|
||||
{
|
||||
m_previousName = m_ui->leName->text();
|
||||
m_ui->leName->setText(QStringLiteral("default"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->leName->setText(m_previousName);
|
||||
}
|
||||
m_ui->leName->setEnabled(!toggled);
|
||||
}
|
||||
|
||||
void OperatorSettingsCreateNewDialog::apply()
|
||||
{
|
||||
const QString name = m_ui->leName->text();
|
||||
if (name.isEmpty())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Please fill the Name Field."), tr("Error"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (nameAlreadyInUse(name))
|
||||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case CreationType::Workspace:
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Workspace name is already in use."), tr("Error"));
|
||||
return;
|
||||
case CreationType::FilterPreset:
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Filter-Preset name is already in use."), tr("Error"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
close();
|
||||
emit resultReady(name);
|
||||
}
|
||||
|
||||
bool OperatorSettingsCreateNewDialog::nameAlreadyInUse(const QString &name) const
|
||||
{
|
||||
return m_cbxNames->findText(name) >= 0;
|
||||
}
|
||||
|
||||
} // OperatorManagement
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManagement - Create a new preset entry
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
class QComboBox;
|
||||
namespace Ui
|
||||
{
|
||||
class OperatorSettingsCreateNewDialog;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
enum class CreationType
|
||||
{
|
||||
Workspace,
|
||||
FilterPreset
|
||||
};
|
||||
|
||||
class OperatorSettingsCreateNewDialog final : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OperatorSettingsCreateNewDialog(CreationType type,
|
||||
QComboBox *cbxNames,
|
||||
QWidget *parent = nullptr);
|
||||
~OperatorSettingsCreateNewDialog();
|
||||
|
||||
signals:
|
||||
void resultReady(const QString &result);
|
||||
|
||||
private slots:
|
||||
void onToggled(bool toggled);
|
||||
|
||||
private:
|
||||
void apply();
|
||||
bool nameAlreadyInUse(const QString &name) const;
|
||||
|
||||
private:
|
||||
Ui::OperatorSettingsCreateNewDialog *m_ui;
|
||||
CreationType m_type;
|
||||
QComboBox *m_cbxNames;
|
||||
QString m_previousName;
|
||||
};
|
||||
|
||||
} // OperatorManagement
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OperatorSettingsCreateNewDialog</class>
|
||||
<widget class="QWidget" name="OperatorSettingsCreateNewDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>348</width>
|
||||
<height>79</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbxName">
|
||||
<property name="text">
|
||||
<string notr="true"><Name>:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leName">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Workspace Name</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAsDefault">
|
||||
<property name="toolTip">
|
||||
<string>If a new Workspace is saved as the default Workspace it will be saved with name 'default' and is loaded if a new app is started.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save as default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vs">
|
||||
<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="LtsWidgets::LtsDialogButtonBox" name="ltsDialogButtonBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1086
File diff suppressed because it is too large.
Load diff
+231
@@ -0,0 +1,231 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* OperatorManangement - Operator Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SettingsGroup/opm_settings_group.h"
|
||||
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <QBasicTimer>
|
||||
#include <QPointer>
|
||||
#include <QLabel>
|
||||
|
||||
enum LtsDate
|
||||
{
|
||||
DtgShort,
|
||||
DtgLong,
|
||||
Iso
|
||||
};
|
||||
|
||||
|
||||
namespace Ui { class OperatorSettingsDialog; }
|
||||
namespace LtsSession { class LtsSession; }
|
||||
namespace LtsUtils
|
||||
{
|
||||
class OperatorSettings;
|
||||
class ProjectSettings;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// OperatorManagementEditDialog
|
||||
// --------------------------------------------------------
|
||||
class OperatorSettingsDialog : public LtsWidgets::LtsDialog
|
||||
, protected OperatorManagement::Interface::Ftc::OperatorCreateModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OperatorSettingsDialog(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~OperatorSettingsDialog();
|
||||
|
||||
//OperatorCreateModifyReplyHandler interface
|
||||
void onOperatorCreateModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
bool init(const QMap<QString, SettingsGroup *> *workspaceMap,
|
||||
const QMap<QString, SettingsGroup *> *filterMap,
|
||||
bool enaDisaFilterPresets,
|
||||
bool enaDisaOpsettings);
|
||||
|
||||
void updateWorkspaceCombobox(const QString &preselectWorkspaceId = QString());
|
||||
void updateFilterPresetCombobox(const QString &preselectFilterId = QString());
|
||||
|
||||
signals:
|
||||
void signalCreateNewWorkspace(const QString &names);
|
||||
void signalCreateNewFilterPreset(const QString &name);
|
||||
|
||||
void signalOverwriteWorkspace(const QString &id, const QString &name, const QString &filterPresetId);
|
||||
void signalOverwriteFilterPreset(const QString &id, const QString &name);
|
||||
|
||||
void signalLoadWorkspace(const QString &id, bool loadFilterPreset);
|
||||
void signalLoadFilterPreset(const QString &id);
|
||||
|
||||
void signalDeleteWorkspace(const QString &id);
|
||||
void signalDeleteFilterPreset(const QString &id);
|
||||
|
||||
private slots:
|
||||
|
||||
void onWorkspaceLoad();
|
||||
void onFilterPresetLoad();
|
||||
|
||||
void onWorkspaceOverwrite();
|
||||
void onFilterPresetOverwrite();
|
||||
|
||||
void onWorkspaceCreateNew();
|
||||
void onFilterPresetCreateNew();
|
||||
|
||||
void onWorkspaceDelete();
|
||||
void onFilterPresetDelete();
|
||||
void onFilterPresetsComboboxIndexChanged(int index);
|
||||
|
||||
void onWorkspacesComboboxIndexChanged(int index);
|
||||
|
||||
void onChangePassword();
|
||||
void onChangeProfilePicture();
|
||||
|
||||
void onMineAreaInputModeChanged();
|
||||
|
||||
void onTimerTimeout();
|
||||
void onTempActions();
|
||||
|
||||
private:
|
||||
void enaDisaOpsettings(bool enabled);
|
||||
void enaDisaFilterPresets(bool enabled);
|
||||
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
void setFilterPresetComboboxIndexById(const QString &filterPresetId);
|
||||
void setWorkspaceComboboxIndexById(const QString &workspaceId);
|
||||
|
||||
void updateCombobox(QComboBox *cbx,
|
||||
const QMap<QString, SettingsGroup *> *items,
|
||||
const QPair<QString, QString> &defaultItem,
|
||||
const QString &preselectId);
|
||||
|
||||
QString selectedFilterId() const;
|
||||
QString selectedWorkspaceId() const;
|
||||
|
||||
QString currentWorkspaceId() const;
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::OperatorSettings *m_opSettings;
|
||||
QTimer *m_timer;
|
||||
Ui::OperatorSettingsDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
LtsSession::LtsSession *m_session;
|
||||
QPixmap m_operatorPixmap;
|
||||
QString m_keyCache;
|
||||
|
||||
const QMap<QString /*workspaceId*/, SettingsGroup *> *m_workspaceMap; // not owning
|
||||
const QMap<QString /*filterId*/, SettingsGroup *> *m_filterMap; // not owning
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*************** Tetra **************/
|
||||
|
||||
enum TetraShape { NoShape = 0, ZShape, SShape, LineShape, TShape, SquareShape,
|
||||
LShape, MirroredLShape
|
||||
};
|
||||
class TetraPiece
|
||||
{
|
||||
public:
|
||||
TetraPiece() { setShape(NoShape); }
|
||||
|
||||
void setRandomShape();
|
||||
void setShape(TetraShape shape);
|
||||
|
||||
TetraShape shape() const { return pieceShape; }
|
||||
int x(int index) const { return coords[index][0]; }
|
||||
int y(int index) const { return coords[index][1]; }
|
||||
int minX() const;
|
||||
int maxX() const;
|
||||
int minY() const;
|
||||
int maxY() const;
|
||||
TetraPiece rotatedLeft() const;
|
||||
TetraPiece rotatedRight() const;
|
||||
|
||||
private:
|
||||
void setX(int index, int x) { coords[index][0] = x; }
|
||||
void setY(int index, int y) { coords[index][1] = y; }
|
||||
|
||||
TetraShape pieceShape;
|
||||
int coords[4][2];
|
||||
};
|
||||
|
||||
class TetraBoard : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TetraBoard(QWidget *parent = nullptr);
|
||||
|
||||
void setNextPieceLabel(QLabel *label);
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void pause();
|
||||
|
||||
signals:
|
||||
void scoreChanged(int score);
|
||||
void levelChanged(int level);
|
||||
void linesRemovedChanged(int numLines);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
enum { BoardWidth = 10, BoardHeight = 22 };
|
||||
|
||||
TetraShape &shapeAt(int x, int y) { return board[(y * BoardWidth) + x]; }
|
||||
int timeoutTime() { return 1000 / (1 + level); }
|
||||
int squareWidth() { return contentsRect().width() / BoardWidth; }
|
||||
int squareHeight() { return contentsRect().height() / BoardHeight; }
|
||||
void clearBoard();
|
||||
void dropDown();
|
||||
void oneLineDown();
|
||||
void pieceDropped(int dropHeight);
|
||||
void removeFullLines();
|
||||
void newPiece();
|
||||
void showNextPiece();
|
||||
bool tryMove(const TetraPiece &newPiece, int newX, int newY);
|
||||
void drawSquare(QPainter &painter, int x, int y, TetraShape shape);
|
||||
|
||||
QBasicTimer timer;
|
||||
QPointer<QLabel> nextPieceLabel;
|
||||
bool isStarted;
|
||||
bool isPaused;
|
||||
bool isWaitingAfterLine;
|
||||
TetraPiece curPiece;
|
||||
TetraPiece nextPiece;
|
||||
int curX;
|
||||
int curY;
|
||||
int numLinesRemoved;
|
||||
int numPiecesDropped;
|
||||
int score;
|
||||
int level;
|
||||
TetraShape board[BoardWidth * BoardHeight];
|
||||
};
|
||||
|
||||
}
|
||||
+557
@@ -0,0 +1,557 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OperatorSettingsDialog</class>
|
||||
<widget class="QWidget" name="OperatorSettingsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1133</width>
|
||||
<height>417</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="9" column="0" colspan="3">
|
||||
<spacer name="vspacer">
|
||||
<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 row="2" column="0">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cbScriptsHideOnDrag">
|
||||
<property name="text">
|
||||
<string>Hide detail area when draging topics</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbWorkspaces">
|
||||
<property name="title">
|
||||
<string>Workspace</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="verticalSpacing">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbWorkspaces">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="7">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="8" rowspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QPushButton" name="pbLoadWorkspace">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pbOverwriteWorkspace">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QPushButton" name="pbDeleteWorkspace">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QPushButton" name="pbCreateNewWorkspace">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save As</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QPushButton" name="pbDEBUGNewWsID">
|
||||
<property name="text">
|
||||
<string notr="true">[Generate New WsID]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbFilterPresets">
|
||||
<property name="title">
|
||||
<string>Filter Presets</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="5">
|
||||
<spacer name="hsFilterPresets">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pbLoadFilterPreset">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pbOverwriteFilterPreset">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pbCreateNewFilterPreset">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save As</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbFilterPresets">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pbDeleteFilterPreset">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbOperator">
|
||||
<property name="title">
|
||||
<string>Operator</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="LtsWidgets::LtsProfileButton" name="ltsProfileButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pbChangePassword">
|
||||
<property name="text">
|
||||
<string>Change Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="hsOperator">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pbTempActions">
|
||||
<property name="text">
|
||||
<string>Temporary Actions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbTime">
|
||||
<property name="title">
|
||||
<string>Time</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="3" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbTimeZone">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbxTimeZone">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time Zone:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbxFixTime">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fix Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbxTimeOffset">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time Offset:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QTimeEdit" name="teTimeOffset">
|
||||
<property name="displayFormat">
|
||||
<string notr="true">mm:ss</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsDateTimeEdit" name="ltsDateTimeEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbTimeDisplay">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbxTimeDisplay">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time Display:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="5">
|
||||
<spacer name="hsTime">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbMineArea">
|
||||
<property name="title">
|
||||
<string>Mine Area</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="2">
|
||||
<spacer name="hsMineArea">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbxInputMode">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Input Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbMineAreaInputMode"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Scripts:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsProfileButton</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_profile_button.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDateTimeEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_date_time_edit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cbWorkspaces</tabstop>
|
||||
<tabstop>pbLoadWorkspace</tabstop>
|
||||
<tabstop>pbOverwriteWorkspace</tabstop>
|
||||
<tabstop>pbCreateNewWorkspace</tabstop>
|
||||
<tabstop>pbDeleteWorkspace</tabstop>
|
||||
<tabstop>pbDEBUGNewWsID</tabstop>
|
||||
<tabstop>cbFilterPresets</tabstop>
|
||||
<tabstop>pbLoadFilterPreset</tabstop>
|
||||
<tabstop>pbOverwriteFilterPreset</tabstop>
|
||||
<tabstop>pbCreateNewFilterPreset</tabstop>
|
||||
<tabstop>pbDeleteFilterPreset</tabstop>
|
||||
<tabstop>pbChangePassword</tabstop>
|
||||
<tabstop>pbTempActions</tabstop>
|
||||
<tabstop>ltsDateTimeEdit</tabstop>
|
||||
<tabstop>teTimeOffset</tabstop>
|
||||
<tabstop>cbTimeZone</tabstop>
|
||||
<tabstop>cbTimeDisplay</tabstop>
|
||||
<tabstop>cbMineAreaInputMode</tabstop>
|
||||
<tabstop>cbScriptsHideOnDrag</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1110
File diff suppressed because it is too large.
Load diff
+178
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for OperatorManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <OperatorManagement/logger.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_gui_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_settings_gui_plugin_interface.h>
|
||||
#include <FilterManagement/flt_participant_plugin_interface.h>
|
||||
#include <FilterManagement/flt_aes_plugin_interface.h>
|
||||
#include <FilterManagement/flt_building_cmpnt_plugin_interface.h>
|
||||
#include <FilterManagement/flt_ftc.h>
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
|
||||
#include "SettingsGroup/opm_settings_group.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class OperatorSettings;
|
||||
class ProjectSettings;
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class OperatorSettingsDialog;
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:opm.settings")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("OperatorSettingsGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType ) const override { return true; }
|
||||
};
|
||||
|
||||
class InterfaceImpl final
|
||||
: public QObject
|
||||
, public ForeignSettingsGuiInterface
|
||||
, public GuiPluginBase::Interface
|
||||
, public FilterManagement::Interface::Ftc::SymbolAppearanceUpdateReplyHandler
|
||||
, public FilterManagement::Interface::Ftc::AesFilterUpdateReplyHandler
|
||||
, public FilterManagement::Interface::Ftc::BuildingComponentFilterUpdateReplyHandler
|
||||
|
||||
, public SubSetHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
~InterfaceImpl();
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override { return tr("Operators"); }
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool availableInPartition(IDL::PartitionType ) const override { return true; }
|
||||
|
||||
// load workspace after the settings were initialized by opm login
|
||||
int executionPriority() const override { return 1; /* after opm login (0) */ }
|
||||
void executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground) override;
|
||||
|
||||
private:
|
||||
// AesFilterUpdateReplyHandler interface
|
||||
void onAesFilterUpdateReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
// SymbolAppearanceUpdateReplyHandler interface
|
||||
void onSymbolAppearanceUpdateReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
// BuildingComponentFilterUpdateReplyHandler interface
|
||||
void onBuildingComponentFilterUpdateReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
|
||||
// ForeignSettingsGuiInterface interface
|
||||
void callWorkspaceSaveUnsaved(const QString &saveAsWorkspaceId) override final;
|
||||
|
||||
// SubSetHandler interface
|
||||
bool saveSubSet(SubSet &subset) override final;
|
||||
bool loadSubSet(SubSet &subset) override final;
|
||||
|
||||
signals:
|
||||
void signalWorkspaceSaveFinished(const QString &workspaceId);
|
||||
void signalFilterPresetSaveFinished(const QString &filterPresetId);
|
||||
|
||||
void signalWorkspaceLoadFinished(const QString &workspaceId);
|
||||
void signalFilterPresetLoadFinished(const QString &filterPresetId);
|
||||
|
||||
void signalWorkspaceDeleteFinished(const QString &workspaceId);
|
||||
void signalFilterPresetDeleteFinished(const QString &filterPresetId);
|
||||
|
||||
private slots:
|
||||
void slotOnSessionReady();
|
||||
void onOperatorSettingsValueChanged(const QString &group, const QString &identifier, const QVariant &value);
|
||||
void onOperatorSettingsValueRemoved(const QString &group, const QString &identifier);
|
||||
|
||||
private:
|
||||
void createNewWorkspace(const QString &workspaceName);
|
||||
void createNewFilterPreset(const QString &filterPresetName);
|
||||
|
||||
bool workspaceExists(const QString &workspaceId) const;
|
||||
QString defaultWorkspaceId() const;
|
||||
|
||||
bool workspaceLoad(const QString &workspaceId, bool loadFilterPreset = true);
|
||||
void workspaceSave(const QString &workspaceId, const QString &workspaceName, const QString &filterPresetId = QString());
|
||||
void workspaceDelete(const QString &workspaceId);
|
||||
void workspaceLoadUnsaved(const QString &workspaceId);
|
||||
void workspaceSaveUnsaved(const QString &workspaceId, const QString &filterPresetId);
|
||||
void workspaceDeleteUnsaved();
|
||||
void fillWorkspaceMapFromSettings();
|
||||
|
||||
QString defaultFilterPresetId() const;
|
||||
bool filterPresetLoad(const QString &filterPresetId);
|
||||
void filterPresetDelete(const QString &filterPresetId);
|
||||
void filterPresetLoadUnsaved(const QString &filterPresetId);
|
||||
void filterPresetSave(const QString &filterPresetId, const QString &filterPresetName);
|
||||
void filterPresetSaveUnsaved(const QString &filterPresetId);
|
||||
void filterPresetDeleteUnsaved();
|
||||
void fillFilterMapFromSettings();
|
||||
|
||||
LtsWidgets::LtsDialog *onShowOperatorSettingsDialog(QWidget *parent);
|
||||
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> m_fltParticipantIfc;
|
||||
std::shared_ptr<FilterManagement::ForeignAesGuiInterface> m_fltAesIfc;
|
||||
std::shared_ptr<FilterManagement::ForeignFltBuildingComponentGuiInterface> m_fltBuildingComponentIfc;
|
||||
std::shared_ptr<FilterManagement::Interface::Ftc> m_fltFtc;
|
||||
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapIfc;
|
||||
|
||||
|
||||
LtsUtils::OperatorSettings *m_opSettings;
|
||||
|
||||
QPointer<OperatorSettingsDialog> m_operatorSettingsDialog;
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
SettingsGroup *m_unsavedWorkspace;
|
||||
SettingsGroup *m_unsavedFilterPreset;
|
||||
bool m_validOperatorMapSettingsSent;
|
||||
|
||||
QMap<QString /*workspaceId*/, SettingsGroup *> m_workspaceMap;
|
||||
QMap<QString /*filterId*/, SettingsGroup *> m_filterMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Workspace final: public SettingsGroup
|
||||
{
|
||||
public:
|
||||
Workspace(const QString &id, SubSetHandler *handler, LtsUtils::OperatorSettings *opSettings);
|
||||
};
|
||||
|
||||
|
||||
class FilterPreset final : public SettingsGroup
|
||||
{
|
||||
public:
|
||||
FilterPreset(const QString &id, SubSetHandler *handler, LtsUtils::OperatorSettings *opSettings);
|
||||
};
|
||||
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -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)
|
||||
|
||||
|
||||
+142
@@ -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
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin Interface for OperatorManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <OperatorManagement/opm_dtc.h>
|
||||
#include <OperatorManagement/opm_ftc.h>
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class ForeignDataInterface;
|
||||
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<OperatorManagement::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<OperatorManagement::Interface::Ftc> getFtc() = 0;
|
||||
virtual std::shared_ptr<ForeignDataInterface> getForeignDataInterface() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The ForeignInterface class provides methods and signals for foreign plugins, that need
|
||||
* access to the data of this DataPlugin
|
||||
*/
|
||||
class ForeignDataInterface
|
||||
{
|
||||
public:
|
||||
ForeignDataInterface() = default;
|
||||
virtual ~ForeignDataInterface() = default;
|
||||
|
||||
virtual void onSendKeepAlive() = 0;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Mueller, SGAS, 2017-10-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSet>
|
||||
#include <functional>
|
||||
|
||||
class QWidget;
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsComboBox;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class ForeignGuiComboboxInterface
|
||||
{
|
||||
|
||||
public:
|
||||
ForeignGuiComboboxInterface() = default;
|
||||
virtual ~ForeignGuiComboboxInterface() = default;
|
||||
|
||||
enum CbxOperatorFilter
|
||||
{
|
||||
eOperators = 0x01,
|
||||
eOc = 0x02,
|
||||
eAll = eOperators|eOc
|
||||
};
|
||||
|
||||
virtual bool fillOperatorComboBox(LtsWidgets::LtsComboBox *cbx, CbxOperatorFilter filter = eOperators) = 0;
|
||||
|
||||
// ActiveApps:
|
||||
virtual bool fillActiveAppOperatorComboBox(LtsWidgets::LtsComboBox *cbx, int appId, int exerciseId, int preSelectedOperatorId = -1) = 0;
|
||||
virtual bool fillActiveAppScreenComboBox(LtsWidgets::LtsComboBox *cbx, int appId, int operatorId, int exerciseId, bool preSelectTopmost = false) = 0;
|
||||
};
|
||||
|
||||
} // namespace OperatorManagement
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
//#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class OverviewForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
OverviewForeignGuiInterface() = default;
|
||||
virtual ~OverviewForeignGuiInterface() = default;
|
||||
|
||||
virtual void showOperators(const QString &windowTitle) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Roeskens, NLSE, 2018-04-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
|
||||
class ForeignSettingsGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignSettingsGuiInterface() = default;
|
||||
virtual ~ForeignSettingsGuiInterface() = default;
|
||||
|
||||
virtual void callWorkspaceSaveUnsaved(const QString &saveAsWorkspaceId = QString()) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user