Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user