Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Tools/DdsView/topicselector.cpp
T
torsten d5c13033e2 Session 022: Migrate Lts/Tools (72 submodules) to Qt6
- Copied complete Lts/Tools directory from qt5-before to qt6-after
- Updated 32 CMakeLists.txt files (Qt5:: → Qt6::)
- Tools subdirectory already included in parent Lts/CMakeLists.txt
- All 72 tool submodules now present in qt6-migrated-legatus
- Includes: Adler, ArAssets, ConfigX, DBAdministration, DBUpdate,
  DdsView, InfrastructureManagement, and 67 more tools
- C++17 standard (RTI 7.7.0 compatibility maintained)
- Tests deferred until final validation phase

Migration progress:
✅ Lts/Application (68 files)
✅ Lts/DDS (verified Qt6-ready)
✅ Lts/Plugins (60 submodules, verified)
✅ Lts/Projects (5 submodules, verified)
✅ Lts/Proxies (13 submodules, verified)
✅ Lts/Services (47 submodules, verified)
✅ Lts/Tools (72 submodules, copied + CMake updated)
✅ Lts/Viewer (LtsFileDialog, LtsReportDisplay, SituationMap)
🟡 TetraIF (partial)
🟡 Z (partial: nglwidgets, QtSingleApplication, qsql_informix, WMS_Interface)
2026-08-25 14:07:20 +02:00

162 lines
5.3 KiB
C++
Executable File

/**
* @RDE_HEADER@
*
* Select Topic data for editing/setting default display data
*
* $Id$
* $HeadURL$
* $Author$
*/
#include "topicselector.h"
#include "typecodeselectordlg.h"
#include "nglsettings.h"
#include "topic_tree_model.h"
#include "ui_topicselector.h"
TopicSelector::TopicSelector(Usage usage, QWidget *parent)
: NGLDialog(parent)
, m_typeCodeInfos(NGLSettings::instance()->infoValues())
, m_ui(new Ui::TopicSelector)
{
m_ui->setupUi(this);
switch (usage)
{
case Usage::SampleSkeletons:
m_ui->nglDialogButtonBox->setStandardButtons(NGLStandardButton::Add | NGLStandardButton::Close);
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onAdd, this, &TopicSelector::onAdd);
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onClose, this, &TopicSelector::accept);
connect(m_ui->tvDataTopics, &QTreeView::doubleClicked, this, &TopicSelector::onAdd);
connect(m_ui->tvFunctionTopics, &QTreeView::doubleClicked, this, &TopicSelector::onAdd);
setWindowTitle(tr("Select Topic..."));
break;
case Usage::TypeCodeInfos:
m_ui->nglDialogButtonBox->setStandardButtons(NGLStandardButton::Ok | NGLStandardButton::Cancel | NGLStandardButton::Edit);
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onEdit, this, &TopicSelector::onEdit);
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onCancel, this, &TopicSelector::onCancel);
connect(m_ui->nglDialogButtonBox, &NGLDialogButtonBox::onOk, this, &TopicSelector::onOk);
connect(m_ui->tvDataTopics, &QTreeView::doubleClicked, this, &TopicSelector::onEdit);
connect(m_ui->tvFunctionTopics, &QTreeView::doubleClicked, this, &TopicSelector::onEdit);
// Todo: Better name...
setWindowTitle(tr("Select Topic..."));
break;
}
m_treeSrcModelData = new TreeModel(this);
m_treeSrcModelData->setWithTypeCode(true);
m_dataSortModel = new TopicSortModel(this);
m_dataSortModel->setSourceModel(m_treeSrcModelData);
m_ui->tvDataTopics->setModel(m_dataSortModel);
m_treeSrcModelFunction = new TreeModel(this);
m_treeSrcModelFunction->setWithTypeCode(true);
m_functionSortModel = new TopicSortModel(this);
m_functionSortModel->setSourceModel(m_treeSrcModelFunction);
m_ui->tvFunctionTopics->setModel(m_functionSortModel);
// QString = topicName (NOT typeName!)
const QMap<std::string, TopicDescriptionEx> dataTopicMap = NGLSettings::instance()->dataTopics();
for (auto it = dataTopicMap.constBegin(); it != dataTopicMap.constEnd(); ++it)
m_dataSortModel->addData(*it, nullptr);
m_dataSortModel->sort(0, Qt::AscendingOrder);
// QString = topicName (NOT typeName!)
const QMap<std::string, TopicDescriptionEx> functionTopicMap = NGLSettings::instance()->functionTopics();
for (auto it = functionTopicMap.constBegin(); it != functionTopicMap.constEnd(); ++it)
m_functionSortModel->addData(*it, nullptr);
m_functionSortModel->sort(0, Qt::AscendingOrder);
m_ui->toolBox->setCurrentIndex(0);
}
TopicSelector::~TopicSelector()
{
delete m_ui;
}
void TopicSelector::onAdd()
{
TopicDescriptionEx topicDesc;
if (m_ui->toolBox->currentWidget() == m_ui->tvFunctionTopics)
{
const QModelIndexList mil = m_ui->tvFunctionTopics->selectionModel()->selectedRows();
if (mil.isEmpty())
return;
topicDesc = m_functionSortModel->getData(mil.at(0));
}
else
{
const QModelIndexList mil = m_ui->tvDataTopics->selectionModel()->selectedRows();
if (mil.isEmpty())
return;
topicDesc = m_dataSortModel->getData(mil.at(0));
}
emit data(dds::core::xtypes::DynamicData(topicDesc.type), QString::fromStdString(topicDesc.name));
}
void TopicSelector::onEdit()
{
TopicDescriptionEx topicDesc;
if (m_ui->toolBox->currentWidget() == m_ui->tvFunctionTopics)
{
const QModelIndexList mil = m_ui->tvFunctionTopics->selectionModel()->selectedRows();
if (mil.isEmpty())
return;
topicDesc = m_functionSortModel->getData(mil.at(0));
}
else
{
const QModelIndexList mil = m_ui->tvDataTopics->selectionModel()->selectedRows();
if (mil.isEmpty())
return;
topicDesc = m_dataSortModel->getData(mil.at(0));
}
if (m_dialogs.contains(topicDesc.typeName))
{
m_dialogs[topicDesc.typeName]->raise();
return;
}
TypeCodeSelectorDlg *tcsd = new TypeCodeSelectorDlg(this);
connect(tcsd, &TypeCodeSelectorDlg::typeCodeInfosChanged,
this, &TopicSelector::onTypeCodeInfosChanged);
connect(tcsd, &TypeCodeSelectorDlg::finished,
this, &TopicSelector::onSubDialogFinished);
QString topicName(QString::fromStdString(topicDesc.name));
tcsd->init(topicName, m_typeCodeInfos.value(topicName), topicDesc.type);
tcsd->show();
m_dialogs[topicDesc.name] = tcsd;
}
void TopicSelector::onOk()
{
NGLSettings::instance()->setInfoValues(m_typeCodeInfos);
emit typeCodeInfosChanged();
for (TypeCodeSelectorDlg *tcsd : qAsConst(m_dialogs))
tcsd->reject();
accept();
}
void TopicSelector::onCancel()
{
for (TypeCodeSelectorDlg *tcsd : qAsConst(m_dialogs))
tcsd->reject();
reject();
}
void TopicSelector::onSubDialogFinished()
{
TypeCodeSelectorDlg *tcsd = qobject_cast<TypeCodeSelectorDlg *>(sender());
if (!tcsd)
return;
std::string key = m_dialogs.key(tcsd);
m_dialogs.remove(key);
}
void TopicSelector::onTypeCodeInfosChanged(const QString &typeCode, const QStringList &infoList)
{
m_typeCodeInfos[typeCode] = infoList;
}