Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+230
@@ -0,0 +1,230 @@
|
||||
#include "flm_hq_report_converter.h"
|
||||
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc_types.h>
|
||||
#include <FileManagement/flm_data_plugin_interface.h>
|
||||
|
||||
#include <Symbology/sidc_builder_base.h>
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include <Symbology/symbol_dictionary.h>
|
||||
#include <SymbologyXML/symbol_types.h>
|
||||
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
FlmHqReportConverter::FlmHqReportConverter() : m_logger(getLogger("HQReportConverter"))
|
||||
{
|
||||
connect(this, &FlmHqReportConverter::allRequestsFinished,
|
||||
this, &FlmHqReportConverter::onRequestsFinished);
|
||||
}
|
||||
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession *session, int currentPartyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
m_partyId = currentPartyId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::addHqToPlanIds(const QMap<int, QList<int>> &hqToPlanIds)
|
||||
{
|
||||
for (auto it = hqToPlanIds.constBegin(); it != hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
m_hqToPlanIds[it.key()].append(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::processCollectedHqs()
|
||||
{
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
m_pendingRequests += it.value().size();
|
||||
}
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<int> &reportIds = it.value();
|
||||
// Request file content for each HqReport
|
||||
for (int id : reportIds)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Request File with ID: " << id << " from plan with ID: " << planId;
|
||||
FileManagement::GetFileContentDataRequest request(id);
|
||||
m_flmFtc->getFileContentDataRequest(request, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::createGeometryFromReport(const HqReportData &data)
|
||||
{
|
||||
m_symbolFactory.build(data.art, data, m_geometryModel);
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::checkIfAllFinished()
|
||||
{
|
||||
if (m_pendingRequests <= 0) emit allRequestsFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(
|
||||
const FileManagement::GetFileContentDataReply &reply)
|
||||
{
|
||||
m_pendingRequests--;
|
||||
|
||||
if (reply.errorString().size() > 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got onGetFileContentDataReply error: " << reply.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
int id = static_cast<int>(reply.id());
|
||||
int planId = -1;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Reply File with ID: " << id << " from plan with ID: " << planId;
|
||||
|
||||
INFO_LOG(m_logger) << "Got reply with id " << id << " and errorString " << reply.errorString();
|
||||
|
||||
QByteArray fileContent = QByteArray(reinterpret_cast<const char*>(reply.content().data()), reply.content().size());
|
||||
|
||||
FlmHqReportJsonParser m_parser = FlmHqReportJsonParser();
|
||||
|
||||
HqReportData data = m_parser.parse(fileContent);
|
||||
data.contentFileId = id;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Party: " << m_partyId << " has Color: "<< QColor::fromRgb(QRgb(m_ppmDtc->party(m_partyId).color())).value();
|
||||
|
||||
data.partyColor = QColor::fromRgb(QRgb(m_ppmDtc->party(m_partyId).color()));
|
||||
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
if (it.value().contains(id))
|
||||
{
|
||||
planId = it.key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_convertedHqToPlanIds[planId].append(data);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Content size: " << reply.content().size();
|
||||
|
||||
checkIfAllFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentModify Reply: " << reply.translated();
|
||||
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated()
|
||||
<< ", error: " << reply.error();
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentRemove Reply: " << reply.translated();
|
||||
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated()
|
||||
<< ", error: " << reply.error();
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onRequestsFinished()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ALL REQUESTS FINISHED";
|
||||
|
||||
for (auto it = m_convertedHqToPlanIds.constBegin(); it != m_convertedHqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
int planId = it.key();
|
||||
const QList<HqReportData> &reportDatas = it.value();
|
||||
|
||||
for (auto &reportData : reportDatas)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "createGeometryFromReport :" << reportData.art;
|
||||
createGeometryFromReport(reportData);
|
||||
}
|
||||
|
||||
const FileManagement::FileContent &flc = m_flmDtc->fileContent(planId);
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
|
||||
DEBUG_LOG(m_logger) << "FILE CONTENT: " << flc.name() << " " << flc.folderId();
|
||||
|
||||
data.id(flc.id());
|
||||
data.name(flc.name());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(flc.folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(m_geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
|
||||
m_flmFtc->fileContentModifyRequest(data, this);
|
||||
|
||||
m_geometryModel->clearModel();
|
||||
}
|
||||
}
|
||||
} // namespace FileManagement
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
#include <FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
|
||||
#include "flm_hq_report_json_parser.h"
|
||||
#include "flm_hq_report_symbol_factory.h"
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
class Ftc;
|
||||
} // namespace Interface
|
||||
|
||||
class FlmHqReportConverter : public QObject,
|
||||
public Interface::Ftc::GetFileContentDataReplyHandler,
|
||||
public Interface::Ftc::FileContentModifyReplyHandler,
|
||||
public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int currentPartyId);
|
||||
/**
|
||||
* @brief add hqToPlanIds to m_hqToPlanIds
|
||||
* @param const QMap<int, QList<int>> &hqToPlanIds -> <planId, QList<HqIds>>
|
||||
*/
|
||||
void addHqToPlanIds(const QMap<int, QList<int>> &hqToPlanIds);
|
||||
/**
|
||||
* @brief Iterate and send GetFileContentDataRequest to get File Information HQ
|
||||
*/
|
||||
void processCollectedHqs();
|
||||
/**
|
||||
* @brief create GeometryModel from HQ Report
|
||||
* @param {data} HQ Report Data
|
||||
*/
|
||||
void createGeometryFromReport(const HqReportData &data);
|
||||
|
||||
private:
|
||||
void checkIfAllFinished();
|
||||
|
||||
protected:
|
||||
void onGetFileContentDataReply(const FileManagement::GetFileContentDataReply &reply) override;
|
||||
void onFileContentModifyReply(const Core::FunctionReplyObject &reply) override;
|
||||
void onFileContentRemoveReply(const Core::FunctionReplyObject &reply) override;
|
||||
public slots:
|
||||
void onRequestsFinished();
|
||||
signals:
|
||||
/**
|
||||
* @brief checks if all getFileContentDataRequests are finished
|
||||
*/
|
||||
void allRequestsFinished();
|
||||
|
||||
private:
|
||||
LOGGER_T m_logger;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_flmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
|
||||
SituationMap::GeometryModel *m_geometryModel{nullptr};
|
||||
QList<SituationMap::GeometryModel::Node> m_planNodes;
|
||||
SymbolFactory m_symbolFactory;
|
||||
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
|
||||
QMap<int, QList<int>> m_hqToPlanIds; /// Map<planIds, QList<HQMessageId>>
|
||||
QMap<int, int> m_hqToPlanIdsLookup; /// Map<planIds, HQMessageId> for Lookup
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds; /// Map<planIds, QList<convertedHqMessage>>
|
||||
}; // class FlmHqReportConverter
|
||||
} // namespace FileManagement
|
||||
@@ -0,0 +1,387 @@
|
||||
#include "flm_hq_report_edit.h"
|
||||
#include "flm_hq_report_model.h"
|
||||
#include "ui_flm_hq_report_edit.h"
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include <SituationMap/GeometryModel/geometry_model.h>
|
||||
#include <SituationMap/GeometryModel/geometry_model_factory.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
HQReportEdit::HQReportEdit(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::HQReportEdit)
|
||||
, m_logger(getLogger("HQReportEdit"))
|
||||
, m_menuGroup(menuGroup)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("New Plan"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &HQReportEdit::onCreateNewPlanClicked);
|
||||
|
||||
connect(m_ui->pbShift, &QPushButton::clicked, this, &HQReportEdit::onShiftClicked);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-HQReport"));
|
||||
}
|
||||
|
||||
HQReportEdit::~HQReportEdit() { delete m_ui; }
|
||||
|
||||
bool HQReportEdit::init(LtsSession::LtsSession *session, int partyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_session = session;
|
||||
|
||||
std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> partyCboInterface;
|
||||
|
||||
if (!m_session->getForeignGuiInterface<ParticipantManagement::ForeignGuiComboboxInterface>(partyCboInterface))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get Party Combobox Interface.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!partyCboInterface->fillPartyComboBox(m_ui->cboParties) || m_ui->cboParties->count() == 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not fill Parties.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// init models
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
|
||||
FlmHQReportModel *planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
FlmHQReportModel *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
|
||||
delete hqReportModel;
|
||||
hqReportModel = nullptr;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
// configure listViewPlan
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
// configure listViewMessage
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// init models
|
||||
qDeleteAll(m_hqModels);
|
||||
m_hqModels.clear();
|
||||
|
||||
qDeleteAll(m_planModels);
|
||||
m_planModels.clear();
|
||||
|
||||
for (int index = 0; index < m_ui->cboParties->count(); ++index)
|
||||
{
|
||||
const int partyId = m_ui->cboParties->itemData(index).toInt();
|
||||
createModels(partyId);
|
||||
}
|
||||
|
||||
// configure listViewPlan
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
// configure listViewMessage
|
||||
m_ui->listViewMessage->setDragDropMode(QAbstractItemView::DragOnly);
|
||||
m_ui->listViewMessage->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewMessage->setDropIndicatorShown(true);
|
||||
|
||||
onPartyChanged();
|
||||
|
||||
connect(m_ui->cboParties, qOverload<int>(&QComboBox::currentIndexChanged), this, &HQReportEdit::onPartyChanged);
|
||||
|
||||
int partyIndex = m_ui->cboParties->findData(partyId); // in case of notification: onPartyChanged() is called when index changes
|
||||
m_ui->cboParties->setCurrentIndex(partyIndex < 0 ? 0 : partyIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::createModels(const int partyId)
|
||||
{
|
||||
const int partyFolderId = m_flmDtc->getPartyFolderId(m_session->exerciseId(), partyId);
|
||||
if (partyFolderId == 0)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No partyFolderId found for partyId " << partyId;
|
||||
return;
|
||||
}
|
||||
|
||||
const int hqReportFolderId = m_flmDtc->findFolder(partyFolderId, QStringLiteral("Messages"));
|
||||
|
||||
auto *planModel = new FlmHQReportModel(m_ui->listViewPlan);
|
||||
if (!planModel->init(m_session, partyFolderId, FileType::inner_enum::TacticalPlan))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
return;
|
||||
}
|
||||
|
||||
auto *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
if (!hqReportModel->init(m_session, hqReportFolderId, FileType::inner_enum::AdlerJson))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init hqReportModel for partyId " << partyId;
|
||||
delete planModel;
|
||||
delete hqReportModel;
|
||||
return;
|
||||
}
|
||||
|
||||
connect(planModel, &FlmHQReportModel::dataAddedOrRemoved, this, &HQReportEdit::slotChangesMade);
|
||||
|
||||
m_planModels.insert(partyId, planModel);
|
||||
m_hqModels.insert(partyId, hqReportModel);
|
||||
}
|
||||
|
||||
bool HQReportEdit::apply()
|
||||
{
|
||||
QMap<int, QList<int>> allHqToPlanIds;
|
||||
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlanIds = it.value()->getHQToPlan(); // <planId, hq-message ids>
|
||||
|
||||
for (auto planId : hqToPlanIds.keys())
|
||||
{
|
||||
allHqToPlanIds[planId].append(hqToPlanIds[planId]);
|
||||
|
||||
it.value()->clearMovedData();
|
||||
}
|
||||
}
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
FlmHqReportConverter *hqRepConv = new FlmHqReportConverter();
|
||||
|
||||
if (hqRepConv->init(m_session, currentPartyId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add HQ to Converter";
|
||||
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::retranslate() { translate(m_ui, tr("HQ Report")); }
|
||||
|
||||
void HQReportEdit::onPartyChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
|
||||
if (!m_planModels.contains(currentPartyId) || !m_hqModels.contains(currentPartyId))
|
||||
{
|
||||
INFO_LOG(m_logger) << "Models for party" << currentPartyId << "not found. Attempting to create...";
|
||||
createModels(currentPartyId);
|
||||
}
|
||||
|
||||
QAbstractItemModel *hqModel = m_hqModels.value(currentPartyId, nullptr);
|
||||
QAbstractItemModel *planModel = m_planModels.value(currentPartyId, nullptr);
|
||||
|
||||
if (m_ui->listViewMessage->selectionModel())
|
||||
{
|
||||
m_ui->listViewMessage->selectionModel()->disconnect(this);
|
||||
}
|
||||
if (m_ui->listViewPlan->selectionModel())
|
||||
{
|
||||
m_ui->listViewPlan->selectionModel()->disconnect(this);
|
||||
}
|
||||
|
||||
m_ui->listViewMessage->setModel(hqModel);
|
||||
m_ui->listViewPlan->setModel(planModel);
|
||||
|
||||
if (hqModel && planModel)
|
||||
{
|
||||
connect(m_ui->listViewMessage->selectionModel(), &QItemSelectionModel::selectionChanged, this, &HQReportEdit::onSelectionChanged);
|
||||
connect(m_ui->listViewPlan->selectionModel(), &QItemSelectionModel::selectionChanged, this, &HQReportEdit::onSelectionChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to switch to party" << currentPartyId << ": Models still missing.";
|
||||
}
|
||||
}
|
||||
void HQReportEdit::onCreateNewPlanClicked()
|
||||
{
|
||||
bool ok = false;
|
||||
QString planName = QInputDialog::getText(this, tr("Enter Plan name"), tr("Name:"), QLineEdit::Normal, QString(), &ok);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No name for new plan entered.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FlmHQReportModel *planModel = static_cast<FlmHQReportModel *>(m_ui->listViewPlan->model());
|
||||
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SituationMap::GeometryModel *geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
|
||||
data.name(planName.toStdString());
|
||||
data.isTemplate(false);
|
||||
data.isHidden(false);
|
||||
data.folderId(planModel->folderId());
|
||||
data.fileStatus(FileManagement::FileStatus::Valid);
|
||||
data.fileCategory(FileManagement::FileCategory::Exercise);
|
||||
data.fileType(FileManagement::FileType::TacticalPlan);
|
||||
data.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
data.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
data.content(LtsUtils::convert<std::vector<uint8_t>>(geometryModel->toByteArray()));
|
||||
data.exerciseId(m_session->exerciseId());
|
||||
|
||||
m_flmFtc->fileContentModifyRequest(data,
|
||||
[this](const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
if (reply.error())
|
||||
{
|
||||
const QString errorMessage = tr("Could not save plan: %1").arg(QString::fromStdString(reply.str()));
|
||||
|
||||
ERROR_LOG(m_logger) << errorMessage;
|
||||
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection &, const QItemSelection &)
|
||||
{
|
||||
m_ui->pbShift->setEnabled(m_ui->listViewMessage->selectionModel()->hasSelection() && m_ui->listViewPlan->selectionModel()->hasSelection());
|
||||
}
|
||||
|
||||
void HQReportEdit::onShiftClicked()
|
||||
{
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
|
||||
FlmHQReportModel *messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel *planModel = m_planModels.value(currentPartyId);
|
||||
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
|
||||
QMimeData *mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
}
|
||||
|
||||
} // namespace FileManagement
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* FileManagement - HQ Meldung dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flm_hq_report_converter.h"
|
||||
#include <FileManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
class QListView;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class HQReportEdit;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
class Ftc;
|
||||
} // namespace Interface
|
||||
|
||||
class FlmHQReportModel;
|
||||
|
||||
class HQReportEdit : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HQReportEdit(const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~HQReportEdit();
|
||||
bool init(LtsSession::LtsSession *session, int partyId = -1);
|
||||
void createModels(const int partyId);
|
||||
|
||||
bool apply() override;
|
||||
void retranslate() override;
|
||||
private Q_SLOTS:
|
||||
void onPartyChanged(int index = 0);
|
||||
void onCreateNewPlanClicked();
|
||||
void onSelectionChanged(const QItemSelection &, const QItemSelection &);
|
||||
void onShiftClicked();
|
||||
|
||||
private:
|
||||
Ui::HQReportEdit *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
QString m_menuGroup;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
QHash<int, FlmHQReportModel *> m_hqModels;
|
||||
QHash<int, FlmHQReportModel *> m_planModels;
|
||||
std::shared_ptr<Interface::Dtc> m_flmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_flmFtc;
|
||||
};
|
||||
} // namespace FileManagement
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HQReportEdit</class>
|
||||
<widget class="QWidget" name="HQReportEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>536</width>
|
||||
<height>332</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="2">
|
||||
<widget class="QListView" name="listViewPlan"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="lblPlans">
|
||||
<property name="text">
|
||||
<string>Plans</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblMessages">
|
||||
<property name="text">
|
||||
<string>Messages</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QListView" name="listViewMessage"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cboParties">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="pbShift">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>>></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
#include "flm_hq_report_json_parser.h"
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
FlmHqReportJsonParser::FlmHqReportJsonParser() : m_logger(getLogger("HQReportParser")) {}
|
||||
|
||||
HqReportData FlmHqReportJsonParser::parse(const QByteArray &data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "START PARSING";
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||
QJsonObject obj = doc.object();
|
||||
HqReportData report;
|
||||
|
||||
report.art = obj[QStringLiteral("art")].toString();
|
||||
report.name = obj[QStringLiteral("name")].toString();
|
||||
|
||||
if ( obj.contains(QStringLiteral("meldungsnummer")))
|
||||
report.number = obj[QStringLiteral("meldungsnummer")].toInt();
|
||||
|
||||
if ((obj.contains(QStringLiteral("bis"))) &&
|
||||
(obj.contains((QStringLiteral("ab")))))
|
||||
{
|
||||
report.bis = parseHqReportTime(obj[QStringLiteral("bis")].toObject());
|
||||
report.ab = parseHqReportTime(obj[QStringLiteral("ab")].toObject());
|
||||
}
|
||||
|
||||
if ((obj.contains(QStringLiteral("koordinaten"))) &&
|
||||
(obj[QStringLiteral("koordinaten")].isArray()))
|
||||
{
|
||||
QJsonArray coordsArray = obj[QStringLiteral("koordinaten")].toArray();
|
||||
|
||||
for (const QJsonValue &value : coordsArray)
|
||||
{
|
||||
QPointF coord;
|
||||
|
||||
QJsonObject coordsObj = value.toObject();
|
||||
|
||||
coord.setX(coordsObj[QStringLiteral("longitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
coord.setY(coordsObj[QStringLiteral("latitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
|
||||
report.koordinaten.push_back(coord);
|
||||
}
|
||||
}
|
||||
|
||||
if ((obj.contains(QStringLiteral("mittelpunkt"))) &&
|
||||
(obj[QStringLiteral("mittelpunkt")].isObject()))
|
||||
{
|
||||
QPointF center;
|
||||
|
||||
QJsonObject coordsObj = obj[QStringLiteral("mittelpunkt")].toObject();
|
||||
|
||||
center.setX(coordsObj[QStringLiteral("longitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
center.setY(coordsObj[QStringLiteral("latitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
|
||||
report.mittelpunkt = center;
|
||||
}
|
||||
|
||||
if (obj.contains(QStringLiteral("radius"))) report.radius = obj[QStringLiteral("radius")].toInt();
|
||||
|
||||
if (obj.contains(QStringLiteral("linkerNachbar")))
|
||||
report.linkerNachbar = obj[QStringLiteral("linkerNachbar")].toString();
|
||||
|
||||
if (obj.contains(QStringLiteral("rechterNachbar")))
|
||||
report.rechterNachbar = obj[QStringLiteral("rechterNachbar")].toString();
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
QString FlmHqReportJsonParser::parseHqReportTime(const QJsonObject &obj)
|
||||
{
|
||||
const int year = obj[QStringLiteral("jahr")].toInt();
|
||||
const int minutes = obj[QStringLiteral("minuten")].toInt();
|
||||
const int month = obj[QStringLiteral("monat")].toInt();
|
||||
const int seconds = obj[QStringLiteral("sekunden")].toInt();
|
||||
const int day = obj[QStringLiteral("tag")].toInt();
|
||||
const int hour = obj[QStringLiteral("stunden")].toInt();
|
||||
|
||||
const QDate date(year, month, day);
|
||||
const QTime time(hour, minutes, seconds);
|
||||
const QDateTime dt(date, time);
|
||||
|
||||
return dt.toString(QStringLiteral("dd.MM.yyyy HH:mm:ss"));
|
||||
}
|
||||
|
||||
} // namespace FileManagement
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc_types.h>
|
||||
#include <FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
using namespace SituationMap;
|
||||
|
||||
struct HqCoordinates
|
||||
{
|
||||
double latitude;
|
||||
double longitude;
|
||||
};
|
||||
struct HqReportData
|
||||
{
|
||||
int contentFileId;
|
||||
QColor partyColor;
|
||||
int maxGipfel{-1};
|
||||
int radius{-1};
|
||||
QString ab;
|
||||
QString art;
|
||||
QString bis;
|
||||
QString name;
|
||||
int number;
|
||||
QString truppenteil;
|
||||
QString linkerNachbar;
|
||||
QString rechterNachbar;
|
||||
QVector<QPointF> koordinaten;
|
||||
QPointF mittelpunkt;
|
||||
};
|
||||
|
||||
class FlmHqReportJsonParser
|
||||
{
|
||||
public:
|
||||
FlmHqReportJsonParser();
|
||||
/**
|
||||
* @brief parses HQ Report to JSON
|
||||
* @param {data} HQ Report Data as QByteArray
|
||||
*/
|
||||
HqReportData parse(const QByteArray &data);
|
||||
/**
|
||||
* @brief create GeometryModel from HQ Report
|
||||
* @param {obj} Time Data as JSON from HQ Report
|
||||
*/
|
||||
QString parseHqReportTime(const QJsonObject &obj);
|
||||
|
||||
private:
|
||||
LOGGER_T m_logger;
|
||||
}; // class FlmHqReportJsonParser
|
||||
} // namespace FileManagement
|
||||
@@ -0,0 +1,294 @@
|
||||
#include "flm_hq_report_model.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
FlmHQReportModel::FlmHQReportModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_logger(getLogger("HQReportModel"))
|
||||
{
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession *session, int contentFolderId, const FileType &fileType)
|
||||
{
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->waitForHistoricalDataFileContent(3000);
|
||||
m_flmDtc->fileContents([this](const FileContent &content){onFileContentChanged(content, DataModification::eAdded);});
|
||||
|
||||
connect(m_flmDtc.get(), &Interface::Dtc::fileContentChanged, this, &FlmHQReportModel::onFileContentChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int FlmHQReportModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return m_data.count();
|
||||
}
|
||||
|
||||
QVariant FlmHQReportModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return createText(index.row());
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDropActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDragActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
QStringList FlmHQReportModel::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
if (parent.isValid() || row < 0 || row >= m_data.size() || (row + count) > m_data.size())
|
||||
return false;
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QMimeData *FlmHQReportModel::mimeData(const QList<QModelIndex> &indexes) const
|
||||
{
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
for (const QModelIndex &index : indexes)
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
HQData md = m_data.at(index.row());
|
||||
stream << md.id << md.name;// Serialize your custom metadata to QByteArray
|
||||
}
|
||||
}
|
||||
mimeData->setData(mimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction)
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData md;
|
||||
|
||||
stream >> md.id >> md.name;
|
||||
|
||||
addMovedData(parent.row(), md);
|
||||
}
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (!parent.isValid() ||
|
||||
!data->hasFormat(mimeType) ||
|
||||
action != Qt::CopyAction ||
|
||||
parent.row() < 0 ||
|
||||
parent.row() >= m_data.size())
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(mimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
const HQData ¤tData = m_data.at(parent.row());
|
||||
|
||||
if (!m_movedData.contains(currentData.id))
|
||||
return true;
|
||||
|
||||
const QList<HQData> &movedDataListForCurrentData = m_movedData.value(currentData.id);
|
||||
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
HQData movedData;
|
||||
|
||||
stream >> movedData.id >> movedData.name;
|
||||
|
||||
if (movedDataListForCurrentData.contains(movedData)) // we do not allow double entries
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addHQReportData(const HQData &data)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_data.append(data);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void FlmHQReportModel::deleteHQReportData(const HQData &data)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
endInsertRows();
|
||||
|
||||
const int zeile = m_data.indexOf(data);
|
||||
|
||||
if (zeile == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(), zeile, zeile);
|
||||
m_data.removeAt(zeile);
|
||||
endRemoveRows();
|
||||
return;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::onFileContentChanged(const FileContent &content, DataModification modType)
|
||||
{
|
||||
HQData data;
|
||||
data.id = content.id();
|
||||
data.name = QString::fromStdString(content.name());
|
||||
if (content.folderId() != m_contentFolderId || content.fileType() != m_fileType)
|
||||
return;
|
||||
|
||||
if (content.fileStatus() == FileStatus::Deleted) {
|
||||
if (modType == DataModification::eModified || modType == DataModification::eAdded) {
|
||||
deleteHQReportData(data);
|
||||
}
|
||||
} else if (modType == DataModification::eAdded) {
|
||||
addHQReportData(data);
|
||||
}
|
||||
}
|
||||
|
||||
int FlmHQReportModel::folderId() const
|
||||
{
|
||||
return m_contentFolderId;
|
||||
}
|
||||
|
||||
QMap<int, QList<int>> FlmHQReportModel::getHQToPlan() const
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlan;
|
||||
|
||||
for (auto it = m_movedData.constBegin(); it != m_movedData.constEnd(); ++it)
|
||||
{
|
||||
const QList<HQData> &movedData = it.value();
|
||||
QList<int> hqIds;
|
||||
|
||||
hqIds.reserve(movedData.size());
|
||||
|
||||
for (const HQData ¤tData : movedData)
|
||||
hqIds.append(currentData.id);
|
||||
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
}
|
||||
|
||||
return hqToPlan;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::clearMovedData()
|
||||
{
|
||||
m_movedData.clear();
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
}
|
||||
|
||||
QString FlmHQReportModel::createText(int dataIndex) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " dataIndex: " << dataIndex;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return QString();
|
||||
|
||||
const HQData &data = m_data.at(dataIndex);
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No moved data for " << data.name;
|
||||
return data.name;
|
||||
}
|
||||
|
||||
const QList<HQData> &movedData = m_movedData.value(data.id);
|
||||
QStringList movedDataNames;
|
||||
|
||||
movedDataNames.reserve(movedData.size());
|
||||
|
||||
for (const HQData ¤tMovedData : movedData)
|
||||
movedDataNames.append(currentMovedData.name);
|
||||
|
||||
return QString(QStringLiteral("%1 (%2)")).arg(data.name).arg(movedDataNames.join(QLatin1Char(',')));
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addMovedData(int dataIndex, const HQData &movedData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " dataIndex: " << dataIndex << ", movedData.id: " << movedData.id << ", movedData.name: " << movedData.name;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
|
||||
const HQData &data = m_data.at(dataIndex);
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
|
||||
m_movedData[data.id].append(movedData);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QStandardItemModel>
|
||||
#include <QList>
|
||||
#include <QMimeData>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
|
||||
#include <FileManagement/flm_enums.hpp>
|
||||
#include <FileManagement/logger.h>
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class FileContent;
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
struct HQData
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
|
||||
bool operator==(const HQData &other) const
|
||||
{
|
||||
return id == other.id &&
|
||||
name == other.name;
|
||||
}
|
||||
};
|
||||
|
||||
class FlmHQReportModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FlmHQReportModel(QObject *parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int contentFolderId, const FileManagement::FileType &fileType);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::DropActions supportedDragActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
QMimeData *mimeData(const QList<QModelIndex> &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
|
||||
void addHQReportData(const HQData &data);
|
||||
void deleteHQReportData(const HQData &data);
|
||||
|
||||
int folderId() const;
|
||||
|
||||
QMap<int, QList<int>> getHQToPlan() const;
|
||||
void clearMovedData();
|
||||
|
||||
private:
|
||||
QString createText(int dataIndex) const;
|
||||
void addMovedData(int dataIndex, const HQData &movedData);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFileContentChanged(const FileContent &content, DataModification modType);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dataAddedOrRemoved();
|
||||
|
||||
private:
|
||||
QList<HQData> m_data;
|
||||
QMap<int, QList<HQData>> m_movedData;
|
||||
const QString mimeType = QStringLiteral("application/x-custom-hqdata");
|
||||
int m_contentFolderId {-1};
|
||||
FileManagement::FileType m_fileType;
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}//namespace FileManagement
|
||||
|
||||
Q_DECLARE_METATYPE(FileManagement::HQData)
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#include "flm_hq_report_symbol_concrete_creators.h"
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <ParticipantManagement/ppm_ftc_types.h>
|
||||
namespace FileManagement {
|
||||
|
||||
void LineCreator::create(const HqReportData &data, SituationMap::GeometryModel *model) const
|
||||
{
|
||||
QList<QPair<GeometryModel::Attribute, QVariant>> symbolAttributes;
|
||||
const int userData = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
symbolAttributes.reserve(2);
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC, QVariant(SymbolCreator::convertBaseSymbolToSidic(m_baseSymbol))));
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC_Color, QVariant(data.partyColor)));
|
||||
|
||||
const SituationMap::GeometryModel::Node &node = model->addPrimitive(GeometryModel::PrimitiveType::DictionarySymbol,
|
||||
data.koordinaten.toList(),
|
||||
symbolAttributes,
|
||||
userData);
|
||||
|
||||
QString text = QStringLiteral("Name: %1 Gültig ab: %2 Gültig bis: %3 ").arg(data.name)
|
||||
.arg(data.ab)
|
||||
.arg(data.bis);
|
||||
|
||||
model->setNodeDisplayName(node, text);
|
||||
|
||||
symbolAttributes.clear();
|
||||
}
|
||||
|
||||
void AreaCreator::create(const HqReportData &data, SituationMap::GeometryModel *model) const
|
||||
{
|
||||
QList<QPair<GeometryModel::Attribute, QVariant>> symbolAttributes;
|
||||
const int userData = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
symbolAttributes.reserve(2);
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC, QVariant(SymbolCreator::convertBaseSymbolToSidic(m_baseSymbol))));
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC_Color, QVariant(data.partyColor)));
|
||||
|
||||
const SituationMap::GeometryModel::Node &node = model->addPrimitive(GeometryModel::PrimitiveType::DictionarySymbol,
|
||||
data.koordinaten.toList(),
|
||||
symbolAttributes,
|
||||
userData);
|
||||
|
||||
QString text = QStringLiteral("Name: %1 Gültig ab: %2 Gültig bis: %3 ").arg(data.art + QStringLiteral(" ") + data.name)
|
||||
.arg(data.ab)
|
||||
.arg(data.bis);
|
||||
|
||||
model->setNodeDisplayName(node, text);
|
||||
|
||||
symbolAttributes.clear();
|
||||
}
|
||||
|
||||
void PointCreator::create(const HqReportData &data, SituationMap::GeometryModel *model) const
|
||||
{
|
||||
QList<QPair<GeometryModel::Attribute, QVariant>> symbolAttributes;
|
||||
const int userData = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
symbolAttributes.reserve(2);
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC, QVariant(SymbolCreator::convertBaseSymbolToSidic(m_baseSymbol))));
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC_Color, QVariant(data.partyColor)));
|
||||
|
||||
const SituationMap::GeometryModel::Node &node = model->addPrimitive(GeometryModel::PrimitiveType::DictionarySymbol,
|
||||
data.koordinaten.toList(),
|
||||
symbolAttributes,
|
||||
userData);
|
||||
|
||||
QString text = QStringLiteral("Name: %1 Gültig ab: %2 Gültig bis: %3").arg(data.name)
|
||||
.arg(data.ab)
|
||||
.arg(data.bis);
|
||||
|
||||
model->setNodeDisplayName(node, text);
|
||||
|
||||
symbolAttributes.clear();
|
||||
}
|
||||
|
||||
void AreaCircularCreator::create(const HqReportData &data, SituationMap::GeometryModel *model) const
|
||||
{
|
||||
QList<QPair<GeometryModel::Attribute, QVariant>> symbolAttributes;
|
||||
const int userData = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
|
||||
symbolAttributes.reserve(2);
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC, QVariant(SymbolCreator::convertBaseSymbolToSidic(m_baseSymbol))));
|
||||
symbolAttributes.append(QPair<GeometryModel::Attribute, QVariant>(GeometryModel::Attribute::SIDC_Color, QVariant(data.partyColor)));
|
||||
|
||||
const SituationMap::GeometryModel::Node &node = model->addPrimitive(GeometryModel::PrimitiveType::DictionarySymbol,
|
||||
{data.mittelpunkt},
|
||||
symbolAttributes,
|
||||
userData);
|
||||
|
||||
QString text = QStringLiteral("Name: %1 Gültig ab: %2 Gültig bis: %3 Radius: %4").arg(data.name)
|
||||
.arg(data.ab)
|
||||
.arg(data.bis)
|
||||
.arg(data.radius);
|
||||
|
||||
model->setNodeDisplayName(node, text);
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <Utils/polygons.h>
|
||||
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include <Symbology/sidc_builder_base.h>
|
||||
|
||||
#include "flm_hq_report_symbol_creator.h"
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class LineCreator : public SymbolCreator
|
||||
{
|
||||
public:
|
||||
LineCreator(const QString &baseSymbol) : m_baseSymbol(baseSymbol) {}
|
||||
|
||||
void create(const HqReportData &data, SituationMap::GeometryModel *model) const override;
|
||||
private:
|
||||
QString m_baseSymbol;
|
||||
|
||||
}; // class LineCreator
|
||||
|
||||
class AreaCreator : public SymbolCreator
|
||||
{
|
||||
public:
|
||||
AreaCreator(const QString &baseSymbol) : m_baseSymbol(baseSymbol) {}
|
||||
|
||||
void create(const HqReportData &data, SituationMap::GeometryModel *model) const override;
|
||||
private:
|
||||
QString m_baseSymbol;
|
||||
}; // class AreaCreator
|
||||
|
||||
class AreaCircularCreator : public SymbolCreator
|
||||
{
|
||||
public:
|
||||
AreaCircularCreator(const QString &baseSymbol) : m_baseSymbol(baseSymbol) {}
|
||||
|
||||
void create(const HqReportData &data, SituationMap::GeometryModel *model) const override;
|
||||
private:
|
||||
QString m_baseSymbol;
|
||||
}; // class AreaCircular
|
||||
|
||||
class PointCreator : public SymbolCreator
|
||||
{
|
||||
public:
|
||||
PointCreator(const QString &baseSymbol) : m_baseSymbol(baseSymbol) {}
|
||||
|
||||
void create(const HqReportData &data, SituationMap::GeometryModel *model) const override;
|
||||
private:
|
||||
QString m_baseSymbol;
|
||||
}; // class PointCreator
|
||||
} // namespace FileManagement
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#include "flm_hq_report_symbol_creator.h"
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
QString SymbolCreator::convertBaseSymbolToSidic(const QString &baseSymbolCode)
|
||||
{
|
||||
QString encodedBaseCode = AdvancedSymbology::SidcCodec::encodeBaseSymbolCode(AdvancedSymbology::SymbologyType::APP6D, baseSymbolCode);
|
||||
const QString sidic = AdvancedSymbology::SidcBuilderBase::baseSymbolCodeToSidc(encodedBaseCode);
|
||||
|
||||
return sidic;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "flm_hq_report_json_parser.h"
|
||||
|
||||
#include <Symbology/sidc_codec.h>
|
||||
#include <Symbology/sidc_builder_base.h>
|
||||
|
||||
#include <Utils/polygons.h>
|
||||
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class SymbolCreator
|
||||
{
|
||||
public:
|
||||
virtual ~SymbolCreator() = default;
|
||||
virtual void create(const HqReportData &data, SituationMap::GeometryModel *model) const = 0;
|
||||
|
||||
static QString convertBaseSymbolToSidic(const QString &baseSymbolCode);
|
||||
}; // class SymbolCreator
|
||||
} // namespace FileManagement
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#include "flm_hq_report_symbol_factory.h"
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
SymbolFactory::SymbolFactory()
|
||||
{
|
||||
// Lines
|
||||
m_normalRegistry.insert(QStringLiteral("AL"), std::make_shared<LineCreator>(QStringLiteral("25141000")));
|
||||
m_normalRegistry.insert(QStringLiteral("ANL"), std::make_shared<LineCreator>(QStringLiteral("25141100")));
|
||||
m_normalRegistry.insert(QStringLiteral("CFL"), std::make_shared<LineCreator>(QStringLiteral("25260200")));
|
||||
m_normalRegistry.insert(QStringLiteral("NFL"), std::make_shared<LineCreator>(QStringLiteral("25240301")));
|
||||
m_normalRegistry.insert(QStringLiteral("FSSL"), std::make_shared<LineCreator>(QStringLiteral("25260200")));
|
||||
m_normalRegistry.insert(QStringLiteral("FSCL"), std::make_shared<LineCreator>(QStringLiteral("25260100")));
|
||||
m_normalRegistry.insert(QStringLiteral("RFL"), std::make_shared<LineCreator>(QStringLiteral("25260500")));
|
||||
m_normalRegistry.insert(QStringLiteral("VZL"), std::make_shared<LineCreator>(QStringLiteral("25140300")));
|
||||
m_normalRegistry.insert(QStringLiteral("PL"), std::make_shared<LineCreator>(QStringLiteral("25140300")));
|
||||
// Points
|
||||
m_normalRegistry.insert(QStringLiteral("RP"), std::make_shared<PointCreator>(QStringLiteral("25131500")));
|
||||
m_normalRegistry.insert(QStringLiteral("SP"), std::make_shared<PointCreator>(QStringLiteral("25131600")));
|
||||
m_normalRegistry.insert(QStringLiteral("PP"), std::make_shared<PointCreator>(QStringLiteral("25131200")));
|
||||
m_normalRegistry.insert(QStringLiteral("CP"), std::make_shared<PointCreator>(QStringLiteral("25130300")));
|
||||
// Area
|
||||
m_normalRegistry.insert(QStringLiteral("AO"), std::make_shared<AreaCreator>(QStringLiteral("25120100")));
|
||||
m_normalRegistry.insert(QStringLiteral("ATRZ"), std::make_shared<AreaCreator>(QStringLiteral("25150103")));
|
||||
m_normalRegistry.insert(QStringLiteral("AMA"), std::make_shared<AreaCreator>(QStringLiteral("25150103")));
|
||||
m_normalRegistry.insert(QStringLiteral("ARA"), std::make_shared<AreaCreator>(QStringLiteral("25120100")));
|
||||
m_normalRegistry.insert(QStringLiteral("BAA"), std::make_shared<AreaCreator>(QStringLiteral("25271700")));
|
||||
m_normalRegistry.insert(QStringLiteral("BCA"), std::make_shared<AreaCreator>(QStringLiteral("25271700")));
|
||||
m_normalRegistry.insert(QStringLiteral("BDRY"), std::make_shared<AreaCreator>(QStringLiteral("25110100")));
|
||||
m_normalRegistry.insert(QStringLiteral("BHA"), std::make_shared<AreaCreator>(QStringLiteral("25271700")));
|
||||
m_normalRegistry.insert(QStringLiteral("CAA"), std::make_shared<AreaCreator>(QStringLiteral("25271800")));
|
||||
m_normalRegistry.insert(QStringLiteral("CFZ"), std::make_shared<AreaCreator>(QStringLiteral("25241401")));
|
||||
m_normalRegistry.insert(QStringLiteral("CHA"), std::make_shared<AreaCreator>(QStringLiteral("25271800")));
|
||||
m_normalRegistry.insert(QStringLiteral("CZ"), std::make_shared<AreaCreator>(QStringLiteral("25241301")));
|
||||
m_normalRegistry.insert(QStringLiteral("EA"), std::make_shared<AreaCreator>(QStringLiteral("25151300")));
|
||||
m_normalRegistry.insert(QStringLiteral("EZ"), std::make_shared<AreaCreator>(QStringLiteral("25150103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("FLET"), std::make_shared<AreaCreator>(QStringLiteral("25 140103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("FLOT"), std::make_shared<AreaCreator>(QStringLiteral("25140103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("FOAZI"), std::make_shared<AreaCreator>(QStringLiteral("25271900")));
|
||||
m_normalRegistry.insert(QStringLiteral("FOAZII"), std::make_shared<AreaCreator>(QStringLiteral("25271900")));
|
||||
m_normalRegistry.insert(QStringLiteral("IZ"), std::make_shared<AreaCreator>(QStringLiteral("25150103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("LZ"), std::make_shared<AreaCreator>(QStringLiteral("25150103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("MA"), std::make_shared<AreaCreator>(QStringLiteral("25270800")));
|
||||
m_normalRegistry.insert(QStringLiteral("NAI"), std::make_shared<AreaCreator>(QStringLiteral("25120200")));
|
||||
m_normalRegistry.insert(QStringLiteral("OA"), std::make_shared<AreaCreator>(QStringLiteral("25151700")));
|
||||
m_normalRegistry.insert(QStringLiteral("ROTACA"), std::make_shared<AreaCreator>(QStringLiteral("25150103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("ROTAHA"), std::make_shared<AreaCreator>(QStringLiteral("25150103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("ROTARA"), std::make_shared<AreaCreator>(QStringLiteral("25150103"))); // E01562-388
|
||||
m_normalRegistry.insert(QStringLiteral("ROUTE"), std::make_shared<AreaCreator>(QStringLiteral("25151700")));
|
||||
m_normalRegistry.insert(QStringLiteral("TAI"), std::make_shared<AreaCreator>(QStringLiteral("25120300")));
|
||||
m_normalRegistry.insert(QStringLiteral("FEBA"), std::make_shared<AreaCreator>(QStringLiteral("25140400")));
|
||||
m_normalRegistry.insert(QStringLiteral("MFLD"), std::make_shared<AreaCreator>(QStringLiteral("25270701")));
|
||||
m_normalRegistry.insert(QStringLiteral("ZOF"), std::make_shared<AreaCreator>(QStringLiteral("25120300")));
|
||||
m_normalRegistry.insert(QStringLiteral("TAREA"), std::make_shared<AreaCreator>(QStringLiteral("25120300")));
|
||||
m_normalRegistry.insert(QStringLiteral("FAA"), std::make_shared<AreaCreator>(QStringLiteral("25240201")));
|
||||
m_normalRegistry.insert(QStringLiteral("NFA"), std::make_shared<AreaCreator>(QStringLiteral("25240301")));
|
||||
m_normalRegistry.insert(QStringLiteral("RFA"), std::make_shared<AreaCreator>(QStringLiteral("25240401")));
|
||||
|
||||
// Areas with radius
|
||||
m_circularRegistry.insert(QStringLiteral("CFZ"), std::make_shared<AreaCircularCreator>(QStringLiteral("25241403")));
|
||||
m_circularRegistry.insert(QStringLiteral("CZ"), std::make_shared<AreaCircularCreator>(QStringLiteral("25241303")));
|
||||
m_circularRegistry.insert(QStringLiteral("FFA"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240303")));
|
||||
m_circularRegistry.insert(QStringLiteral("NFA"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240303")));
|
||||
m_circularRegistry.insert(QStringLiteral("RFA"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240403")));
|
||||
m_circularRegistry.insert(QStringLiteral("FSCL"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240403")));
|
||||
m_circularRegistry.insert(QStringLiteral("RFL"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240403")));
|
||||
m_circularRegistry.insert(QStringLiteral("FSSL"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240403")));
|
||||
m_circularRegistry.insert(QStringLiteral("NFL"), std::make_shared<AreaCircularCreator>(QStringLiteral("25240403")));
|
||||
}
|
||||
|
||||
void SymbolFactory::build(const QString &art, const HqReportData &data, SituationMap::GeometryModel *model)
|
||||
{
|
||||
if(m_normalRegistry.contains(art))
|
||||
{
|
||||
if(data.radius < 0)
|
||||
m_normalRegistry[art]->create(data, model);
|
||||
else
|
||||
{
|
||||
if ( m_circularRegistry.contains(art))
|
||||
m_circularRegistry[art]->create(data, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
|
||||
#include "flm_hq_report_symbol_creator.h"
|
||||
#include "flm_hq_report_symbol_concrete_creators.h"
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class SymbolFactory
|
||||
{
|
||||
public:
|
||||
SymbolFactory();
|
||||
|
||||
void build(const QString &art, const HqReportData &data, SituationMap::GeometryModel *model);
|
||||
private:
|
||||
QHash<QString, std::shared_ptr<SymbolCreator>> m_normalRegistry; /// Map HQ message type(art) to BaseSymbolCode
|
||||
QHash<QString, std::shared_ptr<SymbolCreator>> m_circularRegistry;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user