Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+39
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# $Id: CMakeLists.txt 49595 2020-01-24 13:28:42Z hjl $
|
||||
# $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/CMakeLists.txt $
|
||||
# $Author: hjl $
|
||||
#
|
||||
# Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
#
|
||||
|
||||
SET(src
|
||||
ism_exercise_assignment_classic_gui_plugin.cpp
|
||||
|
||||
#ism_exercise_assignment_dialog.h
|
||||
ism_exercise_assignment_dialog.cpp
|
||||
#ism_exercise_assignment_dialog_model.h
|
||||
ism_exercise_assignment_dialog_model.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(src
|
||||
ism_exercise_assignment_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS IsmExerciseAssignmentClassicGuiPlugin MODULE ${src})
|
||||
NGL_TARGET_LINK_LIBRARIES(IsmExerciseAssignmentClassicGuiPlugin
|
||||
NGLLogger
|
||||
nglwidgets
|
||||
LtsPrinting
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
IsmDataPluginInterface
|
||||
IsmShared
|
||||
IsmExerciseAssignmentClassicGuiPluginInterface
|
||||
ExmDataPluginInterface
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(IsmExerciseAssignmentClassicGuiPlugin)
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for AudioVideoConfig
|
||||
* $Id: ism_audio_video_config_gui_plugin.cpp 52254 2020-10-06 11:50:47Z wille_m $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/ism_audio_video_config_gui_plugin.cpp $
|
||||
* $Author: wille_m $
|
||||
*
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
*/
|
||||
|
||||
#include "ism_exercise_assignment_classic_gui_plugin.h"
|
||||
#include "ism_exercise_assignment_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_background_widget.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <InfrastructureManagement/logger.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
|
||||
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("AudioVideoConfigPlugin"))
|
||||
// , m_ismDtc(nullptr)
|
||||
// , m_ismFtc(nullptr)
|
||||
, m_exmDtc(nullptr)
|
||||
// , m_ismDataInterface(nullptr)
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
LtsWidgets::PluginData plugin;
|
||||
|
||||
plugin.menuGroup = tr("Exercise Assignment");
|
||||
plugin.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
|
||||
plugin.menuText = tr("Exercise Assignment");
|
||||
plugin.identifier = QLatin1String("IsmAvcExerciseAssignmentDialog_CLASSIC");
|
||||
plugin.menuIcon = QIcon(QLatin1String("icon:set_exercise_process.svg"));
|
||||
plugin.createWidgetFunc = [this](QWidget * parent) -> LtsWidgets::LtsDialog *
|
||||
{
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ismFtc;
|
||||
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(ismDtc)
|
||||
|| !m_session->getFtc<InfrastructureManagement::DataInterface>(ismFtc))
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(m_session->baseLayoutWidget(), tr("The Infrastructure Management is not available!"), tr("Cannot open Exercise Assignment"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return LtsWidgets::initDialog(new ExerciseAssignmentDialog(m_session, parent),
|
||||
ismDtc, ismFtc, m_exmDtc);
|
||||
};
|
||||
|
||||
return {plugin};
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
return /*m_session->getDtc<DataInterface>(m_ismDtc) &&
|
||||
m_session->getFtc<DataInterface>(m_ismFtc) &&*/
|
||||
m_session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc)/* &&
|
||||
m_session->getForeignDataInterface<DataInterface>(m_ismDataInterface)*/;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
//m_ismDataInterface = nullptr;
|
||||
m_exmDtc = nullptr;
|
||||
}
|
||||
|
||||
//void InterfaceImpl::executePayload(LtsWidgets::LtsBackgroundWidget *)
|
||||
//{
|
||||
// DEBUG_LOG(m_logger) << "executePayload";
|
||||
|
||||
// connect(this, &InterfaceImpl::signalSuccess,
|
||||
// m_session, &LtsSession::LtsSession::slotExecuteNextPayload, Qt::QueuedConnection);
|
||||
|
||||
// emit signalSuccess();
|
||||
//}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for AudioVideoConfig
|
||||
* $Id: ism_audio_video_config_gui_plugin.h 58505 2022-11-28 15:41:44Z wille_m $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/ism_audio_video_config_gui_plugin.h $
|
||||
* $Author: wille_m $
|
||||
*
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <InfrastructureManagement/ism_ftc.h>
|
||||
#include <InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <InfrastructureManagement/ism_exercise_assignment_classic_gui_plugin_interface.h>
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ism.eac")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return ForeignExerciseAssignmentClassicGuiInterface::pluginName(); }
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final
|
||||
: public QObject
|
||||
, public ForeignExerciseAssignmentClassicGuiInterface
|
||||
, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QString menuGroup() const override { return tr("Training Voice Communication"); }
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
|
||||
// // be able to show exercise chooser
|
||||
// int executionPriority() const override { return 9999; }
|
||||
// void executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground) override;
|
||||
|
||||
private: // attributes
|
||||
// std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
// std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ismFtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
//std::shared_ptr<ForeignDataInterface> m_ismDataInterface;
|
||||
signals:
|
||||
void signalSuccess();
|
||||
};
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ExerciseAssignmentDialog shows how many assets are needed for a specific schedule, needed elsewhere,
|
||||
* totally possessed, free, and missing
|
||||
* $Id: ism_exercise_assignment_dialog.cpp 57779 2022-08-03 08:07:45Z ojog_i $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/ExerciseAssignment/ism_exercise_assignment_dialog.cpp $
|
||||
* $Author: ojog_i $
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
*/
|
||||
|
||||
#include "ism_exercise_assignment_dialog.h"
|
||||
#include "ui_ism_exercise_assignment_dialog.h"
|
||||
|
||||
#include "ism_exercise_assignment_dialog_model.h"
|
||||
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
|
||||
ExerciseAssignmentDialog::ExerciseAssignmentDialog(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::ExerciseAssignmentDialog)
|
||||
, m_ismDtc(nullptr)
|
||||
, m_ismFtc(nullptr)
|
||||
, m_exmDtc(nullptr)
|
||||
, m_model(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("ExerciseAssignmentDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->assetListView->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ExerciseAssignmentDialog::onPrint);
|
||||
setOnlineHelpFilename(QStringLiteral("Ressourcen-Exercise_Assignment"));
|
||||
}
|
||||
|
||||
ExerciseAssignmentDialog::~ExerciseAssignmentDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ExerciseAssignmentDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Exercise Assignment"));
|
||||
}
|
||||
|
||||
bool ExerciseAssignmentDialog::init(const std::shared_ptr<Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ismFtc,
|
||||
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc)
|
||||
{
|
||||
m_ismDtc = ismDtc;
|
||||
m_ismFtc = ismFtc;
|
||||
m_exmDtc = exmDtc;
|
||||
delete m_model;
|
||||
|
||||
if (!m_ismFtc->enableInstrumentationAssetModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FT InstrumentationAssetModify of ISM";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_ismFtc->enableMainStructureElementModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable FT MainStructureElementModify of ISM";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_exmDtc->enableExercise())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable DT Exercise of EXM";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add all available exercises to comboBox
|
||||
const QMap<qint32, ExerciseManagement::Exercise> exercises = m_exmDtc->exercises();
|
||||
m_ui->cbExercises->addItem(QStringLiteral("-"), 0);
|
||||
for (const auto &exercise : exercises)
|
||||
m_ui->cbExercises->addItem(QString::fromStdString(exercise.name()), exercise.id());
|
||||
|
||||
m_ui->pbAssigned->setEnabled(false);
|
||||
|
||||
m_model = new ExerciseAssignmentDialogModel(this);
|
||||
if (!m_model->initModel(m_ismDtc, m_exmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->assetListView->setModel(m_model);
|
||||
|
||||
connect(m_ui->assetListView, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ExerciseAssignmentDialog::onSelectionChanged);
|
||||
connect(m_ui->pbAssigned, &QPushButton::clicked,
|
||||
this, &ExerciseAssignmentDialog::onAssignedClicked);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ExerciseAssignmentDialog::onMainStructureElementModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ExerciseAssignmentDialog::onAssignedClicked()
|
||||
{
|
||||
const QModelIndexList selectedIndexs = m_ui->assetListView->selectedRows();
|
||||
if (selectedIndexs.size() < 1)
|
||||
return;
|
||||
|
||||
for (const auto &index : selectedIndexs)
|
||||
{
|
||||
m_requestHelper->addRequest([this, index]()
|
||||
{
|
||||
MainStructureElementModifyRequest request;
|
||||
MainStructureElement &req = request;
|
||||
req = m_model->getRowData(index.row());
|
||||
|
||||
QJsonObject obj = QJsonDocument::fromJson(QByteArray::fromStdString(request.properties())).object();
|
||||
|
||||
// Exercise choose?
|
||||
QJsonArray array;
|
||||
if (m_ui->cbExercises->currentIndex() != 0)
|
||||
array.push_back(m_ui->cbExercises->currentData().toInt());
|
||||
obj.insert(QStringLiteral("available_in_exercise"), array);
|
||||
request.properties(QJsonDocument(obj).toJson(QJsonDocument::Compact).toStdString());
|
||||
|
||||
return m_ismFtc->mainStructureElementModifyRequest(request, this);
|
||||
|
||||
});
|
||||
}
|
||||
m_requestHelper->startRequests();
|
||||
//m_requestHelper->startSingleRequest([this, request]() {return m_ismFtc->mainStructureElementModifyRequest(request, this);});
|
||||
}
|
||||
|
||||
void ExerciseAssignmentDialog::onSelectionChanged()
|
||||
{
|
||||
const auto selectedIndexes = m_ui->assetListView->selectedRows();
|
||||
m_ui->pbAssigned->setEnabled(!selectedIndexes.isEmpty());
|
||||
m_ui->cbExercises->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void ExerciseAssignmentDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->assetListView->treeView());
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The AssetListDialog shows how many assets are needed for a specific schedule, needed elsewhere,
|
||||
* totally possessed, free, and missing
|
||||
* $Id: ism_exercise_assignment_dialog.h 45935 2019-03-08 08:36:11Z ehrlicher $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/ExerciseAssignment/ism_exercise_assignment_dialog.h $
|
||||
* $Author: ehrlicher $
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <InfrastructureManagement/ism_ftc.h>
|
||||
#include <InfrastructureManagement/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ExerciseAssignmentDialog;
|
||||
}
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
class ExerciseAssignmentDialogModel;
|
||||
|
||||
class ExerciseAssignmentDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected InfrastructureManagement::Interface::Ftc::MainStructureElementModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExerciseAssignmentDialog(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~ExerciseAssignmentDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &ismDtc, const std::shared_ptr<Interface::Ftc> &ismFtc, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc);
|
||||
void onMainStructureElementModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAssignedClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
|
||||
private: // methods
|
||||
void retranslate() override;
|
||||
|
||||
private: // attributes
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::ExerciseAssignmentDialog *m_ui;
|
||||
std::shared_ptr<Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ismFtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
ExerciseAssignmentDialogModel *m_model;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
}; // class AssetListDialogModel
|
||||
} // namespace InfrastructureManagement
|
||||
Lts/Plugins/InfrastructureManagement/Gui/ExerciseAssignmentClassic/ism_exercise_assignment_dialog.ui
Executable
+70
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExerciseAssignmentDialog</class>
|
||||
<widget class="QWidget" name="ExerciseAssignmentDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>630</width>
|
||||
<height>328</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="assetListView"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbExercises">
|
||||
<property name="text">
|
||||
<string>Exercises:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbExercises">
|
||||
<property name="currentText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbAssigned">
|
||||
<property name="text">
|
||||
<string>Assign to selection</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>
|
||||
</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>
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ExerciseAssignmentDialogModel provices data for AssetListDialog
|
||||
* $Id: ism_exercise_assignment_dialog_model.cpp 49203 2019-12-17 09:50:35Z rudolphus_g $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/ExerciseAssignment/ism_exercise_assignment_dialog_model.cpp $
|
||||
* $Author: rudolphus_g $
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
*/
|
||||
|
||||
#include "ism_exercise_assignment_dialog_model.h"
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
using namespace InfrastructureManagement;
|
||||
|
||||
ExerciseAssignmentDialogModel::ExerciseAssignmentDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<MainStructureElement>(
|
||||
{
|
||||
tr("Name"),
|
||||
tr("Assigned Exercise")
|
||||
},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_exmDtc(nullptr)
|
||||
, m_logger(getLogger("ExerciseAssignmentDialogModel"))
|
||||
{
|
||||
}
|
||||
|
||||
ExerciseAssignmentDialogModel::~ExerciseAssignmentDialogModel()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant ExerciseAssignmentDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const MainStructureElement ¤tMainStructureElement = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return m_dtc->getBuildingDisplayName(currentMainStructureElement.id());
|
||||
case ASSIGNED_EXERCISES:
|
||||
{
|
||||
if (!currentMainStructureElement.properties().size())
|
||||
return QChar(QLatin1Char('-'));
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(QByteArray::fromStdString(currentMainStructureElement.properties()), &parseError);
|
||||
|
||||
if (parseError.error != QJsonParseError::NoError)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Could not parse JSON props of building with ID "
|
||||
<< currentMainStructureElement.id()
|
||||
<< ". Reason: "
|
||||
<< parseError.errorString()
|
||||
<< "; JSON: "
|
||||
<< doc.toJson(QJsonDocument::Compact);
|
||||
return QChar(QLatin1Char('-'));
|
||||
}
|
||||
|
||||
QJsonArray arr = doc.object().value(QLatin1String("available_in_exercise")).toArray();
|
||||
|
||||
if (arr.isEmpty())
|
||||
return QChar(QLatin1Char('-'));
|
||||
|
||||
QString exercise = QString::fromUtf8(QJsonDocument(arr).toJson(QJsonDocument::Compact));
|
||||
|
||||
exercise.remove(QLatin1Char('['));
|
||||
exercise.remove(QLatin1Char(']'));
|
||||
|
||||
if (exercise.size())
|
||||
{
|
||||
int exId = exercise.toInt();
|
||||
return QString::fromStdString(m_exmDtc->exercise(exId).name());
|
||||
}
|
||||
return QChar(QLatin1Char('-'));
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool ExerciseAssignmentDialogModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
if (!m_dtc->enableInstrumentationAsset())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable Datatopic InstrumentationAsset of the Data Topic Client";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_exmDtc->enableExercise())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable Topic Exercise from Exercise Management DTC";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_dtc.get(), &Interface::Dtc::mainStructureElementChanged,
|
||||
this, &ExerciseAssignmentDialogModel::onDataChanged);
|
||||
|
||||
auto cb = [this](const InfrastructureManagement::MainStructureElement &mse)
|
||||
{
|
||||
onDataChanged(mse, DataModification::eAdded);
|
||||
};
|
||||
m_dtc->mainStructureElements(cb);
|
||||
|
||||
INFO_LOG(m_logger) << "initModel successful";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExerciseAssignmentDialogModel::isFiltered(const InfrastructureManagement::MainStructureElement &data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
return (data.structureElementTypeId() != InfrastructureManagement::StructureElementType::Building &&
|
||||
data.structureElementTypeId() != InfrastructureManagement::StructureElementType::Announcement);
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ExerciseAssignmentDialogModel provices data for AssetListDialog
|
||||
* $Id: ism_exercise_assignment_dialog_model.h 41411 2018-04-24 14:51:44Z ojog_i $
|
||||
* $HeadURL: svn://192.168.133.21/TDS/branches/product/iterations/22_01_homer/Lts/Plugins/InfrastructureManagement/Gui/AudioVideoConfig/ExerciseAssignment/ism_exercise_assignment_dialog_model.h $
|
||||
* $Author: ojog_i $
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-06-29
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <InfrastructureManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
class ExerciseAssignmentDialogModel final : public LtsWidgets::LtsAbstractTableModel<MainStructureElement>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExerciseAssignmentDialogModel(QObject *parent = nullptr);
|
||||
~ExerciseAssignmentDialogModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc);
|
||||
|
||||
protected:
|
||||
bool isFiltered(const InfrastructureManagement::MainStructureElement &data, DataModification modType) const override;
|
||||
|
||||
private: // other
|
||||
enum Columns
|
||||
{
|
||||
NAME,
|
||||
ASSIGNED_EXERCISES
|
||||
};
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
}; // class ExerciseAssignmentDialogModel
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
Q_DECLARE_METATYPE(InfrastructureManagement::MainStructureElement)
|
||||
Reference in new issue
Block a user