Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+75
@@ -0,0 +1,75 @@
|
||||
#include "participant_search_widget.h"
|
||||
#include "ui_participant_search_widget.h"
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
ParticipantSearchWidget::ParticipantSearchWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::ParticipantSearchWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->pbCancel, &QPushButton::clicked, this, &ParticipantSearchWidget::close);
|
||||
connect(m_ui->pbOk, &QPushButton::clicked, this, &ParticipantSearchWidget::onOkay);
|
||||
connect(m_ui->leEquipmentNo, &QLineEdit::returnPressed, this, &ParticipantSearchWidget::onOkay);
|
||||
}
|
||||
|
||||
ParticipantSearchWidget::~ParticipantSearchWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
void ParticipantSearchWidget::onOkay()
|
||||
{
|
||||
int participantId = m_eqId2PartId.value(m_ui->leEquipmentNo->text().toInt());
|
||||
if (participantId > 0)
|
||||
emit participantSelected(participantId);
|
||||
close();
|
||||
}
|
||||
void ParticipantSearchWidget::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
{
|
||||
const int newEqId = data.equipmentNumber().is_set() ? data.equipmentNumber().get() : 0;
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
const int oldEqId = m_partId2EqId.value(data.id());
|
||||
if (oldEqId == newEqId)
|
||||
return;
|
||||
if (oldEqId != 0)
|
||||
m_eqId2PartId.remove(oldEqId);
|
||||
if (newEqId == 0)
|
||||
return;
|
||||
m_partId2EqId[data.id()] = newEqId;
|
||||
m_eqId2PartId[newEqId] = data.id();
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
const int oldEqId = m_partId2EqId.value(data.id());
|
||||
m_partId2EqId.remove(data.id());
|
||||
if (oldEqId != 0)
|
||||
m_eqId2PartId.remove(oldEqId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
bool ParticipantSearchWidget::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc)
|
||||
{
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
auto cb = [this](const Participant &data)
|
||||
{
|
||||
if (!data.equipmentNumber().is_set())
|
||||
return;
|
||||
const int newEqId = data.equipmentNumber().get();
|
||||
m_partId2EqId[data.id()] = newEqId;
|
||||
m_eqId2PartId[newEqId] = data.id();
|
||||
};
|
||||
dtc->participants(cb);
|
||||
connect(dtc.get(), &Interface::Dtc::participantChanged,
|
||||
this, &ParticipantSearchWidget::onParticipantChanged);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
Reference in new issue
Block a user