An item can be added to the model with accepting the NewItemDialog.
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#include "newitemdialog.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
@ -58,3 +60,21 @@ void NewItemDialog::createContent() {
|
||||
|
||||
m_outerLayout->insertWidget(0, m_contentContainer);
|
||||
}
|
||||
|
||||
void NewItemDialog::accept() {
|
||||
QJsonObject itemObject;
|
||||
itemObject.insert("Name", m_nameEdit->text());
|
||||
itemObject.insert("Description", m_descriptionEdit->text());
|
||||
itemObject.insert("Info", m_infoEdit->text());
|
||||
itemObject.insert("Amount", m_amountBox->value());
|
||||
itemObject.insert("Factor", m_factorBox->value());
|
||||
|
||||
QJsonDocument jsonDoc;
|
||||
QJsonArray itemArray;
|
||||
itemArray.append(itemObject);
|
||||
jsonDoc.setArray(itemArray);
|
||||
emit addItems(jsonDoc.toJson(QJsonDocument::Compact));
|
||||
|
||||
// resetContent();
|
||||
AbstractDialog::accept();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user