Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+151
-157
@@ -1,230 +1,224 @@
|
||||
#include "flm_hq_report_converter.h"
|
||||
|
||||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||||
#include <FileManagement/flm_data_plugin_interface.h>
|
||||
#include <FileManagement/flm_ftc.h>
|
||||
#include <FileManagement/flm_ftc_types.h>
|
||||
#include <FileManagement/flm_data_plugin_interface.h>
|
||||
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <ParticipantManagement/ppm_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);
|
||||
connect(this, &FlmHqReportConverter::allRequestsFinished, this, &FlmHqReportConverter::onRequestsFinished);
|
||||
}
|
||||
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession *session, int currentPartyId)
|
||||
bool FlmHqReportConverter::init(LtsSession::LtsSession* session, int currentPartyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
if (!m_session->getDtc<DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
if (!m_session->getFtc<DataInterface>(m_flmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Ftc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
if (!session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get PPM Dtc.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
if (!m_flmFtc->enableFileContentModify())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could enable fileContentModify.";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->enableFolder();
|
||||
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
if (m_geometryModel != nullptr)
|
||||
{
|
||||
delete m_geometryModel;
|
||||
m_geometryModel = nullptr;
|
||||
}
|
||||
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
m_geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
m_partyId = currentPartyId;
|
||||
m_partyId = currentPartyId;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::addHqToPlanIds(const QMap<int, QList<int>> &hqToPlanIds)
|
||||
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());
|
||||
}
|
||||
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();
|
||||
|
||||
for (int id : reportIds)
|
||||
for (auto it = m_hqToPlanIds.constBegin(); it != m_hqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Request File with ID: " << id << " from plan with ID: " << planId;
|
||||
FileManagement::GetFileContentDataRequest request(id);
|
||||
m_flmFtc->getFileContentDataRequest(request, this);
|
||||
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();
|
||||
|
||||
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)
|
||||
void FlmHqReportConverter::createGeometryFromReport(const HqReportData& data)
|
||||
{
|
||||
m_symbolFactory.build(data.art, data, m_geometryModel);
|
||||
m_symbolFactory.build(data.art, data, m_geometryModel);
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::checkIfAllFinished()
|
||||
{
|
||||
if (m_pendingRequests <= 0) emit allRequestsFinished();
|
||||
if (m_pendingRequests <= 0)
|
||||
emit allRequestsFinished();
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(
|
||||
const FileManagement::GetFileContentDataReply &reply)
|
||||
void FlmHqReportConverter::onGetFileContentDataReply(const FileManagement::GetFileContentDataReply& reply)
|
||||
{
|
||||
m_pendingRequests--;
|
||||
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))
|
||||
if (reply.errorString().size() > 0)
|
||||
{
|
||||
planId = it.key();
|
||||
break;
|
||||
ERROR_LOG(m_logger) << "Got onGetFileContentDataReply error: " << reply.errorString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_convertedHqToPlanIds[planId].append(data);
|
||||
int id = static_cast<int>(reply.id());
|
||||
int planId = -1;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Content size: " << reply.content().size();
|
||||
DEBUG_LOG(m_logger) << "Reply File with ID: " << id << " from plan with ID: " << planId;
|
||||
|
||||
checkIfAllFinished();
|
||||
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)
|
||||
void FlmHqReportConverter::onFileContentModifyReply(const Core::FunctionReplyObject& reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentModify Reply: " << reply.translated();
|
||||
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();
|
||||
}
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error while insert HX Message: " << reply.translated() << ", error: " << reply.error();
|
||||
}
|
||||
}
|
||||
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
void FlmHqReportConverter::onFileContentRemoveReply(const Core::FunctionReplyObject& reply)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Got FileContentRemove Reply: " << reply.translated();
|
||||
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();
|
||||
}
|
||||
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";
|
||||
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)
|
||||
for (auto it = m_convertedHqToPlanIds.constBegin(); it != m_convertedHqToPlanIds.constEnd(); ++it)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "createGeometryFromReport :" << reportData.art;
|
||||
createGeometryFromReport(reportData);
|
||||
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();
|
||||
}
|
||||
|
||||
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
|
||||
Executable → Regular
+41
-45
@@ -1,10 +1,10 @@
|
||||
#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"
|
||||
|
||||
#include <FileManagement/logger.h>
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
@@ -16,59 +16,55 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
class Ftc;
|
||||
}
|
||||
} // namespace Interface
|
||||
|
||||
class FlmHqReportConverter : public QObject,
|
||||
public Interface::Ftc::GetFileContentDataReplyHandler,
|
||||
public Interface::Ftc::FileContentModifyReplyHandler,
|
||||
public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
public Interface::Ftc::GetFileContentDataReplyHandler,
|
||||
public Interface::Ftc::FileContentModifyReplyHandler,
|
||||
public Interface::Ftc::FileContentRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlmHqReportConverter();
|
||||
~FlmHqReportConverter() = default;
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int currentPartyId);
|
||||
|
||||
bool init(LtsSession::LtsSession* session, int currentPartyId);
|
||||
|
||||
void addHqToPlanIds(const QMap<int, QList<int>> &hqToPlanIds);
|
||||
|
||||
void addHqToPlanIds(const QMap<int, QList<int>>& hqToPlanIds);
|
||||
|
||||
void processCollectedHqs();
|
||||
|
||||
void processCollectedHqs();
|
||||
|
||||
void createGeometryFromReport(const HqReportData &data);
|
||||
void createGeometryFromReport(const HqReportData& data);
|
||||
|
||||
private:
|
||||
void checkIfAllFinished();
|
||||
private:
|
||||
void checkIfAllFinished();
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
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:
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
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:
|
||||
|
||||
void allRequestsFinished();
|
||||
void allRequestsFinished();
|
||||
|
||||
private:
|
||||
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;
|
||||
private:
|
||||
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;
|
||||
SituationMap::GeometryModel* m_geometryModel{nullptr};
|
||||
QList<SituationMap::GeometryModel::Node> m_planNodes;
|
||||
SymbolFactory m_symbolFactory;
|
||||
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
int m_partyId;
|
||||
int m_pendingRequests{0};
|
||||
|
||||
QMap<int, QList<int>> m_hqToPlanIds;
|
||||
QMap<int, int> m_hqToPlanIdsLookup;
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds;
|
||||
};
|
||||
}
|
||||
QMap<int, QList<int>> m_hqToPlanIds;
|
||||
QMap<int, int> m_hqToPlanIdsLookup;
|
||||
QMap<int, QList<HqReportData>> m_convertedHqToPlanIds;
|
||||
};
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+288
-289
@@ -1,386 +1,385 @@
|
||||
#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 <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsCore/dds_vector.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.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_menuGroup(menuGroup)
|
||||
HQReportEdit::HQReportEdit(const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::HQReportEdit),
|
||||
m_menuGroup(menuGroup)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("New Plan"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &HQReportEdit::onCreateNewPlanClicked);
|
||||
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"));
|
||||
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)
|
||||
HQReportEdit::~HQReportEdit()
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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))
|
||||
bool HQReportEdit::init(LtsSession::LtsSession* session, int partyId)
|
||||
{
|
||||
if (session == nullptr)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Could not init planModel for partyId " << partyId;
|
||||
ERROR_LOG(m_logger) << "Got invalid session";
|
||||
|
||||
delete planModel;
|
||||
planModel = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
continue;
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
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);
|
||||
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"));
|
||||
|
||||
FlmHQReportModel *hqReportModel = new FlmHQReportModel(m_ui->listViewMessage);
|
||||
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;
|
||||
planModel = nullptr;
|
||||
|
||||
delete hqReportModel;
|
||||
hqReportModel = nullptr;
|
||||
|
||||
continue;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::CopyAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
m_ui->listViewPlan->setDragDropMode(QAbstractItemView::DropOnly);
|
||||
m_ui->listViewPlan->setDefaultDropAction(Qt::MoveAction);
|
||||
m_ui->listViewPlan->setDropIndicatorShown(true);
|
||||
|
||||
|
||||
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);
|
||||
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;
|
||||
QMap<int, QList<int>> allHqToPlanIds;
|
||||
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlanIds = it.value()->getHQToPlan();
|
||||
|
||||
for (auto planId : hqToPlanIds.keys())
|
||||
for (auto it = m_planModels.begin(); it != m_planModels.end(); ++it)
|
||||
{
|
||||
allHqToPlanIds[planId].append(hqToPlanIds[planId]);
|
||||
QMap<int, QList<int>> hqToPlanIds = it.value()->getHQToPlan();
|
||||
|
||||
it.value()->clearMovedData();
|
||||
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();
|
||||
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";
|
||||
if (hqRepConv->init(m_session, currentPartyId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Add HQ to Converter";
|
||||
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
hqRepConv->addHqToPlanIds(allHqToPlanIds);
|
||||
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
hqRepConv->processCollectedHqs();
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HQReportEdit::retranslate() { translate(m_ui, tr("HQ Report")); }
|
||||
void HQReportEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("HQ Report"));
|
||||
}
|
||||
|
||||
void HQReportEdit::onPartyChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index);
|
||||
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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.";
|
||||
}
|
||||
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);
|
||||
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.";
|
||||
if (!ok)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No name for new plan entered.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FlmHQReportModel *planModel = static_cast<FlmHQReportModel *>(m_ui->listViewPlan->model());
|
||||
FlmHQReportModel* planModel = static_cast<FlmHQReportModel*>(m_ui->listViewPlan->model());
|
||||
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
if (planModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> no plan model present.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SituationMap::GeometryModel *geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
SituationMap::GeometryModel* geometryModel = SituationMap::GeometryModelFactory::singleton()->create();
|
||||
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
if (geometryModel == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
if (m_session == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not create plan --> not possible to create GeometryModel.";
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FileManagement::FileContentModifyRequest data;
|
||||
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());
|
||||
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()));
|
||||
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;
|
||||
ERROR_LOG(m_logger) << errorMessage;
|
||||
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
new LtsWidgets::LtsMessageDialogNew(this, errorMessage, tr("Save failed"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection &, const QItemSelection &)
|
||||
void HQReportEdit::onSelectionChanged(const QItemSelection&, const QItemSelection&)
|
||||
{
|
||||
m_ui->pbShift->setEnabled(m_ui->listViewMessage->selectionModel()->hasSelection() && m_ui->listViewPlan->selectionModel()->hasSelection());
|
||||
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();
|
||||
const int currentPartyId = m_ui->cboParties->currentData().toInt();
|
||||
|
||||
FlmHQReportModel *messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel *planModel = m_planModels.value(currentPartyId);
|
||||
FlmHQReportModel* messageModel = m_hqModels.value(currentPartyId);
|
||||
FlmHQReportModel* planModel = m_planModels.value(currentPartyId);
|
||||
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
if (messageModel == nullptr || planModel == nullptr)
|
||||
return;
|
||||
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
const QModelIndex currentMessageIndex = m_ui->listViewMessage->currentIndex();
|
||||
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
if (!currentMessageIndex.isValid())
|
||||
return;
|
||||
|
||||
QMimeData *mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
QMimeData* mimeData = messageModel->mimeData({currentMessageIndex});
|
||||
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
if (mimeData == nullptr)
|
||||
return;
|
||||
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
if (!planModel->dropMimeData(mimeData, Qt::CopyAction, -1, 0, m_ui->listViewPlan->currentIndex()))
|
||||
return;
|
||||
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
m_ui->listViewPlan->viewport()->update();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+22
-23
@@ -1,9 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "flm_hq_report_converter.h"
|
||||
|
||||
#include <FileManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
@@ -25,37 +25,36 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
class Ftc;
|
||||
}
|
||||
} // namespace Interface
|
||||
|
||||
class FlmHQReportModel;
|
||||
|
||||
class HQReportEdit : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
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);
|
||||
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;
|
||||
bool apply() override;
|
||||
void retranslate() override;
|
||||
private Q_SLOTS:
|
||||
void onPartyChanged(int index = 0);
|
||||
void onCreateNewPlanClicked();
|
||||
void onSelectionChanged(const QItemSelection &, const QItemSelection &);
|
||||
void onShiftClicked();
|
||||
void onPartyChanged(int index = 0);
|
||||
void onCreateNewPlanClicked();
|
||||
void onSelectionChanged(const QItemSelection&, const QItemSelection&);
|
||||
void onShiftClicked();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Ui::HQReportEdit *m_ui;
|
||||
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;
|
||||
NGL::INGLLogger& m_logger;
|
||||
Ui::HQReportEdit* m_ui;
|
||||
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
|
||||
Executable → Regular
+56
-58
@@ -4,82 +4,80 @@ namespace FileManagement
|
||||
{
|
||||
FlmHqReportJsonParser::FlmHqReportJsonParser() : m_logger(getLogger("HQReportParser")) {}
|
||||
|
||||
HqReportData FlmHqReportJsonParser::parse(const QByteArray &data)
|
||||
HqReportData FlmHqReportJsonParser::parse(const QByteArray& data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "START PARSING";
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||
QJsonObject obj = doc.object();
|
||||
HqReportData report;
|
||||
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();
|
||||
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("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)
|
||||
if ((obj.contains(QStringLiteral("bis"))) && (obj.contains((QStringLiteral("ab")))))
|
||||
{
|
||||
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);
|
||||
report.bis = parseHqReportTime(obj[QStringLiteral("bis")].toObject());
|
||||
report.ab = parseHqReportTime(obj[QStringLiteral("ab")].toObject());
|
||||
}
|
||||
}
|
||||
|
||||
if ((obj.contains(QStringLiteral("mittelpunkt"))) &&
|
||||
(obj[QStringLiteral("mittelpunkt")].isObject()))
|
||||
{
|
||||
QPointF center;
|
||||
if ((obj.contains(QStringLiteral("koordinaten"))) && (obj[QStringLiteral("koordinaten")].isArray()))
|
||||
{
|
||||
QJsonArray coordsArray = obj[QStringLiteral("koordinaten")].toArray();
|
||||
|
||||
QJsonObject coordsObj = obj[QStringLiteral("mittelpunkt")].toObject();
|
||||
for (const QJsonValue& value : coordsArray)
|
||||
{
|
||||
QPointF coord;
|
||||
|
||||
center.setX(coordsObj[QStringLiteral("longitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
center.setY(coordsObj[QStringLiteral("latitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
QJsonObject coordsObj = value.toObject();
|
||||
|
||||
report.mittelpunkt = center;
|
||||
}
|
||||
coord.setX(coordsObj[QStringLiteral("longitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
coord.setY(coordsObj[QStringLiteral("latitude")].toDouble() * LtsCoordTrans::deg2rad());
|
||||
|
||||
if (obj.contains(QStringLiteral("radius"))) report.radius = obj[QStringLiteral("radius")].toInt();
|
||||
report.koordinaten.push_back(coord);
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.contains(QStringLiteral("linkerNachbar")))
|
||||
report.linkerNachbar = obj[QStringLiteral("linkerNachbar")].toString();
|
||||
if ((obj.contains(QStringLiteral("mittelpunkt"))) && (obj[QStringLiteral("mittelpunkt")].isObject()))
|
||||
{
|
||||
QPointF center;
|
||||
|
||||
if (obj.contains(QStringLiteral("rechterNachbar")))
|
||||
report.rechterNachbar = obj[QStringLiteral("rechterNachbar")].toString();
|
||||
QJsonObject coordsObj = obj[QStringLiteral("mittelpunkt")].toObject();
|
||||
|
||||
return report;
|
||||
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)
|
||||
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 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);
|
||||
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"));
|
||||
return dt.toString(QStringLiteral("dd.MM.yyyy HH:mm:ss"));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+25
-27
@@ -5,7 +5,6 @@
|
||||
#include <GeometryModel/geometry_model.h>
|
||||
#include <GeometryModel/geometry_model_factory.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
@@ -22,39 +21,38 @@ using namespace SituationMap;
|
||||
|
||||
struct HqCoordinates
|
||||
{
|
||||
double latitude;
|
||||
double longitude;
|
||||
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;
|
||||
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();
|
||||
|
||||
public:
|
||||
FlmHqReportJsonParser();
|
||||
|
||||
HqReportData parse(const QByteArray &data);
|
||||
|
||||
HqReportData parse(const QByteArray& data);
|
||||
|
||||
QString parseHqReportTime(const QJsonObject &obj);
|
||||
QString parseHqReportTime(const QJsonObject& obj);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+199
-192
@@ -5,288 +5,295 @@
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
FlmHQReportModel::FlmHQReportModel(QObject *parent) : QAbstractListModel(parent),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
FlmHQReportModel::FlmHQReportModel(QObject* parent)
|
||||
: QAbstractListModel(parent), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession *session, int contentFolderId, const FileType &fileType)
|
||||
bool FlmHQReportModel::init(LtsSession::LtsSession* session, int contentFolderId, const FileType& fileType)
|
||||
{
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
if (!session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Got invalid Session";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not get FLM Dtc";
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
m_contentFolderId = contentFolderId;
|
||||
m_fileType = fileType;
|
||||
|
||||
m_flmDtc->enableFileContent();
|
||||
m_flmDtc->waitForHistoricalDataFileContent(3000);
|
||||
m_flmDtc->fileContents([this](const FileContent &content){onFileContentChanged(content, DataModification::eAdded);});
|
||||
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);
|
||||
connect(m_flmDtc.get(), &Interface::Dtc::fileContentChanged, this, &FlmHQReportModel::onFileContentChanged);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int FlmHQReportModel::rowCount(const QModelIndex &parent) const
|
||||
int FlmHQReportModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return m_data.count();
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return m_data.count();
|
||||
}
|
||||
|
||||
QVariant FlmHQReportModel::data(const QModelIndex &index, int role) const
|
||||
QVariant FlmHQReportModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return createText(index.row());
|
||||
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return createText(index.row());
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags FlmHQReportModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
if (!index.isValid())
|
||||
return defaultFlags;
|
||||
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
return defaultFlags | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDropActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
Qt::DropActions FlmHQReportModel::supportedDragActions() const
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
QStringList FlmHQReportModel::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
QStringList types;
|
||||
types << mimeType;
|
||||
return types;
|
||||
}
|
||||
|
||||
bool FlmHQReportModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
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;
|
||||
if (parent.isValid() || row < 0 || row >= m_data.size() || (row + count) > m_data.size())
|
||||
return false;
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
beginRemoveRows(QModelIndex(), row, row + count - 1);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
for (int i = 0; i < count; ++i)
|
||||
m_data.removeAt(row);
|
||||
|
||||
endRemoveRows();
|
||||
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;
|
||||
}
|
||||
}
|
||||
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))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addHQReportData(const HQData &data)
|
||||
QMimeData* FlmHQReportModel::mimeData(const QList<QModelIndex>& indexes) const
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
m_data.append(data);
|
||||
endInsertRows();
|
||||
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;
|
||||
}
|
||||
}
|
||||
mimeData->setData(mimeType, encodedData);
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::deleteHQReportData(const HQData &data)
|
||||
bool FlmHQReportModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||
endInsertRows();
|
||||
Q_UNUSED(row)
|
||||
Q_UNUSED(column)
|
||||
|
||||
const int zeile = m_data.indexOf(data);
|
||||
if (!parent.isValid() || !data->hasFormat(mimeType) || action != Qt::CopyAction)
|
||||
return false;
|
||||
|
||||
if (zeile == -1) {
|
||||
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& currentData = 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))
|
||||
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;
|
||||
}
|
||||
|
||||
beginRemoveRows(QModelIndex(), zeile, zeile);
|
||||
m_data.removeAt(zeile);
|
||||
endRemoveRows();
|
||||
return;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::onFileContentChanged(const FileContent &content, DataModification modType)
|
||||
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;
|
||||
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);
|
||||
}
|
||||
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;
|
||||
return m_contentFolderId;
|
||||
}
|
||||
|
||||
QMap<int, QList<int>> FlmHQReportModel::getHQToPlan() const
|
||||
{
|
||||
QMap<int, QList<int>> hqToPlan;
|
||||
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;
|
||||
for (auto it = m_movedData.constBegin(); it != m_movedData.constEnd(); ++it)
|
||||
{
|
||||
const QList<HQData>& movedData = it.value();
|
||||
QList<int> hqIds;
|
||||
|
||||
hqIds.reserve(movedData.size());
|
||||
hqIds.reserve(movedData.size());
|
||||
|
||||
for (const HQData ¤tData : movedData)
|
||||
hqIds.append(currentData.id);
|
||||
for (const HQData& currentData : movedData)
|
||||
hqIds.append(currentData.id);
|
||||
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
}
|
||||
hqToPlan.insert(it.key(), hqIds);
|
||||
}
|
||||
|
||||
return hqToPlan;
|
||||
return hqToPlan;
|
||||
}
|
||||
|
||||
void FlmHQReportModel::clearMovedData()
|
||||
{
|
||||
m_movedData.clear();
|
||||
m_movedData.clear();
|
||||
|
||||
emit dataAddedOrRemoved();
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
emit dataAddedOrRemoved();
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0));
|
||||
}
|
||||
|
||||
QString FlmHQReportModel::createText(int dataIndex) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return QString();
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return QString();
|
||||
|
||||
const HQData &data = m_data.at(dataIndex);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
const QList<HQData>& movedData = m_movedData.value(data.id);
|
||||
QStringList movedDataNames;
|
||||
|
||||
movedDataNames.reserve(movedData.size());
|
||||
movedDataNames.reserve(movedData.size());
|
||||
|
||||
for (const HQData ¤tMovedData : movedData)
|
||||
movedDataNames.append(currentMovedData.name);
|
||||
for (const HQData& currentMovedData : movedData)
|
||||
movedDataNames.append(currentMovedData.name);
|
||||
|
||||
return QString(QStringLiteral("%1 (%2)")).arg(data.name).arg(movedDataNames.join(QLatin1Char(',')));
|
||||
return QString(QStringLiteral("%1 (%2)")).arg(data.name).arg(movedDataNames.join(QLatin1Char(',')));
|
||||
}
|
||||
|
||||
void FlmHQReportModel::addMovedData(int dataIndex, const HQData &movedData)
|
||||
void FlmHQReportModel::addMovedData(int dataIndex, const HQData& movedData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex << ", movedData.id: " << movedData.id << ", movedData.name: " << movedData.name;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " dataIndex: " << dataIndex << ", movedData.id: " << movedData.id
|
||||
<< ", movedData.name: " << movedData.name;
|
||||
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
if (dataIndex < 0 || dataIndex >= m_data.size())
|
||||
return;
|
||||
|
||||
const HQData &data = m_data.at(dataIndex);
|
||||
const HQData& data = m_data.at(dataIndex);
|
||||
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
if (!m_movedData.contains(data.id))
|
||||
m_movedData.insert(data.id, QList<HQData>());
|
||||
|
||||
m_movedData[data.id].append(movedData);
|
||||
m_movedData[data.id].append(movedData);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+52
-54
@@ -1,28 +1,26 @@
|
||||
|
||||
#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>
|
||||
#include <QAbstractListModel>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QList>
|
||||
#include <QMimeData>
|
||||
#include <QObject>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
class FileContent;
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace FileManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
@@ -33,65 +31,65 @@ namespace FileManagement
|
||||
{
|
||||
struct HQData
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
int id;
|
||||
QString name;
|
||||
|
||||
bool operator==(const HQData &other) const
|
||||
{
|
||||
return id == other.id &&
|
||||
name == other.name;
|
||||
}
|
||||
bool operator==(const HQData& other) const
|
||||
{
|
||||
return id == other.id && name == other.name;
|
||||
}
|
||||
};
|
||||
|
||||
class FlmHQReportModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FlmHQReportModel(QObject *parent = nullptr);
|
||||
public:
|
||||
explicit FlmHQReportModel(QObject* parent = nullptr);
|
||||
|
||||
bool init(LtsSession::LtsSession *session, int contentFolderId, const FileManagement::FileType &fileType);
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
void addHQReportData(const HQData& data);
|
||||
void deleteHQReportData(const HQData& data);
|
||||
|
||||
int folderId() const;
|
||||
int folderId() const;
|
||||
|
||||
QMap<int, QList<int>> getHQToPlan() const;
|
||||
void clearMovedData();
|
||||
QMap<int, QList<int>> getHQToPlan() const;
|
||||
void clearMovedData();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QString createText(int dataIndex) const;
|
||||
void addMovedData(int dataIndex, const HQData& movedData);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QString createText(int dataIndex) const;
|
||||
void addMovedData(int dataIndex, const HQData &movedData);
|
||||
private Q_SLOTS:
|
||||
void onFileContentChanged(const FileContent& content, DataModification modType);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFileContentChanged(const FileContent &content, DataModification modType);
|
||||
Q_SIGNALS:
|
||||
void dataAddedOrRemoved();
|
||||
|
||||
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;
|
||||
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;
|
||||
};
|
||||
}
|
||||
} // namespace FileManagement
|
||||
|
||||
Q_DECLARE_METATYPE(FileManagement::HQData)
|
||||
Executable → Regular
+338
-367
@@ -1,77 +1,65 @@
|
||||
|
||||
|
||||
|
||||
#include "topic_editor.h"
|
||||
|
||||
#include "ui_topic_editor.h"
|
||||
#include <LtsWidgets/lts_text_edit_dialog.h>
|
||||
|
||||
#include <LtsUtilsCore/dds_vector.h>
|
||||
#include <LtsUtilsCore/dds_vector_to_pixmap.h>
|
||||
#include <LtsWidgets/lts_text_edit_dialog.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Script/Common/topic_designer.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <TopicEditorBase/topic_previewer.h>
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
|
||||
#include <TopicEditorBase/topic_previewer.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
FileTopicEditor::FileTopicEditor(
|
||||
LtsSession::LtsSession *session, FileContentPreviewPlaybackWidget *previewWidget, const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
QWidget *parent
|
||||
)
|
||||
: TopicEditorBase::TopicEditor(parent)
|
||||
, m_session(session)
|
||||
, m_getContent(new FileManagement::GetFileContent(ftc, this))
|
||||
, m_previewPlaybackWidget(previewWidget)
|
||||
, m_ui(new Ui::FileTopicEditor)
|
||||
FileTopicEditor::FileTopicEditor(LtsSession::LtsSession* session, FileContentPreviewPlaybackWidget* previewWidget,
|
||||
const std::shared_ptr<Interface::Ftc>& ftc, QWidget* parent)
|
||||
: TopicEditorBase::TopicEditor(parent), m_session(session),
|
||||
m_getContent(new FileManagement::GetFileContent(ftc, this)), m_previewPlaybackWidget(previewWidget),
|
||||
m_ui(new Ui::FileTopicEditor)
|
||||
{
|
||||
|
||||
m_ui->setupUi(this);
|
||||
init(m_ui->widget);
|
||||
m_ftc = ftc;
|
||||
m_ui->scrollArea->setWidget(m_previewPlaybackWidget);
|
||||
|
||||
connect(m_previewPlaybackWidget, &FileContentPreviewPlaybackWidget::currentPageChanged,
|
||||
this, &FileTopicEditor::onPageNoChanged);
|
||||
connect(m_previewPlaybackWidget, &FileContentPreviewPlaybackWidget::rotationChanged,
|
||||
this, &FileTopicEditor::onRotationChanged);
|
||||
m_ui->setupUi(this);
|
||||
init(m_ui->widget);
|
||||
m_ftc = ftc;
|
||||
m_ui->scrollArea->setWidget(m_previewPlaybackWidget);
|
||||
|
||||
if (m_ui->pbSetTopicPosition->isEnabled())
|
||||
m_ui->pbSetTopicPosition->setToolTip(tr("Starts a replay at the time that the topic was positioned.%1").arg(QString()));
|
||||
else
|
||||
m_ui->pbSetTopicPosition->setToolTip(tr("Starts a replay at the time that the topic was positioned.%1").arg(QStringLiteral(" <b>%1</b>").arg(tr("You need to position the topic on a screen track first to start a preview.", "Sie müssen das Topic auf eine Screen-Spur ziehen, bevor Sie eine Vorschau starten können."))));
|
||||
connect(m_previewPlaybackWidget, &FileContentPreviewPlaybackWidget::currentPageChanged, this,
|
||||
&FileTopicEditor::onPageNoChanged);
|
||||
connect(m_previewPlaybackWidget, &FileContentPreviewPlaybackWidget::rotationChanged, this,
|
||||
&FileTopicEditor::onRotationChanged);
|
||||
|
||||
connect(m_ui->pbBrowse, &QPushButton::clicked,
|
||||
this, &FileTopicEditor::onSelectFile);
|
||||
connect(m_ui->pbEnterText, &QPushButton::clicked,
|
||||
this, &FileTopicEditor::onEnterText);
|
||||
if (m_ui->pbSetTopicPosition->isEnabled())
|
||||
m_ui->pbSetTopicPosition->setToolTip(
|
||||
tr("Starts a replay at the time that the topic was positioned.%1").arg(QString()));
|
||||
else
|
||||
m_ui->pbSetTopicPosition->setToolTip(
|
||||
tr("Starts a replay at the time that the topic was positioned.%1")
|
||||
.arg(QStringLiteral(" <b>%1</b>")
|
||||
.arg(tr("You need to position the topic on a screen track first to start a preview.",
|
||||
"Sie müssen das Topic auf eine Screen-Spur ziehen, bevor Sie eine Vorschau starten "
|
||||
"können."))));
|
||||
|
||||
connect(m_ui->zoomSlider, &QSlider::valueChanged,
|
||||
this, &FileTopicEditor::onZoomSliderChanged);
|
||||
connect(m_ui->pbBrowse, &QPushButton::clicked, this, &FileTopicEditor::onSelectFile);
|
||||
connect(m_ui->pbEnterText, &QPushButton::clicked, this, &FileTopicEditor::onEnterText);
|
||||
|
||||
connect(m_ui->sbPageNo, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &FileTopicEditor::onPageNoChanged);
|
||||
connect(m_ui->zoomSlider, &QSlider::valueChanged, this, &FileTopicEditor::onZoomSliderChanged);
|
||||
|
||||
connect(m_ui->sbRotation, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &FileTopicEditor::onRotationChanged);
|
||||
connect(m_ui->sbPageNo, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
&FileTopicEditor::onPageNoChanged);
|
||||
|
||||
connect(m_ui->sbRotation, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
&FileTopicEditor::onRotationChanged);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_ui->pbSetTopicPosition->setEnabled(false);
|
||||
m_ui->pbSetTopicPosition->setEnabled(false);
|
||||
#if 0
|
||||
connect(m_ui->pbSetTopicPosition, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
@@ -80,433 +68,416 @@ FileTopicEditor::FileTopicEditor(
|
||||
emit signalSetTopicPosition(m_ui->scrollArea, m_topicData.id);
|
||||
});
|
||||
#else
|
||||
{
|
||||
connect(m_ui->pbSetTopicPosition, &QPushButton::clicked, this, &FileTopicEditor::onPreview);
|
||||
}
|
||||
{
|
||||
connect(m_ui->pbSetTopicPosition, &QPushButton::clicked, this, &FileTopicEditor::onPreview);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FileTopicEditor::~FileTopicEditor()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FileTopicEditor::updatePreview()
|
||||
{
|
||||
setUnchangeable(true);
|
||||
setUnchangeable(true);
|
||||
|
||||
if (m_userText.isEmpty())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "file id = " << m_fileId;
|
||||
m_fileContent = m_dtc->fileContent(m_fileId);
|
||||
m_fileName = QString::fromStdString(m_fileContent.name());
|
||||
m_ui->leFileName->setText(m_fileName);
|
||||
DEBUG_LOG(m_logger) << "file name = " << m_fileName;
|
||||
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
if (m_userText.isEmpty())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "zoom level = " << m_zoomLevel;
|
||||
m_ui->zoomSlider->setValue(m_zoomLevel);
|
||||
DEBUG_LOG(m_logger) << "file id = " << m_fileId;
|
||||
m_fileContent = m_dtc->fileContent(m_fileId);
|
||||
m_fileName = QString::fromStdString(m_fileContent.name());
|
||||
m_ui->leFileName->setText(m_fileName);
|
||||
DEBUG_LOG(m_logger) << "file name = " << m_fileName;
|
||||
|
||||
DEBUG_LOG(m_logger) << "rotation = " << m_rotation;
|
||||
m_ui->sbRotation->setValue(m_rotation);
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "zoom level = " << m_zoomLevel;
|
||||
m_ui->zoomSlider->setValue(m_zoomLevel);
|
||||
|
||||
const int pageNo = m_pageNo;
|
||||
m_ui->sbPageNo->setRange(1, m_previewPlaybackWidget->getNumPages());
|
||||
m_pageNo = pageNo;
|
||||
DEBUG_LOG(m_logger) << "page no = " << m_pageNo;
|
||||
m_ui->sbPageNo->setValue(m_pageNo);
|
||||
DEBUG_LOG(m_logger) << "rotation = " << m_rotation;
|
||||
m_ui->sbRotation->setValue(m_rotation);
|
||||
|
||||
m_ui->sbPageNo->setEnabled(true);
|
||||
m_ui->zoomSlider->setEnabled(true);
|
||||
m_ui->sbRotation->setEnabled(true);
|
||||
const int pageNo = m_pageNo;
|
||||
m_ui->sbPageNo->setRange(1, m_previewPlaybackWidget->getNumPages());
|
||||
m_pageNo = pageNo;
|
||||
DEBUG_LOG(m_logger) << "page no = " << m_pageNo;
|
||||
m_ui->sbPageNo->setValue(m_pageNo);
|
||||
|
||||
m_ui->sbPageNo->setEnabled(true);
|
||||
m_ui->zoomSlider->setEnabled(true);
|
||||
m_ui->sbRotation->setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileId = 0;
|
||||
m_ui->leFileName->setText(tr("Custom text"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileId = 0;
|
||||
m_ui->leFileName->setText(tr("Custom text"));
|
||||
}
|
||||
|
||||
m_previewPlaybackWidget->setVisible(true);
|
||||
m_previewPlaybackWidget->init(m_fileContent, m_pageNo, m_zoomLevel / 100., m_rotation, 0, m_userText);
|
||||
setUnchangeable(false);
|
||||
m_previewPlaybackWidget->setVisible(true);
|
||||
m_previewPlaybackWidget->init(m_fileContent, m_pageNo, m_zoomLevel / 100., m_rotation, 0, m_userText);
|
||||
setUnchangeable(false);
|
||||
}
|
||||
|
||||
bool FileTopicEditor::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_guiIfc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Flm ForeignGuiInterface";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_guiIfc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Flm ForeignGuiInterface";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getDtc<FileManagement::DataInterface>(m_dtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Flm Dtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<FileManagement::DataInterface>(m_dtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Flm Dtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FileTopicEditor::updateInternalData()
|
||||
{
|
||||
enaDisa();
|
||||
enaDisa();
|
||||
|
||||
if (m_topicData.topicType != TopicEditorBase::TopicType::Text)
|
||||
m_ui->pbEnterText->hide();
|
||||
if (m_topicData.topicType != TopicEditorBase::TopicType::Text)
|
||||
m_ui->pbEnterText->hide();
|
||||
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::TacticalPlan)
|
||||
{
|
||||
m_ui->pbSetTopicPosition->hide();
|
||||
m_ui->scrollArea->hide();
|
||||
}
|
||||
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Text ||
|
||||
m_topicData.topicType == TopicEditorBase::TopicType::Image ||
|
||||
m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
|
||||
if (m_topicData.x <= 0 && m_topicData.y <= 0 && m_topicData.w <= 0 && m_topicData.h <= 0)
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::TacticalPlan)
|
||||
{
|
||||
m_topicData.x = 0;
|
||||
m_topicData.y = 0;
|
||||
m_topicData.h = 0.8;
|
||||
m_topicData.w = 0.8;
|
||||
m_ui->pbSetTopicPosition->hide();
|
||||
m_ui->scrollArea->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_fileTypes.clear();
|
||||
switch (m_topicData.topicType)
|
||||
{
|
||||
case TopicEditorBase::TopicType::Image:
|
||||
m_fileTypes << FileManagement::FileType_def::Jpg << FileManagement::FileType_def::Png;
|
||||
break;
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Text ||
|
||||
m_topicData.topicType == TopicEditorBase::TopicType::Image ||
|
||||
m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
|
||||
case TopicEditorBase::TopicType::Pdf:
|
||||
m_fileTypes << FileManagement::FileType_def::Pdf;
|
||||
break;
|
||||
if (m_topicData.x <= 0 && m_topicData.y <= 0 && m_topicData.w <= 0 && m_topicData.h <= 0)
|
||||
{
|
||||
m_topicData.x = 0;
|
||||
m_topicData.y = 0;
|
||||
m_topicData.h = 0.8;
|
||||
m_topicData.w = 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
case TopicEditorBase::TopicType::Text:
|
||||
m_fileTypes << FileManagement::FileType_def::Text << FileManagement::FileType_def::EvaluationSchema;
|
||||
break;
|
||||
m_fileTypes.clear();
|
||||
switch (m_topicData.topicType)
|
||||
{
|
||||
case TopicEditorBase::TopicType::Image:
|
||||
m_fileTypes << FileManagement::FileType_def::Jpg << FileManagement::FileType_def::Png;
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::Xml:
|
||||
m_fileTypes << FileManagement::FileType_def::Xml;
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Pdf:
|
||||
m_fileTypes << FileManagement::FileType_def::Pdf;
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::TacticalPlan:
|
||||
m_fileTypes << FileManagement::FileType_def::TacticalPlan;
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Text:
|
||||
m_fileTypes << FileManagement::FileType_def::Text << FileManagement::FileType_def::EvaluationSchema;
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::MSOffice:
|
||||
m_fileTypes << FileManagement::FileType_def::MSOfficeDocument
|
||||
<< FileManagement::FileType_def::MSOfficeDocument97
|
||||
<< FileManagement::FileType_def::MSOfficePresentation
|
||||
<< FileManagement::FileType_def::MSOfficePresentation97
|
||||
<< FileManagement::FileType_def::MSOfficeSpreadsheet
|
||||
<< FileManagement::FileType_def::MSOfficeSpreadsheet97;
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Xml:
|
||||
m_fileTypes << FileManagement::FileType_def::Xml;
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::OpenOffice:
|
||||
m_fileTypes << FileManagement::FileType_def::OpenOfficeDocument
|
||||
<< FileManagement::FileType_def::OpenOfficePresentation
|
||||
<< FileManagement::FileType_def::OpenOfficeSpreadsheet;
|
||||
break;
|
||||
case TopicEditorBase::TopicType::TacticalPlan:
|
||||
m_fileTypes << FileManagement::FileType_def::TacticalPlan;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case TopicEditorBase::TopicType::MSOffice:
|
||||
m_fileTypes << FileManagement::FileType_def::MSOfficeDocument
|
||||
<< FileManagement::FileType_def::MSOfficeDocument97
|
||||
<< FileManagement::FileType_def::MSOfficePresentation
|
||||
<< FileManagement::FileType_def::MSOfficePresentation97
|
||||
<< FileManagement::FileType_def::MSOfficeSpreadsheet
|
||||
<< FileManagement::FileType_def::MSOfficeSpreadsheet97;
|
||||
break;
|
||||
|
||||
switch (m_topicData.topicType)
|
||||
{
|
||||
case TopicEditorBase::TopicType::Image:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Image_Topic"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::OpenOffice:
|
||||
m_fileTypes << FileManagement::FileType_def::OpenOfficeDocument
|
||||
<< FileManagement::FileType_def::OpenOfficePresentation
|
||||
<< FileManagement::FileType_def::OpenOfficeSpreadsheet;
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::Pdf:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_PDF_Topic"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
case TopicEditorBase::TopicType::Text:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Text_Topic"));
|
||||
break;
|
||||
switch (m_topicData.topicType)
|
||||
{
|
||||
case TopicEditorBase::TopicType::Image:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Image_Topic"));
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::Xml:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_XML_Topic"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Pdf:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_PDF_Topic"));
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::TacticalPlan:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Tactical_Plan_Topic"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Text:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Text_Topic"));
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::MSOffice:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_MS_Office_Topic"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Xml:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_XML_Topic"));
|
||||
break;
|
||||
|
||||
case TopicEditorBase::TopicType::OpenOffice:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Open_Office_Topic"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::TacticalPlan:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Tactical_Plan_Topic"));
|
||||
break;
|
||||
|
||||
default:
|
||||
translate(m_ui, tr("Unknown File Topic Editor"));
|
||||
break;
|
||||
}
|
||||
case TopicEditorBase::TopicType::MSOffice:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_MS_Office_Topic"));
|
||||
break;
|
||||
|
||||
m_ui->pbSetTopicPosition->setEnabled(!m_topicData.channel.isEmpty() || !m_topicData.parentChannel.isEmpty());
|
||||
case TopicEditorBase::TopicType::OpenOffice:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Open_Office_Topic"));
|
||||
break;
|
||||
|
||||
|
||||
m_userText = getTopicDataValue(QStringLiteral("UserText")).toString();
|
||||
m_fileId = getTopicDataValue(QStringLiteral("FileId")).toInt();
|
||||
default:
|
||||
translate(m_ui, tr("Unknown File Topic Editor"));
|
||||
break;
|
||||
}
|
||||
|
||||
m_pageNo = getTopicDataValue(QStringLiteral("PageNo")).toInt();
|
||||
m_zoomLevel = getTopicDataValue(QStringLiteral("ZoomLevel")).toInt();
|
||||
m_rotation = getTopicDataValue(QStringLiteral("Rotation")).toInt();
|
||||
m_ui->pbSetTopicPosition->setEnabled(!m_topicData.channel.isEmpty() || !m_topicData.parentChannel.isEmpty());
|
||||
|
||||
if (hasTopicDataProperties())
|
||||
updatePreview();
|
||||
m_userText = getTopicDataValue(QStringLiteral("UserText")).toString();
|
||||
m_fileId = getTopicDataValue(QStringLiteral("FileId")).toInt();
|
||||
|
||||
m_pageNo = getTopicDataValue(QStringLiteral("PageNo")).toInt();
|
||||
m_zoomLevel = getTopicDataValue(QStringLiteral("ZoomLevel")).toInt();
|
||||
m_rotation = getTopicDataValue(QStringLiteral("Rotation")).toInt();
|
||||
|
||||
if (hasTopicDataProperties())
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
void FileTopicEditor::retranslate()
|
||||
{
|
||||
switch (m_topicData.topicType)
|
||||
{
|
||||
case TopicEditorBase::TopicType::Image:
|
||||
translate(m_ui, tr("Image Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Pdf:
|
||||
translate(m_ui, tr("Pdf Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Text:
|
||||
translate(m_ui, tr("Text Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Xml:
|
||||
translate(m_ui, tr("Xml Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::TacticalPlan:
|
||||
translate(m_ui, tr("Tactical Plan Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::MSOffice:
|
||||
translate(m_ui, tr("MS Office Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::OpenOffice:
|
||||
translate(m_ui, tr("Open Office Topic Editor"));
|
||||
break;
|
||||
default:
|
||||
translate(m_ui, tr("Unknown File Topic Editor"));
|
||||
break;
|
||||
}
|
||||
switch (m_topicData.topicType)
|
||||
{
|
||||
case TopicEditorBase::TopicType::Image:
|
||||
translate(m_ui, tr("Image Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Pdf:
|
||||
translate(m_ui, tr("Pdf Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Text:
|
||||
translate(m_ui, tr("Text Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::Xml:
|
||||
translate(m_ui, tr("Xml Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::TacticalPlan:
|
||||
translate(m_ui, tr("Tactical Plan Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::MSOffice:
|
||||
translate(m_ui, tr("MS Office Topic Editor"));
|
||||
break;
|
||||
case TopicEditorBase::TopicType::OpenOffice:
|
||||
translate(m_ui, tr("Open Office Topic Editor"));
|
||||
break;
|
||||
default:
|
||||
translate(m_ui, tr("Unknown File Topic Editor"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (hasTopicDataProperties())
|
||||
updatePreview();
|
||||
if (hasTopicDataProperties())
|
||||
updatePreview();
|
||||
}
|
||||
|
||||
|
||||
void FileTopicEditor::enaDisa()
|
||||
{
|
||||
if (m_previewPlaybackWidget)
|
||||
m_previewPlaybackWidget->setVisible(false);
|
||||
m_ui->lblPageNo->setVisible(false);
|
||||
m_ui->sbPageNo->setVisible(false);
|
||||
m_ui->lblZoom->setVisible(false);
|
||||
m_ui->zoomSlider->setVisible(false);
|
||||
m_ui->lblZoomValue->setVisible(false);
|
||||
m_ui->sbRotation->setVisible(false);
|
||||
m_ui->lblRotation->setVisible(false);
|
||||
if (m_previewPlaybackWidget)
|
||||
m_previewPlaybackWidget->setVisible(false);
|
||||
m_ui->lblPageNo->setVisible(false);
|
||||
m_ui->sbPageNo->setVisible(false);
|
||||
m_ui->lblZoom->setVisible(false);
|
||||
m_ui->zoomSlider->setVisible(false);
|
||||
m_ui->lblZoomValue->setVisible(false);
|
||||
m_ui->sbRotation->setVisible(false);
|
||||
m_ui->lblRotation->setVisible(false);
|
||||
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
m_ui->lblPageNo->setVisible(true);
|
||||
m_ui->sbPageNo->setVisible(true);
|
||||
m_ui->lblZoom->setVisible(true);
|
||||
m_ui->zoomSlider->setVisible(true);
|
||||
m_ui->lblZoomValue->setVisible(true);
|
||||
m_ui->sbRotation->setVisible(true);
|
||||
m_ui->lblRotation->setVisible(true);
|
||||
m_ui->sbPageNo->setEnabled(false);
|
||||
m_ui->zoomSlider->setEnabled(false);
|
||||
m_ui->sbRotation->setEnabled(false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
}
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
m_ui->lblPageNo->setVisible(true);
|
||||
m_ui->sbPageNo->setVisible(true);
|
||||
m_ui->lblZoom->setVisible(true);
|
||||
m_ui->zoomSlider->setVisible(true);
|
||||
m_ui->lblZoomValue->setVisible(true);
|
||||
m_ui->sbRotation->setVisible(true);
|
||||
m_ui->lblRotation->setVisible(true);
|
||||
m_ui->sbPageNo->setEnabled(false);
|
||||
m_ui->zoomSlider->setEnabled(false);
|
||||
m_ui->sbRotation->setEnabled(false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FileTopicEditor::apply2()
|
||||
{
|
||||
setTopicDataProperty(QStringLiteral("FileId"), m_fileId);
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
setTopicDataProperty(QStringLiteral("PageNo"), m_pageNo);
|
||||
setTopicDataProperty(QStringLiteral("ZoomLevel"), m_zoomLevel);
|
||||
setTopicDataProperty(QStringLiteral("Rotation"), m_rotation);
|
||||
}
|
||||
setTopicDataProperty(QStringLiteral("UserText"), m_userText);
|
||||
setDescription(m_ui->widget->description());
|
||||
m_ui->widget->previewer()->setTopicData(m_topicData);
|
||||
|
||||
if (m_fileId == 0)
|
||||
{
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Text && !m_userText.isEmpty())
|
||||
setTopicDataProperty(QStringLiteral("FileId"), m_fileId);
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Pdf)
|
||||
{
|
||||
emit changesSaved(m_topicData);
|
||||
return true;
|
||||
setTopicDataProperty(QStringLiteral("PageNo"), m_pageNo);
|
||||
setTopicDataProperty(QStringLiteral("ZoomLevel"), m_zoomLevel);
|
||||
setTopicDataProperty(QStringLiteral("Rotation"), m_rotation);
|
||||
}
|
||||
setTopicDataProperty(QStringLiteral("UserText"), m_userText);
|
||||
setDescription(m_ui->widget->description());
|
||||
m_ui->widget->previewer()->setTopicData(m_topicData);
|
||||
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("No content was selected for this topic."), tr("Applying changes failed"));
|
||||
return false;
|
||||
}
|
||||
emit changesSaved(m_topicData);
|
||||
return true;
|
||||
if (m_fileId == 0)
|
||||
{
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::Text && !m_userText.isEmpty())
|
||||
{
|
||||
emit changesSaved(m_topicData);
|
||||
return true;
|
||||
}
|
||||
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("No content was selected for this topic."),
|
||||
tr("Applying changes failed"));
|
||||
return false;
|
||||
}
|
||||
emit changesSaved(m_topicData);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FileTopicEditor::onSelectFile()
|
||||
{
|
||||
QByteArray content;
|
||||
int folderId = 0;
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::TacticalPlan)
|
||||
folderId = m_dtc->findFolder(0, QStringLiteral("Tactical Plans"));
|
||||
int fileId = m_guiIfc->loadFileContent(this, content, m_fileTypes, 0, QString(), folderId);
|
||||
if (fileId > 0)
|
||||
{
|
||||
m_fileId = fileId;
|
||||
m_userText.clear();
|
||||
updatePreview();
|
||||
slotChangesMade();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Cannot load file from library";
|
||||
}
|
||||
QByteArray content;
|
||||
int folderId = 0;
|
||||
if (m_topicData.topicType == TopicEditorBase::TopicType::TacticalPlan)
|
||||
folderId = m_dtc->findFolder(0, QStringLiteral("Tactical Plans"));
|
||||
int fileId = m_guiIfc->loadFileContent(this, content, m_fileTypes, 0, QString(), folderId);
|
||||
if (fileId > 0)
|
||||
{
|
||||
m_fileId = fileId;
|
||||
m_userText.clear();
|
||||
updatePreview();
|
||||
slotChangesMade();
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Cannot load file from library";
|
||||
}
|
||||
}
|
||||
|
||||
void FileTopicEditor::onZoomSliderChanged()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
m_zoomLevel = m_ui->zoomSlider->value();
|
||||
m_ui->zoomSlider->setToolTip(tr("Zoom %1 %").arg(m_zoomLevel));
|
||||
m_ui->lblZoomValue->setText(QString::number(m_zoomLevel) + QStringLiteral(" %"));
|
||||
m_previewPlaybackWidget->setZoomFactor(m_zoomLevel / 100.);
|
||||
m_zoomLevel = m_ui->zoomSlider->value();
|
||||
m_ui->zoomSlider->setToolTip(tr("Zoom %1 %").arg(m_zoomLevel));
|
||||
m_ui->lblZoomValue->setText(QString::number(m_zoomLevel) + QStringLiteral(" %"));
|
||||
m_previewPlaybackWidget->setZoomFactor(m_zoomLevel / 100.);
|
||||
}
|
||||
|
||||
void FileTopicEditor::onPageNoChanged(int pageNo)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "page no = " << pageNo;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << "page no = " << pageNo;
|
||||
|
||||
m_pageNo = pageNo;
|
||||
m_ui->sbPageNo->setValue(m_pageNo);
|
||||
m_previewPlaybackWidget->setPage(m_pageNo);
|
||||
m_pageNo = pageNo;
|
||||
m_ui->sbPageNo->setValue(m_pageNo);
|
||||
m_previewPlaybackWidget->setPage(m_pageNo);
|
||||
}
|
||||
|
||||
void FileTopicEditor::onEnterText()
|
||||
{
|
||||
if (m_textEditDialog)
|
||||
{
|
||||
focusDialog(menuGroup(), QStringLiteral("FileTopicTextEditDialog"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
return;
|
||||
}
|
||||
if (m_textEditDialog)
|
||||
{
|
||||
focusDialog(menuGroup(), QStringLiteral("FileTopicTextEditDialog"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
return;
|
||||
}
|
||||
|
||||
m_textEditDialog = new LtsWidgets::LtsTextEditDialog(this);
|
||||
m_textEditDialog->enableBackgroundColor(true);
|
||||
QString html;
|
||||
m_textEditDialog = new LtsWidgets::LtsTextEditDialog(this);
|
||||
m_textEditDialog->enableBackgroundColor(true);
|
||||
QString html;
|
||||
|
||||
if (m_userText.isEmpty() && m_fileContent.id() != 0)
|
||||
{
|
||||
std::vector<uint8_t> content;
|
||||
m_getContent->getContent(m_fileContent.id(), content);
|
||||
html = QString::fromUtf8(LtsUtils::toQByteArray(content));
|
||||
}
|
||||
else
|
||||
html = m_userText;
|
||||
if (m_userText.isEmpty() && m_fileContent.id() != 0)
|
||||
{
|
||||
std::vector<uint8_t> content;
|
||||
m_getContent->getContent(m_fileContent.id(), content);
|
||||
html = QString::fromUtf8(LtsUtils::toQByteArray(content));
|
||||
}
|
||||
else
|
||||
html = m_userText;
|
||||
|
||||
|
||||
const int backGroundColorIndex = html.indexOf(QLatin1String("background-color"));
|
||||
const int backGroundColorIndex = html.indexOf(QLatin1String("background-color"));
|
||||
|
||||
if (backGroundColorIndex != -1)
|
||||
{
|
||||
const int rgbIndex = html.indexOf(QLatin1Char('#'), backGroundColorIndex);
|
||||
const QColor backGroundColor(html.mid(rgbIndex, 7));
|
||||
const int backGroundColorIndexEnd = html.indexOf(QLatin1Char(';'), backGroundColorIndex);
|
||||
if (backGroundColorIndex != -1)
|
||||
{
|
||||
const int rgbIndex = html.indexOf(QLatin1Char('#'), backGroundColorIndex);
|
||||
const QColor backGroundColor(html.mid(rgbIndex, 7));
|
||||
const int backGroundColorIndexEnd = html.indexOf(QLatin1Char(';'), backGroundColorIndex);
|
||||
|
||||
m_textEditDialog->setInitialBackgroundColor(backGroundColor);
|
||||
m_textEditDialog->setInitialBackgroundColor(backGroundColor);
|
||||
|
||||
html.remove(backGroundColorIndex, backGroundColorIndexEnd - backGroundColorIndex + 2);
|
||||
}
|
||||
html.remove(backGroundColorIndex, backGroundColorIndexEnd - backGroundColorIndex + 2);
|
||||
}
|
||||
|
||||
m_textEditDialog->setHtml(html);
|
||||
m_textEditDialog->setHtml(html);
|
||||
|
||||
connect(m_textEditDialog.data(), &LtsWidgets::LtsTextEditDialog::signalTextAppliedWithBackGroundColor,
|
||||
this, &FileTopicEditor::onCustomTextChanged);
|
||||
addDialog(m_textEditDialog, menuGroup(), QStringLiteral("FileTopicTextEditDialog"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
connect(m_textEditDialog.data(), &LtsWidgets::LtsTextEditDialog::signalTextAppliedWithBackGroundColor, this,
|
||||
&FileTopicEditor::onCustomTextChanged);
|
||||
addDialog(m_textEditDialog, menuGroup(), QStringLiteral("FileTopicTextEditDialog"),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void FileTopicEditor::onRotationChanged(int rotation)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " rotation = " << rotation;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO << " rotation = " << rotation;
|
||||
|
||||
m_rotation = rotation;
|
||||
m_ui->sbRotation->setValue(m_rotation);
|
||||
m_previewPlaybackWidget->setRotation(m_rotation);
|
||||
m_rotation = rotation;
|
||||
m_ui->sbRotation->setValue(m_rotation);
|
||||
m_previewPlaybackWidget->setRotation(m_rotation);
|
||||
}
|
||||
|
||||
void FileTopicEditor::onCustomTextChanged(const QString &htmlText)
|
||||
void FileTopicEditor::onCustomTextChanged(const QString& htmlText)
|
||||
{
|
||||
m_userText = htmlText;
|
||||
m_ui->leFileName->setText(tr("Custom text"));
|
||||
m_fileId = 0;
|
||||
m_fileContent = FileContent();
|
||||
updatePreview();
|
||||
slotChangesMade();
|
||||
m_userText = htmlText;
|
||||
m_ui->leFileName->setText(tr("Custom text"));
|
||||
m_fileId = 0;
|
||||
m_fileContent = FileContent();
|
||||
updatePreview();
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FileTopicEditor::onPreview()
|
||||
{
|
||||
if(m_ui->scrollArea == nullptr || m_ftc == nullptr)
|
||||
return;
|
||||
updatePreview();
|
||||
if (m_ui->scrollArea == nullptr || m_ftc == nullptr)
|
||||
return;
|
||||
updatePreview();
|
||||
|
||||
QScrollArea *scrollArea = new QScrollArea(m_ui->scrollArea);
|
||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
FileContentPreviewPlaybackWidget *prevWidget = new FileContentPreviewPlaybackWidget(m_ftc, m_previewPlaybackWidget);
|
||||
prevWidget->setGeometry(QRect(0, 0, 566, 69));
|
||||
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
sizePolicy1.setHorizontalStretch(0);
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
sizePolicy1.setHeightForWidth(prevWidget->sizePolicy().hasHeightForWidth());
|
||||
prevWidget->setSizePolicy(sizePolicy1);
|
||||
prevWidget->setVisible(true);
|
||||
prevWidget->init(m_fileContent, m_pageNo, m_zoomLevel / 100., m_rotation, 0, m_userText);
|
||||
QScrollArea* scrollArea = new QScrollArea(m_ui->scrollArea);
|
||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
FileContentPreviewPlaybackWidget* prevWidget = new FileContentPreviewPlaybackWidget(m_ftc, m_previewPlaybackWidget);
|
||||
prevWidget->setGeometry(QRect(0, 0, 566, 69));
|
||||
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
sizePolicy1.setHorizontalStretch(0);
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
sizePolicy1.setHeightForWidth(prevWidget->sizePolicy().hasHeightForWidth());
|
||||
prevWidget->setSizePolicy(sizePolicy1);
|
||||
prevWidget->setVisible(true);
|
||||
prevWidget->init(m_fileContent, m_pageNo, m_zoomLevel / 100., m_rotation, 0, m_userText);
|
||||
|
||||
scrollArea->setWidget(prevWidget);
|
||||
scrollArea->setWidget(prevWidget);
|
||||
|
||||
connect(prevWidget, &FileContentPreviewPlaybackWidget::currentPageChanged,
|
||||
this, &FileTopicEditor::onPageNoChanged);
|
||||
connect(prevWidget, &FileContentPreviewPlaybackWidget::currentPageChanged, this, &FileTopicEditor::onPageNoChanged);
|
||||
|
||||
connect(prevWidget, &FileContentPreviewPlaybackWidget::rotationChanged,
|
||||
this, [this, prevWidget](int rotation)
|
||||
{
|
||||
if(m_ui->sbRotation == nullptr)
|
||||
return;
|
||||
m_rotation = rotation;
|
||||
m_ui->sbRotation->setValue(m_rotation);
|
||||
prevWidget->setRotation(m_rotation);
|
||||
});
|
||||
emit signalSetTopicPosition(scrollArea, m_topicData.id);
|
||||
connect(prevWidget, &FileContentPreviewPlaybackWidget::rotationChanged, this, [this, prevWidget](int rotation) {
|
||||
if (m_ui->sbRotation == nullptr)
|
||||
return;
|
||||
m_rotation = rotation;
|
||||
m_ui->sbRotation->setValue(m_rotation);
|
||||
prevWidget->setRotation(m_rotation);
|
||||
});
|
||||
emit signalSetTopicPosition(scrollArea, m_topicData.id);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+54
-52
@@ -1,81 +1,83 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <FileManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/Gui/Explorer/flm_preview_playback.h>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <QPointer>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class FileTopicEditor;
|
||||
}
|
||||
|
||||
namespace Ui { class FileTopicEditor; }
|
||||
|
||||
namespace PresentationManagement { class TopicDesigner; }
|
||||
|
||||
namespace LtsWidgets { class LtsTextEditDialog; }
|
||||
namespace PresentationManagement
|
||||
{
|
||||
class TopicDesigner;
|
||||
}
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class LtsTextEditDialog;
|
||||
}
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
|
||||
class FileTopicEditor : public TopicEditorBase::TopicEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileTopicEditor(
|
||||
LtsSession::LtsSession *session, FileContentPreviewPlaybackWidget *previewWidget,
|
||||
const std::shared_ptr<FileManagement::Interface::Ftc> &ftc, QWidget *parent = nullptr
|
||||
);
|
||||
~FileTopicEditor();
|
||||
public:
|
||||
explicit FileTopicEditor(LtsSession::LtsSession* session, FileContentPreviewPlaybackWidget* previewWidget,
|
||||
const std::shared_ptr<FileManagement::Interface::Ftc>& ftc, QWidget* parent = nullptr);
|
||||
~FileTopicEditor();
|
||||
|
||||
void updatePreview();
|
||||
bool fetchInterfaces();
|
||||
void updatePreview();
|
||||
bool fetchInterfaces();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
void enaDisa();
|
||||
|
||||
void enaDisa();
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
void onSelectFile();
|
||||
void onZoomSliderChanged();
|
||||
void onPageNoChanged(int pageNo);
|
||||
void onRotationChanged(int rotation);
|
||||
void onEnterText();
|
||||
void onCustomTextChanged(const QString& htmlText);
|
||||
void onPreview();
|
||||
|
||||
void onSelectFile();
|
||||
void onZoomSliderChanged();
|
||||
void onPageNoChanged(int pageNo);
|
||||
void onRotationChanged(int rotation);
|
||||
void onEnterText();
|
||||
void onCustomTextChanged(const QString &htmlText);
|
||||
void onPreview();
|
||||
private:
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_dtc{nullptr};
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_guiIfc{nullptr};
|
||||
std::shared_ptr<FileManagement::Interface::Ftc> m_ftc{nullptr};
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<FileManagement::Interface::Dtc> m_dtc{nullptr};
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_guiIfc{nullptr};
|
||||
std::shared_ptr<FileManagement::Interface::Ftc> m_ftc{nullptr};
|
||||
QVector<FileManagement::FileType> m_fileTypes;
|
||||
FileManagement::GetFileContent* m_getContent{nullptr};
|
||||
FileContentPreviewPlaybackWidget* m_previewPlaybackWidget{nullptr};
|
||||
FileContent m_fileContent;
|
||||
QString m_fileName;
|
||||
int m_fileId{0};
|
||||
int m_pageNo{1};
|
||||
int m_zoomLevel{100};
|
||||
int m_rotation{0};
|
||||
QString m_userText;
|
||||
|
||||
QVector<FileManagement::FileType> m_fileTypes;
|
||||
FileManagement::GetFileContent *m_getContent{nullptr};
|
||||
FileContentPreviewPlaybackWidget *m_previewPlaybackWidget{nullptr};
|
||||
FileContent m_fileContent;
|
||||
QString m_fileName;
|
||||
int m_fileId{0};
|
||||
int m_pageNo{1};
|
||||
int m_zoomLevel{100};
|
||||
int m_rotation{0};
|
||||
QString m_userText;
|
||||
|
||||
QPointer<LtsWidgets::LtsTextEditDialog> m_textEditDialog;
|
||||
QPointer<LtsWidgets::LtsTextEditDialog> m_textEditDialog;
|
||||
|
||||
Ui::FileTopicEditor *m_ui{nullptr};
|
||||
Ui::FileTopicEditor* m_ui{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Executable → Regular
+1454
-1573
File diff suppressed because it is too large.
Load diff
Executable → Regular
+131
-159
@@ -1,188 +1,160 @@
|
||||
|
||||
|
||||
|
||||
#include "flm_dialog_model_file.h"
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <Plugins/FileManagement/flm_data_plugin_interface.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
#include <Plugins/ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <QDateTime>
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace FileManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
DialogModelFile::DialogModelFile(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<FileManagement::FileContent>(
|
||||
DialogModelFile::DialogModelFile(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<FileManagement::FileContent>(
|
||||
{tr("Name"), tr("Type"), tr("Category"), tr("Status"), tr("Template"), tr("Exercise"), tr("Phase"),
|
||||
tr("Operator"), tr("Used"), tr("Uses"), tr("Last modified"), tr("Properties"), tr("Folder Id"),
|
||||
tr("File Id")},
|
||||
parent)
|
||||
{
|
||||
tr("Name"),
|
||||
tr("Type"),
|
||||
tr("Category"),
|
||||
tr("Status"),
|
||||
tr("Template"),
|
||||
tr("Exercise"),
|
||||
tr("Phase"),
|
||||
tr("Operator"),
|
||||
tr("Used"),
|
||||
tr("Uses"),
|
||||
tr("Last modified"),
|
||||
tr("Properties"),
|
||||
tr("Folder Id"),
|
||||
tr("File Id")
|
||||
},
|
||||
parent)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
bool DialogModelFile::initModel(LtsSession::LtsSession *session,
|
||||
const QString &xmlType,
|
||||
const std::function<bool(const FileManagement::FileContent &, const QString &)> &predicate)
|
||||
{
|
||||
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc))
|
||||
return false;
|
||||
|
||||
clear();
|
||||
|
||||
|
||||
auto files = [this, xmlType, predicate](const FileManagement::FileContent & fc)
|
||||
{
|
||||
if (!predicate(fc, xmlType))
|
||||
return;
|
||||
insertRow(fc);
|
||||
};
|
||||
m_flmDtc->fileContents(files);
|
||||
DEBUG_LOG(m_logger) << "initModel - #Files: " << m_vecData.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVariant DialogModelFile::data(const QModelIndex &index, int role) const
|
||||
bool DialogModelFile::initModel(
|
||||
LtsSession::LtsSession* session, const QString& xmlType,
|
||||
const std::function<bool(const FileManagement::FileContent&, const QString&)>& predicate)
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return {};
|
||||
|
||||
const FileManagement::FileContent &fl = m_vecData.at(index.row());
|
||||
if (!session->getDtc<FileManagement::DataInterface>(m_flmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
|
||||
return false;
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(m_exmDtc))
|
||||
return false;
|
||||
|
||||
switch(role)
|
||||
{
|
||||
case Qt::BackgroundRole:
|
||||
{
|
||||
if (fl.fileStatus() == FileManagement::FileStatus::Deleted)
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
switch (index.column())
|
||||
clear();
|
||||
|
||||
auto files = [this, xmlType, predicate](const FileManagement::FileContent& fc) {
|
||||
if (!predicate(fc, xmlType))
|
||||
return;
|
||||
insertRow(fc);
|
||||
};
|
||||
m_flmDtc->fileContents(files);
|
||||
DEBUG_LOG(m_logger) << "initModel - #Files: " << m_vecData.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant DialogModelFile::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return {};
|
||||
|
||||
const FileManagement::FileContent& fl = m_vecData.at(index.row());
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(fl.name());
|
||||
case ISTEMPLATE:
|
||||
return fl.isTemplate() ? tr("Yes") : tr("No");
|
||||
case FOLDER:
|
||||
return fl.folderId();
|
||||
case FILEID:
|
||||
return fl.id();
|
||||
case FILETYPE:
|
||||
return FileManagement::toString(fl.fileType());
|
||||
case FILECATEGORY:
|
||||
return FileManagement::toString(fl.fileCategory());
|
||||
case FILESTATUS:
|
||||
return FileManagement::toString(fl.fileStatus());
|
||||
case OPERATOR:
|
||||
return QString::fromStdString(m_opmDtc->user(fl.operatorId()).name());
|
||||
case EXERCISE:
|
||||
return fl.exerciseId().is_set() ? QString::fromStdString(m_exmDtc->exercise(fl.exerciseId().get()).name()) : QVariant();
|
||||
case PHASE:
|
||||
return fl.phaseId().is_set() ? QString::fromStdString(m_exmDtc->exercisePhase(fl.phaseId().get()).name()) : QVariant();
|
||||
case USEDBY:
|
||||
return fl.isUsedBy() ? tr("Yes") : tr("No");
|
||||
case USES:
|
||||
return fl.usedBy();
|
||||
case LASTMODIFIED:
|
||||
return QDateTime::fromMSecsSinceEpoch(fl.lastModified());
|
||||
case PROPERTIES:
|
||||
return QString::fromStdString(fl.properties());
|
||||
case Qt::BackgroundRole: {
|
||||
if (fl.fileStatus() == FileManagement::FileStatus::Deleted)
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
}
|
||||
case Qt::DisplayRole: {
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(fl.name());
|
||||
case ISTEMPLATE:
|
||||
return fl.isTemplate() ? tr("Yes") : tr("No");
|
||||
case FOLDER:
|
||||
return fl.folderId();
|
||||
case FILEID:
|
||||
return fl.id();
|
||||
case FILETYPE:
|
||||
return FileManagement::toString(fl.fileType());
|
||||
case FILECATEGORY:
|
||||
return FileManagement::toString(fl.fileCategory());
|
||||
case FILESTATUS:
|
||||
return FileManagement::toString(fl.fileStatus());
|
||||
case OPERATOR:
|
||||
return QString::fromStdString(m_opmDtc->user(fl.operatorId()).name());
|
||||
case EXERCISE:
|
||||
return fl.exerciseId().is_set()
|
||||
? QString::fromStdString(m_exmDtc->exercise(fl.exerciseId().get()).name())
|
||||
: QVariant();
|
||||
case PHASE:
|
||||
return fl.phaseId().is_set()
|
||||
? QString::fromStdString(m_exmDtc->exercisePhase(fl.phaseId().get()).name())
|
||||
: QVariant();
|
||||
case USEDBY:
|
||||
return fl.isUsedBy() ? tr("Yes") : tr("No");
|
||||
case USES:
|
||||
return fl.usedBy();
|
||||
case LASTMODIFIED:
|
||||
return QDateTime::fromMSecsSinceEpoch(fl.lastModified());
|
||||
case PROPERTIES:
|
||||
return QString::fromStdString(fl.properties());
|
||||
}
|
||||
}
|
||||
case Qt::DecorationRole: {
|
||||
if (index.column() == NAME && fl.isHidden())
|
||||
return QIcon(QLatin1String(":/style/lock.svg"));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
if (index.column() == NAME && fl.isHidden())
|
||||
return QIcon(QLatin1String(":/style/lock.svg"));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
FileManagement::FileContent DialogModelFile::findFileFromName(const QString &fileName) const
|
||||
FileManagement::FileContent DialogModelFile::findFileFromName(const QString& fileName) const
|
||||
{
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
const FileManagement::FileContent &fl = m_vecData.at(row);
|
||||
if (QString::fromStdString(fl.name()) == fileName)
|
||||
return fl;
|
||||
}
|
||||
return FileManagement::FileContent();
|
||||
}
|
||||
|
||||
void DialogFileProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<DialogModelFile*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
const FileManagement::FileContent& fl = m_vecData.at(row);
|
||||
if (QString::fromStdString(fl.name()) == fileName)
|
||||
return fl;
|
||||
}
|
||||
return FileManagement::FileContent();
|
||||
}
|
||||
|
||||
bool DialogFileProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
void DialogFileProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
m_sourceModel = qobject_cast<DialogModelFile*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool DialogFileProxyModel::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 LASTMODIFIED:
|
||||
return dataLeft.lastModified() < dataRight.lastModified();
|
||||
case NAME:
|
||||
case FILETYPE:
|
||||
case FILECATEGORY:
|
||||
case FILESTATUS:
|
||||
case ISTEMPLATE:
|
||||
case EXERCISE:
|
||||
case PHASE:
|
||||
case OPERATOR:
|
||||
case USEDBY:
|
||||
case USES:
|
||||
case PROPERTIES:
|
||||
case FOLDER:
|
||||
case FILEID:
|
||||
case COUNT:
|
||||
break;
|
||||
}
|
||||
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 LASTMODIFIED:
|
||||
return dataLeft.lastModified() < dataRight.lastModified();
|
||||
case NAME:
|
||||
case FILETYPE:
|
||||
case FILECATEGORY:
|
||||
case FILESTATUS:
|
||||
case ISTEMPLATE:
|
||||
case EXERCISE:
|
||||
case PHASE:
|
||||
case OPERATOR:
|
||||
case USEDBY:
|
||||
case USES:
|
||||
case PROPERTIES:
|
||||
case FOLDER:
|
||||
case FILEID:
|
||||
case COUNT:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace FileManagement
|
||||
Reference in new issue
Block a user