Files
qt5-legatus-legacy/Lts/Plugins/ParticipantManagement/Gui/ParticipantInfo/participants_mounted_table_dialog.cpp
T
2026-08-13 18:33:10 +02:00

69 lines
2.0 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Dialog for mounted participants table
* $Id$
* $HeadURL$
* $Author$
* Created by Dassow Philipp, SLEA, 2017-08-30
*/
#include "participants_mounted_table_dialog.h"
#include "ui_participants_mounted_table_dialog.h"
namespace ParticipantManagement {
ParticipantsMountedTableDialog::ParticipantsMountedTableDialog(int32_t carrierId, QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
, m_carrierId(carrierId)
, m_dtc(nullptr)
, m_ppmGuiIfc(nullptr)
, m_mountedTableModel(nullptr)
, m_ui(new Ui::ParticipantsMountedTableDialog)
, m_logger(getLogger("ParticipantsMountedTableDialog"))
{
m_ui->setupUi(this);
}
ParticipantsMountedTableDialog::~ParticipantsMountedTableDialog()
{
delete m_ui;
}
bool ParticipantsMountedTableDialog::init(const std::shared_ptr<Interface::Dtc> &dtc,
const std::shared_ptr<ForeignParticipantInfoGuiInterface> &ppmGuiIfc)
{
m_dtc = dtc;
m_ppmGuiIfc = ppmGuiIfc;
m_mountedTableModel = new ParticipantsMountedTableModel(this);
if (!m_mountedTableModel->initModel(m_carrierId, m_dtc))
return false;
m_ui->tvMountedParticipants->setModel(m_mountedTableModel);
connect(m_ui->tvMountedParticipants, &LtsDataView::LtsDataView::signalDoubleClicked,
this,
&ParticipantsMountedTableDialog::onShowTlnInfo);
return true;
}
void ParticipantsMountedTableDialog::onShowTlnInfo()
{
if (!m_ppmGuiIfc)
return;
DEBUG_LOG(m_logger) << "onDoubleClick --> showTlnInfo";
const QModelIndex idx = m_ui->tvMountedParticipants->currentIndex();
const int id = m_mountedTableModel->getRowData(idx.row()).id();
m_ppmGuiIfc->showParticipantInfoWindow(id);
}
void ParticipantsMountedTableDialog::retranslate()
{
const dds::core::optional<int32_t> eqId = m_dtc->participant(m_carrierId).equipmentNumber();
const QString id = (eqId.is_set() ? QString::number(eqId.get()) : QString());
translate(m_ui, id, false, tr("participants on vehicle")); // will be 'Show participants on vehicle: 4711'
}
}