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

85 lines
2.7 KiB
C++
Executable File

/**
* @RDE_HEADER@
* GUI Plugin for ParticipantManagement - ParticipantHistoryDialog
* $Id$
* $HeadURL$
* $Author$
* Created by Patric Karwat, SLSE, 2016-07-07
*/
#include <LtsUtilsSettings/settings.h>
#include "participant_history_dialog.h"
#include "ui_participant_history_dialog.h"
#include <QDebug>
namespace ParticipantManagement
{
ParticipantHistoryDialog::ParticipantHistoryDialog(QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
, m_ddsId(-1)
, m_model(new ParticipantHistoryDialogModel(this))
, m_proxyModel(new ParticipantHistorySortModel(this))
, m_dtc(nullptr)
, m_ui(new Ui::ParticipantHistoryDialog)
, m_logger(getLogger("ParticipantHistoryDialog"))
{
m_proxyModel->setSourceModel(m_model);
m_ui->setupUi(this);
m_ui->tvHistory->setModel(m_proxyModel);
#ifndef LTS_DEBUG
m_ui->tvHistory->hideColumn(ParticipantHistoryDialogModel::VulnerabilityBits);
#endif
const bool showVulnerabilityKindProject = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
QStringLiteral("ShowVulnerabilityKind"));
if (!showVulnerabilityKindProject)
m_ui->tvHistory->hideColumn(ParticipantHistoryDialogModel::Vulnerability);
setUnchangeable();
}
ParticipantHistoryDialog::~ParticipantHistoryDialog()
{
delete m_ui;
}
void ParticipantHistoryDialog::retranslate()
{
const dds::core::optional<int32_t> eqId = m_dtc->participant(m_ddsId).equipmentNumber();
const QString id = (eqId.is_set() ? QString::number(eqId.get()) : QString());
translate(m_ui, id, false, tr("Participant History"));
}
bool ParticipantHistoryDialog::init(int ddsId,
const std::shared_ptr<Interface::Dtc> &dtc,
const std::shared_ptr<ProjectDataManagement::Interface::Dtc> &pdmDtc,
const std::shared_ptr<AreaEffectSimulation::Interface::Dtc> &aesDtc)
{
m_ddsId = ddsId;
m_dtc = dtc;
if (!m_dtc)
return false;
if (m_model->initModel(m_ddsId, m_dtc, pdmDtc, aesDtc))
{
m_ui->tvHistory->syncSearchHeaderAndTableContentColumnSize();
bool isHuman = m_dtc->type(m_dtc->participant(m_ddsId).typeId()).typeClass() == ParticipantManagement::TypeClass::Human;
const bool showPvSan = LtsUtils::ProjectSettings::isFunctionEnabled(QStringLiteral("ParticipantInformation"),
QStringLiteral("HasPvSan"));
if (!showPvSan || !isHuman)
m_ui->tvHistory->hideColumn(ParticipantHistoryDialogModel::Vitality);
return true;
}
return false;
}
} // namespace ParticipantManagement