Close ppm.msdl/ppm.saab floors: re-implement MSDL/SAAB import without Qt XmlPatterns

Qt6::Xml (QDomDocument) + xmllint schema check; MSDL links XercesC + xsdc++ tree classes; both moved into GROUP12
This commit is contained in:
berrux-dev committed 2026-10-24 19:31:04 +02:00
1 parent 3924b1e72b
commit 8e9594d25c
18 files changed
+179 -248

No files matched your search

@@ -43,6 +43,9 @@ SET(zwmssaab_UICS
ui/saab_mapping_dialog.ui
)
# .ui files live in the ui/ subdirectory; tell AUTOUIC where to find them
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)
NGL_WRAP_UI(zwmssaab_SRCS ${zwmssaab_UICS})
NGL_ADD_LIBRARY2(WS zwmssaab SHARED ${zwmssaab_SRCS} ${zwmssaab_UICS} ${zwmssaab_IDLS})
NGL_TARGET_INCLUDE_DIRECTORIES(zwmssaab
@@ -55,7 +58,6 @@ if(QT6_GUI_AVAILABLE)
PRIVATE
${Qt6_Gui}
Qt6::Xml
Qt6::XmlPatterns
PUBLIC
svcPpmCommon
LtsUtilsSettings
@@ -45,6 +45,7 @@ ExportSaab::ExportSaab(LtsSession::LtsSession *session, const std::shared_ptr<Pa
, m_session(session)
, m_configFile(nullptr)
, m_ui(new Ui_SAABExport)
, m_logger(saab::getLogger("ExportSaab"))
{
m_ui->setupUi(this);
@@ -369,13 +370,13 @@ void ExportSaab::writeExercise(QXmlStreamWriter *writer) const
using namespace XmlStrings;
writer->writeStartElement(SAAB_EXERCISE());
writer->writeAttribute(SAAB_ID(), QUuid(l, m_currentExercise.id(), w2, b1, b2, b3, b4, b5, b6, b7, GuidContext::GuidExercise).toString(QUuid::WithoutBraces));
writer->writeAttribute(SAAB_ID(), QUuid(l, m_currentExercise.id, w2, b1, b2, b3, b4, b5, b6, b7, GuidContext::GuidExercise).toString(QUuid::WithoutBraces));
writer->writeTextElement(SAAB_EXPORT_TIME(), toSaabTime(m_session->partitionTime()));
writer->writeTextElement(SAAB_PLANNED_START_TIME(), toSaabTime(m_currentExercise.beginTime()));
writer->writeTextElement(SAAB_PLANNED_STOP_TIME(), toSaabTime(m_currentExercise.endTime()));
writer->writeTextElement(SAAB_DESIGNATION(), QString::fromStdString(m_currentExercise.name()));
writer->writeTextElement(SAAB_DESCRIPTION(), QString::fromStdString(m_currentExercise.description()));
writer->writeTextElement(SAAB_PLANNED_START_TIME(), toSaabTime(m_currentExercise.beginTime));
writer->writeTextElement(SAAB_PLANNED_STOP_TIME(), toSaabTime(m_currentExercise.endTime));
writer->writeTextElement(SAAB_DESIGNATION(), QString::fromStdString(m_currentExercise.name));
writer->writeTextElement(SAAB_DESCRIPTION(), QString::fromStdString(m_currentExercise.description));
writer->writeTextElement(SAAB_WIND_SPEED(), QStringLiteral("0"));
writer->writeTextElement(SAAB_WIND_DIRECTION(), QStringLiteral("0"));
writer->writeEmptyElement(SAAB_EVALUATION_PACKAGE_FILE_NAME());
@@ -420,13 +421,13 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Party &party,
result = new SaabUnit;
result->symbol = m_mapPartyToForce.value(party.id()).symbolCode;
static_cast<SaabUnit *>(result)->unitSize = m_mapPartyToForce.value(party.id()).echelonCode;
result->designation = QString::fromStdString(party.name());
result->symbol = m_mapPartyToForce.value(party.id).symbolCode;
static_cast<SaabUnit *>(result)->unitSize = m_mapPartyToForce.value(party.id).echelonCode;
result->designation = QString::fromStdString(party.name);
result->trashcan = false;
result->isExternalPlayer = true;
result->force = m_mapPartyToForce.value(party.id()).forceCode;
result->guid = QUuid(l, m_currentExercise.id(), w2, static_cast<uchar>(party.id()), b2, b3, b4, b5, b6, b7, GuidContext::GuidParty).toString(QUuid::WithoutBraces);
result->force = m_mapPartyToForce.value(party.id).forceCode;
result->guid = QUuid(l, m_currentExercise.id, w2, static_cast<uchar>(party.id), b2, b3, b4, b5, b6, b7, GuidContext::GuidParty).toString(QUuid::WithoutBraces);
QList<int> keys = remainingParticipants.keys();
@@ -438,7 +439,7 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Party &party,
ParticipantManagement::Participant participant = remainingParticipants.value(key);
if (!(participant.partyId() == party.id() && participant.superiorId() == 0))
if (!(participant.partyId == party.id && participant.superiorId == 0))
continue;
SaabPlayer *player = toSaabPlayer(participant, remainingParticipants);
@@ -454,26 +455,26 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Party &party,
SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Participant &participant, QMap<int, ParticipantManagement::Participant> &remainingParticipants)
{
if (participant.isDeleted())
if (participant.isDeleted)
{
DEBUG_LOG(m_logger) << "Participant with id " << participant.id() << " id deleted --> skipping";
DEBUG_LOG(m_logger) << "Participant with id " << participant.id << " id deleted --> skipping";
return nullptr;
}
if (participant.externalId())
if (participant.externalId)
{
DEBUG_LOG(m_logger) << "Particpant with id " << participant.id() << " has external ID set to " << participant.externalId() << " --> not being exported.";
DEBUG_LOG(m_logger) << "Particpant with id " << participant.id << " has external ID set to " << participant.externalId << " --> not being exported.";
return nullptr;
}
SaabPlayer *result;
ParticipantManagement::Type type = m_types.value(participant.typeId());
ParticipantManagement::Type type = m_types.value(participant.typeId);
if (!m_mapTypeToSaabSymbol.contains(type.id()))
if (!m_mapTypeToSaabSymbol.contains(type.id))
mapType(type);
switch (type.typeClass())
switch (type.typeClass)
{
case ParticipantManagement::TypeClass::SupportEntity:
result = new SaabOcPlayer;
@@ -491,9 +492,9 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Participant &p
{
result = new SaabUnit;
DEBUG_LOG(m_logger) << "Reading unit with " << participant.inferiorIds().size() << " inferiors";
DEBUG_LOG(m_logger) << "Reading unit with " << participant.inferiorIds.size() << " inferiors";
for (int32_t id : participant.inferiorIds())
for (int32_t id : participant.inferiorIds)
{
SaabPlayer *player = toSaabPlayer(remainingParticipants.value(id), remainingParticipants);
@@ -509,7 +510,7 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Participant &p
if (!static_cast<SaabUnit *>(result)->inferiors.size())
{
DEBUG_LOG(m_logger) << "Unit " << participant.id() << " has no inferiors.";
DEBUG_LOG(m_logger) << "Unit " << participant.id << " has no inferiors.";
return nullptr;
}
@@ -519,11 +520,11 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Participant &p
case ParticipantManagement::TypeClass::Aircraft:
case ParticipantManagement::TypeClass::Unknown:
default:
DEBUG_LOG(m_logger) << "Type " << participant.typeId() << " is not supported.";
DEBUG_LOG(m_logger) << "Type " << participant.typeId << " is not supported.";
return nullptr;
}
QString symbol = m_mapTypeToSaabSymbol.value(type.id());
QString symbol = m_mapTypeToSaabSymbol.value(type.id);
if (typeid(*result) == typeid(SaabUnit))
{
@@ -535,22 +536,22 @@ SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Participant &p
else
result->symbol = symbol;
result->designation = QString::fromStdString(participant.designator());
result->trashcan = participant.isDeleted();
result->designation = QString::fromStdString(participant.designator);
result->trashcan = participant.isDeleted;
result->rank = QStringLiteral("OF1");
result->isExternalPlayer = true;
if (participant.equipmentNumber().has_value())
result->simulatorId = participant.equipmentNumber().get();
result->force = m_mapPartyToForce.value(participant.partyId()).forceCode;
result->guid = QUuid(participant.id(), m_currentExercise.id(), w2, static_cast<uchar>(participant.partyId()), b2, b3, b4, b5, b6, b7, GuidContext::GuidParticipant).toString(QUuid::WithoutBraces);
if (participant.equipmentNumber.has_value())
result->simulatorId = participant.equipmentNumber.get();
result->force = m_mapPartyToForce.value(participant.partyId).forceCode;
result->guid = QUuid(participant.id, m_currentExercise.id, w2, static_cast<uchar>(participant.partyId), b2, b3, b4, b5, b6, b7, GuidContext::GuidParticipant).toString(QUuid::WithoutBraces);
return result;
}
ParticipantManagement::Participant ExportSaab::rootParticipant(const ParticipantManagement::Participant &participant, const QMap<int, ParticipantManagement::Participant> &participants) const
{
if (participant.superiorId())
return rootParticipant(participants.value(participant.superiorId()), participants);
if (participant.superiorId)
return rootParticipant(participants.value(participant.superiorId), participants);
return participant;
}
@@ -563,10 +564,10 @@ void ExportSaab::mapType(const ParticipantManagement::Type &type)
{
using namespace ParticipantManagement;
MapType dialog(ParticipantManagement::trTypeName(type.name()),
MapType dialog(ParticipantManagement::trTypeName(type.name),
m_mapEchelons,
m_mapSymbols,
type.typeClass() == TypeClass::Unit || type.typeClass() == TypeClass::SupportUnit,
type.typeClass == TypeClass::Unit || type.typeClass == TypeClass::SupportUnit,
this);
dialog.exec();
@@ -579,19 +580,19 @@ void ExportSaab::mapType(const ParticipantManagement::Type &type)
saabTypeStr.append(dialog.echelonCode());
}
m_mapTypeToSaabSymbol.insert(type.id(), saabTypeStr);
m_mapTypeToSaabSymbol.insert(type.id, saabTypeStr);
}
void ExportSaab::mapPartyToForce(const ParticipantManagement::Party &party)
{
MapParty dialog(QString::fromStdString(party.name()), m_mapForces, m_mapEchelons, m_mapSymbols, this);
MapParty dialog(QString::fromStdString(party.name), m_mapForces, m_mapEchelons, m_mapSymbols, this);
dialog.exec();
if (dialog.isSkipped())
return;
m_mapPartyToForce.insert(party.id(), { m_mapForces.take(dialog.force()), dialog.echelonCode(), dialog.symbolCode() });
m_mapPartyToForce.insert(party.id, { m_mapForces.take(dialog.force()), dialog.echelonCode(), dialog.symbolCode() });
}
}
@@ -166,17 +166,16 @@ ParticipantManagement::ParticipantData ImportSaab::createParticipant(SaabPlayer
p.tacticalIdentifier(player->designation.toStdString());
p.tacticalIdentifier = player->designation.toStdString();
p.equipmentNumber(player->simulatorId != INT_MIN ? player->simulatorId : 0);
p.assignState() = ParticipantManagement::ParticipantAssignState::HandoutExcon;
p.equipmentNumber = (player->simulatorId != INT_MIN ? player->simulatorId : 0);
p.assignState = ParticipantManagement::ParticipantAssignState::HandoutExcon;
if (player->simulatorId != INT_MIN)
p.externalId(player->simulatorId);
p.externalId = player->simulatorId;
p.symbol(m_mapTypes[player->mappedTypeId].symbol());
p.typeId(player->mappedTypeId);
p.symbol = m_mapTypes[player->mappedTypeId].symbol;
p.typeId = player->mappedTypeId;
return p;
}
@@ -192,7 +191,7 @@ void ImportSaab::insertParty(SaabUnit *party)
{
ParticipantManagement::ParticipantData newParty;
newParty.designator(party->designation.toStdString());
newParty.designator = party->designation.toStdString();
createNode(newParty, m_indexRoot, party);
}
@@ -182,18 +182,3 @@ void ImportSaabShow::slotCustomContextMenuActionTriggered(QAction *ac)
}
void SchemaMessageHandler::handleMessage(QtMsgType type,
const QString &description,
const QUrl &identifier,
const QSourceLocation &sourceLocation)
{
ERROR_LOG(mLogger) << "type: " << type << " desc: " << description;
if (identifier.isValid())
ERROR_LOG(mLogger) << "identifier: " << identifier.toString();
if (!sourceLocation.isNull())
ERROR_LOG(mLogger) << "sourceLocation: "
<< sourceLocation.uri().toString()
<< " line: " << sourceLocation.line()
<< " column: " << sourceLocation.column()
;
}
@@ -4,7 +4,6 @@
#pragma once
#include <QtXml/QDomDocument>
#include <QtXmlPatterns/QAbstractMessageHandler>
#include <nglwidgets/ngldialog.h>
#include "saab_logging.h"
@@ -13,25 +12,6 @@
namespace saab
{
class SchemaMessageHandler : public QAbstractMessageHandler
{
Q_OBJECT
public:
explicit SchemaMessageHandler(QObject *parent = nullptr)
: QAbstractMessageHandler(parent)
, mLogger(getLogger("SchemaMessageHandler"))
{}
~SchemaMessageHandler()
{}
protected:
void handleMessage(QtMsgType type,
const QString &description,
const QUrl &identifier = QUrl(),
const QSourceLocation &sourceLocation = QSourceLocation());
private:
LOGGER_T mLogger;
};
class ImportSaabShow : public NGLDialog
{
Q_OBJECT
@@ -26,16 +26,16 @@ MappingDialog::MappingDialog(QWidget *parent, bool typeClassIsUnit, const QStrin
for (const ParticipantManagement::Type &type : std::as_const(m_mapTypes))
{
if (!m_offerDatabaseEntriesWithoutDISType && (type.disEntities().size() == 0))
if (!m_offerDatabaseEntriesWithoutDISType && (type.disEntities.size() == 0))
{
WARNING_LOG(mLogger) << "Type id " << type.id() << " does not have assigned DIS types! Type cannot be used when importing SAAB data!";
WARNING_LOG(mLogger) << "Type id " << type.id << " does not have assigned DIS types! Type cannot be used when importing SAAB data!";
continue;
}
if (type.isDeleted())
if (type.isDeleted)
continue;
const ParticipantManagement::TypeClass typeClassId = type.typeClass();
const ParticipantManagement::TypeClass typeClassId = type.typeClass;
if (typeClassId == ParticipantManagement::TypeClass::Unknown ||
typeClassId == ParticipantManagement::TypeClass::Vessel ||
@@ -57,7 +57,7 @@ MappingDialog::MappingDialog(QWidget *parent, bool typeClassIsUnit, const QStrin
}
for (const auto &typeclass : setTypeClasses)
mUi->m_ltsComboBox_typeClass->addItem(ParticipantManagement::toString(typeclass), typeclass);
mUi->m_ltsComboBox_typeClass->addItem(ParticipantManagement::toString(typeclass), static_cast<int>(typeclass));
slotClassTypeChanged();
@@ -76,24 +76,24 @@ void MappingDialog::slotClassTypeChanged()
{
mUi->m_ltsComboBox_type->clear();
int currentClass = mUi->m_ltsComboBox_typeClass->currentData().toInt();
ParticipantManagement::TypeClass currentClass = static_cast<ParticipantManagement::TypeClass>(mUi->m_ltsComboBox_typeClass->currentData().toInt());
for (const ParticipantManagement::Type &type : std::as_const(m_mapTypes))
{
if(type.isDeleted())
if(type.isDeleted)
continue;
if (type.typeClass() != currentClass)
if (type.typeClass != currentClass)
continue;
if (!m_offerDatabaseEntriesWithoutDISType && (type.disEntities().size() == 0))
if (!m_offerDatabaseEntriesWithoutDISType && (type.disEntities.size() == 0))
{
WARNING_LOG(mLogger) << "Type id " << type.id() << " does not have assigned DIS types! Type cannot be used when importing SAAB data!";
WARNING_LOG(mLogger) << "Type id " << type.id << " does not have assigned DIS types! Type cannot be used when importing SAAB data!";
continue;
}
mUi->m_ltsComboBox_type->addItem(QString::fromStdString(type.name()), type.id());
mUi->m_ltsComboBox_type->addItem(QString::fromStdString(type.name), type.id);
}
}
@@ -126,6 +126,6 @@ bool MappingDialog::skipAllUnmappedElements() const
int32_t MappingDialog::getMappedTypeId() const
{
int index = mUi->m_ltsComboBox_type->currentData().toInt();
return m_mapTypes[index].id();
return m_mapTypes[index].id;
}
}