Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+161
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
Reference in new issue
Block a user