#include "aes_base_info.h" #include "ui_aes_base_info.h" #include #include #include #include #include #include namespace AreaEffectSimulation { BaseInfo::BaseInfo(QWidget *parent) : LtsDialog(parent) , m_session(nullptr) , m_ui(new Ui::BaseInfo) { m_ui->setupUi(this); } BaseInfo::~BaseInfo() { delete m_ui; } void BaseInfo::retranslate() { translate(m_ui, tr("AES Info")); } void BaseInfo::setEffectStart(qint64 effectStart) { if (effectStart > 0) { m_ui->lblEffectStart->show(); m_ui->lbxEffectStart->show(); m_ui->lblEffectStart->setText(QDateTime::fromMSecsSinceEpoch(effectStart).toString()); } else { m_ui->lblEffectStart->hide(); m_ui->lbxEffectStart->hide(); } } void BaseInfo::setEffectDuration(int32_t effectDuration) { if (effectDuration > 0) { m_ui->lblEffectDuration->show(); m_ui->lbxEffectDuration->show(); m_ui->lblEffectDuration->setText(LtsWidgets::readableDuration(effectDuration, false)); } else { m_ui->lblEffectDuration->hide(); m_ui->lbxEffectDuration->hide(); } } bool BaseInfo::setData(const AesItem *item) { if (!m_session) return false; std::shared_ptr pdmDtc = nullptr; std::shared_ptr ppmDtc = nullptr; m_session->getDtc(ppmDtc); if (!m_session->getDtc(pdmDtc) || !pdmDtc ) return false; setEffectDuration(item->effectDuration()); m_ui->lblIdentifier->setText(QString::fromStdString(item->name().c_str())); m_ui->lblChargeType->setText(pdmDtc->trChargeTypeShortName(item->chargeStruct().chargeTypeId(), true)); m_ui->lblChargeType->setToolTip(pdmDtc->trChargeTypeName(item->chargeStruct().chargeTypeId(), true)); m_ui->lblEffectState->setText(AreaEffectSimulation::toString(item->effectStateId())); setEffectStart(item->effectStart().is_set() ? item->effectStart().get() : 0); if (item->participantId().is_set()) { if (!ppmDtc) m_ui->lblParticipant->setText(tr("ID: %1").arg(item->participantId().get())); else { ParticipantManagement::Participant participant = ppmDtc->participant(item->partyId().get()); m_ui->lblParticipant->setText(QString::fromStdString(participant.name())); } } else { m_ui->lblParticipant->hide(); m_ui->lbxParticipant->hide(); } if (item->partyId().is_set()) { if (!ppmDtc) m_ui->lblParty->setText(tr("ID: %1").arg(item->partyId().get())); else { ParticipantManagement::Party party = ppmDtc->party(item->partyId().get()); m_ui->lblParty->setText(ParticipantManagement::trPartyName(party.name())); } } else { m_ui->lblParty->hide(); m_ui->lblParty->hide(); } return true; } void BaseInfo::init(LtsSession::LtsSessionDataDds *session) { m_session = session; } }