Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,111 @@
/**
* @RDE_HEADER@
* The ScheduleDifferencesListDialog shows differences for an incomplete instrumentation plan (schedule)
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLTE, 2021-08-24
*/
#include "ism_schedule_differences_list_dialog.h"
#include "ui_ism_schedule_differences_list_dialog.h"
#include "ism_schedule_differences_list_model.h"
#include <InfrastructureManagement/ism_translation.h>
#include <LtsPrinting/printing.h>
#include <ngltools/ngltools_dtg.h>
#include <QTreeView>
using namespace InfrastructureManagement;
ScheduleDifferencesListDialog::ScheduleDifferencesListDialog(const QString &menuGroup, QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkCancel)
, m_ui(new Ui::ScheduleDifferencesListDialog)
, m_sourceModel(nullptr)
, m_menuGroup(menuGroup)
, m_logger(getLogger("ScheduleDifferencesListDialog"))
{
m_ui->setupUi(this);
setOnlineHelpFilename(QStringLiteral("Ressourcen-Completeness_Check"));
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ScheduleDifferencesListDialog::onPrint);
}
ScheduleDifferencesListDialog::~ScheduleDifferencesListDialog()
{
if (m_sourceModel)
{
delete m_sourceModel;
m_sourceModel = nullptr;
}
delete m_ui;
}
void ScheduleDifferencesListDialog::retranslate()
{
translate(m_ui, tr("Completeness Check: %1").arg(QString::fromStdString(m_dtc->mainSchedule(m_scheduleId).name())));
}
bool ScheduleDifferencesListDialog::init(LtsSession::LtsSession *session,
const std::shared_ptr<Interface::Dtc> &dtc,
int scheduleId)
{
m_dtc = dtc;
m_session = session;
m_scheduleId = scheduleId;
if (m_scheduleId <= 0)
{
ERROR_LOG(m_logger) << "Invalid id for Instrumentation plan: " << m_scheduleId;
return false;
}
connect(m_dtc.get(), &Interface::Dtc::mainScheduleChanged, this, &ScheduleDifferencesListDialog::dataChanged);
m_sourceModel = new ScheduleDifferencesListDialogModel(this);
if (!m_sourceModel->initModel(m_scheduleId, m_dtc))
{
ERROR_LOG(m_logger) << "Could not init ScheduleDifferencesListDialogModel";
delete m_sourceModel;
m_sourceModel = nullptr;
return false;
}
m_ui->mpDifferencesListView->setModel(m_sourceModel);
return true;
}
void ScheduleDifferencesListDialog::dataChanged(const InfrastructureManagement::MainSchedule &data, DataModification modType)
{
Q_UNUSED(modType);
if (data.id() == m_scheduleId)
m_sourceModel->initModel(m_scheduleId, m_dtc);
}
void ScheduleDifferencesListDialog::onPrint()
{
MainSchedule ms = m_dtc->mainSchedule(m_scheduleId);
QString header;
header += QStringLiteral("<p>");
header += QStringLiteral("<b>") + tr("Differences List - Plan incomplete") + QStringLiteral("</b>");
header += QStringLiteral("<hr/>");
header += tr("Instrumentation Plan: %1").arg(QString::fromStdString(ms.name()));
header += QStringLiteral("<br/>");
header += tr("Status: %1").arg(toString(ms.statusId()));
header += QStringLiteral("<br/>");
header += tr("Created: %1").arg(DTG::toStringMSec(ms.timeCreated()));
header += QStringLiteral("<br/>");
if (ms.timeStart().is_set())
header += tr("START: %1").arg(DTG::toStringMSec(ms.timeStart().get()));
else
header += tr("START: %1").arg(tr("[N/A]"));
header += QStringLiteral(" - ");
if (ms.timeEnd().is_set())
header += tr("END: %1").arg(DTG::toStringMSec(ms.timeEnd().get()));
else
header += tr("END: %1").arg(tr("[N/A]"));
header += QStringLiteral("<br/>");
header += QStringLiteral("</p>");
LtsPrinting::printView(m_session, this, m_ui->mpDifferencesListView->treeView(), header);
}
@@ -0,0 +1,59 @@
/**
* @RDE_HEADER@
* The ScheduleDifferencesListDialog shows differences for an incomplete instrumentation plan (schedule)
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLTE, 2021-08-24
*/
#pragma once
#include <LtsWidgets/lts_dialog.h>
#include <InfrastructureManagement/ism_dtc.h>
#include <InfrastructureManagement/logger.h>
namespace Ui
{
class ScheduleDifferencesListDialog;
}
namespace LtsSession
{
class LtsSession;
}
namespace InfrastructureManagement
{
class ScheduleDifferencesListDialogModel;
class ScheduleDifferencesListDialog final
: public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit ScheduleDifferencesListDialog(const QString &menuGroup, QWidget *parent = nullptr);
~ScheduleDifferencesListDialog();
bool init(LtsSession::LtsSession *session,
const std::shared_ptr<Interface::Dtc> &dtc,
int scheduleId);
private: // methods
void retranslate() override;
void dataChanged(const InfrastructureManagement::MainSchedule &data, DataModification modType);
private slots:
void onPrint();
private: // attributes
Ui::ScheduleDifferencesListDialog *m_ui{nullptr};
ScheduleDifferencesListDialogModel *m_sourceModel{nullptr};
std::shared_ptr<Interface::Dtc> m_dtc{nullptr};
QString m_menuGroup;
LtsSession::LtsSession *m_session{nullptr};
int m_scheduleId{-1};
LOGGER_T m_logger;
}; // class ScheduleDifferencesListDialog
} // namespace InfrastructureManagement
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScheduleDifferencesListDialog</class>
<widget class="QWidget" name="ScheduleDifferencesListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1169</width>
<height>517</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Differences</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="LtsDataView::LtsDataView" name="mpDifferencesListView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<property name="showColumnCount" stdset="0">
<bool>false</bool>
</property>
<property name="toolButtonsVisible">
<bool>false</bool>
</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,112 @@
/**
* @RDE_HEADER@
* The ScheduleDifferencesListDialogModel provices data for ScheduleDifferencesListDialog
* Modified version using the checkStateProxyModel to allow setting via the checkboxes of the tree structure hjl 5/19
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLTE, 2021-08-24
*/
#include "ism_schedule_differences_list_model.h"
#include <InfrastructureManagement/ism_translation.h>
#include <InfrastructureManagement/Shared/ism_mounting_point.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace InfrastructureManagement
{
ScheduleDifferencesListDialogModel::ScheduleDifferencesListDialogModel(QObject *parent)
: LtsWidgets::LtsAbstractTableModel<MountingPointPlan>({tr("Id"),
tr("Name"),
tr("Type"),
tr("Building"),
tr("Position"),
tr("Aim State"),
tr("Current State"),
tr("Asset Id"),
tr("Asset Name")},
parent)
, m_logger(getLogger("ScheduleDifferencesListDialogModel"))
{
}
QVariant ScheduleDifferencesListDialogModel::data(const QModelIndex &index, int role) const
{
if (!(index.isValid() && role == Qt::DisplayRole))
return QVariant();
MountingPointPlan item = m_vecData.at(index.row());
InfrastructureManagement::StructureElement se;
m_dtc->getStructureElementById(item.structureElementId(), se);
int assetId = m_dtc->getMountedAssetId(item.structureElementId());
switch (index.column())
{
case SE_ID:
return item.structureElementId();
case SE_TYPE:
return InfrastructureManagement::toString(se.mountingPointTypeId());
case SE_NAME:
return QString::fromStdString(se.displayName().size() > 0 ? se.displayName() : se.name());
case MSE_NAME:
return m_dtc->getBuildingDisplayName(se.mainStructureElementId());
case SE_POS:
return LtsCoordTrans::mgrsFromGeographic(se.geoPosition().lon(), se.geoPosition().lat());
case MP_AIM_STATE:
return InfrastructureManagement::toString(item.mountingPointState());
case MP_CURRENT_STATE: // opposite as desired
if (item.mountingPointState() == MountingPointState::Equipped)
return InfrastructureManagement::toString(MountingPointState::Empty);
if (item.mountingPointState() == MountingPointState::Empty)
return InfrastructureManagement::toString(MountingPointState::Equipped);
return {};
case ASSET_ID:
if (assetId > 0)
return assetId;
return {};
case ASSET_NAME:
if (assetId > 0)
return QString::fromStdString(m_dtc->instrumentationAsset(assetId).name());
}
return QVariant();
}
bool ScheduleDifferencesListDialogModel::initModel(int scheduleId,
const std::shared_ptr<Interface::Dtc> &dtc)
{
clear();
m_dtc = dtc;
m_scheduleId = scheduleId;
if (m_scheduleId <= 0)
{
ERROR_LOG(m_logger) << "Invalid scheduleId = " << m_scheduleId;
return false;
}
QList<MountingPointPlan> diff;
bool isComplete = m_dtc->getScheduleDifferences(m_scheduleId, diff);
DEBUG_LOG(m_logger) << "Plan id = " << m_scheduleId << ", Differences = " << diff.size();
if (isComplete)
{
WARNING_LOG(m_logger) << "Instrumentation plan is complete. No differences to show.";
return false;
}
for (const MountingPointPlan &mpp : qAsConst(diff))
{
DEBUG_LOG(m_logger) << "Adding to model MPP = " << mpp.id();
insertRow(mpp);
}
DEBUG_LOG(m_logger) << "initModel successful";
return true;
}
} // namespace InfrastructureManagement
@@ -0,0 +1,47 @@
/**
* @RDE_HEADER@
* The ScheduleDifferencesListDialogModel provices data for ScheduleDifferencesListDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLTE, 2021-08-24
*/
#pragma once
#include <InfrastructureManagement/logger.h>
#include <InfrastructureManagement/ism_dtc.h>
#include <LtsWidgets/lts_abstract_table_model.h>
namespace InfrastructureManagement
{
class ScheduleDifferencesListDialogModel : public LtsWidgets::LtsAbstractTableModel<MountingPointPlan>
{
Q_OBJECT
public:
enum Columns
{
SE_ID,
SE_NAME,
SE_TYPE,
MSE_NAME,
SE_POS,
MP_AIM_STATE,
MP_CURRENT_STATE,
ASSET_ID,
ASSET_NAME
};
explicit ScheduleDifferencesListDialogModel(QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role) const override;
bool initModel(int scheduleId, const std::shared_ptr<Interface::Dtc> &dtc);
private:
int m_scheduleId{-1};
std::shared_ptr<Interface::Dtc> m_dtc{nullptr};
LOGGER_T m_logger;
}; // class ScheduleDifferencesListDialogModel
} // namespace InfrastructureManagement