Added roles for BeetRound purpose.

This commit is contained in:
2026-02-07 17:56:46 +01:00
parent 2fcd69df5f
commit c6d6b18ab3
10 changed files with 375 additions and 162 deletions

View File

@ -6,6 +6,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QStringListModel>
#include "formats/jsonparser.h"
#include "model/metadata.h"
@ -24,39 +25,82 @@ void NewItemDialog::createContent() {
// 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);
m_numberLabel = new QLabel(GET_HEADER_FOR_COLUMN(0));
m_numberBox = new QSpinBox();
m_numberBox->setMaximum(1000);
m_descriptionLabel = new QLabel("&Description");
m_descriptionEdit = new QLineEdit();
m_descriptionLabel->setBuddy(m_descriptionEdit);
m_lastNameLabel = new QLabel(GET_HEADER_FOR_COLUMN(1));
m_lastNameEdit = new QLineEdit();
m_lastNameLabel->setBuddy(m_lastNameEdit);
m_infoLabel = new QLabel("&Info");
m_infoEdit = new QLineEdit();
m_infoLabel->setBuddy(m_infoEdit);
m_firstNameLabel = new QLabel(GET_HEADER_FOR_COLUMN(2));
m_firstNameEdit = new QLineEdit();
m_firstNameLabel->setBuddy(m_firstNameEdit);
m_amountLabel = new QLabel("&Amount");
m_amountBox = new QSpinBox();
m_amountBox->setMaximum(1000);
m_amountLabel->setBuddy(m_amountBox);
m_shareTypeLabel = new QLabel(GET_HEADER_FOR_COLUMN(3));
m_shareTypeBox = new QComboBox();
m_shareTypeLabel->setBuddy(m_shareTypeBox);
m_shareTypeModel = new QStringListModel(SHARE_TYPES, this);
m_shareTypeBox->setModel(m_shareTypeModel);
m_factorLabel = new QLabel("&Factor");
m_factorBox = new QDoubleSpinBox();
m_factorBox->setMaximum(1000);
m_factorLabel->setBuddy(m_factorBox);
m_amountLabel = new QLabel(GET_HEADER_FOR_COLUMN(4));
m_amountSpinBox = new QDoubleSpinBox();
m_amountLabel->setBuddy(m_amountSpinBox);
m_biddingTypeLabel = new QLabel(GET_HEADER_FOR_COLUMN(5));
m_biddingTypeBox = new QComboBox();
m_biddingTypeLabel->setBuddy(m_biddingTypeBox);
m_biddingTypeModel = new QStringListModel(BIDDING_TYPES, this);
m_biddingTypeBox->setModel(m_biddingTypeModel);
m_bidding1Label = new QLabel(GET_HEADER_FOR_COLUMN(6));
m_bidding1SpinBox = new QSpinBox();
m_bidding1SpinBox->setMaximum(500);
m_bidding2Label = new QLabel(GET_HEADER_FOR_COLUMN(7));
m_bidding2SpinBox = new QSpinBox();
m_bidding2SpinBox->setMaximum(500);
m_bidding3Label = new QLabel(GET_HEADER_FOR_COLUMN(8));
m_bidding3SpinBox = new QSpinBox();
m_bidding3SpinBox->setMaximum(500);
m_depotWish1Label = new QLabel(GET_HEADER_FOR_COLUMN(9));
m_depotWish1Edit = new QLineEdit();
m_depotWish1Label->setBuddy(m_depotWish1Edit);
m_depotWish2Label = new QLabel(GET_HEADER_FOR_COLUMN(10));
m_depotWish2Edit = new QLineEdit();
m_depotWish2Label->setBuddy(m_depotWish2Edit);
m_mailLabel = new QLabel(GET_HEADER_FOR_COLUMN(11));
m_mailEdit = new QLineEdit();
m_mailEdit->setMinimumWidth(200);
m_mailLabel->setBuddy(m_mailEdit);
/// layouting
QGridLayout* layout = new QGridLayout();
layout->addWidget(m_nameLabel, 0, 0, 1, 1);
layout->addWidget(m_nameEdit, 0, 1, 1, 1);
layout->addWidget(m_descriptionLabel, 1, 0, 1, 1);
layout->addWidget(m_descriptionEdit, 1, 1, 1, 1);
layout->addWidget(m_infoLabel, 2, 0, 1, 1);
layout->addWidget(m_infoEdit, 2, 1, 1, 1);
layout->addWidget(m_amountLabel, 3, 0, 1, 1);
layout->addWidget(m_amountBox, 3, 1, 1, 1);
layout->addWidget(m_factorLabel, 4, 0, 1, 1);
layout->addWidget(m_factorBox, 4, 1, 1, 1);
layout->addWidget(m_numberLabel, 0, 0, 1, 1);
layout->addWidget(m_numberBox, 0, 1, 1, 1);
layout->addWidget(m_lastNameLabel, 1, 0, 1, 1);
layout->addWidget(m_lastNameEdit, 1, 1, 1, 1);
layout->addWidget(m_firstNameLabel, 2, 0, 1, 1);
layout->addWidget(m_firstNameEdit, 2, 1, 1, 1);
layout->addWidget(m_shareTypeLabel, 3, 0, 1, 1);
layout->addWidget(m_shareTypeBox, 3, 1, 1, 1);
layout->addWidget(m_amountLabel, 4, 0, 1, 1);
layout->addWidget(m_amountSpinBox, 4, 1, 1, 1);
layout->addWidget(m_biddingTypeLabel, 5, 0, 1, 1);
layout->addWidget(m_biddingTypeBox, 5, 1, 1, 1);
layout->addWidget(m_bidding1Label, 6, 0, 1, 1);
layout->addWidget(m_bidding1SpinBox, 6, 1, 1, 1);
layout->addWidget(m_bidding2Label, 7, 0, 1, 1);
layout->addWidget(m_bidding2SpinBox, 7, 1, 1, 1);
layout->addWidget(m_bidding3Label, 8, 0, 1, 1);
layout->addWidget(m_bidding3SpinBox, 8, 1, 1, 1);
layout->addWidget(m_depotWish1Label, 9, 0, 1, 1);
layout->addWidget(m_depotWish1Edit, 9, 1, 1, 1);
layout->addWidget(m_depotWish2Label, 10, 0, 1, 1);
layout->addWidget(m_depotWish2Edit, 10, 1, 1, 1);
layout->addWidget(m_mailLabel, 11, 0, 1, 1);
layout->addWidget(m_mailEdit, 11, 1, 1, 1);
m_contentContainer->setLayout(layout);
@ -67,11 +111,19 @@ void NewItemDialog::accept() {
ModelItemValues 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());
itemValues.insert(AmountRole, m_amountBox->value());
itemValues.insert(FactorRole, m_factorBox->value());
// itemValues.insert(LastNameRole, m_nameEdit->text());
itemValues.insert(GET_ROLE_FOR_COLUMN(0), m_numberBox->value());
itemValues.insert(GET_ROLE_FOR_COLUMN(1), m_lastNameEdit->text());
itemValues.insert(GET_ROLE_FOR_COLUMN(2), m_firstNameEdit->text());
itemValues.insert(GET_ROLE_FOR_COLUMN(3), m_shareTypeBox->currentText());
itemValues.insert(GET_ROLE_FOR_COLUMN(4), m_amountSpinBox->value());
itemValues.insert(GET_ROLE_FOR_COLUMN(5), m_biddingTypeBox->currentText());
itemValues.insert(GET_ROLE_FOR_COLUMN(6), m_bidding1SpinBox->value());
itemValues.insert(GET_ROLE_FOR_COLUMN(7), m_bidding2SpinBox->value());
itemValues.insert(GET_ROLE_FOR_COLUMN(8), m_bidding3SpinBox->value());
itemValues.insert(GET_ROLE_FOR_COLUMN(9), m_depotWish1Edit->text());
itemValues.insert(GET_ROLE_FOR_COLUMN(10), m_depotWish2Edit->text());
itemValues.insert(GET_ROLE_FOR_COLUMN(11), m_mailEdit->text());
const QByteArray jsonDoc = JsonParser::itemValuesListToJson({itemValues}, ITEMS_KEY_STRING);
emit addItems(jsonDoc);

View File

@ -3,6 +3,9 @@
#include "abstractdialog.h"
#include <QComboBox>
class QStringListModel;
class QDoubleSpinBox;
class QLineEdit;
class QSpinBox;
@ -24,20 +27,40 @@ class NewItemDialog : public AbstractDialog {
// void reject() override;
private:
QLabel* m_nameLabel = nullptr;
QLineEdit* m_nameEdit = nullptr;
QLabel* m_numberLabel;
QSpinBox* m_numberBox;
QLabel* m_descriptionLabel = nullptr;
QLineEdit* m_descriptionEdit = nullptr;
QLabel* m_lastNameLabel;
QLineEdit* m_lastNameEdit;
QLabel* m_infoLabel = nullptr;
QLineEdit* m_infoEdit = nullptr;
QLabel* m_firstNameLabel;
QLineEdit* m_firstNameEdit;
QLabel* m_amountLabel = nullptr;
QSpinBox* m_amountBox = nullptr;
QLabel* m_shareTypeLabel;
QComboBox* m_shareTypeBox;
QStringListModel* m_shareTypeModel = nullptr;
QLabel* m_factorLabel = nullptr;
QDoubleSpinBox* m_factorBox = nullptr;
QLabel* m_amountLabel;
QDoubleSpinBox* m_amountSpinBox;
QLabel* m_biddingTypeLabel;
QComboBox* m_biddingTypeBox;
QStringListModel* m_biddingTypeModel = nullptr;
QLabel* m_bidding1Label;
QSpinBox* m_bidding1SpinBox;
QLabel* m_bidding2Label;
QSpinBox* m_bidding2SpinBox;
QLabel* m_bidding3Label;
QSpinBox* m_bidding3SpinBox;
QLabel* m_depotWish1Label;
QLineEdit* m_depotWish1Edit;
QLabel* m_depotWish2Label;
QLineEdit* m_depotWish2Edit;
QLabel* m_mailLabel;
QLineEdit* m_mailEdit;
};
#endif // NEWITEMDIALOG_H