Files
prodejna/core/formdialog.cpp
T

48 lines
922 B
C++
Raw Normal View History

2015-11-17 22:24:00 +01:00
#include "formdialog.h"
#include "ui_formdialog.h"
2016-01-20 21:18:47 +01:00
#include <QMessageBox>
2015-11-17 22:24:00 +01:00
FormDialog::FormDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FormDialog)
{
ui->setupUi(this);
m_formSet = false;
m_form = NULL;
}
FormDialog::~FormDialog()
{
delete ui;
}
void FormDialog::setForm(IForm *formWidget)
{
if (m_form == NULL)
{
ui->verticalLayout->addWidget(formWidget);
m_form = formWidget;
2016-01-20 21:18:47 +01:00
connect(m_form, SIGNAL(validationError(QString)), this, SLOT(onValidationError(QString)));
2015-11-17 22:24:00 +01:00
setGeometry(formWidget->geometry());
}
}
2016-01-20 21:18:47 +01:00
void FormDialog::onValidationError(const QString &message)
2015-11-17 22:24:00 +01:00
{
2016-01-20 21:18:47 +01:00
QMessageBox::critical(this, tr("Validation error"), tr(message.toStdString().c_str()));
}
void FormDialog::accept()
{
if (m_form->saveRecord())
{
QDialog::accept();
}
2015-11-17 22:24:00 +01:00
}
2016-02-13 21:41:05 +01:00
void FormDialog::reject()
{
m_form->refresh();
QDialog::reject();
}