/** * @RDE_HEADER@ * $Id$ * $HeadURL$ * $Author$ */ #include "msdl_mapping_dialog.h" #include "ui_msdl_mapping_dialog.h" #include #include namespace msdl { MappingDialog::MappingDialog(QWidget *parent, bool typeClassIsUnit, const QString &strReason, const std::shared_ptr &ppmDtc, bool offerDatabaseEntriesWithoutDISType) : LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal) , m_offerDatabaseEntriesWithoutDISType(offerDatabaseEntriesWithoutDISType) , mLogger(msdl::getLogger("MSDLMappingDialog")) , m_ppmDtc(ppmDtc) , mUi(new Ui_MSDLMappingDialog) { mUi->setupUi(this); mUi->m_label_ConflictReason->setText(strReason); m_mapTypes = m_ppmDtc->types(); std::set 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 MSDL data!"; continue; } const ParticipantManagement::TypeClass typeClassId = type.typeClass(); if (typeClassIsUnit) { if (typeClassId != ParticipantManagement::TypeClass::Unit) continue; } else { if (typeClassId == ParticipantManagement::TypeClass::Unit || typeClassId == ParticipantManagement::TypeClass::SupportUnit || typeClassId == ParticipantManagement::TypeClass::SupportEntity) 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(&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.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 MSDL 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; } bool MappingDialog::autoMapAllUnmappedElements() const { return mUi->m_checkBox_UseTypeForAllConflicts->isChecked(); } int32_t MappingDialog::getMappedTypeId() const { int index = mUi->m_ltsComboBox_type->currentData().toInt(); return m_mapTypes[index].id(); } }