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

+28
View File
@@ -0,0 +1,28 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Christian Ehrlicher, SLSE, 2016-03-01
#
ADD_SUBDIRECTORY(Data)
ADD_SUBDIRECTORY(Gui)
#
# Info Gui Plugin Interface
#
ADD_INTERFACE_LIBRARY(RepGuiPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/rep_gui_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
GuiPluginInterface TopicReplayInterface TopicEditorInterface Qt5::Core
)
#
# Data Plugin Interface
#
ADD_INTERFACE_LIBRARY(RepDataPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/rep_data_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
DataPluginInterface
svcRepCommon
)
+19
View File
@@ -0,0 +1,19 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-09-06
#
#
# Data Plugin
#
NGL_ADD_LIBRARY(WS RepDataPlugin MODULE rep_data_plugin.cpp rep_data_plugin.h)
NGL_TARGET_LINK_LIBRARIES(RepDataPlugin
Qt5::Core
RepDataPluginInterface
svcRepClient
NGLLogger
LtsSessionDataDds
)
NGL_INSTALL_TARGET(RepDataPlugin)
+34
View File
@@ -0,0 +1,34 @@
/**
* @RDE_HEADER@
* Data Plugin for Report Management
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017
*/
#include "rep_data_plugin.h"
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsSession/lts_session_data_dds.h>
namespace ReportManagement
{
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
{
std::shared_ptr<ReportManagement::Interface::Dtc> dtc;
std::shared_ptr<ReportManagement::Interface::Ftc> ftc;
if (!session->createTopicClient(dtc, ftc))
return std::shared_ptr<DataPluginBase::Interface>();
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
}
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc,
const std::shared_ptr<ReportManagement::Interface::Ftc> &ftc)
: DataInterface()
, m_dtc(dtc)
, m_ftc(ftc)
{}
} // namespace ReportManagement
+54
View File
@@ -0,0 +1,54 @@
/**
* @RDE_HEADER@
* Data Plugin for Report Management
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017
*/
#pragma once
#include <PluginInterfaces/data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
namespace ReportManagement
{
class DataPlugin final : public QObject, public DataPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "data:3:rep")
Q_INTERFACES(DataPluginBase::Plugin)
Q_OBJECT
public:
DataPlugin() = default;
~DataPlugin() = default;
QString pluginName() const override { return QStringLiteral("ReportManagement"); }
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return partition == IDL::PartitionType::Exercise ||
partition == IDL::PartitionType::Replay;
}
};
class DataInterfaceImpl final : public DataInterface
{
public:
DataInterfaceImpl(const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc,
const std::shared_ptr<ReportManagement::Interface::Ftc> &ftc);
std::shared_ptr<ReportManagement::Interface::Dtc> getDtc() override { return m_dtc; }
std::shared_ptr<ReportManagement::Interface::Ftc> getFtc() override { return m_ftc; }
private:
std::shared_ptr<ReportManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ReportManagement::Interface::Ftc> m_ftc;
};
} // namespace ReportManagement
+7
View File
@@ -0,0 +1,7 @@
#
# $Id$
# $HeadURL$
# $Author$
#
ADD_SUBDIRECTORY(ReportViewer)
@@ -0,0 +1,119 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Patric Karwat, SLSE, 2016-10-05
#
FIND_PACKAGE(KDReports REQUIRED)
FIND_PACKAGE(KDChart REQUIRED)
SET(rep_report_viewer_gui_SRCS
rep_report_viewer_gui_plugin.cpp
rep_report_viewer_gui_plugin.h
rep_report_list.cpp
rep_report_list.h
rep_report_model.cpp
rep_report_model.h
rep_report_edit.cpp
rep_report_edit.h
rep_report_preview.cpp
rep_report_preview.h
rep_report_interval.cpp
rep_report_interval.h
rep_report_interval_model.cpp
rep_report_interval_model.h
CustomView/rep_entry.h
CustomView/rep_entry.cpp
Input/rep_input_aes_model.cpp
Input/rep_input_aes_model.h
Input/rep_input_type_model.cpp
Input/rep_input_type_model.h
Input/rep_input_charge_model.cpp
Input/rep_input_charge_model.h
Input/rep_input_building_model.cpp
Input/rep_input_building_model.h
Input/rep_input_sanitation_material_model.cpp
Input/rep_input_sanitation_material_model.h
Models/rep_abstract_model.h
Models/rep_abstract_model.cpp
Models/rep_unit_power_model.h
Models/rep_unit_power_model.cpp
Models/rep_participant_distance_model.h
Models/rep_participant_distance_model.cpp
Models/rep_charge_administration_model.h
Models/rep_charge_administration_model.cpp
Models/rep_charge_resupply_model.h
Models/rep_charge_resupply_model.cpp
Models/rep_firings_model.h
Models/rep_firings_model.cpp
Models/rep_air_support_model.h
Models/rep_air_support_model.cpp
Models/rep_mine_area_model.h
Models/rep_mine_area_model.cpp
Models/rep_nbc_model.h
Models/rep_nbc_model.cpp
Models/rep_maintenance_model.h
Models/rep_maintenance_model.cpp
Models/rep_building_damage_model.h
Models/rep_building_damage_model.cpp
Models/rep_sanitation_material_model.h
Models/rep_sanitation_material_model.cpp
Models/rep_medevac_nine_liner_model.h
Models/rep_medevac_nine_liner_model.cpp
Models/rep_treatment_model.h
Models/rep_treatment_model.cpp
Models/rep_treatment_timeline_model.h
Models/rep_treatment_timeline_model.cpp
./TopicEditor/topic_editor.h
./TopicEditor/topic_editor.cpp
)
NGL_WRAP_UI(rep_report_viewer_gui_SRCS
rep_report_list.ui
rep_report_interval.ui
rep_report_edit.ui
rep_report_preview.ui
CustomView/rep_entry.ui
./TopicEditor/topic_editor.ui
)
NGL_ADD_LIBRARY(WS RepReportViewerGuiPlugin MODULE ${rep_report_viewer_gui_SRCS})
NGL_TARGET_LINK_LIBRARIES(RepReportViewerGuiPlugin
AsbDataPluginInterface
Qt5::Widgets
KDReports::KDReports
KDChart::KDChart
NGLLogger
ngltools
nglsettings
ngltranslator
LtsPrinting
LtsSession
LtsSessionData
LtsWidgets
LtsReportDisplay
LtsDataView
LtsUtilsGuiDds
ltsCoordWidget
LtsCoordTrans
RepGuiPluginInterface
RepDataPluginInterface
PpmDataPluginInterface
OpmDataPluginInterface
AesDataPluginInterface
ExmDataPluginInterface
PdmDataPluginInterface
FlmDataPluginInterface
EvlDataPluginInterface
PdmChargeTableGui
PpmGuiParticipantsPluginInterface
PpmGuiComboboxPluginInterface
PpmCommon
IsmDataPluginInterface
TopicEditorBase
LtsScriptTimeline
LtsUtilsSettings
)
NGL_INSTALL_TARGET(RepReportViewerGuiPlugin)
@@ -0,0 +1,44 @@
/**
* @RDE_HEADER@
* CustomView for MDM Station
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-05
*/
#include "rep_entry.h"
#include "ui_rep_entry.h"
#include "rep_report_model.h"
namespace ReportManagement
{
CustomViewReport::CustomViewReport(QWidget *parent)
: AbstractDisplayWidget(parent)
, m_ui(new Ui::CustomViewReport)
{
m_ui->setupUi(this);
}
CustomViewReport::~CustomViewReport()
{
delete m_ui;
}
bool CustomViewReport::init(const QModelIndex &idx)
{
if (!idx.isValid())
return false;
m_ui->lblName->setText(rowData(idx, ReportManagement::ReportModel::Name).toString());
m_ui->lblType->setText(rowData(idx, ReportManagement::ReportModel::Type).toString());
m_ui->lblParty->setText(rowData(idx, ReportManagement::ReportModel::Party).toString());
m_ui->lblEndTime->setText(rowData(idx, ReportManagement::ReportModel::EndTime).toString());
m_ui->lblStartTime->setText(rowData(idx, ReportManagement::ReportModel::StartTime).toString());
m_ui->teDescription->setText(rowData(idx, ReportManagement::ReportModel::Description).toString());
return true;
}
} // namespace ReportManagement
@@ -0,0 +1,32 @@
/**
* @RDE_HEADER@
* CustomView for MRK Marker
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2016-04-08
*/
#pragma once
#include <Viewer/LtsDataView/abstract_display_widget.h>
namespace Ui
{
class CustomViewReport;
}
namespace ReportManagement
{
class CustomViewReport : public LtsDataView::AbstractDisplayWidget
{
Q_OBJECT
public:
explicit CustomViewReport(QWidget *parent = nullptr);
~CustomViewReport();
bool init(const QModelIndex &idx) override;
private:
Ui::CustomViewReport *m_ui;
};
} // namespace ReportManagement
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomViewReport</class>
<widget class="QWidget" name="CustomViewReport">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>196</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="lblName">
<property name="text">
<string notr="true">&lt;NAME&gt;</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Party:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lblType">
<property name="text">
<string notr="true">&lt;Type&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lblParty">
<property name="text">
<string notr="true">&lt;Party&gt;</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<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>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbNote">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Description:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTextEdit" name="teDescription">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Start Time:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblStartTime">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>End Time:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblEndTime">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>20</height>
</size>
</property>
</spacer>
</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>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,259 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection AES Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_aes_model.h"
#include <ngltools/ngltools_dtg.h>
#include <QDateTime>
namespace ReportManagement
{
ReportAesModel::ReportAesModel(const ReportType &reportType,
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ReportAesEntry>({
tr("Name"),
tr("Charge Type"),
tr("Start Time"),
tr("End Time"),
tr("Party")}, parent)
, m_partyId(-1)
, m_aesDtc(aesDtc)
, m_pdmDtc(pdmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportAesModel"))
{
}
bool ReportAesModel::initModel(int partyId)
{
if (!m_aesDtc || !m_pdmDtc)
return false;
m_partyId = partyId;
clear();
switch (m_reportType.underlying())
{
case ReportType::Nbc:
{
auto cb = [this](const AreaEffectSimulation::BCContamination & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||
m_partyId == 0 || cont.partyId() != m_partyId)
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->bCContaminations(cb);
auto cbN = [this](const AreaEffectSimulation::NContamination & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared || m_partyId > 0) // No N-areas for other Party selected than Pool
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->nContaminations(cbN);
break;
}
case ReportType::Firings:
case ReportType::AirSupport:
case ReportType::ExplosiveDevice:
{
auto cb = [this](const AreaEffectSimulation::ExplosionSingle & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||
(m_partyId > 0 && cont.partyId() != m_partyId))
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->explosionSingles(cb);
auto cbA = [this](const AreaEffectSimulation::ExplosionArea & cont)
{
if (cont.isDeleted() || cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||
(m_partyId > 0 && cont.partyId() != m_partyId))
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->explosionAreas(cbA);
break;
}
case ReportType::MineArea:
{
auto cb = [this](const AreaEffectSimulation::MineArea & cont)
{
// do not show deleted mine areas!
if (cont.isDeleted() || /*cont.effectStateId() == AreaEffectSimulation::AesEffectState::EsPrepared ||*/
(m_partyId > 0 && cont.partyId() != m_partyId))
return;
ReportAesEntry entry;
entry.setId(cont.id());
entry.chargeType = cont.chargeStruct().chargeTypeId();
entry.name = QString::fromStdString(cont.name());
if (cont.effectStart().is_set())
entry.startTime = cont.effectStart().get();
else
entry.startTime = 0;
entry.endTime = entry.startTime + cont.effectDuration();
if (cont.partyId().is_set())
entry.partyId = cont.partyId().get();
else
entry.partyId = 0;
insertRow(entry);
};
m_aesDtc->mineAreas(cb);
break;
}
default:
return false;
}
return true;
}
//int ReportAesModel::getAesId(const QModelIndex &index) const
//{
// if (index.row() > m_vecData.size())
// return -1;
// return m_vecData.at(index.row()).id;
//}
QVariant ReportAesModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const ReportAesEntry entry = m_vecData.at(index.row());
switch (index.column())
{
case Name:
return entry.name;
case ChargeType:
return m_pdmDtc->trChargeTypeShortName(entry.chargeType, true);
case StartTime:
return QDateTime::fromMSecsSinceEpoch(entry.startTime); //USE same converter from AES
case EndTime:
return QDateTime::fromMSecsSinceEpoch(entry.endTime);
case Party:
return entry.partyId;
}
return QVariant();
}
//
// ReportAesProxyModel
//
bool ReportAesProxyModel::initModel(int partyId)
{
return m_sourceModel ? m_sourceModel->initModel(partyId) : false;
}
int ReportAesProxyModel::getId(const QModelIndex &index) const
{
if (!m_sourceModel)
{
Q_ASSERT(false);
return -1;
}
return m_sourceModel->getId(mapToSource(index));
}
void ReportAesProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<ReportAesModel*>(sourceModel);
QSortFilterProxyModel::setSourceModel(sourceModel);
}
bool ReportAesProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return QSortFilterProxyModel::lessThan(source_left, source_right);
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case ReportAesModel::StartTime:
return dataLeft.startTime < dataRight.startTime;
case ReportAesModel::EndTime:
return dataLeft.endTime < dataRight.endTime;
case ReportAesModel::Name:
case ReportAesModel::ChargeType:
case ReportAesModel::Party:
break;
}
return QSortFilterProxyModel::lessThan(source_left, source_right);
}
} //namespace ReportManagement
@@ -0,0 +1,86 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection AES Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h> //oh hell.. we will split this someday..
#include <ReportManagement/rep_enums.hpp>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <QSortFilterProxyModel>
namespace ReportManagement
{
// This struct needs a "id()" method, to be able to evaluate LtsWidgets::LtsAbstractTableModel<ReportAesEntry>::getId() properly.
struct ReportAesEntry
{
QString name;
int64_t startTime = 0;
int64_t endTime = 0;
int chargeType = 0;
int partyId = 0;
int id() const { return _id; }
void setId(int newId) { _id = newId; }
private:
int _id = 0;
};
class ReportAesModel final : public LtsWidgets::LtsAbstractTableModel<ReportAesEntry>
{
public:
enum Columns
{
Name,
ChargeType,
StartTime,
EndTime,
Party
};
Q_OBJECT
public:
explicit ReportAesModel(const ReportType &reportType,
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent = nullptr);
bool initModel(int partyId);
QVariant data(const QModelIndex &index, int role) const override final;
private:
int m_partyId;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
friend class ReportAesProxyModel;
};
class ReportAesProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
using QSortFilterProxyModel::QSortFilterProxyModel;
bool initModel(int partyId);
int getId(const QModelIndex &index) const;
void setSourceModel(QAbstractItemModel *sourceModel) override;
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
private:
ReportAesModel *m_sourceModel = nullptr;
};
} //namespace
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Buildings Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_building_model.h"
namespace ReportManagement
{
ReportBuildingModel::ReportBuildingModel(LtsSession::LtsSession *session,
const ReportManagement::ReportType &reportType,
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<InfrastructureManagement::MainStructureElement>(
{
tr("Name")
},
parent)
, m_session(session)
, m_ismDtc(ismDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportBuildingModel"))
{
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
this, &ReportBuildingModel::onDataChanged);
initModel();
}
bool ReportBuildingModel::initModel()
{
if (!m_ismDtc)
return false;
clear();
auto cb = [this] (const InfrastructureManagement::MainStructureElement &mse)
{
#ifdef GUEZ_MODE
if (m_ismDtc->isElementAssignedToExercise(mse, m_session->exerciseId()) && mse.id() >= 1000)
#else
if (m_ismDtc->isElementAssignedToExercise(mse, m_session->exerciseId()) && mse.externalWlsId() > 0)
#endif
onDataChanged(mse, DataModification::eAdded);
};
m_ismDtc->mainStructureElements(cb);
return true;
}
QVariant ReportBuildingModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const InfrastructureManagement::MainStructureElement &mse = m_vecData.at(index.row());
switch (index.column())
{
case BUILDING_NAME:
return m_ismDtc->getBuildingDisplayName(mse);
}
return QVariant();
}
} //namespace ReportManagement
@@ -0,0 +1,45 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Buildings Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_enums.hpp>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <LtsSession/lts_session.h>
namespace ReportManagement
{
class ReportBuildingModel final : public LtsWidgets::LtsAbstractTableModel<InfrastructureManagement::MainStructureElement>
{
Q_OBJECT
public:
enum Columns
{
BUILDING_NAME = 0
};
explicit ReportBuildingModel(LtsSession::LtsSession *session,
const ReportManagement::ReportType &reportType,
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
QObject *parent = nullptr);
~ReportBuildingModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
private:
LtsSession::LtsSession *m_session;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
} //namespace ReportManagement
@@ -0,0 +1,154 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Charge Types Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_charge_model.h"
#include <ProjectDataManagement/pdm_translation.h>
#include <LtsUtils/LtsUtilsCore/json_object.h>
namespace ReportManagement
{
ReportChargeModel::ReportChargeModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::ChargeType>(
{
tr("Name"),
tr("Gear Class"),
tr("Charge Id")
},
parent)
, m_pdmDtc(pdmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportChargeModel"))
{
connect(m_pdmDtc.get(), &ProjectDataManagement::Interface::Dtc::chargeTypeChanged,
this, &ReportChargeModel::onDataChanged);
initModel();
}
bool ReportChargeModel::initModel()
{
if (!m_pdmDtc)
return false;
clear();
auto cb = [this](const ProjectDataManagement::ChargeType &ct)
{
onDataChanged(ct, DataModification::eAdded);
};
return m_pdmDtc->chargeTypes(cb);
}
QVariant ReportChargeModel::data(const QModelIndex &index, int role) const
{
if (!indexIsValid(index))
return QVariant();
const ProjectDataManagement::ChargeType &charge = m_vecData.at(index.row());
if (role == Qt::ToolTipRole && index.column() == ChargeTypeName)
return m_pdmDtc->trChargeTypeName(charge.id(), true);
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case ChargeTypeName:
return m_pdmDtc->trChargeTypeShortName(charge.id(), true);
case GearClass:
return ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(charge.id()));
case ChargeTypeId:
return charge.id();
}
}
return QVariant();
}
bool ReportChargeModel::isFiltered(const ProjectDataManagement::ChargeType &data, DataModification modType) const
{
Q_UNUSED(modType);
if (LtsUtils::JsonObject::fromJson(data.properties()).valueOr<bool>("suppressVisibility", false))
return true;
const ProjectDataManagement::GearClass gc = m_pdmDtc->gearClassFromChargeTypeId(data.id());
switch (m_reportType.underlying())
{
case ReportType::ChargeAdministration:
return (gc != ProjectDataManagement::GearClass::Artillery &&
gc != ProjectDataManagement::GearClass::Mortar &&
gc != ProjectDataManagement::GearClass::Rocket);
case ReportType::ChargeResupply:
// return !m_pdmDtc->isDryFire(data.id());
// update 29.09.2020 after discussion with Ulli: showing same charge types as in Firings report
case ReportType::Firings:
// NOTE: igniterType/IgniterFunciton = 0 as long as ReportChargeModel does not contain values
return (gc != ProjectDataManagement::GearClass::DuelSim ||
m_pdmDtc->isDryFire(data.id(),0,0) || m_pdmDtc->isIed(data.id(),0,0));
// IO 04.09.2018 - REGG-5031: Not only DuelSim, but also Unknown except DryFire and Ied
// update 25.09.2018: Only DuelSim except Ied and DryFire
case ReportType::AirSupport:
return (gc != ProjectDataManagement::GearClass::AirSupport);
case ReportType::ExplosiveDevice:
return !m_pdmDtc->isIed(data.id(),0,0);
default:
break;
}
return false;
}
//
// ReportChargeProxyModel
//
bool ReportChargeProxyModel::initModel()
{
return m_sourceModel ? m_sourceModel->initModel() : false;
}
int ReportChargeProxyModel::getId(const QModelIndex &index) const
{
if (!m_sourceModel)
{
Q_ASSERT(false);
return -1;
}
return m_sourceModel->getId(mapToSource(index));
}
void ReportChargeProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<ReportChargeModel*>(sourceModel);
QSortFilterProxyModel::setSourceModel(sourceModel);
}
bool ReportChargeProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return QSortFilterProxyModel::lessThan(source_left, source_right);
//const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
//const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case ReportChargeModel::GearClass:
case ReportChargeModel::ChargeTypeName:
case ReportChargeModel::ChargeTypeId:
break;
}
return QSortFilterProxyModel::lessThan(source_left, source_right);
}
} //namespace ReportManagement
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Charge Types Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_dtc.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <QSortFilterProxyModel>
namespace ReportManagement
{
class ReportChargeModel final : public LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::ChargeType>
{
Q_OBJECT
public:
enum Columns
{
ChargeTypeName = 0,
GearClass = 1,
ChargeTypeId = 2
};
explicit ReportChargeModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent = nullptr);
~ReportChargeModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
protected:
bool isFiltered(const ProjectDataManagement::ChargeType &data, DataModification modType) const override;
private:
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
class ReportChargeProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
using QSortFilterProxyModel::QSortFilterProxyModel;
bool initModel();
int getId(const QModelIndex &index) const;
void setSourceModel(QAbstractItemModel *sourceModel) override;
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
private:
ReportChargeModel *m_sourceModel = nullptr;
};
} //namespace ReportManagement
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#include "rep_input_sanitation_material_model.h"
#include <ProjectDataManagement/pdm_translation.h>
namespace ReportManagement
{
ReportSanitationMaterialModel::ReportSanitationMaterialModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::SanitationMaterial>(
{
tr("Id"),
tr("Name")
},
parent)
, m_pdmDtc(pdmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportSanitationMaterialModel"))
{
connect(m_pdmDtc.get(), &ProjectDataManagement::Interface::Dtc::sanitationMaterialChanged,
this, &ReportSanitationMaterialModel::onDataChanged);
initModel();
}
bool ReportSanitationMaterialModel::initModel()
{
if (!m_pdmDtc)
return false;
clear();
auto cb = [this](const ProjectDataManagement::SanitationMaterial &sm)
{
onDataChanged(sm, DataModification::eAdded);
};
return m_pdmDtc->sanitationMaterials(cb);
}
QVariant ReportSanitationMaterialModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const ProjectDataManagement::SanitationMaterial &sanMat = m_vecData.at(index.row());
switch (index.column())
{
case MaterialId:
return sanMat.id();
case MaterialName:
return ProjectDataManagement::trSanitationMaterialName(sanMat.name());
}
return QVariant();
}
} //namespace ReportManagement
@@ -0,0 +1,43 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_dtc.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
namespace ReportManagement
{
class ReportSanitationMaterialModel final : public LtsWidgets::LtsAbstractTableModel<ProjectDataManagement::SanitationMaterial>
{
Q_OBJECT
public:
enum Columns
{
MaterialId = 0,
MaterialName = 1
};
explicit ReportSanitationMaterialModel(const ReportManagement::ReportType &reportType,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
QObject *parent = nullptr);
~ReportSanitationMaterialModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
private:
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
} //namespace ReportManagement
@@ -0,0 +1,90 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Participant Type Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_input_type_model.h"
#include <ParticipantManagement/ppm_translation.h>
namespace ReportManagement
{
ReportTypeModel::ReportTypeModel(const ReportType &reportType,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Type>(
{
tr("Name"),
tr("Type Class")
},
parent)
, m_ppmDtc(ppmDtc)
, m_reportType(reportType)
, m_logger(getLogger("ReportTypeModel"))
{
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::typeChanged,
this, &ReportTypeModel::onDataChanged);
initModel();
}
bool ReportTypeModel::initModel()
{
auto cb = [this](const ParticipantManagement::Type &type)
{
// hide units and types not used
if (m_ppmDtc->isTypeInUse(type.id()) &&
type.typeClass() != ParticipantManagement::TypeClass::Unit &&
type.typeClass() != ParticipantManagement::TypeClass::SupportUnit &&
type.typeClass() != ParticipantManagement::TypeClass::SupportEntity )
onDataChanged(type, DataModification::eAdded);
};
return m_ppmDtc->types(cb);
}
QVariant ReportTypeModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const ParticipantManagement::Type &entry = m_vecData.at(index.row());
switch (index.column())
{
case TypeClass:
return ParticipantManagement::toString(entry.typeClass());
case TypeName:
return QString::fromStdString(entry.name());
}
return QVariant();
}
bool ReportTypeModel::isFiltered(const ParticipantManagement::Type &data, DataModification) const
{
const auto tc = data.typeClass();
switch (m_reportType.underlying())
{
case ReportManagement::ReportType::VehicleRepair:
return (tc != ParticipantManagement::TypeClass::GroundVehicle &&
tc != ParticipantManagement::TypeClass::VehicleWithGear &&
tc != ParticipantManagement::TypeClass::WeaponSystem);
case ReportManagement::ReportType::Decontamination:
case ReportManagement::ReportType::Treatment:
case ReportManagement::ReportType::TreatmentPriority:
case ReportManagement::ReportType::TreatmentTimeline:
case ReportManagement::ReportType::TreatmentChain:
return (tc != ParticipantManagement::TypeClass::Human);
default:
return (tc == ParticipantManagement::TypeClass::Unit ||
tc == ParticipantManagement::TypeClass::SupportUnit ||
tc == ParticipantManagement::TypeClass::SupportEntity);
}
return false;
}
} // namespace ReportManagement
@@ -0,0 +1,47 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Selection Participant Type Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_enums.hpp>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
namespace ReportManagement
{
class ReportTypeModel final : public LtsWidgets::LtsAbstractTableModel<ParticipantManagement::Type>
{
Q_OBJECT
public:
enum Columns
{
TypeName = 0,
TypeClass = 1
};
explicit ReportTypeModel(const ReportType &reportType,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
QObject *parent = nullptr);
~ReportTypeModel() = default;
bool initModel();
QVariant data(const QModelIndex &index, int role) const override;
protected:
bool isFiltered(const ParticipantManagement::Type &data, DataModification) const override;
private:
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
ReportType m_reportType;
LOGGER_T m_logger;
};
} // namespace ReportManagement
@@ -0,0 +1,233 @@
/**
* @RDE_HEADER@
* Base class and factory for further ChartModel classes
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-03-01
*/
#include "rep_abstract_model.h"
#include "rep_unit_power_model.h"
#include "rep_participant_distance_model.h"
#include "rep_charge_administration_model.h"
#include "rep_charge_resupply_model.h"
#include "rep_firings_model.h"
#include "rep_air_support_model.h"
#include "rep_mine_area_model.h"
#include "rep_nbc_model.h"
#include "rep_maintenance_model.h"
#include "rep_building_damage_model.h"
#include "rep_sanitation_material_model.h"
#include "rep_medevac_nine_liner_model.h"
#include "rep_treatment_model.h"
#include "rep_treatment_timeline_model.h"
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <LtsUtilsCore/dds_vector.h>
using namespace ReportManagement;
// -----------------------------------------------------------------------------------------------------------------------------------------------
ReportManagement::AbstractModel *ReportManagement::AbstractModel::create(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
{
switch (report.reportType().underlying())
{
case ReportType::UnitPower:
return new UnitPowerModel(report, session, parent);
case ReportType::ParticipantDistance:
return new ParticipantDistanceModel(report, session, parent);
case ReportType::MineArea:
return new MineAreaModel(report, session, parent);
case ReportType::Nbc:
return new NbcModel(report, session, parent);
case ReportType::Firings:
case ReportType::ExplosiveDevice:
return new FiringsModel(report, session, parent);
case ReportType::AirSupport:
return new AirSupportModel(report, session, parent);
case ReportType::ChargeAdministration:
return new ChargeAdministrationModel(report, session, parent);
case ReportType::ChargeResupply:
return new ChargeResupplyModel(report, session, parent);
case ReportType::VehicleRepair:
case ReportType::Decontamination:
return new MaintenanceModel(report, session, parent);
case ReportType::BuildingDamage:
return new BuildingDamageModel(report, session, parent);
case ReportType::SanitationMaterial:
return new SanitationMaterialModel(report, session, parent);
case ReportType::MedevacNineLiner:
return new MedevacNineLinerModel(report, session, parent);
case ReportType::Treatment:
case ReportType::TreatmentPriority:
case ReportType::TreatmentChain:
return new TreatmentModel(report, session, parent);
case ReportType::TreatmentTimeline:
return new TreatmentTimelineModel(report, session, parent);
}
return nullptr;
}
// -----------------------------------------------------------------------------------------------------------------------------------------------
AbstractModel::AbstractModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: QAbstractTableModel(parent)
, m_report(report)
, m_reportJsonArray(QJsonArray())
, m_requestHelper(new LtsUtils::RequestHelper(this))
, m_session(session)
{
}
// -----------------------------------------------------------------------------------------------------------------------------------------------
bool AbstractModel::getReportData(const ReportManagement::ReportInfo &report)
{
std::shared_ptr<ReportManagement::Interface::Ftc> ftc;
if (!m_session->getFtc<ReportManagement::DataInterface>(ftc))
return false;
std::vector<uint8_t> content;
std::function<void(const Core::FunctionReply &baseReply)> handleContent = [&](const Core::FunctionReply & baseReply)
{
const GetReportDataReply &reply = static_cast<const GetReportDataReply &>(baseReply);
content = reply.reportData();
};
if (!m_requestHelper->startSingleRequest([ = ]()
{
GetReportDataRequest req;
req.reportId(report.id());
req.reportType(report.reportType());
return ftc->getReportDataRequest(req, this);
}, handleContent))
{
return false;
}
QJsonDocument doc(QJsonDocument::fromBinaryData(LtsUtils::toQByteArray(content)));
if (doc.isNull() || doc.isEmpty())
return false;
m_reportJsonArray = doc.array(); // no main key here!
return true;
}
//----------------------------------------------------------------------------
bool AbstractProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
if (m_groupId > 0 && sourceModel())
{
int groupId = sourceModel()->data(sourceModel()->index(source_row,0), Qt::EditRole).toInt();
return (m_groupId == groupId);
}
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
// Treatment reports columns, from rep_treatment_model.h
enum Columns
{
PARTICIPANT = 0,
VITALITY = 1,
VULNERABILITY = 2,
TIME_VULNERABILITY = 3,
TIME_VITALITY = 4,
TIME_NINE_LINER = 5,
TIME_POSITION_CHANGED = 6,
TIME_ENTER_AREA = 7,
TIME_TREATMENT = 8,
DURATION_TREATMENT = 9,
GOLDEN_HOUR = 11,
SANITATION_PROCEDURES_TAKEN = 12,
SANITATION_RESULT = 13,
QUALIFICATION = 14,
SANITATION_EVALUATION = 15,
PRIORITY = 16,
PRIORITY_CORRECT = 17,
DURATION_NINE_LINER = 18,
DURATION_POSITION_CHANGED= 19,
DURATION_ENTER_AREA = 20,
FUNCTIONAL_AREA = 21,
PARTICIPANT_TYPE_NAME = 22,
PARTICIPANT_EQUIPMENT_NO = 23,
PARTICIPANT_NAME = 24,
PARTICIPANT_ID = 25,
PARTICIPANT_TYPE_ID = 26,
AREA_ID = 27,
#ifdef LTS_DEBUG
COUNT = 28
#else
COUNT = 22 // without last 6 columns
#endif
};
/*
enum TimelineColumns
{
EVENT_TIME = 0,
EVENT_TYPE = 1,
VULNERABILITY = 2,
VITALITY = 3,
AREA_NAME = 4,
PARTICIPANT_EQUIPMENT_NO = 5,
PARTICIPANT_NAME = 6,
PARTICIPANT_ID = 7,
PARTICIPANT_TYPE_ID = 8,
PARTICIPANT_TYPE_NAME = 9
};
*/
//----------------------------------------------------------------------------
bool AbstractProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const
{
if (m_rt == ReportManagement::ReportType::TreatmentChain)
{
if (m_vis == VisualisationType::Table)
return !(source_column >= Columns::TIME_VITALITY &&
source_column <= Columns::PRIORITY_CORRECT); // hide columns
else
return (source_column >= Columns::DURATION_TREATMENT &&
source_column <= Columns::DURATION_NINE_LINER); // only duration columns
}
if (m_rt == ReportManagement::ReportType::TreatmentPriority) // hide these columns
return !(source_column == Columns::TIME_VITALITY ||
source_column == Columns::DURATION_TREATMENT ||
source_column == Columns::TIME_NINE_LINER ||
source_column == Columns::TIME_POSITION_CHANGED ||
source_column == Columns::TIME_ENTER_AREA ||
source_column == Columns::SANITATION_PROCEDURES_TAKEN ||
source_column == Columns::SANITATION_RESULT ||
source_column == Columns::SANITATION_EVALUATION ||
source_column >= Columns::DURATION_NINE_LINER);
/*
if (m_rt == ReportManagement::ReportType::Treatment && m_vis == VisualisationType::Table) // hide these columns
return !(//source_column == Columns::TIME_VULNERABILITY ||
//source_column == Columns::TIME_TREATMENT ||
source_column == Columns::TIME_VITALITY ||
source_column == Columns::VITALITY ||
source_column == Columns::SANITATION_RESULT ||
source_column == Columns::SANITATION_PROCEDURES_TAKEN ||
source_column == Columns::TIME_NINE_LINER ||
source_column == Columns::TIME_POSITION_CHANGED ||
//source_column == Columns::TIME_ENTER_AREA ||
source_column >= Columns::SANITATION_EVALUATION);
*/
if (m_rt == ReportManagement::ReportType::TreatmentTimeline && m_vis == VisualisationType::Line) // show only TimelineColumns::VITALITY
return (source_column == 3);
return QSortFilterProxyModel::filterAcceptsColumn(source_column, source_parent);
}
//----------------------------------------------------------------------------
void AbstractProxyModel::setFilterGroup(int groupId)
{
if (m_groupId == groupId)
return;
m_groupId = groupId;
invalidateFilter();
}
@@ -0,0 +1,81 @@
/**
* @RDE_HEADER@
* Base class and factory for further ChartModel classes
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-03-01
*/
#pragma once
#include <QSet>
#include <QSortFilterProxyModel>
#include <QAbstractTableModel>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QVariantList>
#include <QtGui/QBrush>
#include <ReportManagement/rep_dtc.h>
#include <ReportManagement/rep_ftc.h>
#include <LtsSession/lts_session.h>
#include <LtsUtilsGuiDds/request_helper.h>
namespace ReportManagement
{
class AbstractModel
: public QAbstractTableModel
, protected ReportManagement::Interface::Ftc::GetReportDataReplyHandler
{
Q_OBJECT
public: // methods
static AbstractModel *create(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent = nullptr);
bool getReportData(const ReportManagement::ReportInfo &report);
virtual bool fetchInterfaces() = 0;
virtual void fillReportData() = 0;
protected: // methods
explicit AbstractModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void onGetReportDataReply(const GetReportDataReply &replyObject) override final { m_requestHelper->requestReply(replyObject); }
template<typename T, typename S>
void sumUp(T &dst, const S &src, int count)
{
for(int i = 0; i < count; ++i)
dst[i] += src[i];
}
protected: // attributes
ReportManagement::ReportInfo m_report;
QJsonArray m_reportJsonArray;
LtsUtils::RequestHelper *m_requestHelper;
LtsSession::LtsSession *m_session;
}; // class AbstractModel
// -------------------------------------------------------------------------------------
class AbstractProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
using QSortFilterProxyModel::QSortFilterProxyModel;
void setFilterGroup(int groupId);
void setReportType(const ReportManagement::ReportType &rt) { m_rt = rt; }
void setReportVisualisation(const ReportManagement::VisualisationType &vis) { m_vis = vis; }
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override;
private:
int m_groupId = 0;
ReportManagement::ReportType m_rt;
ReportManagement::VisualisationType m_vis;
};
} // namespace
@@ -0,0 +1,478 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_air_support_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <ProjectDataManagement/pdm_translation.h>
#include <LtsSession/lts_session.h>
#include <ngltools/ngltools_dtg.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
AirSupportModel::AirSupportModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_pdmDtc(nullptr)
, m_logger(getLogger("AirSupportModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultDataTable resData;
// charge type 371
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::CatastrophicKill;
resData.hits = {9, 4, 4, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::MobilityKill;
resData.hits = {9, 4, 3, 1};
m_dataTable.append(resData);
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::VisibleMobilityKill;
resData.hits = {2, 2, 2, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady; // total firings and hits on all VBGs
resData.hits = {20, 10, 9, 1};
m_dataTable.append(resData);
resultDataPie pieData;
pieData.chargeTypeId = 371;
pieData.startTime = 1513758640000;
pieData.hits = {20, 10, 9, 1};
m_dataPie.append(pieData);
// charge type 372
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::CatastrophicKill;
resData.hits = {14, 4, 4, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::MobilityKill;
resData.hits = {4, 4, 3, 1};
m_dataTable.append(resData);
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::VisibleMobilityKill;
resData.hits = {2, 2, 2, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady; // total firings and hits on all VBGs
resData.hits = {20, 10, 9, 1};
m_dataTable.append(resData);
pieData.chargeTypeId = 372;
pieData.startTime = 1513758640000;
pieData.hits = {20, 10, 9, 1};
m_dataPie.append(pieData);
resData.chargeTypeId = 0; // total
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady; // total firings and hits on all VBGs
resData.hits = {40, 20, 18, 2};
m_dataTable.append(resData);
#else
getReportData(report);
if (report.visualisationType() == VisualisationType::Table)
fillReportData();
else
fillPieData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool AirSupportModel::fetchInterfaces()
{
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int AirSupportModel::rowCount(const QModelIndex &parent) const
{
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
return parent.isValid() ? 0 : m_dataPie.count();
else
return parent.isValid() ? 0 : m_dataTable.count();
}
// -----------------------------------------------------------------------------------------------------
int AirSupportModel::columnCount(const QModelIndex &parent) const
{
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
return parent.isValid() ? 0 : COUNT_PIE;
else
return parent.isValid() ? 0 : COUNT_TABLE;
}
// -----------------------------------------------------------------------------------------------------
QVariant AirSupportModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (m_report.visualisationType() == VisualisationType::Table)
{
const resultDataTable &displayInfo = m_dataTable[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
case IMPACTS:
case HITS_TOTAL:
case HITS_ENEMY:
case HITS_FRIENDLY:
case HITS_BUILDING:
return Qt::AlignRight;
case START_TIME:
case CHARGE_TYPE_NAME:
case VULNERABILITY_STATE:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total on charge type
if (displayInfo.chargeTypeId == 0 || displayInfo.vulnerabilityState == ProjectDataManagement::VulnerabilityState::NotReady)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
return (displayInfo.chargeTypeId > 0 ? displayInfo.chargeTypeId : QVariant());
case CHARGE_TYPE_NAME:
{
QString displayTypeName;
if (displayInfo.chargeTypeId > 0)
{
QString chargeTypeName = m_pdmDtc->trChargeTypeShortName(displayInfo.chargeTypeId);
if (displayInfo.vulnerabilityState == ProjectDataManagement::VulnerabilityState::NotReady)
displayTypeName = tr("Total [%1]").arg(chargeTypeName);
else
displayTypeName = chargeTypeName;
}
return (displayInfo.chargeTypeId > 0 ? displayTypeName : tr("TOTAL:"));
}
case START_TIME:
{
QString timeInterval = DTG::toStringMSec(displayInfo.startTime) + QStringLiteral(" - " ) + DTG::toStringMSec(displayInfo.endTime);
return (displayInfo.vulnerabilityState != ProjectDataManagement::VulnerabilityState::NotReady ? timeInterval : QVariant());
}
case IMPACTS:
return (displayInfo.hits[4] > 0 ? displayInfo.hits[4] : QVariant());
case HITS_BUILDING:
return (displayInfo.hits[0] > 0 ? displayInfo.hits[0] : QVariant());
case HITS_TOTAL:
return (displayInfo.hits[1] > 0 ? displayInfo.hits[1] : QVariant());
case HITS_ENEMY:
return displayInfo.hits[2];
case HITS_FRIENDLY:
return displayInfo.hits[3];
case VULNERABILITY_STATE:
return ((displayInfo.vulnerabilityState != ProjectDataManagement::VulnerabilityState::NotReady &&
displayInfo.vulnerabilityState != ProjectDataManagement::VulnerabilityState::CombatReady) ?
ProjectDataManagement::toString(displayInfo.vulnerabilityState): QVariant());
default:
return QVariant();
}
}
}
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
{
const resultDataPie &pieInfo = m_dataPie[index.row()];
if (role == Qt::EditRole)
{
return pieInfo.chargeTypeId;
}
if (role == Qt::UserRole)
{
return pieInfo.chargeTypeId > 0 ? m_pdmDtc->trChargeTypeShortName(pieInfo.chargeTypeId) : QVariant();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case HITS_ENEMY_PIE:
return pieInfo.hits[2] > 0 ? pieInfo.hits[2] : QVariant();
case HITS_FRIENDLY_PIE:
return pieInfo.hits[3] > 0 ? pieInfo.hits[3] : QVariant();
case HITS_BUILDING_PIE:
return pieInfo.hits[0] > 0 ? pieInfo.hits[0] :QVariant();
case START_TIME_PIE:
return DTG::toStringMSec(pieInfo.startTime);
default:
return QVariant();
}
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant AirSupportModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
if (m_report.visualisationType() == VisualisationType::Table)
{
switch (section)
{
case CHARGE_TYPE_ID:
return tr("Charge Id");
case CHARGE_TYPE_NAME:
return tr("Charge Type");
case VULNERABILITY_STATE:
return tr("Hit Effects");
case START_TIME:
return tr("Interval Start Time");
case IMPACTS:
return tr("Impacts");
case HITS_TOTAL:
return tr("Hits");
case HITS_ENEMY:
return tr("Enemy Forces Hits");
case HITS_FRIENDLY:
return tr("Own Force Hits");
case HITS_BUILDING:
return tr("Hit Buildings");
default:
return QVariant();
}
}
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
{
switch (section)
{
case START_TIME_PIE:
return tr("Time");
case HITS_ENEMY_PIE:
return tr("Enemy Forces Hits");
case HITS_FRIENDLY_PIE:
return tr("Own Force Hits");
case HITS_BUILDING_PIE:
return tr("Buildings hits");
default:
return QVariant();
}
}
}
if (orientation == Qt::Vertical && role == Qt::DisplayRole && m_report.visualisationType() == VisualisationType::Bar)
{
return DTG::toStringMSec(m_dataPie[section].startTime);
}
return QAbstractTableModel::headerData(section, orientation, role);
}
// ------------------------------------------------------------------
void AirSupportModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int chargeTypeId = -1;
QMap<int, QVector<int> > sums;
QVector<int> bigTotal(5, 0);
resultDataTable resData;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resData.startTime = obj[QStringLiteral("start_time")].toDouble();
resData.endTime = obj[QStringLiteral("end_time")].toDouble();
resData.hits[4] = obj[QStringLiteral("impacts")].toInt();
resData.vulnerabilityState = static_cast<ProjectDataManagement::VulnerabilityState::type>(obj[QStringLiteral("vulnerability_state")].toInt());
resData.hits[0] = obj[QStringLiteral("hits_buildings")].toInt();
resData.hits[3] = obj[QStringLiteral("hits_friendly_fire")].toInt();
resData.hits[2] = obj[QStringLiteral("hits")].toInt();
resData.hits[1] = resData.hits[2] + resData.hits[3] + resData.hits[0];
INFO_LOG(m_logger) << "Charge type id = " << resData.chargeTypeId;
INFO_LOG(m_logger) << "Start time = " << resData.startTime;
INFO_LOG(m_logger) << "VulnerabilityState = " << resData.vulnerabilityState;
INFO_LOG(m_logger) << "Hits = ("
<< resData.hits[0] << ", "
<< resData.hits[1] << ", "
<< resData.hits[2] << ", "
<< resData.hits[3] << ", "
<< resData.hits[4] << ")" ;
if (chargeTypeId != resData.chargeTypeId) // new chargeTypeId
{
DEBUG_LOG(m_logger) << "New chargeTypeId: " << resData.chargeTypeId;
if (chargeTypeId != -1) // total on chargeTypeId
{
resultDataTable totalChargeTypeId;
totalChargeTypeId.chargeTypeId = chargeTypeId;
totalChargeTypeId.startTime = 0;
totalChargeTypeId.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
totalChargeTypeId.hits = sums[chargeTypeId];
m_dataTable.append(std::move(totalChargeTypeId));
sumUp(bigTotal, sums[chargeTypeId], sums[chargeTypeId].size());
}
chargeTypeId = resData.chargeTypeId;
sums[chargeTypeId].append(resData.hits);
}
else
{
DEBUG_LOG(m_logger) << "Adding values to chargeType id: " << chargeTypeId;
resData.hits[4] = 0; // count impact only once
sumUp(sums[chargeTypeId], resData.hits, resData.hits.size());
}
m_dataTable.append(resData); // no std::move() - allocated outside loop
}
if (m_reportJsonArray.size() > 0)
{
// last total on charge type
resultDataTable totalChargeTypeId;
totalChargeTypeId.chargeTypeId = chargeTypeId;
totalChargeTypeId.startTime = 0;
totalChargeTypeId.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
totalChargeTypeId.hits = sums[chargeTypeId];
m_dataTable.append(std::move(totalChargeTypeId));
sumUp(bigTotal, sums[chargeTypeId], sums[chargeTypeId].size());
// big total
resultDataTable total;
total.chargeTypeId = 0;
total.startTime = 0;
total.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
total.hits = bigTotal;
m_dataTable.append(std::move(total));
}
}
// ------------------------------------------------------------------
void AirSupportModel::fillPieData()
{
DEBUG_LOG(m_logger) << "fillPieData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
QMap<QPair<int,double>, QVector<int> > sums;
resultDataPie resPieData;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resPieData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resPieData.startTime = obj[QStringLiteral("start_time")].toDouble();
resPieData.hits[0] = obj[QStringLiteral("hits_buildings")].toInt();
resPieData.hits[3] = obj[QStringLiteral("hits_friendly_fire")].toInt();
resPieData.hits[2] = obj[QStringLiteral("hits")].toInt();
resPieData.hits[1] = resPieData.hits[2] + resPieData.hits[3];
INFO_LOG(m_logger) << "Charge type id = " << resPieData.chargeTypeId;
INFO_LOG(m_logger) << "Start time = " << resPieData.startTime;
INFO_LOG(m_logger) << "Hits = ("
<< resPieData.hits[0] << ", "
<< resPieData.hits[1] << ", "
<< resPieData.hits[2] << ", "
<< resPieData.hits[3] << ")" ;
QPair<int,double> key;
key.first = resPieData.chargeTypeId;
key.second = resPieData.startTime;
if (!sums.contains(key))
sums[key].append({0,0,0,0,0});
// wäre folgendes nicht einfacher und sprechender? 'sums[key] += resPieData.hits'
for(int i = 0; i < resPieData.hits.size(); ++i)
sums[key][i] += resPieData.hits[i];
}
const auto &keyValues = sums.keys();
for (const auto &key : keyValues) // do not iterate on temporary
{
resultDataPie resPie;
resPie.chargeTypeId = key.first;
resPie.startTime = key.second;
resPie.hits = sums[key];
INFO_LOG(m_logger) << "ChargeType: " << resPie.chargeTypeId;
INFO_LOG(m_logger) << "StartTime: " << resPie.startTime;
for(int i = 0; i < resPie.hits.size(); ++i)
INFO_LOG(m_logger) << "Hits = ("
<< resPie.hits[0] << ", "
<< resPie.hits[1] << ", "
<< resPie.hits[2] << ", "
<< resPie.hits[3] << ")" ;
m_dataPie.append(std::move(resPie));
}
}
@@ -0,0 +1,84 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ProjectDataManagement/pdm_dtc.h>
#include <AreaEffectSimulation/aes_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class AirSupportModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit AirSupportModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
void fillPieData();
enum ColumnsTable
{
CHARGE_TYPE_NAME = 0,
START_TIME = 1,
IMPACTS = 2,
HITS_TOTAL = 3,
VULNERABILITY_STATE = 4,
HITS_ENEMY = 5,
HITS_BUILDING = 6,
HITS_FRIENDLY = 7,
CHARGE_TYPE_ID = 8,
#ifdef LTS_DEBUG
COUNT_TABLE = 9
#else
COUNT_TABLE = 7 // without last column
#endif
};
enum ColumnsPie
{
HITS_ENEMY_PIE = 0,
HITS_FRIENDLY_PIE = 1,
HITS_BUILDING_PIE = 2,
START_TIME_PIE = 3,
COUNT_PIE = 3
};
struct resultDataPie
{
//int aesId = 0;
int chargeTypeId = 0;
qint64 startTime = 0;
qint64 endTime = 0;
QVector<int> hits = {0, 0, 0, 0, 0};
};
struct resultDataTable : public resultDataPie
{
//QString aesName;
ProjectDataManagement::VulnerabilityState vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
};
QVector<resultDataTable> m_dataTable;
QVector<resultDataPie> m_dataPie;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,202 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_building_damage_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <ngltools/ngltools_dtg.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
BuildingDamageModel::BuildingDamageModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ismDtc(nullptr)
, m_logger(getLogger("BuildingDamageModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.buildingId = 301;
resData.timePoint = 1513758640000;
resData.damages[0] = 20;
resData.damages[1] = 20;
resData.damages[2] = 20;
resData.damages[3] = 20;
resData.damages[4] = 20;
m_data.append(resData);
resData.buildingId = 301;
resData.timePoint = 1513758650000;
resData.damages[0] = 10;
resData.damages[1] = 30;
resData.damages[2] = 20;
resData.damages[3] = 20;
resData.damages[4] = 20;
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
int BuildingDamageModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int BuildingDamageModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant BuildingDamageModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case BUILDING_ID:
case DAMAGE_20:
case DAMAGE_40:
case DAMAGE_60:
case DAMAGE_80:
case DAMAGE_100:
return Qt::AlignRight;
case BUILDING_NAME:
case TIME_POINT:
case ROOM_COUNT:
default:
return Qt::AlignLeft;
}
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case BUILDING_ID:
return displayInfo.buildingId;
case BUILDING_NAME:
return m_ismDtc->getBuildingDisplayName(displayInfo.buildingId);
case TIME_POINT:
return DTG::toStringMSec(displayInfo.timePoint);
case ROOM_COUNT:
return m_ismDtc->getBuildingRoomsCount(displayInfo.buildingId);
case DAMAGE_20:
return displayInfo.damages[0];
case DAMAGE_40:
return displayInfo.damages[1];
case DAMAGE_60:
return displayInfo.damages[2];
case DAMAGE_80:
return displayInfo.damages[3];
case DAMAGE_100:
return displayInfo.damages[4];
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant BuildingDamageModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case BUILDING_ID:
return tr("Building Id");
case BUILDING_NAME:
return tr("Building Name");
case ROOM_COUNT:
return tr("#Rooms");
case TIME_POINT:
return tr("Timepoint (start/end)");
case DAMAGE_20:
return tr("Damage level 0-20%");
case DAMAGE_40:
return tr("Damage level 20-40%");
case DAMAGE_60:
return tr("Damage level 40-60%");
case DAMAGE_80:
return tr("Damage level 60-80%");
case DAMAGE_100:
return tr("Damage level 80-100%");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void BuildingDamageModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.buildingId = obj[QStringLiteral("building_id")].toInt();
resData.timePoint = obj[QStringLiteral("time_point")].toDouble();
resData.damages[0] = obj[QStringLiteral("damage_20")].toInt();
resData.damages[1] = obj[QStringLiteral("damage_40")].toInt();
resData.damages[2] = obj[QStringLiteral("damage_60")].toInt();
resData.damages[3] = obj[QStringLiteral("damage_80")].toInt();
resData.damages[4] = obj[QStringLiteral("damage_100")].toInt();
resData.buildingDamagePercent = obj[QStringLiteral("damage_percent")].toInt();
INFO_LOG(m_logger) << "Building Id = " << resData.buildingId;
INFO_LOG(m_logger) << "Time point = " << resData.timePoint;
INFO_LOG(m_logger) << "Damages = " << resData.damages;
INFO_LOG(m_logger) << "Building Damage Percent = " << resData.buildingDamagePercent;
m_data.append(std::move(resData));
}
}
// -----------------------------------------------------------------------------------------------------
bool BuildingDamageModel::fetchInterfaces()
{
if (!m_session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc))
{
ERROR_LOG(m_logger) << "Could not fetch ISM DTC Interface";
return false;
}
return true;
}
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <InfrastructureManagement/ism_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class BuildingDamageModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit BuildingDamageModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
BUILDING_NAME = 0,
TIME_POINT = 1,
ROOM_COUNT = 2,
DAMAGE_20 = 3,
DAMAGE_40 = 4,
DAMAGE_60 = 5,
DAMAGE_80 = 6,
DAMAGE_100 = 7,
BUILDING_ID = 8,
#ifdef LTS_DEBUG
COUNT = 9
#else
COUNT = 8 // without last column
#endif
};
struct resultData
{
int buildingId = 0;
int buildingDamagePercent = 0;
int damages[5] = {0,0,0,0,0};
qint64 timePoint = 0;
};
QVector<resultData> m_data;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,255 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_charge_administration_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <ProjectDataManagement/pdm_translation.h>
#include <LtsSession/lts_session.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
ChargeAdministrationModel::ChargeAdministrationModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_pdmDtc(nullptr)
, m_logger(getLogger("ChargeAdministrationModel"))
{
if (!fetchInterfaces())
return;
// #define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.chargeTypeId = 371;
resData.charges[0] = 1000;
resData.charges[1] = 1000;
resData.charges[2] = 500;
resData.charges[3] = 1500;
m_data.append(resData);
resData.chargeTypeId = 372;
resData.charges[0] = 1000;
resData.charges[1] = 1000;
resData.charges[2] = 500;
resData.charges[3] = 1500;
m_data.append(resData);
resData.chargeTypeId = 0;
resData.charges[0] = 2000;
resData.charges[1] = 2000;
resData.charges[2] = 1000;
resData.charges[3] = 3000;
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool ChargeAdministrationModel::fetchInterfaces()
{
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int ChargeAdministrationModel::rowCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : m_data.count(); }
// -----------------------------------------------------------------------------------------------------
int ChargeAdministrationModel::columnCount(const QModelIndex &parent) const { return parent.isValid() ? 0 : COUNT; }
// -----------------------------------------------------------------------------------------------------
QVariant ChargeAdministrationModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
case GEAR_CLASS:
case CHARGE_START:
case CHARGE_END:
case CHARGE_RESUPPLIED:
case CHARGE_FIRED:
case CHARGE_PLANNED:
case CHARGE_AVAILABLE:
return Qt::AlignRight;
case CHARGE_TYPE_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total
if (displayInfo.chargeTypeId == 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
return (displayInfo.chargeTypeId > 0 ? displayInfo.chargeTypeId : QVariant());
case EFFECT_SOURCE_ID:
return (displayInfo.effectSourceId.underlying() >= 0 ? ProjectDataManagement::toString(displayInfo.effectSourceId) : tr("Total:"));
case GEAR_CLASS:
return (displayInfo.chargeTypeId > 0 ? ProjectDataManagement::toString(m_pdmDtc->gearClassFromChargeTypeId(displayInfo.chargeTypeId)) : QVariant());
case CHARGE_TYPE_NAME:
return (displayInfo.chargeTypeId > 0 ? m_pdmDtc->trChargeTypeShortName(displayInfo.chargeTypeId, true) : tr("TOTAL:"));
case CHARGE_START:
return displayInfo.charges[0];
case CHARGE_RESUPPLIED:
return displayInfo.charges[1];
case CHARGE_END:
return displayInfo.charges[2];
case CHARGE_FIRED:
return displayInfo.charges[3];
case CHARGE_PLANNED:
return displayInfo.charges[4];
case CHARGE_AVAILABLE:
return displayInfo.charges[5];
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant ChargeAdministrationModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case EFFECT_SOURCE_ID:
return tr("Effect Source Id");
case CHARGE_TYPE_ID:
return tr("Charge Id");
case GEAR_CLASS:
return tr("Gear Class");
case CHARGE_TYPE_NAME:
return tr("Charge Type");
case CHARGE_START:
return tr("Stock Start");
case CHARGE_RESUPPLIED:
return tr("Resupplied");
case CHARGE_END:
return tr("Total Stock");
case CHARGE_FIRED:
return tr("Used");
case CHARGE_PLANNED:
return tr("Planned");
case CHARGE_AVAILABLE:
return tr("Available");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void ChargeAdministrationModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int sums[6] = {0, 0, 0, 0, 0, 0};
int bigTotal[6] = {0, 0, 0, 0, 0, 0};
ProjectDataManagement::EffectSource effectSourceId = ProjectDataManagement::EffectSource::ES_Unknown;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resData.effectSourceId = static_cast<ProjectDataManagement::EffectSource::type>(obj[QStringLiteral("effect_source_id")].toInt());
resData.charges[0] = obj[QStringLiteral("charge_start")].toInt();
resData.charges[1] = obj[QStringLiteral("charge_resupplied")].toInt();
resData.charges[2] = obj[QStringLiteral("charge_end")].toInt();
resData.charges[3] = obj[QStringLiteral("charge_fired")].toInt();
resData.charges[4] = obj[QStringLiteral("charge_planned")].toInt();
resData.charges[5] = obj[QStringLiteral("charge_available")].toInt();
INFO_LOG(m_logger) << "Charge type id = " << resData.chargeTypeId;
INFO_LOG(m_logger) << "Effect Source id = " << resData.effectSourceId;
INFO_LOG(m_logger) << "Charges = (" << resData.charges[0] << ", " << resData.charges[1] << ", " << resData.charges[2] << ", " << resData.charges[3] << ", "
<< resData.charges[4] << ", " << resData.charges[5] << ")";
// if (resData.charges[0] != 0 || resData.charges[1] != 0 || resData.charges[2] != 0 || resData.charges[3] != 0)
if (effectSourceId != resData.effectSourceId)
{
DEBUG_LOG(m_logger) << "New effectSourceId: " << resData.effectSourceId;
if (effectSourceId != ProjectDataManagement::EffectSource::ES_Unknown)
{
resultData totalEffectSource;
totalEffectSource.effectSourceId = effectSourceId;
std::copy(std::begin(sums), std::end(sums), std::begin(totalEffectSource.charges));
m_data.append(std::move(totalEffectSource));
sumUp(bigTotal, totalEffectSource.charges, 6);
}
effectSourceId = resData.effectSourceId.underlying();
std::fill(std::begin(sums), std::end(sums), 0);
}
sumUp(sums, resData.charges, 6);
m_data.append(std::move(resData));
}
if (m_data.size() > 0) // total
{
// last total on effectSourceId
resultData totalEffectSource;
totalEffectSource.effectSourceId = effectSourceId;
totalEffectSource.chargeTypeId = -1;
std::copy(std::begin(sums), std::end(sums), std::begin(totalEffectSource.charges));
m_data.append(std::move(totalEffectSource));
sumUp(bigTotal, totalEffectSource.charges, 6);
// big total
resultData total;
total.effectSourceId = ProjectDataManagement::EffectSource::ES_Unknown;
total.chargeTypeId = -1;
std::copy(std::begin(bigTotal), std::end(bigTotal), std::begin(total.charges));
m_data.append(std::move(total));
}
}
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ProjectDataManagement/pdm_dtc.h>
#include <ReportManagement/logger.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class ChargeAdministrationModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit ChargeAdministrationModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
EFFECT_SOURCE_ID = 0,
GEAR_CLASS = 1,
CHARGE_TYPE_NAME = 2,
CHARGE_START = 3,
CHARGE_RESUPPLIED = 4,
CHARGE_END = 5,
CHARGE_PLANNED = 6,
CHARGE_AVAILABLE = 7,
CHARGE_FIRED = 8,
CHARGE_TYPE_ID = 9,
#ifdef LTS_DEBUG
COUNT = 10
#else
COUNT = 9 // without last column
#endif
};
struct resultData
{
ProjectDataManagement::EffectSource effectSourceId = ProjectDataManagement::EffectSource::get_default();
int chargeTypeId = 0;
int charges[6] = {0, 0, 0, 0, 0, 0};
};
QVector<resultData> m_data;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
LOGGER_T m_logger;
};
} // namespace ReportManagement
@@ -0,0 +1,333 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_charge_resupply_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
ChargeResupplyModel::ChargeResupplyModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_logger(getLogger("ChargeResupplyModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.participantTypeId = 23;
resData.chargeTypeId = 371;
resData.charges[0] = 1000;
resData.charges[1] = 1000;
resData.charges[2] = 500;
resData.charges[3] = 1500;
resData.charges[4] = 1000;
m_data.append(resData);
resData.participantTypeId = 23;
resData.chargeTypeId = 372;
resData.charges[0] = 1000;
resData.charges[1] = 1000;
resData.charges[2] = 500;
resData.charges[3] = 1500;
resData.charges[4] = 1000;
m_data.append(resData);
resData.participantTypeId = 23;
resData.chargeTypeId = 0; // total on participant type
resData.charges[0] = 2000;
resData.charges[1] = 2000;
resData.charges[2] = 1000;
resData.charges[3] = 3000;
resData.charges[4] = 2000;
m_data.append(resData);
resData.participantTypeId = 32;
resData.chargeTypeId = 371;
resData.charges[0] = 1000;
resData.charges[1] = 1000;
resData.charges[2] = 500;
resData.charges[3] = 1500;
resData.charges[4] = 1000;
m_data.append(resData);
resData.participantTypeId = 32;
resData.chargeTypeId = 372;
resData.charges[0] = 1000;
resData.charges[1] = 1000;
resData.charges[2] = 500;
resData.charges[3] = 1500;
resData.charges[4] = 1000;
m_data.append(resData);
resData.participantTypeId = 32;
resData.chargeTypeId = 0; // total on participant type
resData.charges[0] = 2000;
resData.charges[1] = 2000;
resData.charges[2] = 1000;
resData.charges[3] = 3000;
resData.charges[4] = 2000;
m_data.append(resData);
resData.participantTypeId = 0; // total
resData.chargeTypeId = 0;
resData.charges[0] = 4000;
resData.charges[1] = 4000;
resData.charges[2] = 2000;
resData.charges[3] = 6000;
resData.charges[4] = 4000;
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool ChargeResupplyModel::fetchInterfaces()
{
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int ChargeResupplyModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int ChargeResupplyModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant ChargeResupplyModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
case PARTICIPANT_TYPE_ID:
case CHARGE_START:
case CHARGE_END:
case CHARGE_TAKEN:
#ifndef GUEZ_MODE
case CHARGE_GIVEN:
#endif
case CHARGE_FIRED:
return Qt::AlignRight;
case CHARGE_TYPE_NAME:
case PARTICIPANT_TYPE_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total
if (displayInfo.chargeTypeId == 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
return (displayInfo.participantTypeId > 0 ? displayInfo.participantTypeId : QVariant());
case CHARGE_TYPE_ID:
return (displayInfo.chargeTypeId > 0 ? displayInfo.chargeTypeId : QVariant());
case PARTICIPANT_TYPE_NAME:
{
QString displayTypeName;
if (displayInfo.participantTypeId > 0)
{
QString typeName = QString::fromStdString(m_ppmDtc->type(displayInfo.participantTypeId).name());
if (displayInfo.chargeTypeId == 0)
displayTypeName = tr("Total [%1]").arg(typeName);
else
displayTypeName = typeName;
}
return (displayInfo.participantTypeId > 0 ? displayTypeName : tr("TOTAL:"));
}
case CHARGE_TYPE_NAME:
return (displayInfo.chargeTypeId > 0 ? m_pdmDtc->trChargeTypeShortName(displayInfo.chargeTypeId, true)
: QVariant());
case CHARGE_START:
return displayInfo.charges[0];
case CHARGE_TAKEN:
return displayInfo.charges[1];
#ifndef GUEZ_MODE
case CHARGE_GIVEN:
return displayInfo.charges[2];
#endif
case CHARGE_END:
return displayInfo.charges[3];
case CHARGE_FIRED:
return displayInfo.charges[4];
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant ChargeResupplyModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case CHARGE_TYPE_ID:
return tr("Charge Id");
case CHARGE_TYPE_NAME:
return tr("Charge Type");
case PARTICIPANT_TYPE_ID:
return tr("Type Id");
case PARTICIPANT_TYPE_NAME:
return tr("Type Name");
case CHARGE_START:
return tr("Stock Start");
case CHARGE_TAKEN:
return tr("Taken");
#ifndef GUEZ_MODE
case CHARGE_GIVEN:
return tr("Given");
#endif
case CHARGE_END:
return tr("Stock End");
case CHARGE_FIRED:
return tr("Charge Used");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void ChargeResupplyModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int participantTypeId = -1;
QMap<int, QVector<int> > sums;
QVector<int> bigTotal(5, 0);
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.participantTypeId = obj[QStringLiteral("participant_type_id")].toInt();
resData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resData.charges[0] = obj[QStringLiteral("charge_start")].toInt();
resData.charges[1] = obj[QStringLiteral("charge_taken")].toInt();
resData.charges[2] = obj[QStringLiteral("charge_given")].toInt();
resData.charges[3] = obj[QStringLiteral("charge_end")].toInt();
resData.charges[4] = obj[QStringLiteral("charge_fired")].toInt();
INFO_LOG(m_logger) << "Participant type id = " << resData.participantTypeId;
INFO_LOG(m_logger) << "Charge type id = " << resData.chargeTypeId;
INFO_LOG(m_logger) << "Charges = ("
<< resData.charges[0] << ", "
<< resData.charges[1] << ", "
<< resData.charges[2] << ", "
<< resData.charges[3] << ", "
<< resData.charges[4] << ")" ;
if (participantTypeId != resData.participantTypeId) // new Type
{
DEBUG_LOG(m_logger) << "New participant type id: " << resData.participantTypeId;
if (participantTypeId != -1) // total on type
{
resultData totalType;
totalType.participantTypeId = participantTypeId;
totalType.chargeTypeId = 0;
totalType.charges = sums[participantTypeId];
m_data.append(std::move(totalType));
sumUp(bigTotal, sums[participantTypeId], sums[participantTypeId].size());
}
participantTypeId = resData.participantTypeId;
sums[participantTypeId].append(resData.charges);
}
else
{
DEBUG_LOG(m_logger) << "Adding values to participant type id: " << participantTypeId;
sumUp(sums[participantTypeId], resData.charges, resData.charges.size());
}
m_data.append(std::move(resData));
}
if (m_reportJsonArray.size() > 0)
{
// last total on type
resultData totalType;
totalType.participantTypeId = participantTypeId;
totalType.chargeTypeId = 0;
totalType.charges = sums[participantTypeId];
m_data.append(std::move(totalType));
sumUp(bigTotal, sums[participantTypeId], sums[participantTypeId].size());
// big total
resultData total;
total.participantTypeId = 0;
total.chargeTypeId = 0;
total.charges = bigTotal;
m_data.append(std::move(total));
}
}
@@ -0,0 +1,70 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ProjectDataManagement/pdm_dtc.h>
#include <ParticipantManagement/ppm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class ChargeResupplyModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit ChargeResupplyModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
PARTICIPANT_TYPE_NAME = 0,
CHARGE_TYPE_NAME = 1,
CHARGE_START = 2,
CHARGE_TAKEN = 3,
#ifndef GUEZ_MODE
CHARGE_GIVEN = 4,
CHARGE_END = 5,
CHARGE_FIRED = 6,
CHARGE_TYPE_ID = 7,
PARTICIPANT_TYPE_ID = 8,
COUNT = 7 // without last 2 columns
#else
CHARGE_END = 4,
CHARGE_FIRED = 5,
CHARGE_TYPE_ID = 6,
PARTICIPANT_TYPE_ID = 7,
COUNT = 6 // without last 2 columns
#endif
};
struct resultData
{
int participantTypeId = 0;
int chargeTypeId = 0;
QVector<int> charges = {0, 0, 0, 0, 0};
};
QVector<resultData> m_data;
std::shared_ptr<ReportManagement::Interface::Ftc> m_ftc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,460 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_firings_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <ProjectDataManagement/pdm_translation.h>
#include <LtsSession/lts_session.h>
#include <ngltools/ngltools_dtg.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
FiringsModel::FiringsModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_pdmDtc(nullptr)
, m_logger(getLogger("FiringsModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultDataTable resData;
// charge type 371
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::CatastrophicKill;
resData.hits = {9, 4, 4, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::MobilityKill;
resData.hits = {9, 4, 3, 1};
m_dataTable.append(resData);
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::VisibleMobilityKill;
resData.hits = {2, 2, 2, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 371;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady; // total firings and hits on all VBGs
resData.hits = {20, 10, 9, 1};
m_dataTable.append(resData);
resultDataPie pieData;
pieData.chargeTypeId = 371;
pieData.startTime = 1513758640000;
pieData.hits = {20, 10, 9, 1};
m_dataPie.append(pieData);
// charge type 372
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::CatastrophicKill;
resData.hits = {14, 4, 4, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::MobilityKill;
resData.hits = {4, 4, 3, 1};
m_dataTable.append(resData);
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::VisibleMobilityKill;
resData.hits = {2, 2, 2, 0};
m_dataTable.append(resData);
resData.chargeTypeId = 372;
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady; // total firings and hits on all VBGs
resData.hits = {20, 10, 9, 1};
m_dataTable.append(resData);
pieData.chargeTypeId = 372;
pieData.startTime = 1513758640000;
pieData.hits = {20, 10, 9, 1};
m_dataPie.append(pieData);
resData.chargeTypeId = 0; // total
resData.startTime = 1513758640000;
resData.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady; // total firings and hits on all VBGs
resData.hits = {40, 20, 18, 2};
m_dataTable.append(resData);
#else
getReportData(report);
if (report.visualisationType() == VisualisationType::Table)
fillReportData();
else
fillPieData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool FiringsModel::fetchInterfaces()
{
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int FiringsModel::rowCount(const QModelIndex &parent) const
{
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
return parent.isValid() ? 0 : m_dataPie.count();
else
return parent.isValid() ? 0 : m_dataTable.count();
}
// -----------------------------------------------------------------------------------------------------
int FiringsModel::columnCount(const QModelIndex &parent) const
{
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
return parent.isValid() ? 0 : COUNT_PIE;
else
return parent.isValid() ? 0 : COUNT_TABLE;
}
// -----------------------------------------------------------------------------------------------------
QVariant FiringsModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (m_report.visualisationType() == VisualisationType::Table)
{
const resultDataTable &displayInfo = m_dataTable[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
case FIRINGS:
case HITS_TOTAL:
case HITS_ENEMY:
case HITS_FRIENDLY:
return Qt::AlignRight;
case START_TIME:
case CHARGE_TYPE_NAME:
case VULNERABILITY_STATE:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total on charge type
if (displayInfo.chargeTypeId == 0 || displayInfo.vulnerabilityState == ProjectDataManagement::VulnerabilityState::NotReady)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case CHARGE_TYPE_ID:
return (displayInfo.chargeTypeId > 0 ? displayInfo.chargeTypeId : QVariant());
case CHARGE_TYPE_NAME:
{
QString displayTypeName;
if (displayInfo.chargeTypeId > 0)
{
QString chargeTypeName = m_pdmDtc->trChargeTypeShortName(displayInfo.chargeTypeId);
if (displayInfo.vulnerabilityState == ProjectDataManagement::VulnerabilityState::NotReady)
displayTypeName = tr("Total [%1]").arg(chargeTypeName);
else
displayTypeName = chargeTypeName;
}
return (displayInfo.chargeTypeId > 0 ? displayTypeName : tr("TOTAL:"));
}
case START_TIME:
return (displayInfo.vulnerabilityState != ProjectDataManagement::VulnerabilityState::NotReady ? DTG::toStringMSec(displayInfo.startTime) : QVariant());
case FIRINGS:
return (displayInfo.hits[0] > 0 ? displayInfo.hits[0] : QVariant());
case HITS_TOTAL:
return (displayInfo.hits[1] > 0 ? displayInfo.hits[1] : QVariant());
case HITS_ENEMY:
return displayInfo.hits[2];
case HITS_FRIENDLY:
return displayInfo.hits[3];
case VULNERABILITY_STATE:
return ((displayInfo.vulnerabilityState != ProjectDataManagement::VulnerabilityState::NotReady &&
displayInfo.vulnerabilityState != ProjectDataManagement::VulnerabilityState::CombatReady) ?
ProjectDataManagement::toString(displayInfo.vulnerabilityState): QVariant());
default:
return QVariant();
}
}
}
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
{
const resultDataPie &pieInfo = m_dataPie[index.row()];
if (role == Qt::EditRole)
{
return pieInfo.chargeTypeId;
}
if (role == Qt::UserRole)
{
return pieInfo.chargeTypeId > 0 ? m_pdmDtc->trChargeTypeShortName(pieInfo.chargeTypeId) : QVariant();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case HITS_ENEMY_PIE:
return pieInfo.hits[2] > 0 ? pieInfo.hits[2] : QVariant();
case HITS_FRIENDLY_PIE:
return pieInfo.hits[3] > 0 ? pieInfo.hits[3] : QVariant();
case FIRE_WITHOUT_HIT:
return (pieInfo.hits[0] - pieInfo.hits[1]) > 0 ? (pieInfo.hits[0] - pieInfo.hits[1]) : QVariant(); // firings - hits total
case START_TIME_PIE:
return DTG::toStringMSec(pieInfo.startTime);
default:
return QVariant();
}
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant FiringsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
if (m_report.visualisationType() == VisualisationType::Table)
{
switch (section)
{
case CHARGE_TYPE_ID:
return tr("Charge Id");
case CHARGE_TYPE_NAME:
return tr("Charge Type");
case VULNERABILITY_STATE:
return tr("Hit Effects");
case START_TIME:
return tr("Interval Start Time");
case FIRINGS:
return tr("Firings");
case HITS_TOTAL:
return tr("Hits");
case HITS_ENEMY:
return tr("Enemy Forces Hits");
case HITS_FRIENDLY:
return tr("Own Force Hits");
default:
return QVariant();
}
}
if (m_report.visualisationType() == VisualisationType::Pie || m_report.visualisationType() == VisualisationType::Bar)
{
switch (section)
{
case START_TIME_PIE:
return tr("Time");
case HITS_ENEMY_PIE:
return tr("Enemy Forces Hits");
case HITS_FRIENDLY_PIE:
return tr("Own Force Hits");
case FIRE_WITHOUT_HIT:
return tr("Firings without hits");
default:
return QVariant();
}
}
}
if (orientation == Qt::Vertical && role == Qt::DisplayRole && m_report.visualisationType() == VisualisationType::Bar)
{
return DTG::toStringMSec(m_dataPie[section].startTime);
}
return QAbstractTableModel::headerData(section, orientation, role);
}
// ------------------------------------------------------------------
void FiringsModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int chargeTypeId = -1;
QMap<int, QVector<int> > sums;
QVector<int> bigTotal(4, 0);
resultDataTable resData;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resData.startTime = obj[QStringLiteral("start_time")].toDouble();
resData.vulnerabilityState = static_cast<ProjectDataManagement::VulnerabilityState::type>(obj[QStringLiteral("vulnerability_state")].toInt());
resData.hits[0] = obj[QStringLiteral("firings")].toInt();
resData.hits[3] = obj[QStringLiteral("hits_friendly_fire")].toInt();
resData.hits[2] = obj[QStringLiteral("hits")].toInt();
resData.hits[1] = resData.hits[2] + resData.hits[3];
INFO_LOG(m_logger) << "Charge type id = " << resData.chargeTypeId;
INFO_LOG(m_logger) << "Start time = " << resData.startTime;
INFO_LOG(m_logger) << "VulnerabilityState = " << resData.vulnerabilityState;
INFO_LOG(m_logger) << "Hits = ("
<< resData.hits[0] << ", "
<< resData.hits[1] << ", "
<< resData.hits[2] << ", "
<< resData.hits[3] << ")" ;
if (chargeTypeId != resData.chargeTypeId) // new Charge Type
{
DEBUG_LOG(m_logger) << "New charge type id: " << resData.chargeTypeId;
if (chargeTypeId != -1) // total on type
{
resultDataTable totalChargeType;
totalChargeType.chargeTypeId = chargeTypeId;
totalChargeType.startTime = 0;
totalChargeType.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
totalChargeType.hits = sums[chargeTypeId];
m_dataTable.append(std::move(totalChargeType));
sumUp(bigTotal, sums[chargeTypeId], sums[chargeTypeId].size());
}
chargeTypeId = resData.chargeTypeId;
sums[chargeTypeId].append(resData.hits);
}
else
{
DEBUG_LOG(m_logger) << "Adding values to charge type id: " << chargeTypeId;
sumUp(sums[chargeTypeId], resData.hits, resData.hits.size());
}
m_dataTable.append(resData); // no std::move() - allocated outside loop
}
if (m_reportJsonArray.size() > 0)
{
// last total on charge type
resultDataTable totalChargeType;
totalChargeType.chargeTypeId = chargeTypeId;
totalChargeType.startTime = 0;
totalChargeType.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
totalChargeType.hits = sums[chargeTypeId];
m_dataTable.append(std::move(totalChargeType));
sumUp(bigTotal, sums[chargeTypeId], sums[chargeTypeId].size());
// big total
resultDataTable total;
total.chargeTypeId = 0;
total.startTime = 0;
total.vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
total.hits = bigTotal;
m_dataTable.append(std::move(total));
}
}
// ------------------------------------------------------------------
void FiringsModel::fillPieData()
{
DEBUG_LOG(m_logger) << "fillPieData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
QMap<QPair<int,double>, QVector<int> > sums;
resultDataPie resPieData;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resPieData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resPieData.startTime = obj[QStringLiteral("start_time")].toDouble();
resPieData.hits[0] = obj[QStringLiteral("firings")].toInt();
resPieData.hits[3] = obj[QStringLiteral("hits_friendly_fire")].toInt();
resPieData.hits[2] = obj[QStringLiteral("hits")].toInt();
resPieData.hits[1] = resPieData.hits[2] + resPieData.hits[3];
INFO_LOG(m_logger) << "Charge type id = " << resPieData.chargeTypeId;
INFO_LOG(m_logger) << "Start time = " << resPieData.startTime;
INFO_LOG(m_logger) << "Hits = ("
<< resPieData.hits[0] << ", "
<< resPieData.hits[1] << ", "
<< resPieData.hits[2] << ", "
<< resPieData.hits[3] << ")" ;
QPair<int,double> key;
key.first = resPieData.chargeTypeId;
key.second = resPieData.startTime;
if (!sums.contains(key))
sums[key].append({0,0,0,0});
for(int i = 0; i < resPieData.hits.size(); ++i)
sums[key][i] += resPieData.hits[i];
}
for (auto key : sums.keys())
{
resultDataPie resPie;
resPie.chargeTypeId = key.first;
resPie.startTime = key.second;
resPie.hits = sums[key];
INFO_LOG(m_logger) << "ChargeType: " << resPie.chargeTypeId;
INFO_LOG(m_logger) << "StartTime: " << resPie.startTime;
for(int i = 0; i < resPie.hits.size(); ++i)
INFO_LOG(m_logger) << "Hits = ("
<< resPie.hits[0] << ", "
<< resPie.hits[1] << ", "
<< resPie.hits[2] << ", "
<< resPie.hits[3] << ")" ;
m_dataPie.append(std::move(resPie));
}
}
@@ -0,0 +1,78 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ProjectDataManagement/pdm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class FiringsModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit FiringsModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
void fillPieData();
enum ColumnsTable
{
CHARGE_TYPE_NAME = 0,
START_TIME = 1,
FIRINGS = 2,
HITS_TOTAL = 3,
VULNERABILITY_STATE = 4,
HITS_ENEMY = 5,
HITS_FRIENDLY = 6,
CHARGE_TYPE_ID = 7,
#ifdef LTS_DEBUG
COUNT_TABLE = 8
#else
COUNT_TABLE = 7 // without last column
#endif
};
enum ColumnsPie
{
HITS_ENEMY_PIE = 0,
HITS_FRIENDLY_PIE = 1,
FIRE_WITHOUT_HIT = 2,
START_TIME_PIE = 3,
COUNT_PIE = 3
};
struct resultDataPie
{
int chargeTypeId = 0;
qint64 startTime = 0;
QVector<int> hits = {0, 0, 0, 0};
};
struct resultDataTable : public resultDataPie
{
ProjectDataManagement::VulnerabilityState vulnerabilityState = ProjectDataManagement::VulnerabilityState::NotReady;
};
QVector<resultDataTable> m_dataTable;
QVector<resultDataPie> m_dataPie;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,229 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_maintenance_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <ngltools/ngltools_dtg.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
MaintenanceModel::MaintenanceModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ppmDtc(nullptr)
, m_logger(getLogger("ReportMaintenanceModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.participantTypeId = 23;
resData.participantId = 31;
resData.time_sanitation = 1513758639000;
resData.success_sanitation = false;
resData.time_event = 1513758640000;
resData.time_position = 1513758640010;
resData.time_vulnerability = 1513758640020;
resData.vitality = 80;
m_data.append(resData);
resData.participantTypeId = 23;
resData.participantId = 32;
resData.time_sanitation = 1513758639000;
resData.success_sanitation = true;
resData.time_event = 1513758640000;
resData.time_position = 1513758640010;
resData.time_vulnerability = 1513758640020;
resData.vitality = 80;
m_data.append(resData);
resData.participantTypeId = 23;
resData.participantId = 33;
resData.time_sanitation = 1513758639000;
resData.success_sanitation = true;
resData.time_event = 1513758640000;
resData.time_position = 1513758640010;
resData.time_vulnerability = 1513758640020;
resData.vitality = 80;
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool MaintenanceModel::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int MaintenanceModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int MaintenanceModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant MaintenanceModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
case PARTICIPANT_ID:
case PARTICIPANT_EQUIPMENT_NO:
case TIME_EVENT:
case TIME_POSITION_CHANGED:
case TIME_VULNERABILITY:
return Qt::AlignRight;
case PARTICIPANT_TYPE_NAME:
case PARTICIPANT_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total and subtotals
if (displayInfo.participantId == 0 || displayInfo.participantTypeId == 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
return (displayInfo.participantTypeId > 0 ? displayInfo.participantTypeId : QVariant());
case PARTICIPANT_TYPE_NAME:
return (displayInfo.participantTypeId > 0 ? QString::fromStdString(m_ppmDtc->type(displayInfo.participantTypeId).name())
: QVariant());
case PARTICIPANT_ID:
return (displayInfo.participantId > 0 ? displayInfo.participantId
: QVariant());
case PARTICIPANT_EQUIPMENT_NO:
return (displayInfo.participantEqNo > 0 ? QString::number(displayInfo.participantEqNo) : QVariant());
case PARTICIPANT_NAME:
return (!displayInfo.participantName.isEmpty() ? displayInfo.participantName : QVariant());
case TIME_EVENT:
return (displayInfo.time_event > 0 ? DTG::toStringMSec(displayInfo.time_event)
: QVariant());
case TIME_POSITION_CHANGED:
return (displayInfo.time_position > 0 ? DTG::toStringMSec(displayInfo.time_position)
: QVariant());
case TIME_VULNERABILITY:
return (displayInfo.time_vulnerability > 0 ? DTG::toStringMSec(displayInfo.time_vulnerability)
: QVariant());
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant MaintenanceModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case PARTICIPANT_TYPE_ID:
return tr("Type Id");
case PARTICIPANT_TYPE_NAME:
return tr("Type Name");
case PARTICIPANT_ID:
return tr("Participant Id");
case PARTICIPANT_EQUIPMENT_NO:
return tr("Equipment Number");
case PARTICIPANT_NAME:
return tr("Participant Name");
case TIME_EVENT:
return tr("Enter Functional Area");
case TIME_POSITION_CHANGED:
return tr("Position Changed");
case TIME_VULNERABILITY:
return tr("Vulnerability Changed");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void MaintenanceModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.participantTypeId = obj[QStringLiteral("participant_type_id")].toInt();
resData.participantId = obj[QStringLiteral("participant_id")].toInt();
resData.participantName = obj[QStringLiteral("participant_name")].toString();
resData.participantEqNo = obj[QStringLiteral("participant_equipment_number")].toInt();
resData.time_event = obj[QStringLiteral("time_event")].toDouble();
resData.time_position = obj[QStringLiteral("time_position_changed")].toDouble();
resData.time_vulnerability = obj[QStringLiteral("time_vulnerability")].toDouble();
INFO_LOG(m_logger) << "Participant id = " << resData.participantId;
INFO_LOG(m_logger) << "Participant type id = " << resData.participantTypeId;
INFO_LOG(m_logger) << "Time event = " << resData.time_event;
INFO_LOG(m_logger) << "Time pos = " << resData.time_position;
INFO_LOG(m_logger) << "Time vulnerability = " << resData.time_vulnerability;
m_data.append(std::move(resData));
}
}
@@ -0,0 +1,62 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class MaintenanceModel : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit MaintenanceModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
PARTICIPANT_TYPE_NAME = 0,
PARTICIPANT_EQUIPMENT_NO = 1,
PARTICIPANT_NAME = 2,
TIME_EVENT = 3,
TIME_POSITION_CHANGED = 4,
TIME_VULNERABILITY = 5,
PARTICIPANT_ID = 6,
PARTICIPANT_TYPE_ID = 7,
COUNT = 8 // without 2 last columns
};
struct resultData
{
int participantTypeId = 0;
int participantId = 0;
int participantEqNo = 0;
QString participantName;
qint64 time_event = 0;
qint64 time_position = 0;
qint64 time_vulnerability = 0;
};
QVector<resultData> m_data;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,228 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Report Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#include "rep_medevac_nine_liner_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/Evaluations/evl_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Evaluations/evl_translation.h>
#include <Services/Evaluations/san_category_line_json.h>
#include <LtsSession/lts_session.h>
#include <ngltools/ngltools_dtg.h>
#include <LtsCoordTrans/lts_coord_trans.h>
using namespace ReportManagement;
//----------------------------------------------------------------------------
MedevacNineLinerModel::MedevacNineLinerModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_evlDtc(nullptr)
, m_logger(getLogger("MedevacNineLinerModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.nineLinerId = 1;
resData.lastModified = 12345678;
resData.callSign = QStringLiteral("Sign 1");
resData.position = QStringLiteral("Pos");
resData.line_3 = QStringLiteral("Line 3");
resData.line_4 = QStringLiteral("Line 4");
resData.line_5 = QStringLiteral("Line 5");
resData.line_6 = QStringLiteral("Line 6");
resData.line_7 = QStringLiteral("Line 7");
resData.line_8 = QStringLiteral("Line 8");
resData.line_9 = QStringLiteral("Line 9");
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool MedevacNineLinerModel::fetchInterfaces()
{
if (!m_session->getDtc<Evaluations::DataInterface>(m_evlDtc))
{
ERROR_LOG(m_logger) << "Could not fetch EVL DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int MedevacNineLinerModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int MedevacNineLinerModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant MedevacNineLinerModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case NINE_LINER_ID:
return Qt::AlignRight;
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case NINE_LINER_ID:
return displayInfo.nineLinerId;
case LAST_MODIFIED:
return displayInfo.lastModified;
case CALL_SIGN:
return displayInfo.callSign;
case POSITION:
return displayInfo.position;
case LINE_3:
return displayInfo.line_3;
case LINE_4:
return displayInfo.line_4;
case LINE_5:
return displayInfo.line_5;
case LINE_6:
return displayInfo.line_6;
case LINE_7:
return displayInfo.line_7;
case LINE_8:
return displayInfo.line_8;
case LINE_9:
return displayInfo.line_9;
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant MedevacNineLinerModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case NINE_LINER_ID:
return tr("NineLiner Id");
case LAST_MODIFIED:
return tr("Last modified");
case POSITION:
return tr("Line 1");
case CALL_SIGN:
return tr("Line 2");
case LINE_3:
return tr("Line 3");
case LINE_4:
return tr("Line 4");
case LINE_5:
return tr("Line 5");
case LINE_6:
return tr("Line 6");
case LINE_7:
return tr("Line 7");
case LINE_8:
return tr("Line 8");
case LINE_9:
return tr("Line 9");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void MedevacNineLinerModel::fillReportData()
{
ERROR_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.nineLinerId = obj[QStringLiteral("nine_liner_id")].toInt();
DEBUG_LOG(m_logger) << "Nine Liner id = " << resData.nineLinerId;
Evaluations::SanNineLiner crtNineLiner = m_evlDtc->sanNineLiner(resData.nineLinerId);
if (crtNineLiner.id() <= 0 )
continue;
resData.lastModified = DTG::toStringMSec(crtNineLiner.lastModified());
const Core::GeoPosition2D &pos = crtNineLiner.line1_position();
resData.position = LtsCoordTrans::mgrsFromGeographic(pos.lon(), pos.lat());
resData.callSign = QString::fromStdString(crtNineLiner.line2_RadioFrequencyCallSignSuffix());
// FromJson line 3 - 9
QVector<Evaluations::Database::SanCategoryLine> linesCategory = Evaluations::SanCategoryLine::fromJson(crtNineLiner.lines(), crtNineLiner.id());
INFO_LOG(m_logger) << "linesCategory size: " << linesCategory.size();
for (const Evaluations::Database::SanCategoryLine &cl : qAsConst(linesCategory))
{
switch (cl.line) {
case 3:
resData.line_3.append(QString::number(cl.amount)+cl.category+QStringLiteral(" "));
break;
case 4:
resData.line_4.append(QString::number(cl.amount)+cl.category+QStringLiteral(" "));
break;
case 5:
resData.line_5.append(QString::number(cl.amount)+cl.category+QStringLiteral(" "));
break;
case 6:
resData.line_6.append(cl.category+QStringLiteral(" "));
break;
case 7:
resData.line_7.append(cl.category+QStringLiteral(" "));
break;
case 8:
resData.line_8.append(QString::number(cl.amount)+cl.category+QStringLiteral(" "));
break;
case 9:
if (cl.category == QStringLiteral("None"))
resData.line_9.append(tr("None"));
else
resData.line_9.append(cl.category+QStringLiteral(" "));
break;
default:
break;
}
}
m_data.append(std::move(resData));
}
}
@@ -0,0 +1,74 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Report Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <Evaluations/evl_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class MedevacNineLinerModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit MedevacNineLinerModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
LAST_MODIFIED = 0,
POSITION = 1,
CALL_SIGN = 2,
LINE_3 = 3,
LINE_4 = 4,
LINE_5 = 5,
LINE_6 = 6,
LINE_7 = 7,
LINE_8 = 8,
LINE_9 = 9,
NINE_LINER_ID = 10,
#ifdef LTS_DEBUG
COUNT = 11
#else
COUNT = 10 // without last column
#endif
};
struct resultData
{
int nineLinerId = 0;
QString lastModified;
QString position; // line 1
QString callSign; // line 2
QString line_3;
QString line_4;
QString line_5;
QString line_6;
QString line_7;
QString line_8;
QString line_9;
};
QVector<resultData> m_data;
std::shared_ptr<Evaluations::Interface::Dtc> m_evlDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,284 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_mine_area_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
MineAreaModel::MineAreaModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ppmDtc(nullptr)
, m_logger(getLogger("MineAreaModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.mineAreaId = 1;
resData.participantTypeId = 23;
resData.hits = {2, 2, 0};
m_data.append(resData);
resData.mineAreaId = 1;
resData.participantTypeId = 32;
resData.hits = {2, 2, 0};
m_data.append(resData);
resData.mineAreaId = 1;
resData.participantTypeId = 0; // total on mine id
resData.hits = {4, 4, 0};
m_data.append(resData);
resData.mineAreaId = 2;
resData.participantTypeId = 23;
resData.hits = {2, 2, 0};
m_data.append(resData);
resData.mineAreaId = 2;
resData.participantTypeId = 32;
resData.hits = {2, 2, 0};
m_data.append(resData);
resData.mineAreaId = 2;
resData.participantTypeId = 0; // total on mine id
resData.hits = {4, 4, 0};
m_data.append(resData);
resData.mineAreaId = 0; // total
resData.participantTypeId = 0;
resData.hits = {8, 8, 0};
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool MineAreaModel::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int MineAreaModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int MineAreaModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant MineAreaModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
case MINE_AREA_ID:
case HIT_TOTAL:
case HIT_ENEMY:
case HIT_OWN:
return Qt::AlignRight;
case PARTICIPANT_TYPE_NAME:
case MINE_AREA_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total and subtotals
if (displayInfo.mineAreaId == 0 || displayInfo.participantTypeId == 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case MINE_AREA_ID:
return (displayInfo.mineAreaId > 0 ? displayInfo.mineAreaId : QVariant());
case MINE_AREA_NAME:
{
QString displayName;
if (displayInfo.mineAreaId > 0)
{
QString mineName = displayInfo.mineAreaName;
if (displayInfo.participantTypeId == 0)
displayName = tr("Total [%1]").arg(mineName);
else
displayName = mineName;
}
return (displayInfo.mineAreaId > 0 ? displayName : tr("TOTAL:"));
}
case PARTICIPANT_TYPE_ID:
return (displayInfo.participantTypeId > 0 ? displayInfo.participantTypeId : QVariant());
case PARTICIPANT_TYPE_NAME:
return (displayInfo.participantTypeId > 0 ? QString::fromStdString(m_ppmDtc->type(displayInfo.participantTypeId).name())
: QVariant());
case HIT_TOTAL:
return displayInfo.hits[0];
case HIT_ENEMY:
return displayInfo.hits[1];
case HIT_OWN:
return displayInfo.hits[2];
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant MineAreaModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case MINE_AREA_ID:
return tr("Mine Area Id");
case MINE_AREA_NAME:
return tr("Mine Area Name");
case PARTICIPANT_TYPE_ID:
return tr("Type Id");
case PARTICIPANT_TYPE_NAME:
return tr("Type Name");
case HIT_TOTAL:
return tr("Total hits");
case HIT_ENEMY:
return tr("Enemy forces");
case HIT_OWN:
return tr("Own forces");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void MineAreaModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int mineAreaId = -1;
QString mineAreaName;
QMap<int, QVector<int> > sums;
QVector<int> bigTotal(3, 0);
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.participantTypeId = obj[QStringLiteral("participant_type_id")].toInt();
resData.mineAreaId = obj[QStringLiteral("mine_area_id")].toInt();
resData.mineAreaName = obj[QStringLiteral("mine_area_name")].toString();
resData.hits[0] = obj[QStringLiteral("hit")].toInt();
resData.hits[2] = obj[QStringLiteral("hit_friendly_fire")].toInt();
resData.hits[1] = resData.hits[0] - resData.hits[2];
INFO_LOG(m_logger) << "Mine area id = " << resData.mineAreaId;
INFO_LOG(m_logger) << "Mine area name = " << resData.mineAreaName;
INFO_LOG(m_logger) << "Participant type id = " << resData.participantTypeId;
INFO_LOG(m_logger) << "Hits = ("
<< resData.hits[0] << ", "
<< resData.hits[1] << ", "
<< resData.hits[2] << ")" ;
if (mineAreaId != resData.mineAreaId) // new Mine area
{
if (mineAreaId != -1) // total on mine area
{
resultData totalType;
totalType.mineAreaId = mineAreaId;
totalType.mineAreaName = mineAreaName;
totalType.participantTypeId = 0;
totalType.hits = sums[mineAreaId];
m_data.append(std::move(totalType));
sumUp(bigTotal, sums[mineAreaId], sums[mineAreaId].size());
}
mineAreaId = resData.mineAreaId;
mineAreaName = resData.mineAreaName;
sums[mineAreaId] = resData.hits;
}
else
{
sumUp(sums[mineAreaId], resData.hits, resData.hits.size());
}
m_data.append(std::move(resData));
}
if (m_reportJsonArray.size() > 0)
{
// last total on mine area
resultData totalType;
totalType.mineAreaId = mineAreaId;
totalType.mineAreaName = mineAreaName;
totalType.participantTypeId = 0;
totalType.hits = sums[mineAreaId];
m_data.append(std::move(totalType));
sumUp(bigTotal, sums[mineAreaId], sums[mineAreaId].size());
// big total
resultData total;
total.mineAreaId = 0;
total.mineAreaName = QString();
total.participantTypeId = 0;
total.hits = bigTotal;
m_data.append(std::move(total));
}
}
@@ -0,0 +1,62 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class MineAreaModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit MineAreaModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
MINE_AREA_NAME = 0,
PARTICIPANT_TYPE_NAME = 1,
HIT_TOTAL = 2,
HIT_ENEMY = 3,
HIT_OWN = 4,
PARTICIPANT_TYPE_ID = 5,
MINE_AREA_ID = 6,
#ifdef LTS_DEBUG
COUNT = 7
#else
COUNT = 5 // without last 2 columns
#endif
};
struct resultData
{
int mineAreaId = 0;
int participantTypeId = 0;
QString mineAreaName;
QVector<int> hits = {0, 0, 0};
};
QVector<resultData> m_data;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,341 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_nbc_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
NbcModel::NbcModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ppmDtc(nullptr)
, m_pdmDtc(nullptr)
, m_logger(getLogger("NbcModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.nbcId = 3;
resData.partyId = 2;
resData.participantTypeId = 23;
resData.hits = {2, 0};
m_data.append(resData);
resData.nbcId = 3;
resData.partyId = 2;
resData.participantTypeId = 32;
resData.hits = {2, 0};
m_data.append(resData);
resData.nbcId = 3;
resData.partyId = 2;
resData.participantTypeId = 0; // total on nbc id and party id
resData.hits = {4, 0};
m_data.append(resData);
resData.nbcId = 3;
resData.partyId = 3;
resData.participantTypeId = 23;
resData.hits = {2, 0};
m_data.append(resData);
resData.nbcId = 3;
resData.partyId = 3;
resData.participantTypeId = 32;
resData.hits = {2, 0};
m_data.append(resData);
resData.nbcId = 3;
resData.partyId = 3;
resData.participantTypeId = 0; // total on nbc id and party id
resData.hits = {4, 0};
m_data.append(resData);
resData.nbcId = 3;
resData.partyId = 0;
resData.participantTypeId = 0; // total on nbc id
resData.hits = {8, 0};
m_data.append(resData);
resData.nbcId = 4;
resData.partyId = 2;
resData.participantTypeId = 23;
resData.hits = {2, 0};
m_data.append(resData);
resData.nbcId = 4;
resData.partyId = 2;
resData.participantTypeId = 32;
resData.hits = {2, 0};
m_data.append(resData);
resData.nbcId = 4;
resData.partyId = 2;
resData.participantTypeId = 0; // total on nbc id and party id
resData.hits = {4, 0};
m_data.append(resData);
resData.nbcId = 0; // total
resData.partyId = 0;
resData.participantTypeId = 0;
resData.hits = {12, 0};
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool NbcModel::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int NbcModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int NbcModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant NbcModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case EVENT_ID:
case PARTY_ID:
case PARTICIPANT_TYPE_ID:
case HITS:
case PROTECTED:
return Qt::AlignRight;
case EVENT_NAME:
case CHARGE_TYPE_NAME:
case PARTY_NAME:
case PARTICIPANT_TYPE_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total and subtotals
if (displayInfo.nbcId == 0 || displayInfo.participantTypeId == 0 || displayInfo.partyId < 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case EVENT_ID:
return (displayInfo.nbcId > 0 ? displayInfo.nbcId : QVariant());
case EVENT_NAME:
{
QString displayName;
if (displayInfo.nbcId > 0)
{
QString eventName = displayInfo.nbcName;
if (displayInfo.participantTypeId == 0)
displayName = tr("Total [%1]").arg(eventName);
else
displayName = eventName;
}
return (displayInfo.nbcId > 0 ? displayName : tr("TOTAL:"));
}
case CHARGE_TYPE_ID:
return (displayInfo.chargeTypeId > 0 ? displayInfo.chargeTypeId : QVariant());
case CHARGE_TYPE_NAME:
return displayInfo.chargeTypeId > 0 ? m_pdmDtc->trChargeTypeShortName(displayInfo.chargeTypeId, true) : QVariant();
case PARTY_ID:
return (displayInfo.partyId >= 0 ? QVariant(displayInfo.partyId) : QVariant());
case PARTY_NAME:
return (displayInfo.partyId > 0 ? QString::fromStdString(m_ppmDtc->party(displayInfo.partyId).name())
: QVariant());
case PARTICIPANT_TYPE_ID:
return (displayInfo.participantTypeId > 0 ? displayInfo.participantTypeId : QVariant());
case PARTICIPANT_TYPE_NAME:
return (displayInfo.participantTypeId > 0 ? QString::fromStdString(m_ppmDtc->type(displayInfo.participantTypeId).name())
: QVariant());
case HITS:
return displayInfo.hits[0];
case PROTECTED:
return displayInfo.hits[1];
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant NbcModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case EVENT_ID:
return tr("Event Id");
case EVENT_NAME:
return tr("Event Name");
case CHARGE_TYPE_ID:
return tr("Charge Type Id");
case CHARGE_TYPE_NAME:
return tr("Charge Type");
case PARTICIPANT_TYPE_ID:
return tr("Type Id");
case PARTICIPANT_TYPE_NAME:
return tr("Type Name");
case HITS:
return tr("Total hits");
case PROTECTED:
return tr("Protected");
case PARTY_ID:
return tr("Party Id");
case PARTY_NAME:
return tr("Party Name");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void NbcModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int nbcId = -1;
QString nbcName;
QMap<int, QVector<int> > sums;
QVector<int> bigTotal(3, 0);
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.nbcId = obj[QStringLiteral("nbc_id")].toInt();
resData.nbcName = obj[QStringLiteral("nbc_name")].toString();
resData.chargeTypeId = obj[QStringLiteral("charge_type_id")].toInt();
resData.partyId = obj[QStringLiteral("party_id")].toInt();
resData.participantTypeId = obj[QStringLiteral("participant_type_id")].toInt();
resData.hits[0] = obj[QStringLiteral("hit")].toInt();
resData.hits[1] = obj[QStringLiteral("protection")].toInt();
INFO_LOG(m_logger) << "Nbc id = " << resData.nbcId;
INFO_LOG(m_logger) << "Nbc name = " << resData.nbcName;
INFO_LOG(m_logger) << "Participant type id = " << resData.participantTypeId;
INFO_LOG(m_logger) << "Hits = ("
<< resData.hits[0] << ", "
<< resData.hits[1];
if (nbcId != resData.nbcId) // new NBC field
{
if (nbcId != -1) // total on NBC id
{
resultData totalType;
totalType.nbcId = nbcId;
totalType.nbcName = nbcName;
totalType.chargeTypeId = 0;
totalType.participantTypeId = 0;
totalType.hits = sums[nbcId];
m_data.append(std::move(totalType));
sumUp(bigTotal, sums[nbcId], sums[nbcId].size());
}
nbcId = resData.nbcId;
nbcName = resData.nbcName;
sums[nbcId] = resData.hits;
}
else
{
sumUp(sums[nbcId], resData.hits, resData.hits.size());
}
m_data.append(std::move(resData));
}
if (m_reportJsonArray.size() > 0)
{
// last total on NBC id
resultData totalType;
totalType.nbcId = nbcId;
totalType.nbcName = nbcName;
totalType.chargeTypeId = 0;
totalType.participantTypeId = 0;
totalType.hits = sums[nbcId];
m_data.append(std::move(totalType));
sumUp(bigTotal, sums[nbcId], sums[nbcId].size());
// big total
resultData total;
total.nbcId = 0;
total.nbcName = QString();
total.chargeTypeId = 0;
total.participantTypeId = 0;
total.hits = bigTotal;
m_data.append(std::move(total));
}
}
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <ProjectDataManagement/pdm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class NbcModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit NbcModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
EVENT_NAME = 0,
CHARGE_TYPE_NAME = 1,
PARTY_NAME = 2,
PARTICIPANT_TYPE_NAME = 3,
HITS = 4,
PROTECTED = 5,
PARTICIPANT_TYPE_ID = 6,
PARTY_ID = 7,
CHARGE_TYPE_ID = 8,
EVENT_ID = 9,
#ifdef LTS_DEBUG
COUNT = 10
#else
COUNT = 6 // without last 4 columns
#endif
};
struct resultData
{
int nbcId = 0;
int chargeTypeId = 0;
int partyId = 0;
int participantTypeId = 0;
QString nbcName;
QVector<int> hits = {0, 0};
};
QVector<resultData> m_data;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,265 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_participant_distance_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
ParticipantDistanceModel::ParticipantDistanceModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ppmDtc(nullptr)
, m_logger(getLogger("ParticipantDistanceModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.participantTypeId = 23;
resData.participantId = 18;
resData.distance = 2000.50;
m_data.append(resData);
resData.participantTypeId = 23;
resData.participantId = 19;
resData.distance = 1200.50;
m_data.append(resData);
resData.participantTypeId = 23;
resData.participantId = 0; // total on type 23
resData.distance = 3201.00;
m_data.append(resData);
resData.participantTypeId = 32;
resData.participantId = 5;
resData.distance = 1500.25;
m_data.append(resData);
resData.participantTypeId = 32;
resData.participantId = 6;
resData.distance = 1000.75;
m_data.append(resData);
resData.participantTypeId = 32;
resData.participantId = 0; // total on type 32
resData.distance = 2501.00;
m_data.append(resData);
resData.participantTypeId = 0; // big total
resData.participantId = 0;
resData.distance = 5702.00;
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool ParticipantDistanceModel::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int ParticipantDistanceModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int ParticipantDistanceModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant ParticipantDistanceModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
case PARTICIPANT_ID:
case PARTICIPANT_EQUIPMENT_NO:
case DISTANCE:
return Qt::AlignRight;
case PARTICIPANT_TYPE_NAME:
case PARTICIPANT_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total and subtotals
if (displayInfo.participantId == 0 || displayInfo.participantTypeId == 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
return (displayInfo.participantTypeId > 0 ? displayInfo.participantTypeId : QVariant());
case PARTICIPANT_TYPE_NAME:
{
QString displayTypeName;
if (displayInfo.participantTypeId > 0)
{
QString typeName = QString::fromStdString(m_ppmDtc->type(displayInfo.participantTypeId).name());
if (displayInfo.participantId == 0)
displayTypeName = tr("Total [%1]").arg(typeName);
else
displayTypeName = typeName;
}
return (displayInfo.participantTypeId > 0 ? displayTypeName : tr("TOTAL:"));
}
case PARTICIPANT_EQUIPMENT_NO:
// return (displayInfo.participantId > 0 && m_ppmDtc->participant(displayInfo.participantId).equipmentNumber().is_set() ? m_ppmDtc->participant(displayInfo.participantId).equipmentNumber().get() : QVariant());
return (displayInfo.participantEqNo > 0 ? QString::number(displayInfo.participantEqNo) : QVariant());
case PARTICIPANT_ID:
return (displayInfo.participantId > 0 ? displayInfo.participantId : QVariant());
case PARTICIPANT_NAME:
// return (displayInfo.participantId > 0 ? QString::fromStdString(m_ppmDtc->participant(displayInfo.participantId).name())
// : QVariant());
return (!displayInfo.participantName.isEmpty() ? displayInfo.participantName : QVariant());
case DISTANCE:
return QString::number(displayInfo.distance); //, 'f', 2);
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant ParticipantDistanceModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case PARTICIPANT_TYPE_ID:
return tr("Type Id");
case PARTICIPANT_TYPE_NAME:
return tr("Type Name");
case PARTICIPANT_ID:
return tr("Participant Id");
case PARTICIPANT_EQUIPMENT_NO:
return tr("Equipment Number");
case PARTICIPANT_NAME:
return tr("Participant Name");
case DISTANCE:
return tr("Covered Distance [m]");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void ParticipantDistanceModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
int participantTypeId = -1;
long bigTotal = 0;
QHash<int, long> sums;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.participantTypeId = obj[QStringLiteral("participant_type_id")].toInt();
resData.participantId = obj[QStringLiteral("participant_id")].toInt();
resData.participantName = obj[QStringLiteral("participant_name")].toString();
resData.participantEqNo = obj[QStringLiteral("participant_equipment_number")].toInt();
resData.distance = obj[QStringLiteral("distance")].toDouble();
INFO_LOG(m_logger) << "Participant id = " << resData.participantId;
INFO_LOG(m_logger) << "Participant type id = " << resData.participantTypeId;
INFO_LOG(m_logger) << "Participant distance = " << resData.distance;
if (participantTypeId != resData.participantTypeId) // new Type
{
if (participantTypeId != -1) // total on type
{
resultData totalType;
totalType.participantTypeId = participantTypeId;
totalType.participantId = 0;
totalType.distance = sums[participantTypeId];
m_data.append(std::move(totalType));
bigTotal += sums[participantTypeId];
}
participantTypeId = resData.participantTypeId;
sums[participantTypeId] = resData.distance;
}
else
sums[participantTypeId] += resData.distance;
m_data.append(std::move(resData));
}
if (m_reportJsonArray.size() > 0)
{
// last total on type
resultData totalType;
totalType.participantTypeId = participantTypeId;
totalType.participantId = 0;
totalType.distance = sums[participantTypeId];
m_data.append(std::move(totalType));
bigTotal += sums[participantTypeId];
// big total
resultData total;
total.participantTypeId = 0;
total.participantId = 0;
total.distance = bigTotal;
m_data.append(std::move(total));
}
}
@@ -0,0 +1,62 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class ParticipantDistanceModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit ParticipantDistanceModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
PARTICIPANT_TYPE_NAME = 0,
PARTICIPANT_EQUIPMENT_NO = 1,
PARTICIPANT_NAME = 2,
DISTANCE = 3,
PARTICIPANT_ID = 4,
PARTICIPANT_TYPE_ID = 5,
#ifdef LTS_DEBUG
COUNT = 6
#else
COUNT = 4 // without last 2 columns
#endif
};
struct resultData
{
int participantTypeId = 0;
int participantId = 0;
int participantEqNo = 0;
qint64 distance = 0;
QString participantName;
};
QVector<resultData> m_data;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,382 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Report Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#include "rep_sanitation_material_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <ProjectDataManagement/pdm_translation.h>
#include <ParticipantManagement/ppm_translation.h>
#include <LtsSession/lts_session.h>
#include <QFont>
using namespace ReportManagement;
//----------------------------------------------------------------------------
SanitationMaterialModel::SanitationMaterialModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_pdmDtc(nullptr)
, m_logger(getLogger("SanitationMaterialModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.uniqueId = 123;
resData.qualification = 1;
resData.materialId = 1;
resData.amounts[0] = 1000;
resData.amounts[1] = 1000;
resData.amounts[2] = 500;
resData.amounts[3] = 1500;
m_data.append(resData);
resData.uniqueId = 123;
resData.qualification = 2;
resData.materialId = 2;
resData.amounts[0] = 1000;
resData.amounts[1] = 1000;
resData.amounts[2] = 500;
resData.amounts[3] = 1500;
m_data.append(resData);
//total on unique id 123
resData.uniqueId = 123;
resData.qualification = 0;
resData.materialId = 0;
resData.amounts[0] = 2000;
resData.amounts[1] = 2000;
resData.amounts[2] = 1000;
resData.amounts[3] = 3000;
m_data.append(resData);
resData.uniqueId = 321;
resData.qualification = 2;
resData.materialId = 3;
resData.amounts[0] = 1000;
resData.amounts[1] = 1000;
resData.amounts[2] = 500;
resData.amounts[3] = 1500;
m_data.append(resData);
//total on unique id 321
resData.uniqueId = 321;
resData.qualification = 0;
resData.materialId = 0;
resData.amounts[0] = 1000;
resData.amounts[1] = 1000;
resData.amounts[2] = 500;
resData.amounts[3] = 1500;
m_data.append(resData);
// grand total
resData.uniqueId = 0;
resData.qualification = 0;
resData.materialId = 0;
resData.amounts[0] = 3000;
resData.amounts[1] = 3000;
resData.amounts[2] = 1500;
resData.amounts[3] = 4500;
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool SanitationMaterialModel::fetchInterfaces()
{
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int SanitationMaterialModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int SanitationMaterialModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant SanitationMaterialModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
switch (index.column())
{
case MATERIAL_ID:
case AMOUNT_START:
case AMOUNT_RESUPPLIED:
case AMOUNT_END:
case AMOUNT_USED:
case DURATION:
return Qt::AlignRight;
case MATERIAL_NAME:
default:
return Qt::AlignLeft;
}
return Qt::AlignLeft;
}
if (role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
// total
if (displayInfo.materialId == 0 || displayInfo.qualification == 0 || displayInfo.uniqueId == 0)
return boldFont;
return QFont();
}
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case UNIQUE_ID:
{
QString tot, uq;
if (displayInfo.uniqueId > 0)
{
uq = QStringLiteral("%1").arg(displayInfo.uniqueId, 2, 16, QLatin1Char('0')); // hex value
if (displayInfo.qualification == 0)
tot = tr("Total [%1]").arg(uq);
else
tot = uq;
}
// else
// tot = tr("TOTAL:");
return tot;
}
case QUALIFICATION:
return (displayInfo.qualification > 0 ? ParticipantManagement::toString(static_cast<ParticipantManagement::Qualification_def::type>(displayInfo.qualification)) : QVariant());
case MATERIAL_ID:
return (displayInfo.materialId > 0 ? displayInfo.materialId : QVariant());
case MATERIAL_NAME:
return (displayInfo.materialId > 0 ? ProjectDataManagement::trSanitationMaterialName(m_pdmDtc->sanitationMaterial(displayInfo.materialId).name())
: tr("TOTAL:"));
case AMOUNT_START:
return displayInfo.amounts[0];
case AMOUNT_RESUPPLIED:
return displayInfo.materialId > 0 ? displayInfo.amounts[1] : QVariant();
case AMOUNT_END:
return displayInfo.amounts[2];
case AMOUNT_USED:
return displayInfo.materialId > 0 ? displayInfo.amounts[3] : QVariant();
case DURATION:
return LtsWidgets::readableDuration(displayInfo.duration);
default:
return QVariant();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant SanitationMaterialModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
if (!(orientation == Qt::Horizontal && role == Qt::DisplayRole))
return QVariant();
switch (section)
{
case UNIQUE_ID:
return tr("Unique Id");
case MATERIAL_ID:
return tr("Material Id");
case MATERIAL_NAME:
return tr("Material");
case AMOUNT_START:
return tr("Stock Start");
case AMOUNT_RESUPPLIED:
return tr("Resupplied");
case AMOUNT_END:
return tr("Stock End");
case AMOUNT_USED:
return tr("Amount Used");
case QUALIFICATION:
return tr("Qualification");
case DURATION:
return tr("No stock duration");
default:
return QVariant();
}
}
// ------------------------------------------------------------------
void SanitationMaterialModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
/*
int uniqueId = -1;
QMap<int, QVector<int> > sums;
QVector<int> bigTotal(4, 0);
*/
// totals per material id
QMap<int, QVector<int> > totals;
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.uniqueId = obj[QStringLiteral("sanitation_unique_id")].toInt();
resData.qualification = obj[QStringLiteral("qualification")].toInt();
resData.materialId = obj[QStringLiteral("material_id")].toInt();
resData.amounts[0] = obj[QStringLiteral("amount_start")].toInt();
resData.amounts[1] = obj[QStringLiteral("amount_resupplied")].toInt();
resData.amounts[2] = obj[QStringLiteral("amount_end")].toInt();
resData.amounts[3] = obj[QStringLiteral("amount_used")].toInt();
resData.duration = obj[QStringLiteral("duration")].toDouble();
ERROR_LOG(m_logger) << "Unique id = " << resData.uniqueId;
ERROR_LOG(m_logger) << "qualification = " << resData.qualification;
ERROR_LOG(m_logger) << "Material id = " << resData.materialId;
ERROR_LOG(m_logger) << "Duration with no stock = " << resData.duration;
ERROR_LOG(m_logger) << "Amounts = ("
<< resData.amounts[0] << ", "
<< resData.amounts[1] << ", "
<< resData.amounts[2] << ", "
<< resData.amounts[3] << ")" ;
/*
if (uniqueId != resData.uniqueId) // new UniqueId
{
if (uniqueId != -1) // total on UniqueId
{
resultData totalUniqueId;
totalUniqueId.uniqueId = uniqueId;
totalUniqueId.materialId = 0;
totalUniqueId.qualification = 0;
totalUniqueId.amounts = sums[uniqueId];
m_data.append(std::move(totalUniqueId));
sumUp(bigTotal, sums[uniqueId], sums[uniqueId].size());
}
uniqueId = resData.uniqueId;
sums[uniqueId] = resData.amounts;
}
else
{
sumUp(sums[uniqueId], resData.amounts, resData.amounts.size());
}
*/
if (!totals.keys().contains(resData.materialId))
totals[resData.materialId] = resData.amounts;
else
sumUp(totals[resData.materialId], resData.amounts, resData.amounts.size());
m_data.append(std::move(resData));
}
if (m_reportJsonArray.size() > 0)
{
resultData total;
total.uniqueId = 0;
total.materialId = 0;
total.qualification = 0;
m_data.append(std::move(total));
// totals on material ids
for (auto matId : totals.keys())
{
resultData totalMatId;
totalMatId.uniqueId = 0;
totalMatId.materialId = matId;
totalMatId.qualification = 0;
totalMatId.amounts = totals[matId];
DEBUG_LOG(m_logger) << "Totals per material id = " << matId << " : "
<< totalMatId.amounts[0] << ", "
<< totalMatId.amounts[1] << ", "
<< totalMatId.amounts[2] << ", "
<< totalMatId.amounts[3];
m_data.append(std::move(totalMatId));
}
}
/*
if (m_reportJsonArray.size() > 0)
{
// last total on UniqueId
resultData totalUniqueId;
totalUniqueId.uniqueId = uniqueId;
totalUniqueId.materialId = 0;
totalUniqueId.qualification = 0;
totalUniqueId.amounts = sums[uniqueId];
m_data.append(std::move(totalUniqueId));
sumUp(bigTotal, sums[uniqueId], sums[uniqueId].size());
// big total
resultData total;
total.uniqueId = 0;
total.materialId = 0;
total.qualification = 0;
total.amounts = bigTotal;
m_data.append(std::move(total));
}
*/
}
/* tried, does not work
QSize SanitationMaterialModel::span(const QModelIndex &index) const
{
if (!index.isValid())
return QSize();
const int row = index.row();
const int column = index.column();
ERROR_LOG(m_logger) << "Spanning row, col = " << row << ", " << column;
if (row < rowCount() - 1)
{
if (m_data[row].uniqueId == m_data[row + 1].uniqueId)
{
if (m_data[row].qualification == m_data[row + 1].qualification)
{
return QSize(1, 3);
}
return QSize(1, 2);
}
}
return QSize();
}
*/
@@ -0,0 +1,67 @@
/**
* @RDE_HEADER@
* Plugin Report Management: Report Sanitation Materials model
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, 2020-06-22
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ProjectDataManagement/pdm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class SanitationMaterialModel final : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
// QSize span(const QModelIndex &index) const override;
private:
explicit SanitationMaterialModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
enum Columns
{
UNIQUE_ID = 0,
QUALIFICATION = 1,
MATERIAL_NAME = 2,
AMOUNT_RESUPPLIED = 3,
AMOUNT_USED = 4,
DURATION = 5,
AMOUNT_START = 6,
AMOUNT_END = 7,
MATERIAL_ID = 8,
#ifdef LTS_DEBUG
COUNT = 5
#else
COUNT = 5 // without last columns
#endif
};
struct resultData
{
int materialId = 0;
int uniqueId = 0;
int qualification = 0;
QVector<int> amounts = {0, 0, 0, 0};
double duration = 0;
};
QVector<resultData> m_data;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
LOGGER_T m_logger;
};
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,261 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <ProjectDataManagement/pdm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class TreatmentModel : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
int getAmountInjuryTotal() { return m_amountInjuryTotal; }
private:
explicit TreatmentModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
void fillParticipantMap();
int getParticipantKey(int participantId);
// recursive
void findTroupId(QSet<int> &partIds, int key);
QString getUnitName(int participantId);
enum Columns
{
PARTICIPANT = 0,
VITALITY = 1,
VULNERABILITY = 2,
TIME_VULNERABILITY = 3,
TIME_VITALITY = 4,
TIME_NINE_LINER = 5,
TIME_POSITION_CHANGED = 6,
TIME_ENTER_AREA = 7,
TIME_TREATMENT = 8,
DURATION_TREATMENT = 9,
INBETWEEN_10_MINUTES = 10,
GOLDEN_HOUR = 11,
SANITATION_PROCEDURES_TAKEN = 12,
SANITATION_RESULT = 13,
QUALIFICATION = 14,
SANITATION_EVALUATION = 15,
PRIORITY = 16,
PRIORITY_CORRECT = 17,
DURATION_NINE_LINER = 18,
DURATION_POSITION_CHANGED= 19,
DURATION_ENTER_AREA = 20,
FUNCTIONAL_AREA = 21,
PARTICIPANT_TYPE_NAME = 22,
PARTICIPANT_EQUIPMENT_NO = 23,
PARTICIPANT_NAME = 24,
PARTICIPANT_ID = 25,
PARTICIPANT_TYPE_ID = 26,
AREA_ID = 27,
#ifdef LTS_DEBUG
COUNT = 28
#else
COUNT = 22 // without last 6 columns
#endif
};
enum ColumnsTable
{
T_PARTICIPANT = 0,
T_PARTICIPANT_NAME = 1,
AMOUNT_LIGHT_WOUNDED = 2,
AMOUNT_MEDIUM_WOUNDED = 3,
AMOUNT_HEAVY_WOUNDED = 4,
AMOUNT_KIA = 5,
AMOUNT_KIA_AFTER_WIA = 6,
AMOUNT_INJURY_TOTAL = 7,
AMOUNT_TREATED = 8,
AMOUNT_PLATIN = 9,
AMOUNT_GOLDEN_HOUR = 10,
AMOUNT_OPTIMAL_TREATED = 11,
AMOUNT_RS_PLATIN = 12,
AMOUNT_RS_GOLDEN_HOUR = 13,
AMOUNT_ENTER_RESCUE_STATION_TREATED = 14,
AMOUNT_ENTER_RESCUE_STATION_NOT_TREATED = 15,
T_PARTICIPANT_ID = 16,
#ifdef LTS_DEBUG
COUNT_TABLE = 17
#else
COUNT_TABLE = 16 // without participantId
#endif
};
struct resultData
{
int participantTypeId = 0;
int participantId = 0;
int participantEqNo = 0;
QString participantName;
qint64 timeVulnerability = 0;
qint64 timeVitality = 0;
qint64 timeNineLiner = 0;
qint64 timePositionChanged = 0;
qint64 timeEnterArea = 0;
qint64 timeTreatment = 0;
qint64 timeTreatmentVulnerability;
bool inbetween10Minutes;
bool goldenHour;
int sanitationResult = 0;
int sanitationEvaluation = 0;
qint64 sanitationProceduresTaken = 0;
int qualification = 0;
bool optimalTreated = false;
int priority = 0;
bool priority_correct = true;
int vulnerability = 0;
int vulnerabilityState = 0;
int vitality = 0;
int areaId = 0;
QString areaName;
bool kiaAfterWia;
};
struct resultDataTable
{
int participantId = 0;
QString participantName;
int amountLightlyWounded = 0;
int amountMediumWounded = 0;
int amountHeavyWounded = 0;
int amountInjuryTotal = 0;
int amountKIA = 0;
int amountKIAAfterWIA = 0;
int amountTreated = 0;
int amountPlatin = 0;
int amountGoldenHour = 0;
int amountRsPlatin = 0;
int amountRsGoldenHour = 0;
int amountEnterRescueStationNotTreated = 0;
int amountEnterRescueStationTreated = 0;
int amountOptimalTreated = 0;
};
/* Columns Pie show the results based on PPM enum
<enumeration name="SanitationResult">
<attribute key="deprecatedNA" value="-1"/>
<attribute key="NoEffect" value="0"/>
<attribute key="Unhandled" value="1"/>
<attribute key="Insufficient" value="2"/>
<attribute key="Sufficient" value="3"/>
<attribute key="Optimal" value="4"/>
</enumeration>
enum ColumnsPie
{
PIE_NoEffect = 0,
PIE_Unhandled = 1,
PIE_Insufficient = 2,
PIE_Sufficient = 3,
PIE_Optimal = 4,
COUNT_PIE = 5
};
*/
enum ColumnsPie
{
PIE_platin, // inbetween 10 min
PIE_goldenHour, // inbetween 1h
PIE_enterRescueArea,
PIE_KIA,
PIE_notEnteredRecueArea,
PIE_total,
PIE_enterRescueAreaPlatin,
PIE_enterRescueAreaGoldenHour,
PIE_optimalTreated,
COUNT_PIE = 4 // without total/enterRsPlatin/enterRsGh/NotEnteredRS
};
struct resultDataPie
{
int groupId = 0;
QVector<int> results = {0, 0, 0, 0, 0, 0};
};
/* Columns PieEvaluation show the results based on PPM enum
<enumeration name="SanitationEvaluation">
<attribute key="NotApplicable" value="-1"/>
<attribute key="Okay" value="0"/>
<attribute key="PartlyWrong" value="1"/>
<attribute key="Wrong" value="2"/>
</enumeration>
*/
enum ColumnsPieEvaluation
{
PIE_Okay = 0,
PIE_PartlyWrong = 1,
PIE_Wrong = 2,
COUNT_PIE_EVAL = 3
};
struct resultDataPieEvaluation
{
int groupId = 0;
QVector<int> results = {0, 0, 0};
};
enum ColumnsPiePriority
{
WRONG = 0,
RIGHT = 1,
COUNT_PIE_PRIORITY = 2
};
struct resultDataPiePriority
{
int groupId = 0;
QVector<int> results = {0, 0};
};
void countVulnerabilityState( int key, const resultData &data);
int m_amountInjuryTotal = 0;
// QMap<troupId, QSet<participantId>
QMap<int,QSet<int>> m_participantMap;
// QMap<participantId, SuperiorId>
QMap<int,int> m_partSuperiorMap;
// QMap<troupId, QMap<VulnerabilityState, QSet<participantId>>>
QMap<int,QMap<int,QSet<int>>> m_vulnerabilityMap;
// QMap<troupId, QMap<TreatmentInterval, QSet<participantId>>>
QMap<int,QMap<int,QSet<int>>> m_treatmentIntervalMap;
//QMap<troupId,QSet<participantId>>
QMap<int,QSet<int>> m_rescueStationTreated;
//QMap<troupId,QSet<participantId>>
QMap<int,QSet<int>> m_rescueStationNotTreated;
//QMap<troupId,QSet<participantId>>
QMap<int,QSet<int>> m_treatmentAmount;
QVector<resultData> m_data;
QVector<resultDataTable> m_dataTable;
QVector<resultDataPie> m_dataPie;
QVector<resultDataPieEvaluation> m_dataPieEval;
QVector<resultDataPiePriority> m_dataPiePriority;
QMap<int, resultDataPieEvaluation> m_bars;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,397 @@
/**
* @RDE_HEADER@
* Shows a report of combat power in form of curves
* $Id$
* $HeadURL$
* $Author$
*/
#include "rep_treatment_timeline_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <ProjectDataManagement/pdm_to_string.h>
#include <ParticipantManagement/ppm_translation.h>
#include <ReportManagement/rep_translation.h>
#include <LtsSession/lts_session.h>
#include <ngltools/ngltools_dtg.h>
using namespace ReportManagement;
//----------------------------------------------------------------------------
TreatmentTimelineModel::TreatmentTimelineModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ppmDtc(nullptr)
, m_pdmDtc(nullptr)
, m_logger(getLogger("ReportTreatmentTimelineModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::VBGChanged;
resData.eventTime = 1513758640000;
resData.vulnerability = 460942;
resData.vitality = 90;
resData.properties = QString();
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::VitalityChanged;
resData.eventTime = 1513758641000;
resData.vitality = 60;
resData.vulnerability = 460942;
resData.properties = QString();
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::NineLinerSet;
resData.eventTime = 1513758642000;
resData.vitality = 60;
resData.vulnerability = 460942;
resData.properties = QString();
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::TransportInitiated;
resData.eventTime = 1513758645000;
resData.vitality = 70;
resData.vulnerability = 460942;
resData.properties = QString();
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::PositionChanged;
resData.eventTime = 1513758646000;
resData.vitality = 70;
resData.vulnerability = 460942;
resData.properties = QString();
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::EnterFunctionalArea;
resData.eventTime = 1513758647000;
resData.vitality = 70;
resData.vulnerability = 460942;
std::string json = R"({"area_id": 1, "area_name": "test area"})";
resData.properties = QString::fromStdString(json);
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::Treatment;
resData.eventTime = 1513758648000;
resData.vitality = 70;
resData.vulnerability = 460942;
resData.properties = QString();
m_data.append(resData);
resData.groupId = 5; //participantId
resData.participantTypeId = 55;
resData.participantId = 5;
resData.participantEqNo = 781;
resData.participantName = QStringLiteral("Soldat 781");
resData.eventTypeId = ReportManagement::EventType::Treatment;
resData.eventTime = 1513758649000;
resData.vitality = 100;
resData.vulnerability = 460942;
resData.properties = QString();
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool TreatmentTimelineModel::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PDM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------
int TreatmentTimelineModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------
int TreatmentTimelineModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------
QVariant TreatmentTimelineModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (m_report.visualisationType() == VisualisationType::Table || m_report.visualisationType() == VisualisationType::Line)
{
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::TextAlignmentRole)
{
return Qt::AlignLeft;
}
else if (role == Qt::DisplayRole)
{
switch (index.column())
{
case PARTICIPANT_TYPE_ID:
return (displayInfo.participantTypeId > 0 ? displayInfo.participantTypeId : QVariant());
case PARTICIPANT_TYPE_NAME:
return (displayInfo.participantTypeId > 0 ? QString::fromStdString(m_ppmDtc->type(displayInfo.participantTypeId).name())
: QVariant());
case PARTICIPANT_ID:
return (displayInfo.participantId > 0 ? displayInfo.participantId
: QVariant());
case PARTICIPANT_EQUIPMENT_NO:
return (displayInfo.participantEqNo > 0 ? QString::number(displayInfo.participantEqNo) : QVariant());
case PARTICIPANT_NAME:
return (!displayInfo.participantName.isEmpty() ? displayInfo.participantName : QVariant());
case EVENT_TIME:
return (displayInfo.eventTime > 0 ? DTG::toStringMSec(displayInfo.eventTime)
: QVariant());
case EVENT_TYPE:
{
QString event = ReportManagement::toString(displayInfo.eventTypeId);
if (displayInfo.eventTypeId == ReportManagement::EventType::EnterFunctionalArea && displayInfo.properties.size() > 0)
event += QStringLiteral("\n") + getAreaName(displayInfo.properties);
if (displayInfo.eventTypeId == ReportManagement::EventType::Treatment && displayInfo.properties.size() > 0)
event += QStringLiteral("\n") + getSanProcs(displayInfo.properties);
return event;
}
case VITALITY:
{
if (m_report.visualisationType() == VisualisationType::Line)
return displayInfo.vitality;
else
{
QString vit = QString::number(displayInfo.vitality);
vit += QStringLiteral(" %");
return vit;
}
}
case VULNERABILITY:
{
QString vbg = ProjectDataManagement::toString(static_cast<ProjectDataManagement::VulnerabilityState::type>(displayInfo.vulnerabilityState));
if (displayInfo.vulnerability > 0)
vbg += QStringLiteral("\n") + m_pdmDtc->trVulnerabilityKindName(displayInfo.vulnerability, ProjectDataManagement::VulnerabilityClass::SoldierInjuries);
return vbg;
}
case AREA_NAME:
if (displayInfo.eventTypeId == ReportManagement::EventType::EnterFunctionalArea && displayInfo.properties.size() > 0)
return getAreaName(displayInfo.properties);
else
return QVariant();
default:
return QVariant();
}
}
else if (role == Qt::UserRole)
{
if (m_report.groupByParty() && displayInfo.participantId > 0)
{
QString part = tr("Participant: %1 - %2").arg(displayInfo.participantEqNo).arg(displayInfo.participantName);
return part;
}
}
else if (role == Qt::EditRole)
{
return displayInfo.participantId;
}
else if (role == Qt::ForegroundRole || role == Qt::BackgroundRole)
{
if (m_report.visualisationType() == VisualisationType::Line)
return eventColor(displayInfo.eventTypeId);
}
else if (role == Qt::UserRole + 1)
{
if (m_report.visualisationType() == VisualisationType::Line)
return displayInfo.eventTypeId.underlying();
}
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------
QVariant TreatmentTimelineModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch (section)
{
case PARTICIPANT_TYPE_ID:
return tr("Type Id");
case PARTICIPANT_TYPE_NAME:
return tr("Type Name");
case PARTICIPANT_ID:
return tr("Participant Id");
case PARTICIPANT_EQUIPMENT_NO:
return tr("Eqpt.No");
case PARTICIPANT_NAME:
return tr("Participant Name");
case VITALITY:
return tr("Vitality");
case VULNERABILITY:
return tr("Vulnerability");
case EVENT_TIME:
return tr("Event time");
case EVENT_TYPE:
return tr("Event type");
case AREA_NAME:
return tr("Functional Area");
}
}
if (orientation == Qt::Vertical && m_report.visualisationType() == VisualisationType::Line)
{
if (role == Qt::BackgroundRole)
{
return eventColor(m_data[section].eventTypeId);
}
else if (role == Qt::TextAlignmentRole)
{
return Qt::AlignRight;
}
else if (role == Qt::DisplayRole)
{
// QString event = DTG::toStringMSec(m_data[section].eventTime) + QStringLiteral("\n");
// event += ReportManagement::toString(m_data[section].eventTypeId);
// return event;
return DTG::toStringMSec(m_data[section].eventTime);
}
}
return QVariant();
}
// ------------------------------------------------------------------
void TreatmentTimelineModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.participantTypeId = obj[QStringLiteral("participant_type_id")].toInt();
resData.participantId = obj[QStringLiteral("participant_id")].toInt();
resData.participantName = obj[QStringLiteral("participant_name")].toString();
resData.participantEqNo = obj[QStringLiteral("participant_equipment_number")].toInt();
resData.vitality = obj[QStringLiteral("vitality")].toInt();
resData.vulnerability = obj[QStringLiteral("vulnerability")].toInt();
resData.vulnerabilityState = obj[QStringLiteral("vulnerability_state")].toInt();
resData.eventTime = obj[QStringLiteral("event_time")].toDouble();
resData.eventTypeId = static_cast<ReportManagement::EventType::type>(obj[QStringLiteral("event_type_id")].toInt());
resData.properties = obj[QStringLiteral("properties")].toString();
DEBUG_LOG(m_logger) << "Participant type id = " << resData.participantTypeId;
DEBUG_LOG(m_logger) << "Participant id = " << resData.participantId;
DEBUG_LOG(m_logger) << "Event type = " << resData.eventTypeId;
DEBUG_LOG(m_logger) << "Event time = " << resData.eventTime;
DEBUG_LOG(m_logger) << "Properties = " << resData.properties;
m_data.append(std::move(resData));
}
}
// ------------------------------------------------------------------
QString TreatmentTimelineModel::getAreaName(const QString& properties) const
{
DEBUG_LOG(m_logger) << "getAreaName from " << properties;
QJsonDocument doc = QJsonDocument::fromJson(properties.toUtf8());
const QJsonObject obj = doc.object();
//const int area_id = obj[QStringLiteral("area_id")].toInt();
QString area_name = obj[QStringLiteral("area_name")].toString();
return area_name;
}
// ------------------------------------------------------------------
QColor TreatmentTimelineModel::eventColor(ReportManagement::EventType eventTypeId) const
{
DEBUG_LOG(m_logger) << "eventColor for event type " << eventTypeId;
switch (eventTypeId.underlying())
{
case ReportManagement::EventType::VBGChanged: return QColor(Qt::red);
case ReportManagement::EventType::VitalityChanged: return QColor(Qt::green);
case ReportManagement::EventType::NineLinerSet: return QColor(Qt::darkYellow);
case ReportManagement::EventType::Treatment: return QColor(Qt::blue);
case ReportManagement::EventType::TransportRequested: return QColor(Qt::darkGray);
case ReportManagement::EventType::TransportInitiated: return QColor(Qt::magenta);
case ReportManagement::EventType::EnterFunctionalArea: return QColor(Qt::darkCyan);
case ReportManagement::EventType::VitalityReset: return QColor(Qt::darkGreen);
case ReportManagement::EventType::SetInjury: return QColor(Qt::darkRed);
case ReportManagement::EventType::VBGSet: return QColor(Qt::black);
}
return QColor(Qt::black);
}
// ------------------------------------------------------------------
QString TreatmentTimelineModel::getSanProcs(const QString& properties) const
{
DEBUG_LOG(m_logger) << "getSanProcs from " << properties;
QString sanProcs;
QJsonDocument doc = QJsonDocument::fromJson(properties.toUtf8());
const QJsonObject obj = doc.object();
qint64 procTaken = obj[QStringLiteral("san_procs")].toDouble();
if (procTaken > 0)
sanProcs = m_pdmDtc->sanitationProceduresList(procTaken).join(QLatin1String(", "));
return sanProcs;
}
@@ -0,0 +1,77 @@
/**
* @RDE_HEADER@
* Shows report player distance
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <ProjectDataManagement/pdm_dtc.h>
//----------------------------------------------------------------------------
namespace ReportManagement
{
class TreatmentTimelineModel : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private:
explicit TreatmentTimelineModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
QString getAreaName(const QString &properties) const;
QColor eventColor(ReportManagement::EventType eventTypeId) const;
QString getSanProcs(const QString &properties) const;
enum Columns
{
EVENT_TIME = 0,
EVENT_TYPE = 1,
VULNERABILITY = 2,
VITALITY = 3,
AREA_NAME = 4,
PARTICIPANT_EQUIPMENT_NO = 5,
PARTICIPANT_NAME = 6,
PARTICIPANT_ID = 7,
PARTICIPANT_TYPE_ID = 8,
PARTICIPANT_TYPE_NAME = 9,
#ifdef LTS_DEBUG
COUNT = 10
#else
COUNT = 4 // without last columns
#endif
};
struct resultData
{
int groupId = 0;
int participantTypeId = 0;
int participantId = 0;
int participantEqNo = 0;
QString participantName;
int vulnerability = 0;
int vulnerabilityState = 0;
int vitality = 0;
ReportManagement::EventType eventTypeId = ReportManagement::EventType::VBGChanged;
qint64 eventTime = 0;
QString properties;
};
QVector<resultData> m_data;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,220 @@
/**
* @RDE_HEADER@
* ChartModel for detailed unit power data
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-03-01
*/
#include "rep_unit_power_model.h"
#include <ProjectDataManagement/pdm_to_string.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <ngltools/ngltools_dtg.h>
#include <QFont>
using namespace ReportManagement;
// -----------------------------------------------------------------------------------------------------------------------------------------------
UnitPowerModel::UnitPowerModel(const ReportInfo &report, LtsSession::LtsSession *session, QObject *parent)
: AbstractModel(report, session, parent)
, m_ppmDtc(nullptr)
, m_logger(getLogger("UnitPowerModel"))
{
if (!fetchInterfaces())
return;
//#define TEST_DATA
#ifdef TEST_DATA
resultData resData;
resData.groupId = 32;
resData.startTime = 1513758640000;
resData.ready = 110;
resData.notReady = 110;
resData.notReadyVbgs = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
m_data.append(resData);
resData.groupId = 33;
resData.startTime = 1513758640000;
resData.ready = 50;
resData.notReady = 220;
resData.notReadyVbgs = {20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20};
m_data.append(resData);
#else
getReportData(report);
fillReportData();
#endif
}
// -----------------------------------------------------------------------------------------------------
bool UnitPowerModel::fetchInterfaces()
{
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Could not fetch PPM DTC Interface";
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------------------------------------------------
int UnitPowerModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : m_data.count();
}
// -----------------------------------------------------------------------------------------------------------------------------------------------
int UnitPowerModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : COUNT;
}
// -----------------------------------------------------------------------------------------------------------------------------------------------
QVariant UnitPowerModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
const resultData &displayInfo = m_data[index.row()];
if (role == Qt::DisplayRole)
{
switch (index.column())
{
case COMBAT_READY:
return displayInfo.ready;
case NOT_READY:
return displayInfo.notReady;
case LIGHT_DAMAGE:
return displayInfo.notReadyVbgs[0];
case MEDIUM_DAMAGE:
return displayInfo.notReadyVbgs[1];
case HEAVY_DAMAGE:
return displayInfo.notReadyVbgs[2];
case MOBILITY_KILL:
return displayInfo.notReadyVbgs[3];
case VISIBLE_MOBILITY_KILL:
return displayInfo.notReadyVbgs[4];
case WEAPON_SYSTEM_DAMAGE:
return displayInfo.notReadyVbgs[5];
case VISIBLE_WEAPON_SYSTEM_DAMAGE:
return displayInfo.notReadyVbgs[6];
case CATASTROPHIC_KILL:
return displayInfo.notReadyVbgs[7];
case TEMPORARY_SEVERANCE:
return displayInfo.notReadyVbgs[8];
case NEAR_MISS:
return displayInfo.notReadyVbgs[9];
case HIT_WITH_NO_EFFECT:
return displayInfo.notReadyVbgs[10];
case START_TIME:
return DTG::toStringMSec(displayInfo.startTime);
default:
return QVariant();
}
}
else if (role == Qt::UserRole)
{
if (!m_report.groupByParty() && displayInfo.groupId > 0)
return QString::fromStdString(m_ppmDtc->type(displayInfo.groupId).name()).trimmed();
else
return QVariant();
}
else if (role == Qt::EditRole)
{
return displayInfo.groupId;
}
return QVariant();
}
// -----------------------------------------------------------------------------------------------------------------------------------------------
QVariant UnitPowerModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch (section)
{
case COMBAT_READY:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::CombatReady);
case NOT_READY:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::NotReady);
case LIGHT_DAMAGE:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::LightDamage);
case MEDIUM_DAMAGE:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::MediumDamage);
case HEAVY_DAMAGE:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::HeavyDamage);
case MOBILITY_KILL:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::MobilityKill);
case VISIBLE_MOBILITY_KILL:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::VisibleMobilityKill);
case WEAPON_SYSTEM_DAMAGE:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::WeaponSystemDamage);
case VISIBLE_WEAPON_SYSTEM_DAMAGE:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::VisibleWeaponSystemDamage);
case CATASTROPHIC_KILL:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::CatastrophicKill);
case TEMPORARY_SEVERANCE:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::TemporarySeverance);
case NEAR_MISS:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::NearMiss);
case HIT_WITH_NO_EFFECT:
return ProjectDataManagement::toString(ProjectDataManagement::VulnerabilityState::HitWithNoEffect);
case START_TIME:
return tr("Time");
default:
return QVariant();
}
}
if (orientation == Qt::Vertical && role == Qt::DisplayRole &&
(m_report.visualisationType() == VisualisationType::Bar || m_report.visualisationType() == VisualisationType::Line))
{
return DTG::toStringMSec(m_data[section].startTime);
}
return QAbstractTableModel::headerData(section, orientation, role);
}
// ------------------------------------------------------------------
void UnitPowerModel::fillReportData()
{
DEBUG_LOG(m_logger) << "fillReportData(): m_reportJsonArray.size() = " << m_reportJsonArray.size();
for (const QJsonValue &arrVal : qAsConst(m_reportJsonArray))
{
const QJsonObject obj = arrVal.toObject();
resultData resData;
resData.groupId = obj[QStringLiteral("group_id")].toInt();
resData.ready = obj[QStringLiteral("ready")].toInt();
resData.notReady = obj[QStringLiteral("not_ready")].toInt();
resData.startTime = obj[QStringLiteral("start_time")].toDouble();
resData.notReadyVbgs[0] = obj[QStringLiteral("vulnerability_state1")].toInt();
resData.notReadyVbgs[1] = obj[QStringLiteral("vulnerability_state2")].toInt();
resData.notReadyVbgs[2] = obj[QStringLiteral("vulnerability_state3")].toInt();
resData.notReadyVbgs[3] = obj[QStringLiteral("vulnerability_state4")].toInt();
resData.notReadyVbgs[4] = obj[QStringLiteral("vulnerability_state5")].toInt();
resData.notReadyVbgs[5] = obj[QStringLiteral("vulnerability_state6")].toInt();
resData.notReadyVbgs[6] = obj[QStringLiteral("vulnerability_state7")].toInt();
resData.notReadyVbgs[7] = obj[QStringLiteral("vulnerability_state8")].toInt();
resData.notReadyVbgs[8] = obj[QStringLiteral("vulnerability_state9")].toInt();
resData.notReadyVbgs[9] = obj[QStringLiteral("vulnerability_state10")].toInt();
resData.notReadyVbgs[10] = obj[QStringLiteral("vulnerability_state11")].toInt();
INFO_LOG(m_logger) << "Group id = " << resData.groupId;
INFO_LOG(m_logger) << "Ready = " << resData.ready;
INFO_LOG(m_logger) << "Not ready = " << resData.notReady;
INFO_LOG(m_logger) << "Start time = " << resData.startTime;
m_data.append(std::move(resData));
}
}
@@ -0,0 +1,89 @@
/**
* @RDE_HEADER@
* ChartModel for detailed unit power data
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-03-01
*/
#pragma once
#include "rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ParticipantManagement/ppm_dtc.h>
namespace ReportManagement
{
enum UnitPowerColumns
{
COMBAT_READY = 0,
LIGHT_DAMAGE = 1,
MEDIUM_DAMAGE = 2,
HEAVY_DAMAGE = 3,
MOBILITY_KILL = 4,
VISIBLE_MOBILITY_KILL = 5,
WEAPON_SYSTEM_DAMAGE = 6,
VISIBLE_WEAPON_SYSTEM_DAMAGE = 7,
CATASTROPHIC_KILL = 8,
TEMPORARY_SEVERANCE = 9,
NOT_READY = 10,
// hidden columns
NEAR_MISS = 11,
HIT_WITH_NO_EFFECT = 12,
START_TIME = 13,
COUNT = 11
};
/* PDM Enum VulnerabilityState:
CombatReady = 0,
LightDamage = 1,
MediumDamage = 2,
HeavyDamage = 3,
MobilityKill = 4,
VisibleMobilityKill = 5,
WeaponSystemDamage = 6,
VisibleWeaponSystemDamage = 7,
CatastrophicKill = 8,
TemporarySeverance = 9,
NearMiss = 10,
HitWithNoEffect = 11,
NotReady = 99
*/
class UnitPowerModel : public AbstractModel
{
Q_OBJECT
friend class AbstractModel;
public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override final;
int columnCount(const QModelIndex &parent = QModelIndex()) const override final;
QVariant data(const QModelIndex &index, int role) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
bool fetchInterfaces() override final;
private: // methods
explicit UnitPowerModel(const ReportManagement::ReportInfo &report, LtsSession::LtsSession *session, QObject *parent);
void fillReportData() override final;
private: //other
struct resultData
{
int groupId = 0;
int ready = 0;
int notReady = 0;
qint64 startTime = 0;
QVector<int> notReadyVbgs = {0,0,0,0,0,0,0,0,0,0,0};
};
QVector<resultData> m_data;
private: // attributes
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,178 @@
/**
* @RDE_HEADER@
* Topic Editor for the Situation Topic in the Script Editor
* $Id$
* $HeadURL$
* $Author$
*
* Created by Iuliana Ojog, SLSE, 2018-03-24
*/
#include "topic_editor.h"
#include "ui_topic_editor.h"
#include <LtsScriptTimeline/track_entry.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_gui_plugin_interface.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <ReportManagement/Gui/ReportViewer/rep_report_model.h>
#include <TopicEditorBase/topic_previewer.h>
namespace ReportManagement
{
ReportTopicEditor::ReportTopicEditor(
const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc, QWidget *parent
)
: TopicEditorBase::TopicEditor(parent)
, m_reportModel(new ReportModel(this))
, m_ui(new Ui::ReportTopicEditor)
, m_logger(getLogger("ReportTopicEditor"))
{
// init UI
m_ui->setupUi(this);
init(m_ui->widget);
connect(m_ui->reportsDataView, &LtsDataView::LtsDataView::signalSelectionChanged,
this, &ReportTopicEditor::onReportSelected);
m_reportModel->initModel(dtc, opmDtc, ppmDtc, ppmGuiCbxIfc);
ReportProxyModel *reportProxyModel = new ReportProxyModel(this);
reportProxyModel->setSourceModel(m_reportModel);
m_ui->reportsDataView->setModel(reportProxyModel);
m_ui->reportsDataView->hideColumn(ReportModel::Description);
m_ui->reportsDataView->hideColumn(ReportModel::Interval);
m_ui->reportsDataView->hideColumn(ReportModel::FileStatus);
#ifndef LTS_DEBUG
m_ui->reportsDataView->hideColumn(ReportModel::Id);
#endif
#if 0
m_ui->pbSetTopicPosition->setEnabled(false);
connect(m_ui->pbSetTopicPosition, &QPushButton::clicked, this, [this]()
{
emit signalSetTopicPosition(m_ui->widget, m_topicData.id);
});
#else
{
connect(m_ui->pbSetTopicPosition, &QPushButton::clicked, this, &ReportTopicEditor::onPreview);
}
#endif
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Report_Topic"));
}
ReportTopicEditor::~ReportTopicEditor()
{
delete m_ui;
}
///////////////////////////////////////////////////////////////////////////////
// PRIVATE
void ReportTopicEditor::updateInternalData()
{
DEBUG_LOG(m_logger) << LOGFUNCTION;
if (m_topicData.x < 0 && m_topicData.y < 0 && m_topicData.h < 0 && m_topicData.w < 0)
{
m_topicData.x = 0.05;
m_topicData.y = m_topicData.x;
m_topicData.h = 1 - (m_topicData.x * 2);
m_topicData.w = m_topicData.h;
}
m_ui->reportsDataView->selectionModel()->clear();
m_reportId = getTopicDataValue(QStringLiteral("ReportId")).toInt();
if (m_reportId > 0) // there is a report id saved (not a new topic)
{
DEBUG_LOG(m_logger) << LOGFUNCTION << " report id = " << m_reportId;
QModelIndex idx = m_reportModel->findIndexForId(m_reportId);
const ReportManagement::ReportInfo report = m_reportModel->getRowData(idx.row());
if (idx.isValid())
{
m_ui->reportsDataView->selectRow(idx);
m_ui->lblName->setText(QString::fromStdString(report.name()));
m_reportInfo = m_reportModel->getRowData(idx.row());
DEBUG_LOG(m_logger) << LOGFUNCTION << " selected report: " << m_reportInfo.name();
}
else
{
m_ui->lblName->setText(m_topicData.properties.value(QStringLiteral("ReportId")).toString(QStringLiteral("<font color='red'>%1</font>").arg(tr("unknown"))));
}
}
else // new topic
{
m_ui->lblName->setText(QStringLiteral("<font color='red'>%1</font>").arg(tr("Please select a valid report")));
}
m_ui->pbSetTopicPosition->setEnabled(!m_topicData.channel.isEmpty() || !m_topicData.parentChannel.isEmpty()); // preview only available if topic is at a screen
}
void ReportTopicEditor::retranslate()
{
translate(m_ui, tr("Report Topic Editor"));
m_uiRequirements->clear();
m_uiRequirements->addRequirement( { m_ui->lbxNamePre, [this]() { return (m_reportId >= 0); }, tr("Invalid or no report selected") } );
}
///////////////////////////////////////////////////////////////////////////////
// PRIVATE SLOTS
bool ReportTopicEditor::apply2()
{
if (m_reportId < 0)
{
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid or no report selected"));
return false;
}
setTopicDataProperty(QStringLiteral("ReportId"), m_reportId);
if (m_ui->widget->description().isEmpty())
setDescription(QString::fromStdString(m_reportInfo.name()));
else
setDescription(m_ui->widget->description());
m_ui->widget->previewer()->setTopicData(m_topicData);
emit changesSaved(m_topicData); // map changes on preview window
return true;
}
void ReportTopicEditor::onReportSelected()
{
const QModelIndex idx = m_ui->reportsDataView->currentIndex();
m_reportInfo = m_reportModel->getRowData(idx.row());
m_reportId = m_reportInfo.id();
m_ui->lblName->setText(QString::fromStdString(m_reportInfo.name()));
slotChangesMade();
}
/*!
* \brief ReportTopicEditor::onPreview
* in this Method the scroll area and the widget will be used as parent
* A new Object will be created and used instead of the parent. to avoid sofware crashed on preview
* setWidget in topic designer: ownership of created scrollArea will be changed there => on delete will be
* automatically deleted.
*/
void ReportTopicEditor::onPreview()
{
if(m_ui->widget == nullptr)
return;
TopicEditorBase::TopicPreviewWidget *widget = new TopicEditorBase::TopicPreviewWidget(m_ui->widget);
QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
widget->setSizePolicy(sizePolicy1);
widget->setMinimumSize(QSize(0, 60));
emit signalSetTopicPosition(widget, m_topicData.id);
}
} // namespace ReportManagement
@@ -0,0 +1,64 @@
/**
* @RDE_HEADER@
* Topic Editor for the Reports in the Script Editor
* $Id$
* $HeadURL$
* $Author$
*
* Created by Iuliana Ojog, SLSE, 2018-03-24
*/
#pragma once
#include <OperatorManagement/opm_dtc.h>
#include <ParticipantManagement/ppm_data_plugin_interface.h>
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_gui_plugin_interface.h>
#include <Plugins/ReportManagement/Gui/ReportViewer/rep_report_preview.h>
#include <ReportManagement/logger.h>
#include <TopicEditorBase/topic_editor_base.h>
namespace Ui { class ReportTopicEditor; }
namespace ReportManagement
{
class ReportModel;
class ReportTopicEditor : public TopicEditorBase::TopicEditor
{
Q_OBJECT
public:
explicit ReportTopicEditor(
const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc, QWidget *parent = nullptr
);
~ReportTopicEditor();
private:
void updateInternalData() override final;
void retranslate() override final;
private slots:
bool apply2() override final;
void onReportSelected();
void onPreview();
private:
int m_reportId;
ReportInfo m_reportInfo;
ReportModel *m_reportModel{nullptr};
Ui::ReportTopicEditor *m_ui{nullptr};
NGL::INGLLogger &m_logger;
};
} // namespace ReportManagement
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportTopicEditor</class>
<widget class="QWidget" name="ReportTopicEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>868</width>
<height>388</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Script Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" 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="0" column="4">
<widget class="QPushButton" name="pbSetTopicPosition">
<property name="text">
<string>Preview Positioning</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Available Reports:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbxNamePre">
<property name="text">
<string>Selected Report:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>511</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lblName">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="2" colspan="2">
<widget class="TopicEditorBase::TopicPreviewWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
</widget>
</item>
<item row="1" column="2" rowspan="3" colspan="4">
<widget class="LtsDataView::LtsDataView" name="reportsDataView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</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>
<customwidget>
<class>TopicEditorBase::TopicPreviewWidget</class>
<extends>QWidget</extends>
<header>TopicEditorBase/topic_preview_widget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,167 @@
/**
* @RDE_HEADER@
* HMI Plugin for ReportManagement - ReportEdit
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-05
*/
#pragma once
#include "Input/rep_input_aes_model.h"
#include "Input/rep_input_building_model.h"
#include "Input/rep_input_charge_model.h"
#include "Input/rep_input_sanitation_material_model.h"
#include "Input/rep_input_type_model.h"
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Services/ReportManagement/logger.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <LtsSession/lts_session.h>
#include <LtsUtilsGuiDds/request_helper.h>
#include <LtsWidgets/lts_dialog.h>
#include <ReportManagement/rep_ftc.h>
#include <ReportManagement/rep_ftc_types.h>
namespace SituationMap
{
class ForeignGuiInterface;
}
class QSortFilterProxyModel;
namespace ParticipantManagement
{
class ParticipantTimePointModel;
class ParticipantTreeFilterProxyModel;
class ForeignGuiComboboxInterface;
} // namespace ParticipantManagement
namespace ProjectDataManagement
{
class ChargeTableDialog;
}
namespace Ui
{
class ReportEdit;
}
namespace ReportManagement
{
class ReportEdit
: public LtsWidgets::LtsDialog
, protected ReportManagement::Interface::Ftc::CreateModifyReportReplyHandler
{
Q_OBJECT
public:
explicit ReportEdit(LtsSession::LtsSession *session, QWidget *parent = nullptr);
~ReportEdit();
bool init(const ReportInfo &currReport, LtsSession::LtsSession *session);
void onCreateModifyReportReply(const CreateModifyReportReply &replyObject) override final; // { m_requestHelper->requestReply(replyObject); }
private:
void retranslate() override;
VisualisationType getVisualization() const;
bool initInputs();
bool initData();
bool fetchInterfaces();
void getParticipantSuperiorAndUnitIds(std::vector<int> &participantIds, std::vector<int> &unitIds, std::vector<Superior> &superiorIds);
std::vector<int> getAesIds() const;
std::vector<int> getTypeIds() const;
std::vector<int> getChargeIds() const;
std::vector<int> getMaterialIds() const;
std::vector<int> getBuildingIds() const;
void fillCbInterval();
void setParticipantAndUnitIds(const std::vector<int32_t> &part, const std::vector<int32_t> &units);
void recursiveGetParticipant(int participantId, std::vector<int> &participantIds, std::vector<int> &unitIds, std::vector<Superior> &superiorIds);
void setTypeIds(const std::vector<int32_t> &types) const;
void setChargeIds(const std::vector<int32_t> &charges) const;
void setMaterialIds(const std::vector<int32_t> &materials) const;
void setAesIds(const std::vector<int32_t> &aesIds) const;
void setBuildingIds(const std::vector<int32_t> &buildings) const;
bool has2DMap();
void showPreviewObject();
private slots:
bool apply() override final;
void onCheck();
void onChangeVisualisationType();
void onTypeSelectionChanged();
void onParticipantDataChanged();
void onAesChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
void onFtcTimerTimeout();
void onPreviewReport();
void onChargeDetailClicked();
void onChargeResetClicked();
void onChargeUleisCodesChanged(const QSet<int> &codes);
void onChargeTableDialogClosed();
void getPosition();
void onMapRectData(const QPointF &bottomLeft, double width, double height, double angleDegNorth, const QPolygonF &coordinates);
void onSelectInterval();
void onFilterAreaClicked(bool checked);
void onEffectSourceToggled(const ProjectDataManagement::EffectSource &es, bool checked);
private:
ReportManagement::ReportInfo m_report;
std::shared_ptr<ReportManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ReportManagement::Interface::Ftc> m_ftc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
std::shared_ptr<SituationMap::ForeignGuiInterface> m_sitMapGuiIfc;
ReportAesProxyModel *m_aesProxyModel{nullptr};
ReportTypeModel *m_typeModel{nullptr};
QSortFilterProxyModel *m_typeProxyModel{nullptr};
// ReportChargeModel *m_chargeModel{nullptr};
ReportChargeProxyModel *m_chargeProxyModel{nullptr};
ReportSanitationMaterialModel *m_sanitationMaterialModel{nullptr};
ReportBuildingModel *m_buildingModel{nullptr};
ParticipantManagement::ParticipantTimePointModel *m_participantModel{nullptr};
ParticipantManagement::ParticipantTreeFilterProxyModel *m_participantProxyModel{nullptr};
LtsSession::LtsSession *m_session{nullptr};
LtsUtils::RequestHelper *m_requestHelper{nullptr};
ProjectDataManagement::ChargeTableDialog *m_ctd{nullptr};
QSet<int> m_chargeTypes;
QPolygonF m_previewPolygon;
QVector<ProjectDataManagement::EffectSource> m_activeEffectSources;
Ui::ReportEdit *m_ui;
bool m_useAes{false};
bool m_useParticipants{false};
bool m_useCharge{false};
bool m_useTypes{false};
bool m_useParty{false};
bool m_usePartyAes{false};
bool m_useBuilding{false};
bool m_useSanitationMaterial{false};
qint64 m_minDateTime{0};
qint64 m_maxDateTime{0};
QTimer *m_ftcTimer{nullptr};
LOGGER_T m_logger;
};
} // namespace ReportManagement
@@ -0,0 +1,761 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportEdit</class>
<widget class="QWidget" name="ReportEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>2219</width>
<height>609</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Report Edit</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="gbBasic">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Base Data</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QLineEdit" name="leName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>45</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblName">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_start">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Start:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QTextEdit" name="teDescription">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteEnd" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_end">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>End:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteStart" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pbPhases">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Select Report Start / End</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbVisualize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Visualization</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QRadioButton" name="rbLineChart">
<property name="text">
<string>&amp;Line Graph</string>
</property>
</widget>
</item>
<item row="8" 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="5" column="0" colspan="2">
<widget class="QCheckBox" name="cbxGroup">
<property name="text">
<string>Group By Party</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbInterval">
<property name="text">
<string>Interval [min]:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="rbBarChart">
<property name="text">
<string>Bar &amp;Graph</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="rbTableView">
<property name="text">
<string>&amp;Table</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="rbPieChart">
<property name="text">
<string>Pie Graph</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="cbInterval">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lblEffectSource">
<property name="text">
<string>Effect Source:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QPushButton" name="pbEffectSource">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbTypes">
<property name="title">
<string>Participant Types</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="lblParticipantTypesView">
<property name="text">
<string>Select at least one participant type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cbAllTypes">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QTreeView" name="treeViewParticipantTypes">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>false</bool>
</property>
</widget>
</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>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbArea">
<property name="title">
<string>Area</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="3" column="0">
<widget class="QLabel" name="lblDimension">
<property name="text">
<string>Dimension [m]:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblPosition">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Position:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<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="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="LtsCoordWidget::LtsCoordWidget" name="positionEdit" native="true"/>
</item>
<item>
<widget class="QPushButton" name="pbPosition">
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normaloff>:/style/position.svg</normaloff>:/style/position.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbClear">
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset>
<normaloff>:/style/remove.svg</normaloff>:/style/remove.svg</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbWidth"/>
</item>
<item>
<widget class="LtsWidgets::LtsSpinBox" name="sbHeight"/>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbFilterArea">
<property name="text">
<string>Filter on area</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbAdditional">
<property name="title">
<string>Additional Items</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="lblAdditionalItemsView">
<property name="text">
<string>Select at least one additional item:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pbAdditionalDetail">
<property name="text">
<string>Detail</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<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="0" column="1">
<widget class="QCheckBox" name="cbAllAdditionalItems">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QStackedWidget" name="swAdditionalDetail">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="pgAdditionalDefault">
<layout class="QGridLayout" name="gridLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QTreeView" name="treeViewAdditionalItems">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pgAdditionalInfo">
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QLabel" name="lblAdditionalInfo">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pbAdditionalReset">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbAes">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Area Effects</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lblPartyAes">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Party:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="cbAllAreas">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LtsWidgets::LtsComboBox" name="cbPartyAes">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QTreeView" name="treeViewAes">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblAreaEffectsView">
<property name="text">
<string>Select at least one area effect:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_3">
<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>
</layout>
</widget>
<widget class="QGroupBox" name="gbParticipants">
<property name="title">
<string>Party Elements / Participants:</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lblParty">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Party:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LtsWidgets::LtsComboBox" name="cbParty">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lblParticipantView">
<property name="text">
<string>Select at least one participant:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="cbAllParticipants">
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_4">
<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="5">
<widget class="QTreeView" name="treeViewParticipants">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsCoordWidget::LtsCoordWidget</class>
<extends>QWidget</extends>
<header>LtsCoordTrans/lts_coord_widget.h</header>
</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>
<customwidget>
<class>LtsWidgets::LtsSpinBox</class>
<extends>QSpinBox</extends>
<header>LtsWidgets/lts_spinbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leName</tabstop>
<tabstop>dteStart</tabstop>
<tabstop>dteEnd</tabstop>
<tabstop>teDescription</tabstop>
<tabstop>rbTableView</tabstop>
<tabstop>rbLineChart</tabstop>
<tabstop>rbBarChart</tabstop>
<tabstop>rbPieChart</tabstop>
<tabstop>cbInterval</tabstop>
<tabstop>cbxGroup</tabstop>
<tabstop>cbAllTypes</tabstop>
<tabstop>treeViewParticipantTypes</tabstop>
<tabstop>cbAllAdditionalItems</tabstop>
<tabstop>treeViewAes</tabstop>
<tabstop>cbParty</tabstop>
<tabstop>cbAllParticipants</tabstop>
<tabstop>treeViewParticipants</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,80 @@
/**
* @RDE_HEADER@
* ExerciseManangement - Phase Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Schröder, SLSE, 2018-04-23
*/
#include "rep_report_interval.h"
#include "rep_report_interval_model.h"
#include "ui_rep_report_interval.h"
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
namespace ReportManagement
{
ReportIntervalDialog::ReportIntervalDialog(QWidget *parent)
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
, m_ui(new Ui::ReportIntervalDialog)
, m_session(nullptr)
, m_phaseModel(nullptr)
, m_logger(getLogger("ReportIntervalDialog"))
{
m_ui->setupUi(this);
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &LtsWidgets::LtsFramelessDialog::reject);
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok), &QPushButton::clicked, this, &LtsWidgets::LtsFramelessDialog::accept);
}
ReportIntervalDialog::~ReportIntervalDialog()
{
delete m_ui;
}
bool ReportIntervalDialog::init(LtsSession::LtsSessionDataDds *session, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc)
{
m_session = session;
m_exmDtc = exmDtc;
DEBUG_LOG(m_logger) << "Exercise id = " << m_session->exerciseId();
m_phaseModel = new ReportIntervalModel(this);
m_phaseModel->initModel(m_session->exerciseId(), m_exmDtc);
m_ui->dvPhases->setModel(m_phaseModel);
m_ui->dvPhases->hideColumn(3); // do not show the description
m_ui->dvPhases->hideColumn(4); // do not show the ExerciseId
connect(m_ui->dvPhases, &LtsDataView::LtsDataView::signalDoubleClicked,
this, &ReportIntervalDialog::selectPhase);
return true;
}
void ReportIntervalDialog::selectPhase()
{
const QModelIndexList indexList = m_ui->dvPhases->selectionModel()->selectedRows();
if (indexList.isEmpty() || indexList.size() > 1)
{
reject();
close();
}
const QModelIndex &idx = indexList.at(0);
const ExerciseManagement::ExercisePhase phase = m_phaseModel->getRowData(idx.row());
m_startTime = phase.beginTime();
m_endTime = phase.endTime();
ERROR_LOG(m_logger) << "Start time: " << m_startTime;
ERROR_LOG(m_logger) << "End time: " << m_endTime;
accept();
close();
}
}
@@ -0,0 +1,50 @@
/**
* @RDE_HEADER@
* ExerciseManangement - Phase Edit Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Malte Schröder, SLSE, 2018-04-23
*/
#pragma once
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
#include <Services/ReportManagement/logger.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsSession/lts_session_data_dds.h>
#include <LtsWidgets/lts_frameless_dialog.h>
namespace Ui {
class ReportIntervalDialog;
}
namespace ReportManagement
{
class ReportIntervalModel;
class ReportIntervalDialog : public LtsWidgets::LtsFramelessDialog
{
Q_OBJECT
public:
explicit ReportIntervalDialog(QWidget *parent = nullptr);
~ReportIntervalDialog();
bool init(LtsSession::LtsSessionDataDds *session, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc);
qint64 getStartTime() { return m_startTime; }
qint64 getEndTime() { return m_endTime; }
private slots:
void selectPhase();
private:
Ui::ReportIntervalDialog *m_ui;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
LtsSession::LtsSessionDataDds *m_session;
ReportIntervalModel *m_phaseModel;
qint64 m_startTime{0};
qint64 m_endTime{0};
LOGGER_T m_logger;
};
}
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportIntervalDialog</class>
<widget class="QWidget" name="ReportIntervalDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>430</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="LtsDataView::LtsDataView" name="dvPhases"/>
</item>
<item row="1" column="0">
<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>
<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,104 @@
/**
* @RDE_HEADER@
* Exercise Phase Overview Model
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2017-04-11
*/
#include "rep_report_interval_model.h"
namespace ReportManagement
{
//---------------------------------
// ReportIntervalModel
//---------------------------------
ReportIntervalModel::ReportIntervalModel(QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ExerciseManagement::ExercisePhase>({tr("Phase"),
tr("Start"),
tr("End"),
tr("Description"),
tr("Exercise-Id")},
parent)
, m_exmDtc(nullptr)
, m_logger(getLogger("ReportIntervalModel"))
{}
bool ReportIntervalModel::initModel(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtc)
{
m_exerciseId = exerciseId;
m_exmDtc = dtc;
connect(m_exmDtc.get(), &ExerciseManagement::Interface::Dtc::exercisePhaseChanged,
this, &ReportIntervalModel::onDataChanged);
// insert phases
m_exmDtc->exercisePhases([this](const ExerciseManagement::ExercisePhase &item) { insertRow(item); });
INFO_LOG(m_logger) << "initModel - #exercise phases: " << m_vecData.size();
return true;
}
QVariant ReportIntervalModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || role != Qt::DisplayRole || index.row() >= m_vecData.size())
return QVariant();
if (role == Qt::DisplayRole)
{
const ExerciseManagement::ExercisePhase &exPhase = m_vecData.at(index.row());
switch (index.column())
{
case Name:
return QString::fromStdString(exPhase.name());
case Start:
return QDateTime::fromMSecsSinceEpoch(exPhase.beginTime());
case End:
return QDateTime::fromMSecsSinceEpoch(exPhase.endTime());
case Description:
return QString::fromStdString(exPhase.description());
case ExerciseId:
return (exPhase.exerciseId());
}
}
return QVariant();
}
//
// ReportIntervalProxyModel
//
void ReportIntervalProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<ReportIntervalModel*>(sourceModel);
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
}
bool ReportIntervalProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case ReportIntervalModel::Start:
return dataLeft.beginTime() < dataRight.beginTime();
case ReportIntervalModel::End:
return dataLeft.endTime() < dataRight.endTime();
case ReportIntervalModel::Name:
case ReportIntervalModel::Description:
case ReportIntervalModel::ExerciseId:
break;
}
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
}
} // namespace
@@ -0,0 +1,69 @@
/**
* @RDE_HEADER@
* ExerciseManangement - Exercise Phase Overview Model
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, SLS1, 2017-04-11
*/
#pragma once
#include <LtsWidgets/lts_abstract_table_model.h>
#include <LtsWidgets/lts_column_filter_proxy_model.h>
#include <ExerciseManagement/exm_dtc.h>
#include <ReportManagement/logger.h>
namespace ReportManagement
{
class ReportIntervalModel final : public LtsWidgets::LtsAbstractTableModel<ExerciseManagement::ExercisePhase>
{
Q_OBJECT
public:
enum Columns
{
Name,
Start,
End,
Description,
ExerciseId
};
explicit ReportIntervalModel(QObject *parent = nullptr);
bool initModel(int exerciseId, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtc);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
protected:
bool isFiltered(const ExerciseManagement::ExercisePhase &data, DataModification modType) const override
{
if (data.exerciseId() != m_exerciseId)
return true;
return LtsWidgets::LtsAbstractTableModel<ExerciseManagement::ExercisePhase>::isFiltered(data, modType);
}
private:
int m_exerciseId{0};
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
LOGGER_T m_logger;
friend class ReportIntervalProxyModel;
};
class ReportIntervalProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
{
Q_OBJECT
public:
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
void setSourceModel(QAbstractItemModel *sourceModel) override;
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
private:
ReportIntervalModel *m_sourceModel = nullptr;
};
}
@@ -0,0 +1,349 @@
/**
* @RDE_HEADER@
* HMI Plugin for ReportManagement - Report Overview Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-05
*/
#include "rep_report_list.h"
#include "rep_report_edit.h"
#include "rep_report_preview.h"
#include "ui_rep_report_list.h"
#include "CustomView/rep_entry.h"
#include <LtsSession/lts_session_manager.h>
#include <LtsSession/lts_session_data.h>
#include <LtsPrinting/printing.h>
#include <ReportManagement/rep_operator_rights.h>
#include <QTreeView>
#include <QDateTime>
namespace ReportManagement
{
//-----------------------------------------------------------------------------
ReportList::ReportList(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
, m_menuGroup(menuGroup)
, m_session(session)
, m_requestHelper(new LtsUtils::RequestHelper(this))
, m_ui(new Ui::ReportList)
, m_logger(getLogger("ReportManagementDialog"))
{
m_ui->setupUi(this);
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &ReportList::onPreviewReport);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Show, true);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ReportList::onEditReport);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Edit, true);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ReportList::onRemoveReport);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, true);
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setText(tr("Remove"));
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &ReportList::slotDelete, Qt::UniqueConnection);
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Delete"));
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, true);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &ReportList::slotRestore, Qt::UniqueConnection);
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Restore"));
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Save, true);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ReportList::onPrint);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Export, this, &ReportList::onExportReport);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Export, true);
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &ReportList::close);
// connects fuer Widgetaenderungen
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ReportList::onSelectionChanged);
bool userHasRightsToEdit = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::ReportsEdit);
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(userHasRightsToEdit);
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setVisible(userHasRightsToEdit);
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setVisible(userHasRightsToEdit);
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setVisible(userHasRightsToEdit);
m_buttonBox->getButton(LtsWidgets::DialogButton::Export)->setVisible(userHasRightsToEdit);
if (userHasRightsToEdit)
{
// double click to edit
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ReportList::onEditReport);
}
setOnlineHelpFilename(QStringLiteral("Situation-Reports"));
} // end of ctor()
//-----------------------------------------------------------------------------
ReportList::~ReportList()
{
delete m_ui;
} // end of dtor()
//-----------------------------------------------------------------------------
void ReportList::retranslate()
{
translate(m_ui, tr("Reports"));
}
//-----------------------------------------------------------------------------
bool ReportList::init(LtsSession::LtsSession *session)
{
m_session = session;
if (!fetchInterfaces())
return false;
m_model = new ReportModel(this);
m_model->initModel(m_dtc, m_opmDtc, m_ppmDtc, m_ppmGuiCbxIfc);
auto proxyModel = new ReportProxyModel(this);
proxyModel->setSourceModel(m_model);
m_ui->widget->setModel(proxyModel, [this]() { return new CustomViewReport(this); });
#ifndef LTS_DEBUG
m_ui->widget->hideColumn(ReportModel::Id);
m_ui->widget->hideColumn(ReportModel::FileStatus);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, false);
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Save, false);
#endif
m_ui->widget->setSortIndicator(ReportModel::Name, Qt::AscendingOrder);
return true;
} // end of init()
//-----------------------------------------------------------------------------
void ReportList::onSelectionChanged()
{
const QModelIndex idx = m_ui->widget->currentIndex();
int row = idx.row();
bool bEnable = (row >= 0);
ReportInfo rep = m_model->getRowData(row);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, bEnable);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEnable);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bEnable);
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, bEnable);
#ifdef LTS_DEBUG
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, bEnable && (rep.fileStatus() == FileStatus::Valid));
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, bEnable && (rep.fileStatus() == FileStatus::Deleted));
#endif
} // end of onSelectionChanged()
//-----------------------------------------------------------------------------------------------------------
void ReportList::onEditReport()
{
DEBUG_LOG(m_logger) << "onEditReport";
QModelIndex selIndex = m_ui->widget->currentIndex();
if (!selIndex.isValid())
return;
ReportManagement::ReportInfo data = m_model->getRowData(m_ui->widget->currentIndex().row());
DEBUG_LOG(m_logger) << "onEditReport Id = " << data.id();
ReportEdit *dialog = new ReportEdit(m_session, this);
if (!dialog->init(data, m_session))
{
delete dialog;
return;
}
addDialog(dialog, m_menuGroup, QStringLiteral("EditReport%1").arg(data.id()), LtsWidgets::LayoutArea::eDialogTab);
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::onShowReport()
{
DEBUG_LOG(m_logger) << "onShowReport";
QModelIndex selIndex = m_ui->widget->currentIndex();
if (!selIndex.isValid())
return;
ReportManagement::ReportInfo data = m_model->getRowData(m_ui->widget->currentIndex().row());
DEBUG_LOG(m_logger) << "onShowReport Id = " << data.id();
ReportPreview *dialog = new ReportPreview(m_session, this);
if (dialog->init(data))
dialog->show();
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::onRemoveReport()
{
QModelIndex selIndex = m_ui->widget->currentIndex();
if (!selIndex.isValid())
return;
DEBUG_LOG(m_logger) << "onRemoveReport";
ReportManagement::ReportInfo data = m_model->getRowData(m_ui->widget->currentIndex().row());
INFO_LOG(m_logger) << "Removing report with id = " << data.id();
Core::RemoveElementRequest req(data.id());
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->removeReportRequest(req, this);
});
if (m_requestHelper->failed())
ERROR_LOG(m_logger) << "Failed to remove report";
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::slotDelete()
{
DEBUG_LOG(m_logger) << "ReportList::slotDelete";
changeStatus(FileStatus::Deleted);
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::slotRestore()
{
DEBUG_LOG(m_logger) << "ReportList::slotRestore";
changeStatus(FileStatus::Valid);
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::onPrint()
{
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::onPreviewReport()
{
DEBUG_LOG(m_logger) << "onPreviewReport";
QModelIndex selIndex = m_ui->widget->currentIndex();
if (!selIndex.isValid())
return;
ReportManagement::ReportInfo data = m_model->getRowData(m_ui->widget->currentIndex().row());
DEBUG_LOG(m_logger) << "onPreviewReport Id = " << data.id();
ReportPreview *dialog = new ReportPreview(m_session, this);
if (dialog->init(data))
dialog->previewReport();
else
ERROR_LOG(m_logger) << "Can not preview report with id = " << data.id();
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::onExportReport()
{
DEBUG_LOG(m_logger) << "onExportReport";
QModelIndex selIndex = m_ui->widget->currentIndex();
if (!selIndex.isValid())
return;
ReportManagement::ReportInfo data = m_model->getRowData(m_ui->widget->currentIndex().row());
DEBUG_LOG(m_logger) << "onExportReport Id = " << data.id();
ReportPreview *dialog = new ReportPreview(m_session, this);
if (dialog->init(data))
dialog->onExport();
else
ERROR_LOG(m_logger) << "Can not export report with id = " << data.id();
}
//-----------------------------------------------------------------------------------------------------------
void ReportList::changeStatus(const FileStatus &fs)
{
QModelIndex selIndex = m_ui->widget->currentIndex();
if (!selIndex.isValid()) // no valid index
return;
ReportInfo rep = m_model->getRowData(m_ui->widget->currentIndex().row());
if (rep.fileStatus() == fs) // nothing to do
return;
m_requestHelper->startSingleRequest([ = ]()
{
DEBUG_LOG(m_logger) << "Changing status for report id = " << rep.id();
ReportChangeStatusRequest req;
req.id(rep.id());
req.fileStatus(fs);
req.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
req.lastModified(QDateTime::currentMSecsSinceEpoch());
return m_ftc->reportChangeStatusRequest(ReportChangeStatusRequest(req), this);
});
if (m_requestHelper->failed())
ERROR_LOG(m_logger) << "Failed to change status for report with id = " << rep.id();
}
void ReportList::tableColumnOrganiserSetting()
{
//LtsColumnOrganiser
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
}
// -----------------------------------------------------------------------------------------------
bool ReportList::fetchInterfaces()
{
if (!m_session->getDtc<ReportManagement::DataInterface>(m_dtc))
{
ERROR_LOG(m_logger) << "Cannot retrieve ReportManagament Dtc interface!";
return false;
}
if (!m_session->getFtc<ReportManagement::DataInterface>(m_ftc))
{
ERROR_LOG(m_logger) << "Cannot retrieve ReportManagament Ftc interface!";
return false;
}
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
ERROR_LOG(m_logger) << "Cannot retrieve ParticipantManagament Dtc interface!";
return false;
}
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
{
ERROR_LOG(m_logger) << "Cannot retrieve AreaEffectSimulation Dtc interface!";
return false;
}
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
ERROR_LOG(m_logger) << "Cannot retrieve ProjectDataManagement Dtc interface!";
return false;
}
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
{
ERROR_LOG(m_logger) << "Cannot retrieve ParticipantManagement ForeignGuiCombobox interface!";
return false;
}
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
{
ERROR_LOG(m_logger) << "Cannot retrieve OperatorManagement Dtc interface!";
return false;
}
return true;
}
//-----------------------------------------------------------------------------
} // namespace ReportManagement
@@ -0,0 +1,87 @@
/**
* @RDE_HEADER@
* HMI Plugin for ReportManagement - Report Dialog
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-05
*/
#pragma once
#include "rep_report_model.h"
#include <Services/ReportManagement/rep_dtc.h>
#include <Services/ReportManagement/rep_ftc.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsSession/lts_session.h>
#include <LtsUtilsGuiDds/request_helper.h>
namespace ParticipantManagement
{
class ForeignGuiComboboxInterface;
}
namespace Ui
{
class ReportList;
}
namespace ReportManagement
{
class ReportList : public LtsWidgets::LtsDialog,
protected ReportManagement::Interface::Ftc::RemoveReportReplyHandler,
protected ReportManagement::Interface::Ftc::ReportChangeStatusReplyHandler
{
Q_OBJECT
public:
explicit ReportList(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
~ReportList();
bool init(LtsSession::LtsSession *session);
void onRemoveReportReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
void onReportChangeStatusReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
private:
void retranslate() override;
void onSelectionChanged();
bool fetchInterfaces();
void changeStatus(const FileStatus &fs);
void tableColumnOrganiserSetting() override;
protected slots:
void onEditReport();
void onShowReport();
void onRemoveReport();
void slotDelete();
void slotRestore();
void onPrint();
void onPreviewReport();
void onExportReport();
private:
QString m_menuGroup;
ReportModel *m_model {nullptr};
std::shared_ptr<ReportManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ReportManagement::Interface::Ftc> m_ftc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
LtsSession::LtsSession *m_session;
LtsUtils::RequestHelper *m_requestHelper;
Ui::ReportList *m_ui;
LOGGER_T m_logger;
};
} // namespace ReportManagement
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportList</class>
<widget class="QWidget" name="ReportList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>455</width>
<height>341</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Report List</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="LtsDataView::LtsDataView" name="widget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</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,298 @@
/**
* @RDE_HEADER@
* HMI Plugin for ReportManagement - Weather Station Overview Dialog Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#include "rep_report_model.h"
#include <ngltools/ngltools_dtg.h>
#include <ReportManagement/rep_translation.h>
#include <ParticipantManagement/ppm_translation.h>
#include <QSet>
namespace dds
{
namespace core
{
static inline uint qHash(const ReportManagement::ReportType &t, uint seed)
{
return ::qHash(t.underlying(), seed);
}
static inline uint qHash(const ReportManagement::VisualisationType &t, uint seed)
{
return ::qHash(t.underlying(), seed);
}
}
}
namespace ReportManagement
{
//---------------------------------
// ReportModel
//---------------------------------
ReportModel::ReportModel(QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ReportInfo>({tr("Id"),
tr("Name"),
tr("Type"),
tr("Party"),
tr("Start Time"),
tr("End Time"),
tr("Visualisation"),
tr("Interval"),
tr("Description"),
tr("Operator"),
tr("Last modified"),
tr("Status")
#ifdef LTS_DEBUG
,tr("Lat")
,tr("Lon")
,tr("Width")
,tr("Height")
#endif
},
parent)
, m_logger(getLogger("ReportModel"))
{}
bool ReportModel::initModel(const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc)
{
m_dtc = dtc;
m_opmDtc = opmDtc;
m_ppmDtc = ppmDtc;
m_ppmGuiCbxIfc = ppmGuiCbxIfc;
connect(m_dtc.get(), &ReportManagement::Interface::Dtc::reportInfoChanged,
this, &ReportModel::onDataChanged);
m_dtc->reportInfos([this](const ReportManagement::ReportInfo & reportInfo) { insertRow(reportInfo); });
connect(this, &ReportModel::rowsInserted,
this, &ReportModel::onUpdateComboboxFilterData, Qt::UniqueConnection);
connect(this, &ReportModel::rowsRemoved,
this, &ReportModel::onUpdateComboboxFilterData, Qt::UniqueConnection);
connect(this, &ReportModel::modelReset,
this, &ReportModel::onUpdateComboboxFilterData, Qt::UniqueConnection);
onUpdateComboboxFilterData();
return true;
}
QVariant ReportModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole &&
role != Qt::DecorationRole &&
role != LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
return QVariant();
if (!indexIsValid(index))
return QVariant();
const ReportManagement::ReportInfo &reportInfo = m_vecData.at(index.row());
if (role == Qt::DecorationRole)
{
switch (index.column())
{
case Party:
return iconFromPartyId(reportInfo.partyId());
default:
break;
}
return QVariant();
}
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
{
switch (index.column())
{
case Type:
return reportInfo.reportType().underlying();
case Party:
return reportInfo.partyId();
case Visualisation:
return reportInfo.visualisationType().underlying();
default:
break;
}
return QVariant();
}
// Qt::DecorationRole
switch (index.column())
{
case Id:
return reportInfo.id();
case Name:
return QString::fromStdString(reportInfo.name());
case Type:
return ReportManagement::toString(reportInfo.reportType());
case Party:
return stringFromPartyId(reportInfo.partyId());
case StartTime:
return QDateTime::fromMSecsSinceEpoch(reportInfo.startTime());
case EndTime:
return QDateTime::fromMSecsSinceEpoch(reportInfo.endTime());
case Visualisation:
return ReportManagement::toString(reportInfo.visualisationType());
case Interval:
return reportInfo.intervalTime() / (1000 * 60); // msec->sec->min
case Description:
return QString::fromStdString(reportInfo.description());
case Operator:
return QString::fromStdString(m_opmDtc->user(reportInfo.operatorId()).name());
case LastModified:
return QDateTime::fromMSecsSinceEpoch(reportInfo.lastModified());
case FileStatus:
return ReportManagement::toString(reportInfo.fileStatus());
case Lat:
return reportInfo.cornerBottomLeft().lat();
case Lon:
return reportInfo.cornerBottomLeft().lon();
case Width:
return reportInfo.width();
case Height:
return reportInfo.height();
}
return QVariant();
}
QVariant ReportModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
{
switch (section)
{
case Type:
return m_cbxReportType;
case Party:
return m_cbxFilterParty;
case Visualisation:
return m_cbxVisualisationType;
default:
return QVariant();
}
}
return LtsWidgets::LtsAbstractTableModel<ReportInfo>::headerData(section, orientation, role);
}
void ReportModel::onUpdateComboboxFilterData()
{
QSet<ReportType> availableReportTypes;
QSet<VisualisationType> availableVisualisationTypes;
QSet<int> availablePartyIds;
for (const auto &data : qAsConst(m_vecData))
{
availableReportTypes.insert(data.reportType());
availableVisualisationTypes.insert(data.visualisationType());
availablePartyIds.insert(data.partyId());
}
updateComboboxFilterData(availableReportTypes, availableVisualisationTypes, availablePartyIds);
}
void ReportModel::updateComboboxFilterData(const QSet<ReportType> &availableReportTypes,
const QSet<VisualisationType> &availableVisualisationTypes,
const QSet<int> &availablePartyIds)
{
LtsWidgets::ComboboxFilterContent cfc;
LtsWidgets::ComboboxFilterData cfd;
for (const auto &i : qAsConst(availableReportTypes))
{
cfd.data = i.underlying();
cfd.text = ReportManagement::toString(i);
cfc.data.push_back(cfd);
}
cfc.sortItems = true;
m_cbxReportType = cfc.toVariant();
cfc.data.clear();
for (const auto &i : qAsConst(availableVisualisationTypes))
{
cfd.data = i.underlying();
cfd.text = ReportManagement::toString(i);
cfc.data.push_back(cfd);
}
cfc.sortItems = true;
m_cbxVisualisationType = cfc.toVariant();
cfc.data.clear();
for (const int i : qAsConst(availablePartyIds))
{
cfd.data = i;
cfd.text = ParticipantManagement::trPartyName(m_ppmDtc->party(i).name());
cfd.icon = iconFromPartyId(i);
cfc.data.push_back(cfd);
}
cfc.sortItems = false;
m_cbxFilterParty = cfc.toVariant();
}
QIcon ReportModel::iconFromPartyId(int partyId) const
{
if (!m_ppmGuiCbxIfc)
return QIcon();
auto it = m_partyIcons.find(partyId);
if (it != m_partyIcons.end())
return it.value();
const QRgb col = QRgb(m_ppmDtc->party(partyId).color());
const QIcon icon = m_ppmGuiCbxIfc->pixmapFromParty(col);
m_partyIcons.insert(partyId, icon);
return icon;
}
QVariant ReportModel::stringFromPartyId(int partyId) const
{
auto it = m_partyNames.find(partyId);
if (it != m_partyNames.end())
return it.value();
const QString name = ParticipantManagement::trPartyName(m_ppmDtc->party(partyId).name());
m_partyNames.insert(partyId, name);
return name;
}
//
// ReportProxyModel
//
void ReportProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<ReportModel*>(sourceModel);
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
}
bool ReportProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case ReportModel::Party:
return dataLeft.partyId() < dataRight.partyId();
case ReportModel::StartTime:
return dataLeft.startTime() < dataRight.startTime();
case ReportModel::EndTime:
return dataLeft.endTime() < dataRight.endTime();
case ReportModel::LastModified:
return dataLeft.lastModified() < dataRight.lastModified();
case ReportModel::Id:
case ReportModel::Name:
case ReportModel::Type:
case ReportModel::Visualisation:
case ReportModel::Interval:
case ReportModel::Description:
case ReportModel::Operator:
case ReportModel::FileStatus:
break;
}
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
}
} // namespace ReportManagement
@@ -0,0 +1,93 @@
/**
* @RDE_HEADER@
* HMI Plugin for ReportManagement - Weather Station Overview Dialog Model
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017-01-17
*/
#pragma once
#include <ReportManagement/rep_dtc.h>
#include <ReportManagement/logger.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <LtsWidgets/lts_column_filter_proxy_model.h>
namespace ReportManagement
{
//--------------------------------------------------------------------------------------
class ReportModel final : public LtsWidgets::LtsAbstractTableModel<ReportManagement::ReportInfo>
{
Q_OBJECT
public:
enum Columns
{
Id,
Name,
Type,
Party,
StartTime,
EndTime,
Visualisation,
Interval,
Description,
Operator,
LastModified,
FileStatus,
Lat,
Lon,
Width,
Height
};
explicit ReportModel(QObject *parent = nullptr);
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc);
QVariant data(const QModelIndex &, int) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
protected:
void onUpdateComboboxFilterData();
void updateComboboxFilterData(const QSet<ReportType> &availableReportTypes,
const QSet<VisualisationType> &availableVisualisationTypes,
const QSet<int> &availablePartyIds);
QIcon iconFromPartyId(int partyId) const;
QVariant stringFromPartyId(int partyId) const;
private:
QVariant m_cbxReportType;
QVariant m_cbxVisualisationType;
QVariant m_cbxFilterParty;
mutable QHash<int, QVariant> m_partyNames;
mutable QHash<int, QIcon> m_partyIcons;
std::shared_ptr<ReportManagement::Interface::Dtc> m_dtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
LOGGER_T m_logger;
friend class ReportProxyModel;
};
//--------------------------------------------------------------------------------------
class ReportProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
{
Q_OBJECT
public:
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
void setSourceModel(QAbstractItemModel *sourceModel) override;
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
private:
ReportModel *m_sourceModel = nullptr;
};
} //namespace ReportManagement
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,155 @@
/**
* @RDE_HEADER@
* Dialog which shows a single online report
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2017-02-28
*/
#pragma once
#include "Models/rep_abstract_model.h"
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_dtc.h>
#include <ReportManagement/rep_ftc.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <ExerciseManagement/exm_dtc.h>
#include <ProjectDataManagement/pdm_dtc.h>
#include <AreaEffectSimulation/aes_dtc.h>
#include <InfrastructureManagement/ism_dtc.h>
#include <FileManagement/flm_ftc.h>
#include <FileManagement/flm_dtc.h>
#include <LtsWidgets/lts_frameless_dialog.h>
#include <LtsUtilsGuiDds/request_helper.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <KDChart/KDChartMarkerAttributes>
class QStandardItemModel;
namespace NGL
{
class Settings;
}
namespace Ui
{
class ReportPreview;
}
namespace KDChart
{
class Chart;
class AbstractDiagram;
class Legend;
}
namespace KDReports
{
class Report;
class AutoTableElement;
class TextElement;
}
namespace ReportManagement
{
class EventTypeModel final : public LtsWidgets::LtsAbstractTableModel<ReportManagement::EventType>
{
Q_OBJECT
public:
explicit EventTypeModel(QObject *parent = nullptr);
~EventTypeModel() = default;
QVariant data(const QModelIndex &, int) const override final;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override final;
QColor eventColor(ReportManagement::EventType eventTypeId) const;
KDChart::MarkerAttributes::MarkerStyle eventMarker(ReportManagement::EventType eventTypeId) const;
void initModel();
int columnCount(const QModelIndex &parent) const override final;
private:
LOGGER_T m_logger;
};
class ReportPreview : public LtsWidgets::LtsFramelessDialog
, protected FileManagement::Interface::Ftc::FileContentModifyReplyHandler
{
Q_OBJECT
public:
explicit ReportPreview(LtsSession::LtsSession *session, QWidget *parent = nullptr);
bool init(const ReportManagement::ReportInfo &report);
KDReports::Report* getReportDisplay() { return m_reportDisplay; }
~ReportPreview();
bool previewReport();
void onExport();
protected:
void onFileContentModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
//private Q_SLOTS:
// void onPrint();
private:
enum ChartType
{
PIE = 0,
BAR = 1,
LINE = 2
};
bool displayReport();
bool displayReportAsTable();
bool displayReportAsPie();
bool displayReportAsLine();
bool displayReportAsBar();
void collectHeaderData();
void addToHeaderData(const QString &strLeft, const QString &strRight);
void addMessage(const QString &msg);
void initInputs();
bool fetchInterfaces();
QVector<QBrush> brushes();
KDChart::Chart *createNewChart(const ChartType &chartType, bool hasToCreateLegend, QAbstractItemModel *proxyModel = nullptr, const QString &header = QString());
KDReports::Report *m_reportDisplay {nullptr};
QStandardItemModel *m_headerDataModel {nullptr};
AbstractModel *m_dataModel {nullptr};
EventTypeModel *m_eventsModel {nullptr};
ReportInfo m_report;
QVector<int> m_groupIds;
QVector<KDChart::Chart*> m_charts;
bool m_useAes {false};
bool m_useParticipants {false};
bool m_useCharge {false};
bool m_useTypes {false};
bool m_useParty {false};
bool m_usePartyAes {false};
bool m_useBuilding {false};
bool m_useSanitationMaterial {false};
std::shared_ptr<ReportManagement::Interface::Ftc> m_ftc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_exmDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
LtsSession::LtsSession *m_session;
LtsUtils::RequestHelper *m_requestHelper;
Ui::ReportPreview *m_ui;
NGL::Settings *m_settings;
LOGGER_T m_logger;
};
}
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ReportPreview</class>
<widget class="QWidget" name="ReportPreview">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>877</width>
<height>783</height>
</rect>
</property>
<property name="windowTitle">
<string>Preview File Content</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="LtsWidgets::LtsDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="lblTitle">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Show Report:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblReportName">
<property name="text">
<string notr="true">Report Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblReportDate">
<property name="text">
<string notr="true">Report Date</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>576</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>861</width>
<height>670</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="LtsWidgets::LtsReportDisplayWidget" name="ltsReportDisplayWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsWidgets::LtsDialogButtonBox</class>
<extends>QWidget</extends>
<header>LtsWidgets/lts_dialog_button_box.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LtsWidgets::LtsReportDisplayWidget</class>
<extends>QWidget</extends>
<header>LtsReportDisplay/lts_report_display_widget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,654 @@
/**
* @RDE_HEADER@
* Gui Plugin for ReportManagement
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-05
*/
#include "rep_report_viewer_gui_plugin.h"
#include "rep_report_list.h"
#include "rep_report_edit.h"
#include <LtsSession/lts_session.h>
#include <LtsUtilsSettings/settings.h>
#include <ReportManagement/rep_operator_rights.h>
#include <KDReports/KDReports.h>
#include <TopicEditor/topic_editor.h>
#include <QBoxLayout>
#include <QLabel>
namespace ReportManagement
{
//----------------------------------------------------------------------------------------------------
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.Rep.ReportViewer"))
, m_dtc(nullptr)
, m_ftc(nullptr)
, m_ppmDtc(nullptr)
, m_ppmGuiCbxIfc(nullptr)
, m_aesDtc(nullptr)
, m_pdmDtc(nullptr)
, m_ismDtc(nullptr)
{
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
m_enableB = ps->value(QStringLiteral("aes"),
QStringLiteral("enableBiologicalContamination")).toBool();
m_enableC = ps->value(QStringLiteral("aes"),
QStringLiteral("enableChemicalContamination")).toBool();
m_enableN = ps->value(QStringLiteral("aes"),
QStringLiteral("enableNuclearContaminations")).toBool();
}
//----------------------------------------------------------------------------------------------------
bool InterfaceImpl::fetchInterfaces()
{
if (!m_session->getDtc<ReportManagement::DataInterface>(m_dtc))
{
DEBUG_LOG(m_logger) << "Failed to fetch ReportManagement DTC interface!";
return false;
}
if (!m_session->getFtc<ReportManagement::DataInterface>(m_ftc))
{
DEBUG_LOG(m_logger) << "Failed to fetch ReportManagement FTC interface!";
return false;
}
//foreign
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
{
DEBUG_LOG(m_logger) << "Failed to fetch ParticipantManagement DTC interface!";
return false;
}
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(m_ppmGuiCbxIfc))
{
DEBUG_LOG(m_logger) << "Failed to fetch ParticipantManagement ForeignGuiComboboxInterface!";
return false;
}
if (!m_session->getDtc<AreaEffectSimulation::DataInterface>(m_aesDtc))
{
DEBUG_LOG(m_logger) << "Failed to fetch AreaEffectSimulation DTC interface!";
return false;
}
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(m_pdmDtc))
{
DEBUG_LOG(m_logger) << "Failed to fetch ProjectDataManagement DTC interface!";
return false;
}
// if (!m_session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc))
// {
// DEBUG_LOG(m_logger) << "Failed to fetch InfrastructureManagement DTC interface!";
// return false;
// }
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
{
DEBUG_LOG(m_logger) << "Failed to fetch OperatorManagement DTC interface!";
return false;
}
return true;
}
//----------------------------------------------------------------------------------------------------
void InterfaceImpl::clearInterfaces()
{
m_dtc = nullptr;
m_ftc = nullptr;
m_ppmDtc = nullptr;
m_opmDtc = nullptr;
m_ppmGuiCbxIfc = nullptr;
m_aesDtc = nullptr;
m_pdmDtc = nullptr;
m_ismDtc = nullptr;
}
//----------------------------------------------------------------------------------------------------
QString InterfaceImpl::menuGroup() const
{
return tr("Reports");
}
//------------------------------------------------------------------------------
QString InterfaceImpl::getAESNbcReportTypeName()
{
if (!m_enableB && !m_enableC && m_enableN)
return tr("Add N Report");
if (m_enableB && !m_enableC && m_enableN)
return tr("Add N/B Report");
if (!m_enableB && m_enableC && m_enableN)
return tr("Add N/C Report");
if (m_enableB && !m_enableC && !m_enableN)
return tr("Add B Report");
if (m_enableB && m_enableC && !m_enableN)
return tr("Add B/C Report");
if (!m_enableB && m_enableC && !m_enableN)
return tr("Add C Report");
if (m_enableB && m_enableC && m_enableN)
return tr("Add N/B/C Report");
return (tr("Non AES N/B/C type set"));
}
//----------------------------------------------------------------------------------------------------
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
LtsWidgets::PluginData plData;
plData.menuGroup = menuGroup();
plData.menuText = tr("Reports");
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableReports")).toBool())
{
plData.identifier = QLatin1String("repReportViewer");
plData.menuIcon = QIcon(QLatin1String("icon:reports_display.svg"));
plData.operatorRight = OperatorRights::ReportsShow;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowReportList(parent);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddUnitPowerReport")).toBool())
{
plData.menuText = tr("Add Unit Power Report");
plData.identifier = QLatin1String("repReportUnitPower");
plData.menuIcon = QIcon(QLatin1String("icon:report_unit_power.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::UnitPower);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddParticipantDistanceReport")).toBool())
{
plData.menuText = tr("Add Participant Distance Report");
plData.identifier = QLatin1String("repReportDistance");
plData.menuIcon = QIcon(QLatin1String("icon:report_participant_distance.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::ParticipantDistance);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddNBCReport")).toBool())
{
if (m_enableB || m_enableC || m_enableN)
{
plData.menuText = getAESNbcReportTypeName();
plData.identifier = QLatin1String("repReportNbc");
plData.menuIcon = QIcon(QLatin1String("icon:report_nc_events.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::Nbc);
};
ret.append(plData);
}
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddFiringsReport")).toBool())
{
plData.menuText = tr("Add Firings Report");
plData.identifier = QLatin1String("repReportFire");
plData.menuIcon = QIcon(QLatin1String("icon:report_weapon_firing.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::Firings);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddMineAreaReport")).toBool())
{
plData.menuText = tr("Add Mine Area Report");
plData.identifier = QLatin1String("repReportMine");
plData.menuIcon = QIcon(QLatin1String("icon:report_mine_area.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::MineArea);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddChargeResupplyReport")).toBool())
{
plData.menuText = tr("Add Charge Resupply Report");
plData.identifier = QLatin1String("repReportChargeRes");
plData.menuIcon = QIcon(QLatin1String("icon:report_ammunition_resupply.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::ChargeResupply);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddChargeAdministrationReport")).toBool())
{
plData.menuText = tr("Add Charge Administration Report");
plData.identifier = QLatin1String("repReportChargeAdm");
plData.menuIcon = QIcon(QLatin1String("icon:report_charge_administration.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::ChargeAdministration);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddVehicleRepairReport")).toBool())
{
plData.menuText = tr("Add Vehicle Repair Report");
plData.identifier = QLatin1String("repReportVehicleRepair");
plData.menuIcon = QIcon(QLatin1String("icon:report_vehicle_repair.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::VehicleRepair);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddAirSupportReport")).toBool())
{
plData.menuText = tr("Add Air Support Report");
plData.identifier = QLatin1String("repReportAirSupport");
plData.menuIcon = QIcon(QLatin1String("icon:report_air_support.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::AirSupport);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddBuildingDamageReport")).toBool())
{
plData.menuText = tr("Add Building Damage Report");
plData.identifier = QLatin1String("repReportBuildingDamage");
plData.menuIcon = QIcon(QLatin1String("icon:report_building_damage.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::BuildingDamage);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddExplosiveDeviceReport")).toBool())
{
plData.menuText = tr("Add Explosive Device Report");
plData.identifier = QLatin1String("repReportExplosiveDevice");
plData.menuIcon = QIcon(QLatin1String("icon:report_explosive_devices.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::ExplosiveDevice);
};
ret.append(plData);
}
if (ps->value(QStringLiteral("rep"),
QStringLiteral("enableAddDecontaminationReport")).toBool())
{
plData.menuText = tr("Add Decontamination Report");
plData.identifier = QLatin1String("repReportDecontamination");
plData.menuIcon = QIcon(QLatin1String("icon:report_decontamination.svg"));
plData.operatorRight = OperatorRights::ReportsEdit;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::Decontamination);
};
ret.append(plData);
}
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
QStringLiteral("HasPvSan"));
if (showPvSan)
{
const bool showSanMat = ps->value(QStringLiteral("rep"),QStringLiteral("enableAddSanitationMaterialReport")).toBool();
if (showSanMat)
{
plData.menuText = tr("Add Sanitation Material Report");
plData.identifier = QLatin1String("repReportSanMat");
plData.menuIcon = QIcon(QLatin1String("icon:report_sanitation_material.svg"));
plData.operatorRight = OperatorRights::ReportsEditSan;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::SanitationMaterial);
};
ret.append(plData);
}
const bool showMedevacNineLiner = ps->value(QStringLiteral("rep"),QStringLiteral("enableAddMedevacNineLinerReport")).toBool();
if (showMedevacNineLiner)
{
plData.menuText = tr("Add Medevac Nine Liner Report");
plData.identifier = QLatin1String("repReportMedevacNineLiner");
plData.menuIcon = QIcon(QLatin1String("icon:report_medevac_nine_liner.svg"));
plData.operatorRight = OperatorRights::ReportsEditSan;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::MedevacNineLiner);
};
ret.append(plData);
}
const bool showSan = ps->value(QStringLiteral("rep"),QStringLiteral("enableAddTreatmentReport")).toBool();
if (showSan)
{
plData.menuText = tr("Add Treatment Report");
plData.identifier = QLatin1String("repReportTreatment");
plData.menuIcon = QIcon(QLatin1String("icon:report_treatment2.svg"));
plData.operatorRight = OperatorRights::ReportsEditSan;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::Treatment);
};
ret.append(plData);
/*
plData.menuText = tr("Add Treatment Priority Report");
plData.identifier = QLatin1String("repReportTreatmentPriority");
plData.menuIcon = QIcon(QLatin1String("icon:report_treatment_priority.svg"));
plData.operatorRight = OperatorRights::ReportsEditSan;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::TreatmentPriority);
};
ret.append(plData);
plData.menuText = tr("Add Treatment Chain Report");
plData.identifier = QLatin1String("repReportTreatmentChain");
plData.menuIcon = QIcon(QLatin1String("icon:report_treatment_chain.svg"));
plData.operatorRight = OperatorRights::ReportsEditSan;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::TreatmentChain);
};
ret.append(plData);
plData.menuText = tr("Add Treatment Timeline Report");
plData.identifier = QLatin1String("repReportTreatmentTimeline");
plData.menuIcon = QIcon(QLatin1String("icon:report_treatment_chain.svg"));
plData.operatorRight = OperatorRights::ReportsEditSan;
plData.createWidgetFunc = [this](QWidget * parent)
{
return onShowAddReport(parent, ReportType::TreatmentTimeline);
};
ret.append(plData);
*/
}
}
return ret;
}
//----------------------------------------------------------------------------------------------------
LtsWidgets::LtsDialog *InterfaceImpl::onShowReportList(QWidget *parent)
{
return LtsWidgets::initDialog(new ReportList(menuGroup(), m_session, parent),
m_session);
}
//----------------------------------------------------------------------------------------------------
LtsWidgets::LtsDialog *InterfaceImpl::onShowAddReport(QWidget *parent, const ReportType &reportType)
{
ReportInfo data;
// new report
data.id(0);
data.reportType(reportType);
return LtsWidgets::initDialog(new ReportEdit(m_session, parent),
data, m_session);
}
//------------------------------------------------------------------------------
TopicEditorBase::TopicEditor *InterfaceImpl::createTopicEditor(const TopicEditorBase::TopicData &data)
{
ReportManagement::ReportTopicEditor *editor = new ReportTopicEditor(m_dtc, m_opmDtc, m_ppmDtc, m_ppmGuiCbxIfc);
editor->setTopicData(data);
return editor;
}
//------------------------------------------------------------------------------
InterfaceImpl::TopicReplayInterface::TopicReplayInterface(LtsSession::LtsSession *session,
const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc)
: m_session(session)
, m_dtc(dtc)
, m_previewDialog(nullptr)
, m_previewReport(nullptr)
, m_previewWidget(nullptr)
, m_logger(getLogger(pluginName()))
{
}
//------------------------------------------------------------------------------
InterfaceImpl::TopicReplayInterface::~TopicReplayInterface()
{
if (m_previewDialog)
m_previewDialog->deleteLater();
m_previewDialog = nullptr;
if (m_previewReport)
m_previewReport->deleteLater();
m_previewReport = nullptr;
if (m_previewWidget)
m_previewWidget->deleteLater();
m_previewWidget = nullptr;
}
//------------------------------------------------------------------------------
QWidget *InterfaceImpl::TopicReplayInterface::createWidget()
{
if (!m_previewDialog)
m_previewDialog = new ReportManagement::ReportPreview(m_session, nullptr);
if (!m_previewReport)
m_previewReport = new LtsWidgets::LtsReportDisplayWidget(m_previewDialog);
if (!m_previewWidget)
{
m_previewWidget = new NGL::PDFWidget(nullptr);
m_previewWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding );
m_previewReport->hide();
m_previewDialog->hide();
//QVBoxLayout* mainLayout = new QVBoxLayout(m_previewWidget);
//mainLayout->setMargin(0);
//mainLayout->setSpacing(0);
//QScrollArea* scrollArea = new QScrollArea(m_previewWidget);
// scrollArea->setWidgetResizable(true);
//scrollArea->setWidget(m_previewReport);
// mainLayout->addWidget(scrollArea);
}
return m_previewWidget;
}
//------------------------------------------------------------------------------
bool InterfaceImpl::TopicReplayInterface::playbackInit(const QJsonObject &attributes)
{
ReportManagement::ReportInfo ri;
int reportId = attributes.value(QStringLiteral("ReportId")).toInt();
if (reportId > 0)
ri = m_dtc->reportInfo(reportId);
DEBUG_LOG(m_logger) << "Report Id = " << ri.id();
if (!m_previewDialog)
{
ERROR_LOG(m_logger) << "Widgets1 not available, playback not possible for report id = "<< ri.id();
return false;
}
if ( !m_previewReport)
{
ERROR_LOG(m_logger) << "Widgets2 not available, playback not possible for report id = "<< ri.id();
return false;
}
if (!m_previewWidget)
{
ERROR_LOG(m_logger) << "Widgets3 not available, playback not possible for report id = "<< ri.id();
return false;
}
if (!m_previewDialog->init(ri))
{
ERROR_LOG(m_logger) << "Preview dialog could not be initialized!";
return false;
}
m_previewDialog->getReportDisplay()->exportToFile(QStringLiteral("/tmp/rep.pdf"));
// NGL::PDFWidget *mpdf = new NGL::PDFWidget(m_previewWidget);
//QVBoxLayout *layout = new QVBoxLayout(m_previewWidget);
//layout->addWidget(mpdf);
//mpdf->resize(m_previewWidget->size());
//m_previewWidget->layout()->addWidget(mpdf);
QFile f(QStringLiteral("/tmp/rep.pdf"));
f.open(QIODevice::ReadOnly);
m_previewWidget->setZoomFactor(1.0);
m_previewWidget->setRotation(Poppler::Page::Rotate0);
m_previewWidget->setPage(1);
m_previewWidget->showPDF(f.readAll());
// if (!m_previewWidget)
// {
// ERROR_LOG(m_logger) << "Preview widget not available for fileId = " << fileId;
// return false;
// }
// if (!m_previewWidget->init(fc, pageNo, zoomLevel / 100., rotation, 0 /* TODO: duration ? */, userText))
// {
// ERROR_LOG(m_logger) << "Preview widget cannot be initialized for fileId = " << fileId;
// return false;
// }
return true;
/*
ReportManagement::ReportInfo ri;
int reportId = attributes.value(QStringLiteral("ReportId")).toInt();
if (reportId > 0)
ri = m_dtc->reportInfo(reportId);
DEBUG_LOG(m_logger) << "Report Id = " << ri.id();
if (!m_previewDialog || !m_previewReport || !m_previewWidget)
{
ERROR_LOG(m_logger) << "Widgets not available, playback not possible for report id = "<< ri.id();
return false;
}
if (!m_previewDialog->init(ri))
{
ERROR_LOG(m_logger) << "Preview dialog could not be initialized!";
return false;
}
m_previewDialog->getReportDisplay()->exportToFile(QStringLiteral("/tmp/rep.pdf"));
m_previewReport->setReport(m_previewDialog->getReportDisplay());
m_previewReport->setNewMinimumSize();
m_previewReport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
*/
// return true;
}
//------------------------------------------------------------------------------
bool InterfaceImpl::TopicReplayInterface::exportTopic(const QJsonObject &attributes,
const QString &folderPath,
TopicEditorBase::ExportNotifier *pExportNotifier)
{
const QString &strPathToFile = folderPath;
const int reportId = attributes.value(QStringLiteral("ReportId")).toInt(0);
if (reportId < 1)
{
ERROR_LOG(m_logger) << "No valid report id given";
pExportNotifier->setExportFailed();
return false;
}
const auto filename = attributes.value(QStringLiteral("filename")).toString();
QString strFileName((filename.isEmpty()) ? QStringLiteral("%1.pdf").arg(reportId) : filename);
if (m_previewDialog == nullptr)
m_previewDialog = new ReportManagement::ReportPreview(m_session, nullptr);
ReportManagement::ReportInfo ri = m_dtc->reportInfo(reportId);
if (ri.fileStatus() != ReportManagement::FileStatus::Valid)
{
ERROR_LOG(m_logger) << "Report with id " << reportId << " was deleted";
pExportNotifier->setExportFailed();
return false;
}
if (!m_previewDialog->init(ri))
{
ERROR_LOG(m_logger) << "Could not init preview for report id = " << reportId;
pExportNotifier->setExportFailed();
return false;
}
KDReports::Report* rp = m_previewDialog->getReportDisplay();
if (rp == nullptr)
{
ERROR_LOG(m_logger) << "Could not retrieve KDReport for report id = " << reportId;
pExportNotifier->setExportFailed();
return false;
}
rp->exportToFile(strPathToFile + strFileName);
pExportNotifier->setExportSuccessful(strFileName);
INFO_LOG(m_logger) << "Successfully exported topic for report with id " << reportId;
rp->deleteLater();
return true;
}
} // namespace ReportManagement
@@ -0,0 +1,120 @@
/**
* @RDE_HEADER@
* Gui Plugin for ReportManagement
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-10-05
*/
#pragma once
#include <ReportManagement/logger.h>
#include <ReportManagement/rep_ftc.h>
#include <ReportManagement/rep_dtc.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <Plugins/ReportManagement/rep_data_plugin_interface.h>
#include <Plugins/ReportManagement/rep_gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
#include <Plugins/AreaEffectSimulation/aes_data_plugin_interface.h>
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
#include <Viewer/LtsReportDisplay/lts_report_display_widget.h>
#include <nglwidgets/nglpdfwidget.h>
namespace ReportManagement
{
class ReportPreview;
class ReportModel;
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:rep")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QLatin1String("ReportManagementViewerGuiPlugin"); }
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return partition == IDL::PartitionType::Exercise ||
partition == IDL::PartitionType::Replay;
}
};
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public ForeignGuiInterface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
bool fetchInterfaces() override;
void clearInterfaces() override;
QString menuGroup() const override;
QVector<LtsWidgets::PluginData> getActions() override;
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
// Script Editor Topic Editor:
TopicEditorBase::TopicEditor *createTopicEditor(const TopicEditorBase::TopicData &data) override;
private:
LtsWidgets::LtsDialog *onShowReportList(QWidget *parent);
LtsWidgets::LtsDialog *onShowAddReport(QWidget *parent, const ReportType &reportType);
QString getAESNbcReportTypeName();
std::shared_ptr<ReportManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ReportManagement::Interface::Ftc> m_ftc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> m_ppmGuiCbxIfc;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
bool m_enableB;
bool m_enableC;
bool m_enableN;
// Script Player
class TopicReplayInterface : public TopicReplay::Interface
{
public:
TopicReplayInterface(LtsSession::LtsSession *session,
const std::shared_ptr<ReportManagement::Interface::Dtc> &dtc);
~TopicReplayInterface();
QWidget *createWidget() override;
// Script Playback Controls:
bool playbackInit(const QJsonObject &attributes) override;
bool exportTopic(const QJsonObject &attributes,
const QString &folderPath,
TopicEditorBase::ExportNotifier *pExportNotifier) override;
private:
LtsSession::LtsSession *m_session;
std::shared_ptr<ReportManagement::Interface::Dtc> m_dtc;
ReportManagement::ReportPreview *m_previewDialog;
LtsWidgets::LtsReportDisplayWidget *m_previewReport;
NGL::PDFWidget *m_previewWidget;
// QWidget *m_previewWidget;
NGL::INGLLogger &m_logger;
};
TopicReplay::Interface *createInterface(TopicEditorBase::TopicType) override
{
return new TopicReplayInterface(m_session, m_dtc);
}
};
} // namespace ReportManagement
+31
View File
@@ -0,0 +1,31 @@
/**
* @RDE_HEADER@
* HMI Plugin for Report Management (Interface for access from other Plugins)
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2017
*/
#pragma once
#include <PluginInterfaces/data_plugin_interface.h>
#include <ReportManagement/rep_dtc.h>
#include <ReportManagement/rep_ftc.h>
namespace ReportManagement
{
/**
* @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<ReportManagement::Interface::Dtc> getDtc() = 0;
virtual std::shared_ptr<ReportManagement::Interface::Ftc> getFtc() = 0;
};
} // namespace ReportManagement
+30
View File
@@ -0,0 +1,30 @@
/**
* @RDE_HEADER@
* HMI Plugin for Reports (Interface for access from other Plugins)
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-07-01
*/
#pragma once
#include <LtsWidgets/lts_abstract_table_model.h>
#include <PluginInterfaces/topic_replay_interface.h>
#include <TopicEditorBase/topic_editor_interface.h>
namespace ReportManagement
{
class ReportModel;
class ForeignGuiInterface : public TopicReplay::Factory, public TopicEditorBase::Interface
{
public:
ForeignGuiInterface() = default;
virtual ~ForeignGuiInterface() = default;
static QString pluginName() { return QStringLiteral("RepGuiPlugin"); }
};
} // namespace ReportManagement