Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# @RDE_HEADER@
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(zwmssaab_SRCS
|
||||
saab_export.cpp
|
||||
saab_export.h
|
||||
saab_import.cpp
|
||||
saab_import.h
|
||||
saab_import_show.cpp
|
||||
saab_import_show.h
|
||||
saab_logging.cpp
|
||||
saab_logging.h
|
||||
saab_mapping_dialog.cpp
|
||||
saab_mapping_dialog.h
|
||||
saab_map_type.cpp
|
||||
saab_map_type.h
|
||||
saab_map_party.cpp
|
||||
saab_map_party.h
|
||||
saab_types.cpp
|
||||
saab_types.h
|
||||
saab_xml_strings.h
|
||||
zwmssaab_export.h
|
||||
)
|
||||
|
||||
SET(zwmssaab_UICS
|
||||
ui/saab_import_show.ui
|
||||
ui/saab_export.ui
|
||||
ui/saab_map_type.ui
|
||||
ui/saab_map_party.ui
|
||||
ui/saab_import.ui
|
||||
ui/saab_mapping_dialog.ui
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(zwmssaab_SRCS ${zwmssaab_UICS})
|
||||
NGL_ADD_LIBRARY(WS zwmssaab SHARED ${zwmssaab_SRCS} ${zwmssaab_UICS} ${zwmssaab_IDLS})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(zwmssaab
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(zwmssaab
|
||||
PRIVATE
|
||||
Qt5::Gui
|
||||
Qt5::Xml
|
||||
Qt5::XmlPatterns
|
||||
PUBLIC
|
||||
svcPpmCommon
|
||||
LtsUtilsSettings
|
||||
LtsUtilsGuiDds
|
||||
LtsSession
|
||||
PpmDataPluginInterface
|
||||
PpmCommon
|
||||
ExmDataPluginInterface
|
||||
OpmDataPluginInterface
|
||||
LtsSessionData
|
||||
ngltools
|
||||
NGLLogger
|
||||
LtsWidgets
|
||||
Qt5::Core
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(zwmssaab)
|
||||
@@ -0,0 +1,620 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Exportieren von SAAB-Dateien
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "saab_export.h"
|
||||
#include "ui_saab_export.h"
|
||||
#include "saab_xml_strings.h"
|
||||
#include "saab_map_type.h"
|
||||
#include "saab_map_party.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDateTime>
|
||||
#include <QUuid>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
|
||||
/*
|
||||
* QUuid::QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8)
|
||||
* Creates a UUID with the value specified by the parameters, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8.
|
||||
* General QUuid format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
* The vaues will be visualized in HEX-Code.
|
||||
|
||||
* Used QUuid Format: aaaaaaaa-bbbb-xxxx-ccxx-xxxxxxxxxxdd
|
||||
* a = Participant ID, Parameter: l
|
||||
* b = Exercise ID, Parameter: w1
|
||||
* c = Party ID, Parameter: b1
|
||||
* d = GUID Context, Parameter: b8
|
||||
* 1 = Exercise
|
||||
* 2 = Party
|
||||
* 3 = Participant
|
||||
* x = Unused, curretly filled with '0'
|
||||
*
|
||||
* Exercise format: xxxxxxxx-bbbb-xxxx-xxxx-xxxxxxxxxx01
|
||||
* Party format: xxxxxxxx-bbbb-xxxx-ccxx-xxxxxxxxxx02
|
||||
* Participant format: aaaaaaaa-bbbb.xxxx.ccxx-xxxxxxxxxx03
|
||||
*/
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
static const QString xmlnsValue(QStringLiteral("http://www.saab.se/training/schemas/ExerciseOrbat/1.1.1"));
|
||||
static const uint l = 0;
|
||||
static const ushort w1 = 0;
|
||||
static const ushort w2 = 0x88;
|
||||
static const uchar b1 = 0;
|
||||
static const uchar b2 = 0xde;
|
||||
static const uchar b3 = 0xad;
|
||||
static const uchar b4 = 0xbe;
|
||||
static const uchar b5 = 0xef;
|
||||
static const uchar b6 = 0x33;
|
||||
static const uchar b7 = 0x44;
|
||||
static const uchar b8 = 0;
|
||||
|
||||
ExportSaab::ExportSaab(LtsSession::LtsSession *session, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc, const ExerciseManagement::Exercise &exercise, QWidget *parent)
|
||||
: LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_currentExercise(exercise)
|
||||
, m_ppmDtc(ppmDtc)
|
||||
, m_session(session)
|
||||
, m_configFile(nullptr)
|
||||
, m_ui(new Ui_SAABExport)
|
||||
, m_logger(getLogger("ExportSaab"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->m_pushbutton_SelectConfig, &QToolButton::clicked,
|
||||
this, &ExportSaab::onSelectConfigFile);
|
||||
connect(m_ui->m_pushbutton_SelectFile, &QToolButton::clicked,
|
||||
this, &ExportSaab::onSelectExportFile);
|
||||
connect(m_ui->m_pushButton_StartImport, &QPushButton::clicked,
|
||||
this, &ExportSaab::onStartExport);
|
||||
|
||||
QString strExportFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedExportFile"), QString()).toString();
|
||||
QString strConfigFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QString()).toString();
|
||||
|
||||
m_ui->m_lineedit_ExportFile->setText(strExportFile);
|
||||
m_ui->m_lineedit_ConfigFile->setText(strConfigFile);
|
||||
|
||||
m_ui->m_pushButton_StartImport->setEnabled(strExportFile.size() && strConfigFile.size());
|
||||
|
||||
m_parties = m_ppmDtc->partys();
|
||||
m_types = m_ppmDtc->types();
|
||||
}
|
||||
|
||||
ExportSaab::~ExportSaab()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ExportSaab::onStartExport()
|
||||
{
|
||||
QString strExportFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedExportFile"), QString()).toString();
|
||||
QString strConfigFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QString()).toString();
|
||||
|
||||
QFile file(strExportFile);
|
||||
|
||||
if (m_configFile)
|
||||
{
|
||||
m_configFile->close();
|
||||
delete m_configFile;
|
||||
m_configFile = nullptr;
|
||||
}
|
||||
|
||||
m_configFile = new QFile(strConfigFile, this);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Not possible to start export. You do not have the permission to write the selected file."));
|
||||
ERROR_LOG(m_logger) << "Could not export exercise: \"" << strExportFile << "\" could not be opened for writing";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValidConfigFile())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Not possible to start export. Config file invalid."));
|
||||
ERROR_LOG(m_logger) << "Could not export exercise: \"" << strConfigFile << "\" invalid";
|
||||
return;
|
||||
}
|
||||
|
||||
importConfig();
|
||||
|
||||
QXmlStreamWriter writer(&file);
|
||||
|
||||
writer.setAutoFormatting(true);
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement(XmlStrings::SAAB_EXERCISE_ORBAT());
|
||||
writer.writeAttribute(XmlStrings::SAAB_XMLNS_XSI(), QStringLiteral("http://www.w3.org/2001/XMLSchema-instance"));
|
||||
writer.writeAttribute(XmlStrings::SAAB_XMLNS_XSD(), QStringLiteral("http://www.w3.org/2001/XMLSchema"));
|
||||
writer.writeAttribute(XmlStrings::SAAB_XMLNS(), xmlnsValue);
|
||||
|
||||
writeExercise(&writer);
|
||||
writeOrbat(&writer);
|
||||
writeFooter(&writer);
|
||||
|
||||
writer.writeEndElement();
|
||||
writer.writeEndDocument();
|
||||
|
||||
file.close();
|
||||
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Export finished"));
|
||||
close();
|
||||
}
|
||||
|
||||
void ExportSaab::onSelectConfigFile()
|
||||
{
|
||||
QString strPathSelectedConfigFolder = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFolder"), QStringLiteral("/shd/CTC/TOOLS/TDS/")).toString();
|
||||
QString strPathSelectedConfigFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QStringLiteral("/shd/CTC/TOOLS/TDS/")).toString();
|
||||
|
||||
QList<QUrl> urls;
|
||||
urls << QUrl::fromLocalFile(strPathSelectedConfigFile);
|
||||
|
||||
QFileDialog fileDialog(this, tr("Select File"), strPathSelectedConfigFolder, tr("XML files (*.xml)"));
|
||||
fileDialog.setSidebarUrls(urls);
|
||||
fileDialog.setOptions(QFileDialog::ReadOnly);
|
||||
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if (fileDialog.exec()) // TODO: use show(), use signals & slots !
|
||||
{
|
||||
strPathSelectedConfigFile = fileDialog.selectedFiles().constFirst();
|
||||
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFolder"), strPathSelectedConfigFolder);
|
||||
|
||||
if (!strPathSelectedConfigFile.size())
|
||||
return;
|
||||
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), strPathSelectedConfigFile);
|
||||
m_ui->m_lineedit_ConfigFile->setText(strPathSelectedConfigFile);
|
||||
m_ui->m_pushButton_StartImport->setEnabled(LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedExportFile"), QString()).toString().size());
|
||||
}
|
||||
}
|
||||
|
||||
void ExportSaab::onSelectExportFile()
|
||||
{
|
||||
QString strPathSelectedExportFolder = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedExportFolder"), QStringLiteral("/tmp")).toString();
|
||||
QString strPathSelectedExportFile = QFileDialog::getSaveFileName(this, tr("Export file"),
|
||||
strPathSelectedExportFolder,
|
||||
tr("XML files (*.xml)"));
|
||||
if (strPathSelectedExportFile.isEmpty())
|
||||
return;
|
||||
|
||||
strPathSelectedExportFolder = strPathSelectedExportFile.mid(0, strPathSelectedExportFile.lastIndexOf(QLatin1Char('/')));
|
||||
|
||||
QString suffix = QStringLiteral(".xml");
|
||||
|
||||
if (!strPathSelectedExportFile.endsWith(suffix))
|
||||
strPathSelectedExportFile += suffix;
|
||||
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedExportFolder"), strPathSelectedExportFolder);
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedExportFile"), strPathSelectedExportFile);
|
||||
|
||||
m_ui->m_lineedit_ExportFile->setText(strPathSelectedExportFile);
|
||||
m_ui->m_pushButton_StartImport->setEnabled(LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QString()).toString().size());
|
||||
}
|
||||
|
||||
bool ExportSaab::isValidConfigFile()
|
||||
{
|
||||
if (!m_configFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: No file selected";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_configFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: Could not open file \""
|
||||
<< m_configFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return false;
|
||||
}
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
QXmlStreamReader reader(m_configFile);
|
||||
|
||||
bool hasSymbols = false;
|
||||
bool hasEchelons = false;
|
||||
bool hasForces = false;
|
||||
|
||||
while (!reader.atEnd() && !(hasSymbols && hasEchelons && hasForces))
|
||||
{
|
||||
if (reader.readNextStartElement())
|
||||
{
|
||||
if (reader.name() == SAAB_SYMBOLS())
|
||||
hasSymbols = true;
|
||||
else if (reader.name() == SAAB_ECHELONS())
|
||||
hasEchelons = true;
|
||||
else if (reader.name() == SAAB_FORCES())
|
||||
hasForces = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_configFile->close();
|
||||
|
||||
if (!hasEchelons)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_ECHELONS() << " in file \"" << m_configFile->fileName() << '\"';
|
||||
if (!hasSymbols)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_SYMBOLS() << " in file \"" << m_configFile->fileName() << '\"';
|
||||
if (!hasForces)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_FORCES() << " in file \"" << m_configFile->fileName() << '\"';
|
||||
|
||||
return hasEchelons && hasSymbols && hasForces;
|
||||
}
|
||||
|
||||
void ExportSaab::importConfig()
|
||||
{
|
||||
if (!m_mapSymbols.isEmpty() || !m_mapEchelons.isEmpty())
|
||||
{
|
||||
using namespace LtsWidgets;
|
||||
|
||||
Button b = LtsMessageDialog::showMessage(this,
|
||||
tr("A config is already imported. Overwrite?"),
|
||||
tr("Overwrite config?"),
|
||||
Behaviour::Modal,
|
||||
Button::Yes | Button::No);
|
||||
if (b != Button::Yes)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_configFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: No file selected";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_configFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: Could not open file \""
|
||||
<< m_configFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return;
|
||||
}
|
||||
|
||||
m_mapSymbols.clear();
|
||||
m_mapEchelons.clear();
|
||||
m_mapTypeToSaabSymbol.clear();
|
||||
m_mapPartyToForce.clear();
|
||||
m_mapForces.clear();
|
||||
|
||||
QXmlStreamReader reader(m_configFile);
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (!reader.atEnd())
|
||||
{
|
||||
if (reader.readNextStartElement())
|
||||
{
|
||||
if (reader.name() == SAAB_SYMBOL())
|
||||
{
|
||||
SaabSymbol newSymbol = readSymbol(&reader);
|
||||
m_mapSymbols.insert(newSymbol.code, newSymbol);
|
||||
}
|
||||
else if (reader.name() == SAAB_ECHELON())
|
||||
{
|
||||
SaabEchelon newEchelon = readEchelon(&reader);
|
||||
m_mapEchelons.insert(newEchelon.code, newEchelon);
|
||||
}
|
||||
else if (reader.name() == SAAB_FORCE())
|
||||
{
|
||||
SaabForce newForce = readForce(&reader);
|
||||
m_mapForces.insert(newForce.text, newForce.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_configFile->close();
|
||||
|
||||
for (auto it = m_parties.constBegin(); it != m_parties.constEnd(); ++it)
|
||||
{
|
||||
if (m_mapForces.isEmpty())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("All Forces are mapped."));
|
||||
break;
|
||||
}
|
||||
|
||||
mapPartyToForce(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
SaabSymbol ExportSaab::readSymbol(QXmlStreamReader *reader) const
|
||||
{
|
||||
SaabSymbol result;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (reader->readNext() != QXmlStreamReader::EndElement && reader->name() != SAAB_SYMBOL())
|
||||
{
|
||||
if (reader->name() == SAAB_CODE())
|
||||
result.code = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TEXT())
|
||||
result.text = reader->readElementText();
|
||||
else if (reader->name() == SAAB_SYMBOL_ID())
|
||||
result.symbolId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_MODEL_ID())
|
||||
result.modelId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_ECHELON_ID())
|
||||
result.echelonId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_PLAYER_TYPE_ID())
|
||||
result.playerTypeId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_COLOR())
|
||||
result.color = reader->readElementText();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabEchelon ExportSaab::readEchelon(QXmlStreamReader *reader) const
|
||||
{
|
||||
SaabEchelon result;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (reader->readNext() != QXmlStreamReader::EndElement && reader->name() != SAAB_ECHELON())
|
||||
{
|
||||
if (reader->name() == SAAB_CODE())
|
||||
result.code = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TEXT())
|
||||
result.text = reader->readElementText();
|
||||
else if (reader->name() == SAAB_ID())
|
||||
result.id = reader->readElementText();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabForce ExportSaab::readForce(QXmlStreamReader *reader) const
|
||||
{
|
||||
SaabForce result;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (reader->readNext() != QXmlStreamReader::EndElement && reader->name() != SAAB_FORCE())
|
||||
{
|
||||
if (reader->name() == SAAB_CODE())
|
||||
result.code = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TEXT())
|
||||
result.text = reader->readElementText();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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->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_WIND_SPEED(), QStringLiteral("0"));
|
||||
writer->writeTextElement(SAAB_WIND_DIRECTION(), QStringLiteral("0"));
|
||||
writer->writeEmptyElement(SAAB_EVALUATION_PACKAGE_FILE_NAME());
|
||||
writer->writeTextElement(SAAB_EXERCISE_STATE(), QStringLiteral("0"));
|
||||
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
void ExportSaab::writeOrbat(QXmlStreamWriter *writer)
|
||||
{
|
||||
using namespace XmlStrings;
|
||||
|
||||
writer->writeStartElement(SAAB_ORBAT());
|
||||
|
||||
QMap<int, ParticipantManagement::Participant> participants = m_ppmDtc->participants();
|
||||
|
||||
for (auto it = m_mapPartyToForce.constBegin(); it != m_mapPartyToForce.constEnd(); ++it)
|
||||
{
|
||||
SaabPlayer *player = toSaabPlayer(m_parties.value(it.key()), participants);
|
||||
|
||||
player->writeToXml(writer);
|
||||
|
||||
delete player;
|
||||
player = nullptr;
|
||||
}
|
||||
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
void ExportSaab::writeFooter(QXmlStreamWriter *writer) const
|
||||
{
|
||||
using namespace XmlStrings;
|
||||
|
||||
writer->writeEmptyElement(SAAB_PERSONS());
|
||||
writer->writeEmptyElement(SAAB_VEHICLES());
|
||||
writer->writeEmptyElement(SAAB_HELICOPTERS());
|
||||
}
|
||||
|
||||
SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Party &party, QMap<int, ParticipantManagement::Participant> &remainingParticipants)
|
||||
{
|
||||
SaabPlayer *result;
|
||||
|
||||
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->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);
|
||||
|
||||
QList<int> keys = remainingParticipants.keys();
|
||||
|
||||
// add the root units/participants
|
||||
for (int key : qAsConst(keys))
|
||||
{
|
||||
if (!remainingParticipants.contains(key))
|
||||
continue;
|
||||
|
||||
ParticipantManagement::Participant participant = remainingParticipants.value(key);
|
||||
|
||||
if (!(participant.partyId() == party.id() && participant.superiorId() == 0))
|
||||
continue;
|
||||
|
||||
SaabPlayer *player = toSaabPlayer(participant, remainingParticipants);
|
||||
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
static_cast<SaabUnit *>(result)->inferiors.append(player);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabPlayer *ExportSaab::toSaabPlayer(const ParticipantManagement::Participant &participant, QMap<int, ParticipantManagement::Participant> &remainingParticipants)
|
||||
{
|
||||
if (participant.isDeleted())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Participant with id " << participant.id() << " id deleted --> skipping";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (participant.externalId())
|
||||
{
|
||||
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());
|
||||
|
||||
if (!m_mapTypeToSaabSymbol.contains(type.id()))
|
||||
mapType(type);
|
||||
|
||||
switch (type.typeClass().underlying())
|
||||
{
|
||||
case ParticipantManagement::TypeClass::SupportEntity: // OC Player
|
||||
result = new SaabOcPlayer;
|
||||
break;
|
||||
case ParticipantManagement::TypeClass::Human: // Person Player
|
||||
result = new SaabPersonPlayer;
|
||||
break;
|
||||
case ParticipantManagement::TypeClass::GroundVehicle: // Vehicle Player
|
||||
case ParticipantManagement::TypeClass::VehicleWithGear:
|
||||
case ParticipantManagement::TypeClass::WeaponSystem:
|
||||
result = new SaabVehiclePlayer;
|
||||
break;
|
||||
case ParticipantManagement::TypeClass::Unit: // Unit
|
||||
case ParticipantManagement::TypeClass::SupportUnit:
|
||||
{
|
||||
result = new SaabUnit;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Reading unit with " << participant.inferiorIds().size() << " inferiors";
|
||||
|
||||
for (int32_t id : participant.inferiorIds())
|
||||
{
|
||||
SaabPlayer *player = toSaabPlayer(remainingParticipants.value(id), remainingParticipants);
|
||||
|
||||
if (player == nullptr)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Skipping inferior with id " << id;
|
||||
continue;
|
||||
}
|
||||
|
||||
static_cast<SaabUnit *>(result)->inferiors.append(player);
|
||||
}
|
||||
|
||||
// do not export empty units
|
||||
if (!static_cast<SaabUnit *>(result)->inferiors.size())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Unit " << participant.id() << " has no inferiors.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ParticipantManagement::TypeClass::Vessel: // we do not support that for export atm
|
||||
case ParticipantManagement::TypeClass::Aircraft:
|
||||
case ParticipantManagement::TypeClass::Unknown:
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Type " << participant.typeId() << " is not supported.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString symbol = m_mapTypeToSaabSymbol.value(type.id());
|
||||
|
||||
if (typeid(*result) == typeid(SaabUnit))
|
||||
{
|
||||
QStringList symbolUnitSize = symbol.split(QLatin1Char(';'));
|
||||
|
||||
result->symbol = symbolUnitSize.at(0);
|
||||
static_cast<SaabUnit *>(result)->unitSize = symbolUnitSize.at(1);
|
||||
}
|
||||
else
|
||||
result->symbol = symbol;
|
||||
|
||||
result->designation = QString::fromStdString(participant.designator());
|
||||
result->trashcan = participant.isDeleted();
|
||||
result->rank = QStringLiteral("OF1");
|
||||
result->isExternalPlayer = true;
|
||||
if (participant.equipmentNumber().is_set())
|
||||
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);
|
||||
return participant;
|
||||
}
|
||||
|
||||
QString ExportSaab::toSaabTime(qint64 msecs) const
|
||||
{
|
||||
return QDateTime::fromMSecsSinceEpoch(msecs).toString(QStringLiteral("yyyy-MM-ddThh:mm:ssZ"));
|
||||
}
|
||||
|
||||
void ExportSaab::mapType(const ParticipantManagement::Type &type)
|
||||
{
|
||||
using namespace ParticipantManagement;
|
||||
|
||||
MapType dialog(ParticipantManagement::trTypeName(type.name()),
|
||||
m_mapEchelons,
|
||||
m_mapSymbols,
|
||||
type.typeClass() == TypeClass::Unit || type.typeClass() == TypeClass::SupportUnit,
|
||||
this);
|
||||
|
||||
dialog.exec();
|
||||
|
||||
QString saabTypeStr = dialog.symbolCode();
|
||||
|
||||
if (!dialog.echelonCode().isEmpty())
|
||||
{
|
||||
saabTypeStr.append(QLatin1Char(';'));
|
||||
saabTypeStr.append(dialog.echelonCode());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
dialog.exec();
|
||||
|
||||
if (dialog.isSkipped())
|
||||
return;
|
||||
|
||||
m_mapPartyToForce.insert(party.id(), { m_mapForces.take(dialog.force()), dialog.echelonCode(), dialog.symbolCode() });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Exportieren von SAAB-Dateien
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "saab_logging.h"
|
||||
#include "zwmssaab_export.h"
|
||||
#include "saab_types.h"
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
#include <QFile>
|
||||
|
||||
class QXmlStreamWriter;
|
||||
class QXmlStreamReader;
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
class Ui_SAABExport;
|
||||
|
||||
namespace saab
|
||||
{
|
||||
class ZWMSSAAB_EXPORT ExportSaab
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExportSaab(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const ExerciseManagement::Exercise &exercise,
|
||||
QWidget *parent = nullptr);
|
||||
virtual ~ExportSaab();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onStartExport();
|
||||
void onSelectConfigFile();
|
||||
void onSelectExportFile();
|
||||
|
||||
private: // other
|
||||
struct MappedPartyInfo
|
||||
{
|
||||
QString forceCode;
|
||||
QString echelonCode;
|
||||
QString symbolCode;
|
||||
};
|
||||
|
||||
enum GuidContext
|
||||
{
|
||||
GuidExercise = 1,
|
||||
GuidParty = 2,
|
||||
GuidParticipant = 3
|
||||
};
|
||||
|
||||
private: // methods
|
||||
bool isValidConfigFile();
|
||||
void importConfig();
|
||||
SaabSymbol readSymbol(QXmlStreamReader *reader) const;
|
||||
SaabEchelon readEchelon(QXmlStreamReader *reader) const;
|
||||
SaabForce readForce(QXmlStreamReader *reader) const;
|
||||
void writeExercise(QXmlStreamWriter *writer) const;
|
||||
void writeOrbat(QXmlStreamWriter *writer);
|
||||
void writeFooter(QXmlStreamWriter *writer) const;
|
||||
SaabPlayer *toSaabPlayer(const ParticipantManagement::Party &party,
|
||||
QMap<int, ParticipantManagement::Participant> &remainingParticipants);
|
||||
SaabPlayer *toSaabPlayer(const ParticipantManagement::Participant &participant,
|
||||
QMap<int, ParticipantManagement::Participant> &remainingParticipants);
|
||||
ParticipantManagement::Participant rootParticipant(const ParticipantManagement::Participant &participant,
|
||||
const QMap<int, ParticipantManagement::Participant> &participants) const;
|
||||
QString toSaabTime(qint64 msecs) const;
|
||||
void mapType(const ParticipantManagement::Type &type);
|
||||
void mapPartyToForce(const ParticipantManagement::Party &party);
|
||||
|
||||
private: // attributes
|
||||
QMap<int32_t, MappedPartyInfo> m_mapPartyToForce;
|
||||
QMap<int32_t, QString> m_mapTypeToSaabSymbol; // <SAAB symbol.code, type.id>
|
||||
QMap<QString, SaabSymbol> m_mapSymbols;
|
||||
QMap<QString, SaabEchelon> m_mapEchelons;
|
||||
QMap<int, ParticipantManagement::Type> m_types;
|
||||
QMap<int, ParticipantManagement::Party> m_parties;
|
||||
QMap<QString, QString> m_mapForces;
|
||||
ExerciseManagement::Exercise m_currentExercise;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
QFile *m_configFile;
|
||||
Ui_SAABExport *m_ui;
|
||||
saab::LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,790 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Importieren von SAAB-Dateien
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "saab_import.h"
|
||||
#include "ui_saab_import.h"
|
||||
#include "saab_logging.h"
|
||||
#include "saab_import_show.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
#include <Common/participant_dis_helper.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include "saab_mapping_dialog.h"
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
ImportSaab::ImportSaab(ParticipantManagement::ParticipantEditModel *pModel, const QModelIndex &index, QWidget *parent, LtsSession::LtsSession *pSession)
|
||||
: NGLDialog(parent)
|
||||
, m_xmlFile(nullptr)
|
||||
, m_configFile(nullptr)
|
||||
, m_indexRoot(index)
|
||||
, m_pModel(pModel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_pUi(new Ui_SAABImport)
|
||||
, m_logger(saab::getLogger("ImportSaab"))
|
||||
{
|
||||
m_pUi->setupUi(this);
|
||||
setWindowTitle(tr("Import SAAB Orbat"));
|
||||
|
||||
if (!pSession->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc) || !pSession->getFtc<ParticipantManagement::DataInterface>(m_ppmFtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Fetching m_ppmDtc or m_ppmFtc failed!";
|
||||
setEnabled(false);
|
||||
}
|
||||
else
|
||||
m_mapTypes = m_ppmDtc->types();
|
||||
|
||||
connect(m_pUi->m_pushbutton_SelectFile, &QToolButton::clicked,
|
||||
this, &ImportSaab::slotOpenImportDialog);
|
||||
connect(m_pUi->m_pushbutton_SelectConfig, &QToolButton::clicked,
|
||||
this, &ImportSaab::slotOpenConfigDialog);
|
||||
connect(m_pUi->m_pushButton_StartImport, &QPushButton::clicked,
|
||||
this, &ImportSaab::slotStartImport);
|
||||
|
||||
QString strImportFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedImportFile"), QString()).toString();
|
||||
QString strConfigFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QString()).toString();
|
||||
|
||||
m_pUi->m_lineedit_ImportFile->setText(strImportFile);
|
||||
m_pUi->m_lineedit_configFile->setText(strConfigFile);
|
||||
|
||||
m_pUi->m_pushButton_StartImport->setEnabled(strImportFile.size() && strConfigFile.size());
|
||||
}
|
||||
|
||||
|
||||
ImportSaab::~ImportSaab()
|
||||
{
|
||||
delete m_pUi;
|
||||
}
|
||||
|
||||
|
||||
void ImportSaab::slotOpenImportDialog()
|
||||
{
|
||||
QString strPathSelectedImportFolder = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedImportFolder"), QStringLiteral("/shd/CTC/TOOLS/TDS/")).toString();
|
||||
QString strPathSelectedImportFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedImportFile"), QStringLiteral("/shd/CTC/TOOLS/TDS/")).toString();
|
||||
|
||||
QList<QUrl> urls;
|
||||
urls << QUrl::fromLocalFile(strPathSelectedImportFile);
|
||||
|
||||
QFileDialog fileDialog(this, tr("Select File"), strPathSelectedImportFolder, tr("XML files (*.xml)"));
|
||||
fileDialog.setSidebarUrls(urls);
|
||||
fileDialog.setOptions(QFileDialog::ReadOnly);
|
||||
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if (fileDialog.exec()) // TODO: use show(), use signals & slots !
|
||||
{
|
||||
strPathSelectedImportFile = fileDialog.selectedFiles().constFirst();
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedImportFolder"), strPathSelectedImportFolder);
|
||||
|
||||
if (!strPathSelectedImportFile.size())
|
||||
return;
|
||||
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedImportFile"), strPathSelectedImportFile);
|
||||
m_pUi->m_lineedit_ImportFile->setText(strPathSelectedImportFile);
|
||||
m_pUi->m_pushButton_StartImport->setEnabled(LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QString()).toString().size());
|
||||
}
|
||||
}
|
||||
|
||||
void ImportSaab::slotOpenConfigDialog()
|
||||
{
|
||||
QString strPathSelectedConfigFolder = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFolder"), QStringLiteral("/shd/CTC/TOOLS/TDS/")).toString();
|
||||
QString strPathSelectedConfigFile = LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), QStringLiteral("/shd/CTC/TOOLS/TDS/")).toString();
|
||||
|
||||
QList<QUrl> urls;
|
||||
urls << QUrl::fromLocalFile(strPathSelectedConfigFile);
|
||||
|
||||
QFileDialog fileDialog(this, tr("Select File"), strPathSelectedConfigFolder, tr("XML files (*.xml)"));
|
||||
fileDialog.setSidebarUrls(urls);
|
||||
fileDialog.setOptions(QFileDialog::ReadOnly);
|
||||
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if (fileDialog.exec()) // TODO: use show(), use signals & slots !
|
||||
{
|
||||
strPathSelectedConfigFile = fileDialog.selectedFiles().constFirst();
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFolder"), strPathSelectedConfigFolder);
|
||||
|
||||
if (!strPathSelectedConfigFile.size())
|
||||
return;
|
||||
|
||||
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("SAAB"), QStringLiteral("pathSelectedConfigFile"), strPathSelectedConfigFile);
|
||||
m_pUi->m_lineedit_configFile->setText(strPathSelectedConfigFile);
|
||||
m_pUi->m_pushButton_StartImport->setEnabled(LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("SAAB"), QStringLiteral("pathSelectedImportFile"), QString()).toString().size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImportSaab::slotStartImport()
|
||||
{
|
||||
if (m_xmlFile)
|
||||
{
|
||||
m_xmlFile->close();
|
||||
delete m_xmlFile;
|
||||
m_xmlFile = nullptr;
|
||||
}
|
||||
|
||||
if (m_configFile)
|
||||
{
|
||||
m_configFile->close();
|
||||
delete m_configFile;
|
||||
m_configFile = nullptr;
|
||||
}
|
||||
|
||||
m_pModel->resetModel();
|
||||
|
||||
QString fileName = m_pUi->m_lineedit_ImportFile->text();
|
||||
QString configFileName = m_pUi->m_lineedit_configFile->text();
|
||||
|
||||
m_xmlFile = new QFile(fileName, this);
|
||||
m_configFile = new QFile(configFileName, this);
|
||||
|
||||
if (!isValidSaabOrbatFile())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Error while reading file \"%1\".").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValidConfigFile())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Error while reading file \"%1\".").arg(configFileName));
|
||||
return;
|
||||
}
|
||||
|
||||
importExerciseScenario();
|
||||
}
|
||||
|
||||
ParticipantManagement::ParticipantData ImportSaab::createParticipant(SaabPlayer *player)
|
||||
{
|
||||
ParticipantManagement::ParticipantData p;
|
||||
|
||||
// Note: According to Uli D., in GÜZ, TactId shall be static and
|
||||
// received from SAAB and designator shall be freely changeable.
|
||||
|
||||
// Designator
|
||||
p.tacticalIdentifier(player->designation.toStdString());
|
||||
|
||||
// State and Equipment
|
||||
p.equipmentNumber(player->simulatorId != INT_MIN ? player->simulatorId : 0);
|
||||
p.assignState() = ParticipantManagement::ParticipantAssignState::HandoutExcon;
|
||||
|
||||
if (player->simulatorId != INT_MIN)
|
||||
p.externalId(player->simulatorId);
|
||||
|
||||
p.symbol(m_mapTypes[player->mappedTypeId].symbol());
|
||||
p.typeId(player->mappedTypeId); // Class type is internally derived from typeid, no need (and possibility) to set it here
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void ImportSaab::insertParticipant(SaabPlayer *player, const QModelIndex &index)
|
||||
{
|
||||
ParticipantManagement::ParticipantData newParticipant = createParticipant(player);
|
||||
createNode(newParticipant, index, player);
|
||||
}
|
||||
|
||||
// Parties are the root units (m_rootUnits)
|
||||
void ImportSaab::insertParty(SaabUnit *party)
|
||||
{
|
||||
// Create "Force"-Node -> No symbol, no tact. identifier, no classtype
|
||||
ParticipantManagement::ParticipantData newParty;
|
||||
newParty.designator(party->designation.toStdString());
|
||||
createNode(newParty, m_indexRoot, party);
|
||||
}
|
||||
|
||||
|
||||
void ImportSaab::createNode(const ParticipantManagement::ParticipantData &participant, const QModelIndex &index, SaabPlayer *parent)
|
||||
{
|
||||
int newRow = m_pModel->onInsertRow(index, participant);
|
||||
QModelIndex newIdx = m_pModel->index(newRow, 0, index);
|
||||
m_parentIndexCache[parent] = newIdx;
|
||||
}
|
||||
|
||||
SaabPerson ImportSaab::saabPersonByGUID(const QString &guid) const
|
||||
{
|
||||
for (const auto ¤t : qAsConst(m_saabPersons))
|
||||
{
|
||||
if (current.guid == guid)
|
||||
return current;
|
||||
}
|
||||
|
||||
return SaabPerson();
|
||||
}
|
||||
|
||||
SaabVehicle ImportSaab::saabVehicleByGUID(const QString &guid) const
|
||||
{
|
||||
for (const auto ¤t : qAsConst(m_saabVehicles))
|
||||
{
|
||||
if (current.guid == guid)
|
||||
return current;
|
||||
}
|
||||
|
||||
return SaabVehicle();
|
||||
}
|
||||
|
||||
void ImportSaab::importOrbat()
|
||||
{
|
||||
if (!m_xmlFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to import ORBAT: No file selected";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_xmlFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to import ORBAT: Could not open file \""
|
||||
<< m_xmlFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return;
|
||||
}
|
||||
|
||||
QXmlStreamReader reader(m_xmlFile);
|
||||
|
||||
qDeleteAll(m_rootUnits);
|
||||
m_rootUnits.clear();
|
||||
m_unknownTypes.clear();
|
||||
|
||||
while (!(reader.readNext() == QXmlStreamReader::EndElement && reader.name() == XmlStrings::SAAB_ORBAT()))
|
||||
{
|
||||
if (reader.atEnd())
|
||||
break;
|
||||
|
||||
if (reader.tokenType() == QXmlStreamReader::StartElement && reader.name() == XmlStrings::SAAB_UNIT())
|
||||
{
|
||||
SaabUnit *unit = static_cast<SaabUnit *>(readUnit(&reader));
|
||||
|
||||
if (unit->isDeletedByDefault)
|
||||
continue;
|
||||
|
||||
m_rootUnits.append(unit);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logger.isDebugEnabled())
|
||||
{
|
||||
for (SaabUnit *u : qAsConst(m_rootUnits))
|
||||
DEBUG_LOG(m_logger) << u->toString();
|
||||
}
|
||||
|
||||
m_xmlFile->close();
|
||||
}
|
||||
|
||||
void ImportSaab::importConfig()
|
||||
{
|
||||
if (!m_mapSymbols.isEmpty() || !m_mapEchelons.isEmpty())
|
||||
{
|
||||
using namespace LtsWidgets;
|
||||
|
||||
Button b = LtsMessageDialog::showMessage(this,
|
||||
tr("A config is already imported. Overwrite?"),
|
||||
tr("Overwrite config?"),
|
||||
Behaviour::Modal,
|
||||
Button::Yes | Button::No);
|
||||
if (b != Button::Yes)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_configFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: No file selected";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_configFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: Could not open file \""
|
||||
<< m_configFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return;
|
||||
}
|
||||
|
||||
m_mapSymbols.clear();
|
||||
m_mapEchelons.clear();
|
||||
m_mapSaabSymbolToType.clear();
|
||||
|
||||
QXmlStreamReader reader(m_configFile);
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (!reader.atEnd())
|
||||
{
|
||||
if (reader.readNextStartElement())
|
||||
{
|
||||
if (reader.name() == SAAB_SYMBOL())
|
||||
{
|
||||
SaabSymbol newSymbol = readSymbol(&reader);
|
||||
m_mapSymbols.insert(newSymbol.code, newSymbol);
|
||||
}
|
||||
else if (reader.name() == SAAB_ECHELON())
|
||||
{
|
||||
SaabEchelon newEchelon = readEchelon(&reader);
|
||||
m_mapEchelons.insert(newEchelon.code, newEchelon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_configFile->close();
|
||||
}
|
||||
|
||||
QVector<SaabPlayer *> ImportSaab::flattenedPlayersWithoutRootUnits() const
|
||||
{
|
||||
QVector<SaabPlayer *> result;
|
||||
|
||||
for (SaabUnit *p : qAsConst(m_rootUnits))
|
||||
{
|
||||
QVector<SaabPlayer *> inferiorInferiors = inferiors(p);
|
||||
|
||||
for (SaabPlayer *infInf : qAsConst(inferiorInferiors))
|
||||
result.append(infInf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QVector<SaabPlayer *> ImportSaab::inferiors(SaabPlayer *player) const
|
||||
{
|
||||
QVector<SaabPlayer *> result;
|
||||
|
||||
if (typeid(*player) != typeid(SaabUnit))
|
||||
{
|
||||
result.append(player);
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabUnit *unit = static_cast<SaabUnit *>(player);
|
||||
|
||||
if (!m_rootUnits.contains(unit))
|
||||
result.append(player);
|
||||
|
||||
for (SaabPlayer *inf : qAsConst(unit->inferiors))
|
||||
{
|
||||
QVector<SaabPlayer *> inferiorInferiors = inferiors(inf);
|
||||
for (SaabPlayer *infInf : qAsConst(inferiorInferiors))
|
||||
result.append(infInf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabPlayer *ImportSaab::readUnit(QXmlStreamReader *reader) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "reading unit: tokentype: " << reader->tokenString() << " | name: " << reader->name().toString();
|
||||
|
||||
SaabUnit *result = new SaabUnit;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
QMap<QString, SaabPlayer*(ImportSaab::*)(QXmlStreamReader *)const> funcMap;
|
||||
funcMap.insert(SAAB_PERSON_PLAYER(), &ImportSaab::readPersonPlayer);
|
||||
funcMap.insert(SAAB_OC_PLAYER(), &ImportSaab::readOcPlayer);
|
||||
funcMap.insert(SAAB_VEHICLE_PLAYER(), &ImportSaab::readVehiclePlayer);
|
||||
funcMap.insert(SAAB_UNIT(), &ImportSaab::readUnit);
|
||||
|
||||
result->guid = reader->attributes().value(SAAB_ID()).toString();
|
||||
|
||||
while (!(reader->readNext() == QXmlStreamReader::EndElement && reader->name() == SAAB_UNIT()))
|
||||
{
|
||||
if (reader->tokenType() == QXmlStreamReader::StartElement)
|
||||
{
|
||||
if (reader->name() == SAAB_DESIGNATION())
|
||||
result->designation = reader->readElementText();
|
||||
else if (reader->name() == SAAB_FORCE())
|
||||
result->force = reader->readElementText();
|
||||
else if (reader->name() == SAAB_SYMBOL())
|
||||
result->symbol = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TRASHCAN())
|
||||
result->trashcan = reader->readElementText() == SAAB_TRUE();
|
||||
else if (reader->name() == SAAB_POSITION_BY_PLAYER_ID())
|
||||
result->positionByPlayerId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_UNIT_SIZE())
|
||||
result->unitSize = reader->readElementText();
|
||||
else if (reader->name() == SAAB_CHANGE_INFO())
|
||||
result->isDeletedByDefault = reader->attributes().value(SAAB_CHANGE_TYPE()).toString() == SAAB_DELETE();
|
||||
else if (reader->name() == SAAB_ORBAT_ENTITIES())
|
||||
{
|
||||
while (!(reader->readNext() == QXmlStreamReader::EndElement && reader->name() == SAAB_ORBAT_ENTITIES()))
|
||||
{
|
||||
QString tagName = reader->name().toString();
|
||||
if (reader->tokenType() == QXmlStreamReader::StartElement && funcMap.contains(tagName))
|
||||
{
|
||||
SaabPlayer *newParticipant = (this->*funcMap.value(tagName))(reader);
|
||||
|
||||
if (newParticipant->isDeletedByDefault || newParticipant->isExternalPlayer)
|
||||
continue;
|
||||
|
||||
newParticipant->superior = result;
|
||||
result->inferiors.append(newParticipant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if the unit has to take the position of a specific participant,
|
||||
// take the participant to the top of the inferiors
|
||||
if (!result->positionByPlayerId.isEmpty())
|
||||
{
|
||||
int index = playerIndexByGuid(result->guid, result->inferiors);
|
||||
|
||||
if (index < 0)
|
||||
WARNING_LOG(m_logger) << SAAB_POSITION_BY_PLAYER_ID() << " set, but GUID " << result->positionByPlayerId << " could not be found.";
|
||||
else
|
||||
result->inferiors.prepend(result->inferiors.takeAt(index));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabPlayer *ImportSaab::readOcPlayer(QXmlStreamReader *reader) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "reading oc player: tokentype: " << reader->tokenString() << " | name: " << reader->name().toString();
|
||||
|
||||
return readPersonOcPlayer<SaabOcPlayer>(reader, XmlStrings::SAAB_OC_PLAYER());;
|
||||
}
|
||||
|
||||
SaabPlayer *ImportSaab::readPersonPlayer(QXmlStreamReader *reader) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "reading person player: tokentype: " << reader->tokenString() << " | name: " << reader->name().toString();
|
||||
|
||||
return readPersonOcPlayer<SaabPersonPlayer>(reader, XmlStrings::SAAB_PERSON_PLAYER());
|
||||
}
|
||||
|
||||
SaabPlayer *ImportSaab::readVehiclePlayer(QXmlStreamReader *reader) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "reading vehicle player: tokentype: " << reader->tokenString() << " | name: " << reader->name().toString();
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
SaabVehiclePlayer *result = readPlayerBaseData<SaabVehiclePlayer>(reader, SAAB_VEHICLE_PLAYER(), SAAB_VEHICLE_REF_ID());
|
||||
|
||||
if (!result->refId.isEmpty())
|
||||
{
|
||||
SaabVehicle vehicle = saabVehicleByGUID(reader->readElementText());
|
||||
|
||||
if (vehicle.guid.isEmpty())
|
||||
WARNING_LOG(m_logger) << SAAB_VEHICLE_REF_ID() << " set, but GUID " << result->refId << " could not be found.";
|
||||
else
|
||||
{
|
||||
result->registrationNumber = vehicle.registrationNumber;
|
||||
result->description = vehicle.description;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabSymbol ImportSaab::readSymbol(QXmlStreamReader *reader) const
|
||||
{
|
||||
SaabSymbol result;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (reader->readNext() != QXmlStreamReader::EndElement && reader->name() != SAAB_SYMBOL())
|
||||
{
|
||||
if (reader->name() == SAAB_CODE())
|
||||
result.code = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TEXT())
|
||||
result.text = reader->readElementText();
|
||||
else if (reader->name() == SAAB_SYMBOL_ID())
|
||||
result.symbolId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_MODEL_ID())
|
||||
result.modelId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_ECHELON_ID())
|
||||
result.echelonId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_PLAYER_TYPE_ID())
|
||||
result.playerTypeId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_COLOR())
|
||||
result.color = reader->readElementText();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SaabEchelon ImportSaab::readEchelon(QXmlStreamReader *reader) const
|
||||
{
|
||||
SaabEchelon result;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (reader->readNext() != QXmlStreamReader::EndElement && reader->name() != SAAB_ECHELON())
|
||||
{
|
||||
if (reader->name() == SAAB_CODE())
|
||||
result.code = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TEXT())
|
||||
result.text = reader->readElementText();
|
||||
else if (reader->name() == SAAB_ID())
|
||||
result.id = reader->readElementText();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int ImportSaab::playerIndexByGuid(const QString &guid, const QVector<SaabPlayer *> &vec)
|
||||
{
|
||||
for (int i = 0; i < vec.size(); ++i)
|
||||
{
|
||||
if (vec.at(i)->guid == guid)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ImportSaab::importExerciseScenario()
|
||||
{
|
||||
using namespace XmlStrings;
|
||||
|
||||
importConfig();
|
||||
importRefData(m_saabPersons, SAAB_PERSONS(), SAAB_PERSON(), SAAB_PERSONAL_ID(), SAAB_NAME()); // import persons
|
||||
importRefData(m_saabVehicles, SAAB_VEHICLES(), SAAB_VEHICLE(), SAAB_REGISTRATION_NUMBER(), SAAB_DESCRIPTION()); // import vehicles
|
||||
importOrbat();
|
||||
|
||||
for (SaabUnit *party : qAsConst(m_rootUnits))
|
||||
insertParty(party);
|
||||
|
||||
QVector<SaabPlayer *> vecUnitsWithValidDISTypes = resolveImportMapping(flattenedPlayersWithoutRootUnits());
|
||||
|
||||
if (!vecUnitsWithValidDISTypes.size())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("There are no units or participants which can be imported."), tr("Import Warning"));
|
||||
return;
|
||||
}
|
||||
|
||||
buildImportTreeView(vecUnitsWithValidDISTypes);
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void ImportSaab::buildImportTreeView(const QVector<SaabPlayer *> &vecUnitsWithValidDISTypes)
|
||||
{
|
||||
QVector<SaabPlayer *> tmp;
|
||||
QVector<SaabPlayer *> current = vecUnitsWithValidDISTypes;
|
||||
do
|
||||
{
|
||||
for (SaabPlayer *player : current)
|
||||
{
|
||||
auto it = m_parentIndexCache.find(player->superior);
|
||||
|
||||
if (it == m_parentIndexCache.end())
|
||||
{
|
||||
// check if the parent exists in vecUnitsWithValidDISTypes for the next approach
|
||||
if (vecUnitsWithValidDISTypes.contains(player->superior))
|
||||
tmp.append(player);
|
||||
else
|
||||
WARNING_LOG(m_logger) << "Parent missing: Could not import player " << player->designation;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
QModelIndex &parentIdx = (*it);
|
||||
insertParticipant(player, parentIdx);
|
||||
}
|
||||
|
||||
current = tmp;
|
||||
tmp.clear();
|
||||
} while (!current.isEmpty());
|
||||
}
|
||||
|
||||
bool ImportSaab::isValidSaabOrbatFile() const
|
||||
{
|
||||
if (!m_xmlFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to import ORBAT: No file selected";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_xmlFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to import ORBAT: Could not open file \""
|
||||
<< m_xmlFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasExerciseOrbatRoot = false;
|
||||
bool hasExercise = false;
|
||||
bool hasOrbat = false;
|
||||
|
||||
QXmlStreamReader reader(m_xmlFile);
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
while (!(hasExerciseOrbatRoot && hasExercise && hasOrbat) && !reader.atEnd())
|
||||
{
|
||||
if (reader.readNextStartElement())
|
||||
{
|
||||
if (reader.name() == SAAB_EXERCISE_ORBAT())
|
||||
hasExerciseOrbatRoot = true;
|
||||
else if (reader.name() == SAAB_EXERCISE())
|
||||
hasExercise = true;
|
||||
else if (reader.name() == SAAB_ORBAT())
|
||||
hasOrbat = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_xmlFile->close();
|
||||
|
||||
if (!hasExerciseOrbatRoot)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_EXERCISE_ORBAT() << " in file \"" << m_xmlFile->fileName() << '\"';
|
||||
if (!hasExercise)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_EXERCISE() << " in file \"" << m_xmlFile->fileName() << '\"';
|
||||
if (!hasOrbat)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_ORBAT() << " in file \"" << m_xmlFile->fileName() << '\"';
|
||||
|
||||
return hasExerciseOrbatRoot && hasExercise && hasOrbat;
|
||||
}
|
||||
|
||||
bool ImportSaab::isValidConfigFile() const
|
||||
{
|
||||
if (!m_configFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: No file selected";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_configFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to read config: Could not open file \""
|
||||
<< m_configFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return false;
|
||||
}
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
QXmlStreamReader reader(m_configFile);
|
||||
|
||||
bool hasSymbols = false;
|
||||
bool hasEchelons = false;
|
||||
|
||||
while (!reader.atEnd() && !(hasSymbols && hasEchelons))
|
||||
{
|
||||
if (reader.readNextStartElement())
|
||||
{
|
||||
if (reader.name() == SAAB_SYMBOLS())
|
||||
hasSymbols = true;
|
||||
else if (reader.name() == SAAB_ECHELONS())
|
||||
hasEchelons = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_configFile->close();
|
||||
|
||||
if (!hasEchelons)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_ECHELONS() << " in file \"" << m_configFile->fileName() << '\"';
|
||||
if (!hasSymbols)
|
||||
ERROR_LOG(m_logger) << "Could not find " << SAAB_SYMBOLS() << " in file \"" << m_configFile->fileName() << '\"';
|
||||
|
||||
return hasEchelons && hasSymbols;
|
||||
}
|
||||
|
||||
bool ImportSaab::hasValidType(SaabPlayer *player) const
|
||||
{
|
||||
return m_mapSymbols.value(player->symbol).mappedTypeId > -1;
|
||||
}
|
||||
|
||||
QVector<SaabPlayer *> ImportSaab::resolveImportMapping(const QVector<SaabPlayer *> &playerVec)
|
||||
{
|
||||
QVector<SaabPlayer *> vecObjectsWithValidTypes;
|
||||
QMap<QString, QVector<SaabPlayer *>> mapParticipantsWithUnknownType, mapUnitsWithUnknownType;
|
||||
|
||||
// first perform a mapping of saab type to rme type
|
||||
for (SaabPlayer *player : playerVec)
|
||||
{
|
||||
if (!hasValidType(player))
|
||||
{
|
||||
if (typeid(*player) == typeid(SaabUnit))
|
||||
{
|
||||
QString text = m_mapSymbols.contains(player->symbol) ? m_mapSymbols.value(player->symbol).text : player->symbol;
|
||||
QString unitSize = static_cast<SaabUnit *>(player)->unitSize;
|
||||
text.append(tr(" - Size: %1").arg(m_mapEchelons.contains(unitSize) ? m_mapEchelons.value(unitSize).text : unitSize));
|
||||
mapUnitsWithUnknownType[text].append(player);
|
||||
}
|
||||
else
|
||||
mapParticipantsWithUnknownType[m_mapSymbols.contains(player->symbol) ? m_mapSymbols.value(player->symbol).text : player->symbol].append(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
// A match between the imported unit (its DIS id) and one of the database types exists: Perform mapping, everything is fine.
|
||||
vecObjectsWithValidTypes.append(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (mapUnitsWithUnknownType.size())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("<b>Units</b> exist whose external type is unknown.<br/>You have to solve this by manually mapping<br/> the external types to existing <b>unit types</b>."), tr("Import Error"));
|
||||
vecObjectsWithValidTypes.append(showMappingDialog(mapUnitsWithUnknownType, true));
|
||||
}
|
||||
|
||||
if (mapParticipantsWithUnknownType.size())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("<b>Participants</b> exist whose external type is unknown.<br/>You have to solve this by manually mapping<br/> the external types to existing <b>participant types</b>."), tr("Import Error"));
|
||||
vecObjectsWithValidTypes.append(showMappingDialog(mapParticipantsWithUnknownType, false));
|
||||
}
|
||||
|
||||
return vecObjectsWithValidTypes;
|
||||
}
|
||||
|
||||
|
||||
QVector<SaabPlayer *> ImportSaab::showMappingDialog(const QMap<QString, QVector<SaabPlayer *>> &mapConflictMap, bool typeClassIsUnit)
|
||||
{
|
||||
QVector<SaabPlayer *> vecUnitsWithValidSymbols;
|
||||
|
||||
int32_t mappedTypeId = 0;
|
||||
|
||||
for (auto it = mapConflictMap.begin(); it != mapConflictMap.end(); ++it)
|
||||
{
|
||||
const QString &strSaabSymbol = it.key();
|
||||
const QVector<SaabPlayer *> &vecData = it.value();
|
||||
|
||||
QString strReason;
|
||||
bool offerDatabaseEntriesWithoutDISType;
|
||||
|
||||
if (!strSaabSymbol.size())
|
||||
{
|
||||
strReason = QString(tr("No type specified."));
|
||||
// Imported unit/participant has no DIS type. Mapping "no DIS type" to database elements without a DIS type does not make sense
|
||||
offerDatabaseEntriesWithoutDISType = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
strReason = QString(tr("Specified type \"%1\" is unknown.")).arg(strSaabSymbol);
|
||||
offerDatabaseEntriesWithoutDISType = true;
|
||||
}
|
||||
|
||||
QString strType = typeClassIsUnit ? tr("unit(s)") : tr("participant(s)");
|
||||
strReason += tr("<br/>This applies for %1 %2. Please choose an option:").arg(QString::number(vecData.size()), strType);
|
||||
|
||||
saab::MappingDialog dialog(this, typeClassIsUnit, strReason, m_ppmDtc, offerDatabaseEntriesWithoutDISType);
|
||||
dialog.exec(); // TODO: use show(), use signals & slots !
|
||||
|
||||
if (dialog.skipAllUnmappedElements())
|
||||
break;
|
||||
|
||||
mappedTypeId = dialog.getMappedTypeId();
|
||||
|
||||
if (dialog.mappingApplied())
|
||||
{
|
||||
m_mapSaabSymbolToType.insert(strSaabSymbol, mappedTypeId);
|
||||
|
||||
for (SaabPlayer *participant : qAsConst(vecData))
|
||||
{
|
||||
participant->mappedTypeId = mappedTypeId;
|
||||
vecUnitsWithValidSymbols.push_back(participant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vecUnitsWithValidSymbols;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Klasse fuer das Importieren von SAAB-Dateien
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nglwidgets/ngldialog.h>
|
||||
#include "saab_logging.h"
|
||||
#include "saab_types.h"
|
||||
#include "zwmssaab_export.h"
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <Plugins/ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
|
||||
#include <memory>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_participants_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_templates_gui_plugin_interface.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QFile>
|
||||
#include "saab_xml_strings.h"
|
||||
|
||||
class QXmlStreamReader;
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
class Ui_SAABImport;
|
||||
|
||||
namespace saab
|
||||
{
|
||||
class ImportSaabShow;
|
||||
|
||||
class ZWMSSAAB_EXPORT ImportSaab : public NGLDialog, protected ParticipantManagement::Interface::Ftc::ModifyTypeReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ImportSaab(ParticipantManagement::ParticipantEditModel *pModel, const QModelIndex &index, QWidget *parent, LtsSession::LtsSession *pSession);
|
||||
virtual ~ImportSaab();
|
||||
|
||||
private slots:
|
||||
void slotOpenImportDialog();
|
||||
void slotOpenConfigDialog();
|
||||
void slotStartImport();
|
||||
|
||||
private: // methods
|
||||
void onModifyTypeReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
ParticipantManagement::ParticipantData createParticipant(SaabPlayer *player);
|
||||
void insertParticipant(SaabPlayer *player, const QModelIndex &index);
|
||||
void insertParty(SaabUnit *party);
|
||||
void createNode(const ParticipantManagement::ParticipantData &participant, const QModelIndex &index, SaabPlayer *parent);
|
||||
SaabPerson saabPersonByGUID(const QString &guid) const;
|
||||
SaabVehicle saabVehicleByGUID(const QString &guid) const;
|
||||
void importOrbat();
|
||||
void importConfig();
|
||||
QVector<SaabPlayer *> flattenedPlayersWithoutRootUnits() const;
|
||||
QVector<SaabPlayer *> inferiors(SaabPlayer *player) const;
|
||||
SaabPlayer *readUnit(QXmlStreamReader *reader) const;
|
||||
SaabPlayer *readOcPlayer(QXmlStreamReader *reader) const;
|
||||
SaabPlayer *readPersonPlayer(QXmlStreamReader *reader) const;
|
||||
SaabPlayer *readVehiclePlayer(QXmlStreamReader *reader) const;
|
||||
SaabSymbol readSymbol(QXmlStreamReader *reader) const;
|
||||
SaabEchelon readEchelon(QXmlStreamReader *reader) const;
|
||||
static int playerIndexByGuid(const QString &guid, const QVector<SaabPlayer *> &vec);
|
||||
void importExerciseScenario();
|
||||
QVector<SaabPlayer *> resolveImportMapping(const QVector<SaabPlayer *> &playerVec);
|
||||
QVector<SaabPlayer *> showMappingDialog(const QMap<QString, QVector<SaabPlayer *> > &mapConflictMap, bool typeClassIsUnit);
|
||||
void buildImportTreeView(const QVector<SaabPlayer *> &vecUnitsWithValidDISTypes);
|
||||
bool isValidSaabOrbatFile() const;
|
||||
bool isValidConfigFile() const;
|
||||
bool hasValidType(SaabPlayer *player) const;
|
||||
|
||||
// import vehicles and persons
|
||||
template <typename T>
|
||||
void importRefData(QVector<T> &vec,
|
||||
const QString &parentTag,
|
||||
const QString &childTag,
|
||||
const QString &firstDataTag,
|
||||
const QString &secondDataTag) // TODO: better naming
|
||||
{
|
||||
vec.clear();
|
||||
|
||||
if (!m_xmlFile)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to import " << parentTag << ": No file selected";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_xmlFile->open(QIODevice::ReadOnly))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Not possible to import " << parentTag << ": Could not open file \""
|
||||
<< m_xmlFile->fileName()
|
||||
<< "\" for reading.";
|
||||
return;
|
||||
}
|
||||
|
||||
QXmlStreamReader reader(m_xmlFile);
|
||||
|
||||
while (!reader.atEnd())
|
||||
{
|
||||
if (reader.readNextStartElement() && reader.name() == parentTag)
|
||||
{
|
||||
QXmlStreamReader::TokenType currentToken;
|
||||
|
||||
do
|
||||
{
|
||||
currentToken = reader.readNext();
|
||||
|
||||
if (reader.name() == childTag && currentToken == QXmlStreamReader::StartElement)
|
||||
{
|
||||
QString guid = reader.attributes().value(XmlStrings::SAAB_ID()).toString();
|
||||
|
||||
do
|
||||
{
|
||||
if (!reader.readNextStartElement())
|
||||
break;
|
||||
|
||||
}
|
||||
while (reader.name().toString() != firstDataTag);
|
||||
|
||||
QString value = reader.readElementText();
|
||||
|
||||
do
|
||||
{
|
||||
if (!reader.readNextStartElement())
|
||||
break;
|
||||
|
||||
}
|
||||
while (reader.name().toString() != secondDataTag);
|
||||
|
||||
vec.append({ guid, value, reader.readElementText() });
|
||||
}
|
||||
|
||||
}
|
||||
while (currentToken != QXmlStreamReader::EndElement || reader.name() != parentTag);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logger.isDebugEnabled())
|
||||
{
|
||||
for (const T ¤t : qAsConst(vec))
|
||||
DEBUG_LOG(m_logger) << childTag << ": " << current.toString();
|
||||
}
|
||||
|
||||
m_xmlFile->close();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *readPlayerBaseData(QXmlStreamReader *reader, const QString &mainTag, const QString &refTag) const
|
||||
{
|
||||
T *result = new T;
|
||||
|
||||
using namespace XmlStrings;
|
||||
|
||||
result->guid = reader->attributes().value(SAAB_ID()).toString();
|
||||
|
||||
while (!(reader->readNext() == QXmlStreamReader::EndElement && reader->name() == mainTag))
|
||||
{
|
||||
if (reader->tokenType() != QXmlStreamReader::StartElement)
|
||||
continue;
|
||||
|
||||
if (reader->name() == SAAB_DESIGNATION())
|
||||
result->designation = reader->readElementText();
|
||||
else if (reader->name() == SAAB_FORCE())
|
||||
result->force = reader->readElementText();
|
||||
else if (reader->name() == SAAB_SYMBOL())
|
||||
result->symbol = reader->readElementText();
|
||||
else if (reader->name() == SAAB_TRASHCAN())
|
||||
result->trashcan = reader->readElementText() == SAAB_TRUE();
|
||||
else if (reader->name() == refTag)
|
||||
result->refId = reader->readElementText();
|
||||
else if (reader->name() == SAAB_CHANGE_INFO())
|
||||
result->isDeletedByDefault = reader->attributes().value(SAAB_CHANGE_TYPE()).toString() == SAAB_DELETE();
|
||||
else if (reader->name() == SAAB_SIMULATOR_ID())
|
||||
result->simulatorId = reader->readElementText().toInt();
|
||||
else if (reader->name() == SAAB_EXTERNAL_PLAYER())
|
||||
result->isExternalPlayer = reader->readElementText() == SAAB_TRUE();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *readPersonOcPlayer(QXmlStreamReader *reader, const QString &mainTag) const
|
||||
{
|
||||
T *result = readPlayerBaseData<T>(reader, mainTag, XmlStrings::SAAB_PERSON_REF_ID());
|
||||
|
||||
if (!result->refId.isEmpty())
|
||||
{
|
||||
SaabPerson person = saabPersonByGUID(result->refId);
|
||||
|
||||
if (person.guid.isEmpty())
|
||||
WARNING_LOG(m_logger) << XmlStrings::SAAB_PERSON_REF_ID() << " set, but GUID " << result->refId << " could not be found.";
|
||||
else
|
||||
{
|
||||
result->personalID = person.personalID;
|
||||
result->name = person.name;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
|
||||
QVector<SaabPerson> m_saabPersons;
|
||||
QVector<SaabVehicle> m_saabVehicles;
|
||||
QVector<SaabUnit *> m_rootUnits;
|
||||
QFile *m_xmlFile;
|
||||
QFile *m_configFile;
|
||||
QMap<QString, int32_t> m_mapSaabSymbolToType; // <SAAB symbol.code, type.id>
|
||||
QMap<QString, QVector<SaabPlayer *> > m_unknownTypes; // <Symbol (from SAAB xml), saab players with the symbol Symbol>
|
||||
QMap<qint32, ParticipantManagement::Type> m_mapTypes; // E.g. participant id "47" to type id
|
||||
QMap<QString, SaabSymbol> m_mapSymbols;
|
||||
QMap<QString, SaabEchelon> m_mapEchelons;
|
||||
QMap<SaabPlayer *, QModelIndex> m_parentIndexCache; // Used to create the treeview with the imported participants
|
||||
QModelIndex m_indexRoot; // Used to append parties/forces to the tree
|
||||
ParticipantManagement::ParticipantEditModel *m_pModel;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui_SAABImport *m_pUi;
|
||||
saab::LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Den Inhalt von SAAB-Dateien anzeigen
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "saab_import_show.h"
|
||||
#include "ui_saab_import_show.h"
|
||||
#include <QMenu>
|
||||
#include <QFile>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
|
||||
#include <nglwidgets/nglstandardbutton.h>
|
||||
|
||||
using namespace saab;
|
||||
|
||||
ImportSaabShow::ImportSaabShow(QWidget *parent, const QString &xmlFile)
|
||||
: NGLDialog(parent)
|
||||
, mImportFile(xmlFile)
|
||||
, mCollapsedAll(true)
|
||||
, mExpandedAll(false)
|
||||
, mLogger(getLogger("ImportSaabShow"))
|
||||
{
|
||||
mUi.setupUi(this);
|
||||
|
||||
setWindowTitle(tr("Exercise Scenario"));
|
||||
move(50, 50);
|
||||
|
||||
// ButtonBox
|
||||
connect(mUi.buttonBox, &NGLDialogButtonBox::onClose,
|
||||
this, &ImportSaabShow::onClose);
|
||||
|
||||
mUi.treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(mUi.treeWidget, &QTreeWidget::customContextMenuRequested,
|
||||
this, &ImportSaabShow::slotCustomContextMenuRequested);
|
||||
|
||||
// buttons
|
||||
buttonClose = mUi.buttonBox->button(NGLStandardButton::Close);
|
||||
buttonClose->setEnabled(true);
|
||||
|
||||
QTreeWidgetItem *header = mUi.treeWidget->headerItem();
|
||||
mUi.treeWidget->setColumnCount(2);
|
||||
mUi.treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
|
||||
header->setText(0, tr("Element"));
|
||||
header->setText(1, tr("Content"));
|
||||
|
||||
// xsd-Schema gegen xml-Datei ueberpruefen
|
||||
initTree();
|
||||
}
|
||||
|
||||
|
||||
void ImportSaabShow::initTree()
|
||||
{
|
||||
QFile file(mImportFile);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("File doesn't exist on filesystem"));
|
||||
return;
|
||||
}
|
||||
|
||||
QDomDocument doc(QStringLiteral("mydocument"));
|
||||
|
||||
if (!doc.setContent(&file))
|
||||
{
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
QDomElement docElem = doc.documentElement();
|
||||
QDomNodeList qdlist = docElem.childNodes();
|
||||
for (int i = 0; i < qdlist.size(); i++)
|
||||
{
|
||||
QDomNode qdn = qdlist.item(i);
|
||||
QDomElement e = qdn.toElement();
|
||||
QTreeWidgetItem *qtWI = new QTreeWidgetItem((QTreeWidget *)nullptr, QStringList(e.tagName()));
|
||||
mItems.append(qtWI);
|
||||
showTree(qdn, qtWI);
|
||||
}
|
||||
|
||||
mUi.treeWidget->insertTopLevelItems(0, mItems);
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
void ImportSaabShow::addChild(const QDomElement &scenarioIdElement, QTreeWidgetItem *qtWI)
|
||||
{
|
||||
QDomNode domNode = scenarioIdElement.firstChildElement();
|
||||
while (!domNode.isNull())
|
||||
{
|
||||
QDomElement domElement = domNode.toElement();
|
||||
if (!domElement.isNull())
|
||||
{
|
||||
|
||||
QStringList itemList;
|
||||
itemList << domElement.tagName() << domElement.text();
|
||||
QTreeWidgetItem *qtWINew = new QTreeWidgetItem((QTreeWidget *)nullptr, itemList);
|
||||
qtWI->addChild(qtWINew);
|
||||
}
|
||||
domNode = domNode.nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImportSaabShow::showTree(const QDomNode &n, QTreeWidgetItem *qtwi)
|
||||
{
|
||||
QDomNodeList qdlist = n.childNodes();
|
||||
|
||||
QTreeWidgetItem *dummyParent = nullptr;
|
||||
for (int i = 0; i < qdlist.size(); i++)
|
||||
{
|
||||
QDomNode qdn = qdlist.item(i);
|
||||
QDomElement qde = qdn.toElement();
|
||||
|
||||
if (qde.tagName().size() == 0)
|
||||
continue;
|
||||
|
||||
QStringList itemList;
|
||||
if (qde.firstChild().toElement().tagName().size())
|
||||
itemList << qde.tagName();
|
||||
else
|
||||
itemList << qde.tagName() << qde.text();
|
||||
|
||||
QTreeWidgetItem *qtWI1 = new QTreeWidgetItem(dummyParent, itemList);
|
||||
qtwi->addChild(qtWI1);
|
||||
showTree(qdn, qtWI1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImportSaabShow::onClose()
|
||||
{
|
||||
INFO_LOG(mLogger) << "ON close() ";
|
||||
accept();
|
||||
emit signalDialogClose(this);
|
||||
}
|
||||
|
||||
|
||||
void ImportSaabShow::slotCustomContextMenuRequested(QPoint p)
|
||||
{
|
||||
INFO_LOG(mLogger) << "slotCustomContextMenuRequested";
|
||||
QMenu *menu = new QMenu(this);
|
||||
QAction *ac = new QAction(tr("Expand all"), this);
|
||||
ac->setCheckable(true);
|
||||
if (mExpandedAll)
|
||||
ac->setChecked(true);
|
||||
else
|
||||
ac->setChecked(false);
|
||||
ac->setData(QVariant(QStringLiteral("E"))); // expand all
|
||||
menu->addAction(ac);
|
||||
ac = new QAction(tr("Collapse all"), this);
|
||||
ac->setCheckable(true);
|
||||
ac->setData(QVariant(QStringLiteral("C"))); // collapse all
|
||||
if (mCollapsedAll)
|
||||
ac->setChecked(true);
|
||||
else
|
||||
ac->setChecked(false);
|
||||
menu->addAction(ac);
|
||||
connect(menu, &QMenu::triggered,
|
||||
this, &ImportSaabShow::slotCustomContextMenuActionTriggered);
|
||||
menu->exec(mUi.treeWidget->mapToGlobal(p));
|
||||
delete menu;
|
||||
}
|
||||
|
||||
|
||||
void ImportSaabShow::slotCustomContextMenuActionTriggered(QAction *ac)
|
||||
{
|
||||
if (!ac)
|
||||
return;
|
||||
if (ac->data().toString() == QStringLiteral("E"))
|
||||
{
|
||||
mUi.treeWidget->expandAll();
|
||||
mCollapsedAll = false;
|
||||
mExpandedAll = true;
|
||||
return;
|
||||
}
|
||||
if (ac->data().toString() == QStringLiteral("C"))
|
||||
{
|
||||
mUi.treeWidget->collapseAll();
|
||||
mCollapsedAll = true;
|
||||
mExpandedAll = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Klasse zum Anzeigen von SAAB-Dateien
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtXml/QDomDocument>
|
||||
#include <QtXmlPatterns/QAbstractMessageHandler>
|
||||
#include <nglwidgets/ngldialog.h>
|
||||
#include "saab_logging.h"
|
||||
|
||||
#include "ui_saab_import_show.h"
|
||||
|
||||
|
||||
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
|
||||
public:
|
||||
ImportSaabShow(QWidget *parent, const QString &xmlFile);
|
||||
|
||||
signals:
|
||||
void signalDialogClose(NGLDialog *ngld);
|
||||
|
||||
private slots:
|
||||
void onClose();
|
||||
void slotCustomContextMenuRequested(QPoint p);
|
||||
void slotCustomContextMenuActionTriggered(QAction *ac);
|
||||
|
||||
private:
|
||||
void initTree();
|
||||
void addChild(const QDomElement &scenarioIdElement, QTreeWidgetItem *qtWI);
|
||||
void showTree(const QDomNode &n, QTreeWidgetItem *qtwi);
|
||||
|
||||
QList<QTreeWidgetItem *> mItems;
|
||||
NGLStandardButton *buttonClose;
|
||||
Ui_SAABImportShow mUi;
|
||||
QString mImportFile;
|
||||
bool mCollapsedAll;
|
||||
bool mExpandedAll;
|
||||
LOGGER_T &mLogger;
|
||||
};
|
||||
} // namespace ZWMSSAAB
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include "saab_logging.h"
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const QLatin1String zwmssaab("NGL.ZWMSSAAB.");
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(zwmssaab.size() + len);
|
||||
loggerName.append(zwmssaab.data(), zwmssaab.size());
|
||||
loggerName.append(name, len);
|
||||
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
|
||||
} // namespace ZWMSSAAB
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* WiSi - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
typedef NGL::INGLLogger &LOGGER_T;
|
||||
|
||||
LOGGER_T getLogger(const char *name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "saab_map_party.h"
|
||||
#include "ui_saab_map_party.h"
|
||||
|
||||
#include "saab_map_type.h"
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
MapParty::MapParty(const QString &partyName,
|
||||
const QMap<QString, QString> &forces, const QMap<QString, SaabEchelon> &echelons, const QMap<QString, SaabSymbol> &symbols,
|
||||
QWidget *parent)
|
||||
: LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_skipped(false)
|
||||
, m_ui(new Ui_MapParty)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->lblText->setText(tr("Party <b>%1</b> needs to be mapped:").arg(partyName));
|
||||
|
||||
QList<QString> forcesList = forces.keys();
|
||||
|
||||
std::sort(forcesList.begin(), forcesList.end());
|
||||
|
||||
for (const QString ¤t : qAsConst(forcesList))
|
||||
m_ui->cbForce->addItem(current);
|
||||
|
||||
QList<SaabEchelon> echelonList = echelons.values();
|
||||
|
||||
sortList(echelonList);
|
||||
|
||||
for (const SaabEchelon ¤t : qAsConst(echelonList))
|
||||
m_ui->cbEchelon->addItem(current.text, current.code);
|
||||
|
||||
QList<SaabSymbol> symbolList = symbols.values();
|
||||
|
||||
sortList(symbolList);
|
||||
|
||||
for (const SaabSymbol ¤t : qAsConst(symbolList))
|
||||
m_ui->cbSymbol->addItem(current.text, current.code);
|
||||
|
||||
connect(m_ui->pbApply, &QPushButton::clicked,
|
||||
this, &MapParty::close);
|
||||
connect(m_ui->pbSkip, &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
m_skipped = true;
|
||||
close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
MapParty::~MapParty()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString MapParty::force() const
|
||||
{
|
||||
if (!m_ui->cbForce->count())
|
||||
return QString();
|
||||
|
||||
return m_ui->cbForce->currentText();
|
||||
}
|
||||
|
||||
QString MapParty::echelonCode() const
|
||||
{
|
||||
if (!m_ui->cbEchelon->count())
|
||||
return QString();
|
||||
|
||||
return m_ui->cbEchelon->currentData().toString();
|
||||
}
|
||||
|
||||
QString MapParty::symbolCode() const
|
||||
{
|
||||
if (!m_ui->cbSymbol->count())
|
||||
return QString();
|
||||
|
||||
return m_ui->cbSymbol->currentData().toString();
|
||||
}
|
||||
|
||||
bool saab::MapParty::isSkipped() const
|
||||
{
|
||||
return m_skipped;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "zwmssaab_export.h"
|
||||
#include "saab_types.h"
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
class Ui_MapParty;
|
||||
|
||||
namespace saab
|
||||
{
|
||||
class ZWMSSAAB_EXPORT MapParty
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MapParty(const QString &partyName,
|
||||
const QMap<QString, QString> &forces,
|
||||
const QMap<QString, SaabEchelon> &echelons,
|
||||
const QMap<QString, SaabSymbol> &symbols,
|
||||
QWidget *parent = nullptr);
|
||||
virtual ~MapParty();
|
||||
|
||||
bool isSkipped() const;
|
||||
|
||||
QString force() const;
|
||||
QString echelonCode() const;
|
||||
QString symbolCode() const;
|
||||
|
||||
private: // methods
|
||||
template <typename T>
|
||||
void sortList(QList<T> &list)
|
||||
{
|
||||
std::sort(list.begin(), list.end(), [](const T &a, const T& b){ return (a.text < b.text); });
|
||||
}
|
||||
|
||||
private: // attributes
|
||||
bool m_skipped;
|
||||
Ui_MapParty *m_ui;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "saab_map_type.h"
|
||||
#include "ui_saab_map_type.h"
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
MapType::MapType(const QString &text, const QMap<QString, SaabEchelon> &echelons, const QMap<QString, SaabSymbol> &symbols, bool isUnit, QWidget *parent)
|
||||
: LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_ui(new Ui_MapType)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
if (isUnit)
|
||||
m_ui->lblText->setText(tr("The Unit-type <b>%2</b> needs to be mapped:").arg(text));
|
||||
else
|
||||
m_ui->lblText->setText(tr("The Participant-type <b>%2</b> needs to be mapped:").arg(text));
|
||||
|
||||
if (!isUnit)
|
||||
{
|
||||
m_ui->cbEchelon->hide();
|
||||
m_ui->label_2->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<SaabEchelon> echelonList = echelons.values();
|
||||
|
||||
sortList(echelonList);
|
||||
|
||||
for (const SaabEchelon ¤t : qAsConst(echelonList))
|
||||
m_ui->cbEchelon->addItem(current.text, current.code);
|
||||
}
|
||||
|
||||
QList<SaabSymbol> symbolList = symbols.values();
|
||||
|
||||
sortList(symbolList);
|
||||
|
||||
for (const SaabSymbol ¤t : qAsConst(symbolList))
|
||||
m_ui->cbSymbol->addItem(current.text, current.code);
|
||||
|
||||
connect(m_ui->pbApply, &QPushButton::clicked,
|
||||
this, &MapType::close);
|
||||
}
|
||||
|
||||
|
||||
MapType::~MapType()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString MapType::echelonCode() const
|
||||
{
|
||||
if (!m_ui->cbEchelon->count())
|
||||
return QString();
|
||||
|
||||
return m_ui->cbEchelon->currentData().toString();
|
||||
}
|
||||
|
||||
QString MapType::symbolCode() const
|
||||
{
|
||||
if (!m_ui->cbSymbol->count())
|
||||
return QString();
|
||||
|
||||
return m_ui->cbSymbol->currentData().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "zwmssaab_export.h"
|
||||
#include "saab_types.h"
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
class Ui_MapType;
|
||||
|
||||
namespace saab
|
||||
{
|
||||
class ZWMSSAAB_EXPORT MapType
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MapType(const QString &typeName,
|
||||
const QMap<QString, SaabEchelon> &echelons,
|
||||
const QMap<QString, SaabSymbol> &symbols,
|
||||
bool isUnit,
|
||||
QWidget *parent = nullptr);
|
||||
virtual ~MapType();
|
||||
|
||||
QString echelonCode() const;
|
||||
QString symbolCode() const;
|
||||
|
||||
private: // methods
|
||||
template <typename T>
|
||||
void sortList(QList<T> &list)
|
||||
{
|
||||
std::sort(list.begin(), list.end(), [](const T &a, const T& b){ return (a.text < b.text); });
|
||||
}
|
||||
|
||||
private: // attributes
|
||||
Ui_MapType *m_ui;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "saab_mapping_dialog.h"
|
||||
#include "ui_saab_mapping_dialog.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <set>
|
||||
|
||||
namespace saab
|
||||
{
|
||||
MappingDialog::MappingDialog(QWidget *parent, bool typeClassIsUnit, const QString &strReason, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc, bool offerDatabaseEntriesWithoutDISType) : LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_offerDatabaseEntriesWithoutDISType(offerDatabaseEntriesWithoutDISType)
|
||||
, mLogger(saab::getLogger("SAABMappingDialog"))
|
||||
, m_ppmDtc(ppmDtc)
|
||||
, mUi(new Ui_SAABMappingDialog)
|
||||
{
|
||||
mUi->setupUi(this);
|
||||
mUi->m_label_ConflictReason->setText(strReason);
|
||||
|
||||
m_mapTypes = m_ppmDtc->types();
|
||||
std::set<ParticipantManagement::TypeClass> setTypeClasses; // unordered set?
|
||||
|
||||
/*
|
||||
* Show only type classes that include types with DIS ids. This should normally the case for all
|
||||
* type classes!
|
||||
*/
|
||||
for (const ParticipantManagement::Type &type : qAsConst(m_mapTypes))
|
||||
{
|
||||
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!";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.isDeleted())
|
||||
continue;
|
||||
|
||||
const ParticipantManagement::TypeClass typeClassId = type.typeClass();
|
||||
|
||||
if (typeClassId == ParticipantManagement::TypeClass::Unknown ||
|
||||
typeClassId == ParticipantManagement::TypeClass::Vessel ||
|
||||
typeClassId == ParticipantManagement::TypeClass::Aircraft)
|
||||
continue;
|
||||
|
||||
if (typeClassIsUnit)
|
||||
{
|
||||
if (typeClassId != ParticipantManagement::TypeClass::Unit && typeClassId != ParticipantManagement::TypeClass::SupportUnit)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeClassId == ParticipantManagement::TypeClass::Unit || typeClassId == ParticipantManagement::TypeClass::SupportUnit)
|
||||
continue;
|
||||
}
|
||||
|
||||
setTypeClasses.insert(typeClassId);
|
||||
}
|
||||
|
||||
for (const auto &typeclass : setTypeClasses)
|
||||
mUi->m_ltsComboBox_typeClass->addItem(ParticipantManagement::toString(typeclass), typeclass.underlying());
|
||||
|
||||
slotClassTypeChanged();
|
||||
|
||||
connect(mUi->m_ltsComboBox_typeClass, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this, &MappingDialog::slotClassTypeChanged);
|
||||
connect(mUi->m_PushButton_Skip, &QPushButton::clicked, this, &MappingDialog::close);
|
||||
connect(mUi->m_pushButton_Apply, &QPushButton::clicked, this, &MappingDialog::slotApplyMapping);
|
||||
connect(mUi->m_pushButton_SkipAllConflicts, &QPushButton::clicked, this, &MappingDialog::slotSkipAllElements);
|
||||
}
|
||||
|
||||
MappingDialog::~MappingDialog()
|
||||
{
|
||||
delete mUi;
|
||||
}
|
||||
|
||||
void MappingDialog::slotClassTypeChanged()
|
||||
{
|
||||
mUi->m_ltsComboBox_type->clear();
|
||||
|
||||
int currentClass = mUi->m_ltsComboBox_typeClass->currentData().toInt();
|
||||
|
||||
for (const ParticipantManagement::Type &type : qAsConst(m_mapTypes))
|
||||
{
|
||||
if(type.isDeleted())
|
||||
continue;
|
||||
|
||||
if (type.typeClass().underlying() != currentClass)
|
||||
continue;
|
||||
|
||||
if (!m_offerDatabaseEntriesWithoutDISType && (type.disEntities().size() == 0))
|
||||
{
|
||||
// Should never happen -> Database broken?!
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MappingDialog::slotApplyMapping()
|
||||
{
|
||||
m_mappingPerformed = true;
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void MappingDialog::slotSkipAllElements()
|
||||
{
|
||||
m_skipAllUnmappedElements = true;
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
bool MappingDialog::mappingApplied() const
|
||||
{
|
||||
return m_mappingPerformed;
|
||||
}
|
||||
|
||||
|
||||
bool MappingDialog::skipAllUnmappedElements() const
|
||||
{
|
||||
return m_skipAllUnmappedElements;
|
||||
}
|
||||
|
||||
int32_t MappingDialog::getMappedTypeId() const
|
||||
{
|
||||
int index = mUi->m_ltsComboBox_type->currentData().toInt();
|
||||
return m_mapTypes[index].id();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "saab_logging.h"
|
||||
|
||||
#include <memory>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
class Ui_SAABMappingDialog;
|
||||
|
||||
namespace saab
|
||||
{
|
||||
class MappingDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MappingDialog(QWidget *parent,
|
||||
bool typeClassIsUnit,
|
||||
const QString &strReason,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
bool offerDatabaseEntriesWithoutDISType);
|
||||
~MappingDialog();
|
||||
|
||||
bool mappingApplied() const;
|
||||
bool skipAllUnmappedElements() const;
|
||||
|
||||
int32_t getMappedTypeId() const;
|
||||
|
||||
private slots:
|
||||
void slotClassTypeChanged();
|
||||
void slotApplyMapping();
|
||||
void slotSkipAllElements();
|
||||
|
||||
private:
|
||||
bool m_offerDatabaseEntriesWithoutDISType = false;
|
||||
bool m_mappingPerformed = false;
|
||||
bool m_skipAllUnmappedElements = false;
|
||||
|
||||
QMap<qint32, ParticipantManagement::Type> m_mapTypes;
|
||||
|
||||
saab::LOGGER_T mLogger;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
Ui_SAABMappingDialog *mUi;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include "saab_types.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QXmlStreamWriter>
|
||||
#include "saab_xml_strings.h"
|
||||
|
||||
namespace saab
|
||||
{
|
||||
|
||||
bool SaabPlayer::hasDisType() const
|
||||
{
|
||||
return !disType.isEmpty();
|
||||
}
|
||||
|
||||
QString SaabPlayer::attrs() const
|
||||
{
|
||||
return QStringLiteral("guid: %1 | designation: %2 | force: %3 | symbol: %4 | trashcan: %5")
|
||||
.arg(guid, designation, force, symbol, trashcan ? QStringLiteral("true") : QStringLiteral("false"));
|
||||
}
|
||||
|
||||
void SaabPlayer::writeBaseInfo(const QString &startTag, QXmlStreamWriter *writer, bool isUnit) const
|
||||
{
|
||||
using namespace XmlStrings;
|
||||
|
||||
writer->writeStartElement(startTag);
|
||||
writer->writeAttribute(SAAB_ID(), guid);
|
||||
|
||||
writer->writeTextElement(SAAB_DESIGNATION(), designation);
|
||||
writer->writeTextElement(SAAB_FORCE(), force);
|
||||
writer->writeTextElement(SAAB_COLOR(), QStringLiteral("0"));
|
||||
writer->writeTextElement(SAAB_SYMBOL(), symbol);
|
||||
if (!isUnit)
|
||||
{
|
||||
if (simulatorId != INT_MIN)
|
||||
writer->writeTextElement(SAAB_SIMULATOR_ID(), QString::number(simulatorId));
|
||||
writer->writeTextElement(SAAB_FIXED_POSITION(), SAAB_FALSE());
|
||||
writer->writeTextElement(SAAB_EXTERNAL_PLAYER(), SAAB_FALSE());
|
||||
writer->writeTextElement(SAAB_RANK(), rank);
|
||||
}
|
||||
writer->writeTextElement(SAAB_TRASHCAN(), trashcan ? SAAB_TRUE() : SAAB_FALSE());
|
||||
}
|
||||
|
||||
QString SaabPersonPlayer::toString() const
|
||||
{
|
||||
return QStringLiteral("Person Player: ( %1 | personalID: %2 | name: %3)").arg(attrs(), personalID, name);
|
||||
}
|
||||
|
||||
void SaabPersonPlayer::writeToXml(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writeBaseInfo(XmlStrings::SAAB_PERSON_PLAYER(), writer);
|
||||
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
QString SaabVehiclePlayer::toString() const
|
||||
{
|
||||
return QStringLiteral("Vehicle Player: ( %1 | registrationNumber: %2 | description: %3)").arg(attrs(), registrationNumber, description);
|
||||
}
|
||||
|
||||
void SaabVehiclePlayer::writeToXml(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writeBaseInfo(XmlStrings::SAAB_VEHICLE_PLAYER(), writer);
|
||||
|
||||
writer->writeTextElement(XmlStrings::SAAB_ORIENTATION(), QStringLiteral("0"));
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
QString SaabUnit::toString() const
|
||||
{
|
||||
return toStringWithDepth(1);
|
||||
}
|
||||
|
||||
QString SaabUnit::toStringWithDepth(int depth) const
|
||||
{
|
||||
QString result = QStringLiteral("Unit: ( %1 | unitSize: %2 | positionByPlayerID: %3 | inferiors:\n").arg(attrs(), unitSize, positionByPlayerId);
|
||||
QString spaces;
|
||||
|
||||
for (int i = 0; i <= depth; ++i)
|
||||
spaces.append(QStringLiteral(" "));
|
||||
|
||||
for (SaabPlayer *current : qAsConst(inferiors))
|
||||
{
|
||||
SaabUnit *unit = dynamic_cast<SaabUnit *>(current);
|
||||
QString line = QStringLiteral("%1|\n%1+-- %2\n")
|
||||
.arg(spaces, (unit ? unit->toStringWithDepth(depth + 1) : current->toString()));
|
||||
|
||||
result.append(line);
|
||||
}
|
||||
|
||||
result.append(spaces + QLatin1Char(')'));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SaabUnit::writeToXml(QXmlStreamWriter *writer) const
|
||||
{
|
||||
using namespace XmlStrings;
|
||||
|
||||
writeBaseInfo(SAAB_UNIT(), writer);
|
||||
|
||||
writer->writeTextElement(SAAB_ORIGINAL_CREATION_ID(), guid);
|
||||
writer->writeTextElement(SAAB_UNIT_SIZE(), unitSize);
|
||||
writer->writeStartElement(SAAB_ORBAT_ENTITIES());
|
||||
|
||||
if (!inferiors.isEmpty())
|
||||
{
|
||||
for (SaabPlayer *player : qAsConst(inferiors))
|
||||
player->writeToXml(writer);
|
||||
}
|
||||
|
||||
writer->writeEndElement();
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
QString SaabOcPlayer::toString() const
|
||||
{
|
||||
QString result = SaabPersonPlayer::toString();
|
||||
|
||||
result.remove(0, 6);
|
||||
result.prepend(QStringLiteral("OC"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SaabOcPlayer::writeToXml(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writeBaseInfo(XmlStrings::SAAB_OC_PLAYER(), writer);
|
||||
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Typen fuer das Importieren von SAAB-Dateien
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <QVector>
|
||||
|
||||
class QXmlStreamWriter;
|
||||
|
||||
namespace saab
|
||||
{
|
||||
struct SaabSymbol
|
||||
{
|
||||
QString code;
|
||||
QString text;
|
||||
QString symbolId;
|
||||
QString modelId;
|
||||
QString echelonId;
|
||||
QString playerTypeId;
|
||||
QString color;
|
||||
qint32 mappedTypeId = -1;
|
||||
};
|
||||
|
||||
struct SaabForce
|
||||
{
|
||||
QString code;
|
||||
QString text;
|
||||
};
|
||||
|
||||
|
||||
struct SaabEchelon
|
||||
{
|
||||
QString id;
|
||||
QString code;
|
||||
QString text;
|
||||
};
|
||||
|
||||
struct SAABParty
|
||||
{
|
||||
QString m_ownHandle;
|
||||
QString m_forceSideName;
|
||||
};
|
||||
|
||||
struct SaabVehicle
|
||||
{
|
||||
QString guid;
|
||||
QString registrationNumber;
|
||||
QString description;
|
||||
|
||||
SaabVehicle() = default;
|
||||
SaabVehicle(const QString &guid, const QString ®istrationNumber, const QString &description)
|
||||
: guid(guid)
|
||||
, registrationNumber(registrationNumber)
|
||||
, description(description)
|
||||
{}
|
||||
|
||||
QString toString() const
|
||||
{
|
||||
return QStringLiteral("GUID: %1 | RegistrationNumber: %2 | Description: %3")
|
||||
.arg(guid, registrationNumber, description);
|
||||
}
|
||||
};
|
||||
|
||||
struct SaabPerson
|
||||
{
|
||||
QString guid;
|
||||
QString personalID;
|
||||
QString name;
|
||||
|
||||
SaabPerson() = default;
|
||||
SaabPerson(const QString &guid, const QString &personalID, const QString &name)
|
||||
: guid(guid)
|
||||
, personalID(personalID)
|
||||
, name(name)
|
||||
{}
|
||||
|
||||
QString toString() const
|
||||
{
|
||||
return QStringLiteral("GUID: %1 | PersonalID: %2 | Name: %3")
|
||||
.arg(guid, personalID, name);
|
||||
}
|
||||
};
|
||||
|
||||
class SaabPlayer
|
||||
{
|
||||
public:
|
||||
qint32 mappedTypeId = 0;
|
||||
int32_t articleNumber = 0;
|
||||
QString disType;
|
||||
QString guid;
|
||||
QString designation;
|
||||
QString refId; // personRefID or vehicleRefID
|
||||
QString rank;
|
||||
QString force;
|
||||
QString symbol; // code attribute of SaabSymbol
|
||||
bool trashcan;
|
||||
SaabPlayer *superior = nullptr;
|
||||
bool isDeletedByDefault = false;
|
||||
int simulatorId = INT_MIN;
|
||||
bool isExternalPlayer = false;
|
||||
|
||||
bool hasDisType() const;
|
||||
|
||||
virtual ~SaabPlayer() = default;
|
||||
virtual QString toString() const = 0;
|
||||
virtual void writeToXml(QXmlStreamWriter *writer) const = 0;
|
||||
|
||||
protected:
|
||||
QString attrs() const;
|
||||
void writeBaseInfo(const QString &startTag, QXmlStreamWriter *writer, bool isUnit = false) const;
|
||||
};
|
||||
|
||||
class SaabPersonPlayer
|
||||
: public SaabPlayer
|
||||
{
|
||||
public:
|
||||
QString personalID;
|
||||
QString name;
|
||||
|
||||
QString toString() const override;
|
||||
void writeToXml(QXmlStreamWriter *writer) const override;
|
||||
};
|
||||
|
||||
class SaabOcPlayer final
|
||||
: public SaabPersonPlayer
|
||||
{
|
||||
public:
|
||||
QString toString() const override final;
|
||||
void writeToXml(QXmlStreamWriter *writer) const override final;
|
||||
};
|
||||
|
||||
class SaabVehiclePlayer final
|
||||
: public SaabPlayer
|
||||
{
|
||||
public:
|
||||
QString registrationNumber;
|
||||
QString description;
|
||||
|
||||
QString toString() const override final;
|
||||
void writeToXml(QXmlStreamWriter *writer) const override final;
|
||||
};
|
||||
|
||||
class SaabUnit final
|
||||
: public SaabPlayer
|
||||
{
|
||||
public:
|
||||
QString positionByPlayerId;
|
||||
QString unitSize;
|
||||
QVector<SaabPlayer *> inferiors;
|
||||
|
||||
~SaabUnit()
|
||||
{
|
||||
qDeleteAll(inferiors);
|
||||
}
|
||||
|
||||
QString toString() const override final;
|
||||
QString toStringWithDepth(int depth) const;
|
||||
void writeToXml(QXmlStreamWriter *writer) const override final;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* occurring tag and attribute strings in saab xml
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace saab
|
||||
{
|
||||
namespace XmlStrings
|
||||
{
|
||||
inline QString SAAB_APPLICATION_ID() { return QStringLiteral("ApplicationID"); }
|
||||
inline QString SAAB_APPLICATION_TYPE() { return QStringLiteral("ApplicationType"); }
|
||||
inline QString SAAB_ARTICLE_NUMBER() { return QStringLiteral("ArticleNumber"); }
|
||||
inline QString SAAB_CHANGE_INFO() { return QStringLiteral("ChangeInfo"); }
|
||||
inline QString SAAB_CHANGE_TYPE() { return QStringLiteral("ChangeType"); }
|
||||
inline QString SAAB_CODE() { return QStringLiteral("Code"); }
|
||||
inline QString SAAB_COLOR() { return QStringLiteral("Color"); }
|
||||
inline QString SAAB_DELETE() { return QStringLiteral("Delete"); }
|
||||
inline QString SAAB_DESCRIPTION() { return QStringLiteral("Description"); }
|
||||
inline QString SAAB_DESIGNATION() { return QStringLiteral("Designation"); }
|
||||
inline QString SAAB_ECHELON() { return QStringLiteral("Echelon"); }
|
||||
inline QString SAAB_ECHELONS() { return QStringLiteral("Echelons"); }
|
||||
inline QString SAAB_ECHELON_ID() { return QStringLiteral("EchelonID"); }
|
||||
inline QString SAAB_EVALUATION_PACKAGE_FILE_NAME() { return QStringLiteral("EvaluationPackageFileName"); }
|
||||
inline QString SAAB_EXERCISE() { return QStringLiteral("Exercise"); }
|
||||
inline QString SAAB_EXERCISE_ORBAT() { return QStringLiteral("ExerciseOrbat"); }
|
||||
inline QString SAAB_EXERCISE_STATE() { return QStringLiteral("ExerciseState"); }
|
||||
inline QString SAAB_EXPORT_TIME() { return QStringLiteral("ExportTime"); }
|
||||
inline QString SAAB_EXTERNAL_PLAYER() { return QStringLiteral("ExternalPlayer"); }
|
||||
inline QString SAAB_FALSE() { return QStringLiteral("false"); }
|
||||
inline QString SAAB_FIXED_POSITION() { return QStringLiteral("FixedPosition"); }
|
||||
inline QString SAAB_FORCE() { return QStringLiteral("Force"); }
|
||||
inline QString SAAB_FORCES() { return QStringLiteral("Forces"); }
|
||||
inline QString SAAB_HELICOPTERS() { return QStringLiteral("Helicopters"); }
|
||||
inline QString SAAB_ID() { return QStringLiteral("ID"); }
|
||||
inline QString SAAB_MODEL_ID() { return QStringLiteral("ModelID"); }
|
||||
inline QString SAAB_NAME() { return QStringLiteral("Name"); }
|
||||
inline QString SAAB_OC_PLAYER() { return QStringLiteral("OCPlayer"); }
|
||||
inline QString SAAB_ORBAT() { return QStringLiteral("Orbat"); }
|
||||
inline QString SAAB_ORBAT_ENTITIES() { return QStringLiteral("OrbatEntities"); }
|
||||
inline QString SAAB_ORIENTATION() { return QStringLiteral("Orientation"); }
|
||||
inline QString SAAB_ORIGINAL_CREATION_ID() { return QStringLiteral("OriginalCreationID"); }
|
||||
inline QString SAAB_PERSON() { return QStringLiteral("Person"); }
|
||||
inline QString SAAB_PERSONS() { return QStringLiteral("Persons"); }
|
||||
inline QString SAAB_PERSON_PLAYER() { return QStringLiteral("PersonPlayer"); }
|
||||
inline QString SAAB_PERSON_REF_ID() { return QStringLiteral("PersonRefID"); }
|
||||
inline QString SAAB_PERSONAL_ID() { return QStringLiteral("PersonalID"); }
|
||||
inline QString SAAB_PLANNED_START_TIME() { return QStringLiteral("PlannedStartTime"); }
|
||||
inline QString SAAB_PLANNED_STOP_TIME() { return QStringLiteral("PlannedStopTime"); }
|
||||
inline QString SAAB_PLAYER_TYPE_ID() { return QStringLiteral("PlayerTypeID"); }
|
||||
inline QString SAAB_POSITION_BY_PLAYER_ID() { return QStringLiteral("PositionByPlayerID"); }
|
||||
inline QString SAAB_RANK() { return QStringLiteral("Rank"); }
|
||||
inline QString SAAB_REGISTRATION_NUMBER() { return QStringLiteral("RegistrationNumber"); }
|
||||
inline QString SAAB_SYMBOL_ID() { return QStringLiteral("SymbolID"); }
|
||||
inline QString SAAB_SIMULATOR_ID() { return QStringLiteral("SimulatorID"); }
|
||||
inline QString SAAB_SYMBOL() { return QStringLiteral("Symbol"); }
|
||||
inline QString SAAB_SYMBOLS() { return QStringLiteral("Symbols"); }
|
||||
inline QString SAAB_SYSTEM_ID() { return QStringLiteral("SystemID"); }
|
||||
inline QString SAAB_TEXT() { return QStringLiteral("Text"); }
|
||||
inline QString SAAB_TRUE() { return QStringLiteral("true"); }
|
||||
inline QString SAAB_UNIT() { return QStringLiteral("Unit"); }
|
||||
inline QString SAAB_UNIT_SIZE() { return QStringLiteral("UnitSize"); }
|
||||
inline QString SAAB_TRASHCAN() { return QStringLiteral("Trashcan"); }
|
||||
inline QString SAAB_VEHICLE() { return QStringLiteral("Vehicle"); }
|
||||
inline QString SAAB_VEHICLES() { return QStringLiteral("Vehicles"); }
|
||||
inline QString SAAB_VEHICLE_PLAYER() { return QStringLiteral("VehiclePlayer"); }
|
||||
inline QString SAAB_VEHICLE_REF_ID() { return QStringLiteral("VehicleRefID"); }
|
||||
inline QString SAAB_WIND_DIRECTION() { return QStringLiteral("WindDirection"); }
|
||||
inline QString SAAB_WIND_SPEED() { return QStringLiteral("WindSpeed"); }
|
||||
inline QString SAAB_XMLNS_XSI() { return QStringLiteral("xmlns:xsi"); }
|
||||
inline QString SAAB_XMLNS_XSD() { return QStringLiteral("xmlns:xsd"); }
|
||||
inline QString SAAB_XMLNS() { return QStringLiteral("xmlns"); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SAABExport</class>
|
||||
<widget class="QWidget" name="SAABExport">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>433</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import Exercise Scenario</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lineedit_ExportFile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_label_Import">
|
||||
<property name="text">
|
||||
<string>Selected Output File:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="m_pushbutton_SelectFile">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Selected Config File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="m_pushbutton_SelectConfig">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_pushButton_StartImport">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Export</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_lineedit_ConfigFile"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_lineedit_ExportFile</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SAABImport</class>
|
||||
<widget class="NGLDialog" name="SAABImport">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>433</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import Exercise Scenario</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lineedit_ImportFile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_label_Import">
|
||||
<property name="text">
|
||||
<string>Selected ORBAT File:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="m_pushbutton_SelectFile">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Selected config File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="m_pushbutton_SelectConfig">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_pushButton_StartImport">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Import</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_lineedit_configFile"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NGLDialog</class>
|
||||
<extends>QDialog</extends>
|
||||
<header>nglwidgets/ngldialog.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_lineedit_ImportFile</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SAABImportShow</class>
|
||||
<widget class="NGLDialog" name="SAABImportShow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>735</width>
|
||||
<height>514</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">defined in source</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="NGLDialogButtonBox" name="buttonBox" native="true">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NGLDialog</class>
|
||||
<extends>QDialog</extends>
|
||||
<header>nglwidgets/ngldialog.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>NGLDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>nglwidgets/ngldialogbuttonbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MapParty</class>
|
||||
<widget class="QWidget" name="MapParty">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>433</width>
|
||||
<height>164</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Map Type</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbForce"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Symbol:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Force:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbSymbol"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbEchelon"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbApply">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbSkip">
|
||||
<property name="text">
|
||||
<string>Skip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Echelon:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblText">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MapType</class>
|
||||
<widget class="QWidget" name="MapType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>433</width>
|
||||
<height>133</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Map Type</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Symbol:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbSymbol"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbApply">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbEchelon"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Echelon:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="lblText">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SAABMappingDialog</class>
|
||||
<widget class="QDialog" name="SAABMappingDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>645</width>
|
||||
<height>194</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import Conflict Occurred</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_label_ConflictReason">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Skip mapping:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="m_label_ConflictReason_2">
|
||||
<property name="text">
|
||||
<string>Note: Skipped types will not be imported</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="m_pushButton_SkipAllConflicts">
|
||||
<property name="text">
|
||||
<string>Skip all remaining types</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="m_PushButton_Skip">
|
||||
<property name="text">
|
||||
<string>Skip only this type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Apply mapping:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="m_ltsComboBox_typeClass"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="m_ltsComboBox_type"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="m_pushButton_Apply">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Export definitions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef ZWMSSAAB_EXPORT
|
||||
# ifdef MAKE_ZWMSSAAB_LIB
|
||||
# define ZWMSSAAB_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define ZWMSSAAB_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
Reference in new issue
Block a user