Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+212
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseChooser Payload UI
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-08-12
|
||||
*/
|
||||
|
||||
#include "exm_chooser.h"
|
||||
#include "ui_exm_chooser.h"
|
||||
|
||||
#include "exm_dialog_model.h"
|
||||
#include "CustomViews/exm_exercise.h"
|
||||
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
#include <OperatorManagement/opm_operator_rights.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
|
||||
ExerciseChooser::ExerciseChooser(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::ExerciseChooser)
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(false);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setWindowTitle(tr("Select Exercise"));
|
||||
setWindowFlags(windowFlags() | /*Qt::WindowStaysOnTopHint | */Qt::FramelessWindowHint); // hints..
|
||||
|
||||
m_ui->widget->seamless();
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ExerciseChooser::enaDisa);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::doubleClicked,
|
||||
this, &ExerciseChooser::slotExerciseSelected, Qt::QueuedConnection);
|
||||
|
||||
connect(m_ui->pbSelect, &QPushButton::clicked,
|
||||
this, &ExerciseChooser::slotExerciseSelected, Qt::QueuedConnection);
|
||||
|
||||
connect(m_ui->pbQuit, &QPushButton::clicked,
|
||||
this, &ExerciseChooser::signalQuit, Qt::QueuedConnection);
|
||||
connect(m_ui->pbQuit, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
//LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait(); // resume plugin manager's loading screen after this ui
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
m_close = true;
|
||||
close();
|
||||
});
|
||||
|
||||
//LtsWidgets::LtsGlobalWaitDialog::getInstance()->done(); // interrupt plugin manager's loading screen for this ui
|
||||
}
|
||||
|
||||
|
||||
ExerciseChooser::~ExerciseChooser()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
bool ExerciseChooser::init(LtsSession::LtsSession *session)
|
||||
{
|
||||
m_session = session;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> dtc;
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(dtc))
|
||||
return false;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Ftc> ftc;
|
||||
if (!session->getFtc<ExerciseManagement::DataInterface>(ftc))
|
||||
return false;
|
||||
|
||||
if (!session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
|
||||
return false;
|
||||
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> pdmDtc;
|
||||
if (!session->getDtc<ProjectDataManagement::DataInterface>(pdmDtc))
|
||||
return false;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> asmDtc;
|
||||
if (!session->getDtc<AssetManagement::DataInterface>(asmDtc))
|
||||
return false;
|
||||
|
||||
|
||||
delete m_model;
|
||||
delete m_proxyModel;
|
||||
|
||||
m_model = new ExerciseManagementDialogModel(this);
|
||||
m_model->initModel(dtc, ftc, asmDtc, pdmDtc, true, true);
|
||||
|
||||
m_proxyModel = new ExerciseManagementProxyModel(this);
|
||||
m_proxyModel->setAdminExerciseVisible(true);
|
||||
m_proxyModel->setVisibleExerciseStates({ExerciseState::Created, ExerciseState::Started, ExerciseState::Paused, ExerciseState::Stopped});
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_proxyModel->setSortRole(Qt::UserRole);
|
||||
m_proxyModel->sort(0);
|
||||
|
||||
|
||||
CustomViewExercise *customViewExerciseDummy = new CustomViewExercise();
|
||||
m_model->setImageSizeConstraints(customViewExerciseDummy->imageSize());
|
||||
delete customViewExerciseDummy;
|
||||
|
||||
|
||||
connect(m_opmDtc.get(), &OperatorManagement::Interface::Dtc::userChanged,
|
||||
this, &ExerciseChooser::onUserChanged);
|
||||
const int opId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
onUserChanged(m_opmDtc->user(opId), DataModification::eAdded);
|
||||
|
||||
m_ui->widget->selectCustomView();
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
m_ui->widget->setModel(m_proxyModel, [this]() { return new CustomViewExercise(this); });
|
||||
for (int i = 0; i < m_proxyModel->columnCount(); ++i)
|
||||
m_ui->widget->hideColumn(i);
|
||||
m_ui->widget->showColumn(ExerciseManagement::ExerciseManagementDialogModel::Name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ExerciseChooser::enaDisa()
|
||||
{
|
||||
m_ui->pbSelect->setEnabled(m_ui->widget->selectedRows().length() == 1);
|
||||
}
|
||||
|
||||
|
||||
void ExerciseChooser::reject()
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
|
||||
if (!m_selected)
|
||||
emit signalQuit();
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
|
||||
void ExerciseChooser::closeEvent(QCloseEvent *event) // TODO: override reject() TODO: renew this method
|
||||
{
|
||||
if (!m_close)
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
|
||||
if (!m_selected)
|
||||
emit signalQuit();
|
||||
}
|
||||
|
||||
|
||||
void ExerciseChooser::slotExerciseSelected()
|
||||
{
|
||||
if (m_selected)
|
||||
return;
|
||||
|
||||
m_selected = true;
|
||||
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const Exercise ex = m_model->getRowData(idx.row());
|
||||
|
||||
if (ex.id() < 0)
|
||||
return;
|
||||
|
||||
setEnabled(false);
|
||||
//hide();
|
||||
//QCoreApplication::processEvents();
|
||||
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
emit signalSelectExercise(ex.id());
|
||||
m_close = true;
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void ExerciseChooser::onUserChanged(const OperatorManagement::User &user, DataModification mod)
|
||||
{
|
||||
if (!m_session || !m_proxyModel)
|
||||
return;
|
||||
const int opId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
if (user.id() != opId)
|
||||
return;
|
||||
|
||||
if (mod == DataModification::eRemoved)
|
||||
{
|
||||
m_proxyModel->setVisibleExerciseIds({});
|
||||
return;
|
||||
}
|
||||
|
||||
const bool hasAdminRights = std::any_of(user.effectiveAcls().begin(), user.effectiveAcls().end(),
|
||||
[](int val) { return val == OperatorRights::Administrator; });
|
||||
if (m_session->app() == LtsAppDescriptor::App::OC ||
|
||||
(hasAdminRights && (m_session->app() == LtsAppDescriptor::App::Situation ||
|
||||
m_session->app() == LtsAppDescriptor::App::PlanEditor)))
|
||||
m_proxyModel->setAdminExerciseVisible(true);
|
||||
else
|
||||
m_proxyModel->setAdminExerciseVisible(false);
|
||||
m_proxyModel->setVisibleExerciseIds(LtsUtils::convert<QVector<int>>(user.exerciseIds()));
|
||||
}
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseChooser Payload UI
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Mike Wille, SLSE, 2016-08-12
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
#include <memory>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ExerciseChooser;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
class User;
|
||||
namespace Interface {
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
class ExerciseManagementDialogModel;
|
||||
class ExerciseManagementProxyModel;
|
||||
|
||||
class ExerciseChooser : public QDialog // TODO: move me directly to Gui ?
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExerciseChooser(QWidget *parent = nullptr);
|
||||
bool init(LtsSession::LtsSession *session);
|
||||
~ExerciseChooser();
|
||||
|
||||
void selectExercise(int exerciseId);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void slotExerciseSelected();
|
||||
void enaDisa();
|
||||
void reject() override;
|
||||
void onUserChanged(const OperatorManagement::User &user, DataModification mod);
|
||||
|
||||
signals:
|
||||
void signalQuit();
|
||||
void signalSelectExercise(int exercise);
|
||||
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
Ui::ExerciseChooser *m_ui{nullptr};
|
||||
ExerciseManagementDialogModel *m_model{nullptr};
|
||||
ExerciseManagementProxyModel *m_proxyModel{nullptr};
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
bool m_selected{false};
|
||||
bool m_close{false};
|
||||
|
||||
};
|
||||
|
||||
} // namespace ExerciseManagement
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExerciseChooser</class>
|
||||
<widget class="QDialog" name="ExerciseChooser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1300</width>
|
||||
<height>820</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>RME EXCON - Exercise Chooser</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="excLayout" stretch="0,999">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Login to Exercise:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbQuit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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="pbSelect">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
Reference in new issue
Block a user