70 lines
2.0 KiB
C++
Executable File
70 lines
2.0 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* HMI Plugin for ParticipantManagement - Insert Template Frameless Dialog
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, SLSE, 2016-10-05
|
|
*/
|
|
|
|
#include "participant_template_chooser_frameless.h"
|
|
#include "ui_participant_template_chooser_frameless.h"
|
|
#include "CustomView/template.h"
|
|
|
|
#include "participant_template_edit.h"
|
|
|
|
namespace ParticipantManagement
|
|
{
|
|
|
|
ParticipantTemplateChooserFrameless::ParticipantTemplateChooserFrameless(LtsSession::LtsSession *session, QWidget *parent)
|
|
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
|
, m_model(nullptr)
|
|
, m_dtc(nullptr)
|
|
, m_session(session)
|
|
, m_ui(new Ui::ParticipantTemplateChooserFrameless)
|
|
, m_logger(getLogger("ParticipantTemplateChooser"))
|
|
{
|
|
m_ui->setupUi(this);
|
|
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
}
|
|
|
|
ParticipantTemplateChooserFrameless::~ParticipantTemplateChooserFrameless()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
bool ParticipantTemplateChooserFrameless::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc)
|
|
{
|
|
if (!dtc)
|
|
return false;
|
|
|
|
m_dtc = dtc;
|
|
m_model = new ParticipantTemplateChooserModel(m_session->partitionId(), this);
|
|
m_model->initModel(m_session, m_dtc);
|
|
m_ui->widget->setModel(m_model, [this]() { return new CustomViewTemplate(this); });
|
|
m_ui->ltsDialogButtonBox->connectButton(LtsWidgets::DialogButton::Add, this, &ParticipantTemplateChooserFrameless::onAddTemplate);
|
|
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
|
//HACK as close is not allowed directly
|
|
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &ParticipantTemplateChooserFrameless::close);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//SLOTS
|
|
|
|
void ParticipantTemplateChooserFrameless::onAddTemplate()
|
|
{
|
|
QModelIndex idx = m_ui->widget->currentIndex();
|
|
if (!idx.isValid())
|
|
return;
|
|
TemplateParticipant data = m_model->getRowData(m_ui->widget->currentIndex().row());
|
|
emit selectedTemplate(data.templateId());
|
|
close();
|
|
}
|
|
|
|
|
|
|
|
} //namespace ParticipantManagement
|