Changing submit policy of QDataWidgetMapper to AutoSubmit because if multiple changes are made at once not all of them are applied.
This commit is contained in:
@ -6,12 +6,12 @@
|
||||
#include <QScreen>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
AbstractDialog::AbstractDialog(QWidget* parent)
|
||||
AbstractDialog::AbstractDialog(QDialogButtonBox::StandardButtons buttons, QWidget* parent)
|
||||
: QDialog(parent) {
|
||||
setWindowTitle(tr("Dialog does what?..."));
|
||||
setModal(true);
|
||||
|
||||
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
m_buttonBox = new QDialogButtonBox(buttons, this);
|
||||
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &AbstractDialog::accept);
|
||||
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &AbstractDialog::reject);
|
||||
|
||||
|
||||
@ -2,15 +2,15 @@
|
||||
#define ABSTRACTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
class QGridLayout;
|
||||
class QDialogButtonBox;
|
||||
class QVBoxLayout;
|
||||
|
||||
class AbstractDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AbstractDialog(QWidget* parent = nullptr);
|
||||
AbstractDialog(QDialogButtonBox::StandardButtons buttons, QWidget* parent = nullptr);
|
||||
virtual void createContent() = 0;
|
||||
|
||||
/// QDialog interface
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
#include "edititemdialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../views/itemdetailmapper.h"
|
||||
|
||||
EditItemDialog::EditItemDialog(QTableView* tableView, QWidget* parent)
|
||||
: AbstractDialog(parent)
|
||||
: AbstractDialog(QDialogButtonBox::Close, parent)
|
||||
, m_tableView(tableView) {}
|
||||
|
||||
void EditItemDialog::createContent() {
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#include "model/metadata.h"
|
||||
|
||||
NewItemDialog::NewItemDialog(QWidget* parent)
|
||||
: AbstractDialog(parent) {}
|
||||
: AbstractDialog(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, parent) {}
|
||||
|
||||
void NewItemDialog::createContent() {
|
||||
if (m_contentContainer) {
|
||||
@ -21,7 +21,9 @@ void NewItemDialog::createContent() {
|
||||
|
||||
m_contentContainer = new QWidget(this);
|
||||
|
||||
// REFACTOR deduce label names and types from meta data & use a factory
|
||||
// REFACTOR use a data structure for input widgets which can be iterated through
|
||||
// using a factory which iterates through the roles from metadata.h
|
||||
// and create the input widgets based on the data type of this role
|
||||
m_nameLabel = new QLabel("&Name");
|
||||
m_nameEdit = new QLineEdit();
|
||||
m_nameLabel->setBuddy(m_nameEdit);
|
||||
@ -63,6 +65,8 @@ void NewItemDialog::createContent() {
|
||||
|
||||
void NewItemDialog::accept() {
|
||||
QHash<int, QVariant> itemValues;
|
||||
// TODO (after refactoring data structure for input widgets) use iteration through the relevant
|
||||
// roles and their input widgets
|
||||
itemValues.insert(NameRole, m_nameEdit->text());
|
||||
itemValues.insert(DescriptionRole, m_descriptionEdit->text());
|
||||
itemValues.insert(InfoRole, m_infoEdit->text());
|
||||
|
||||
Reference in New Issue
Block a user