Added onlineID and accessUrl widgets to the edit item dialog layout. No functionality yet.
This commit is contained in:
@ -8,8 +8,7 @@
|
||||
|
||||
EditItemDialog::EditItemDialog(QTableView* tableView, QWidget* parent)
|
||||
: AbstractDialog(QDialogButtonBox::Ok, parent)
|
||||
, m_tableView(tableView)
|
||||
, m_qrCodeDisplay(new QLabel("QR Code")) {}
|
||||
, m_tableView(tableView) {}
|
||||
|
||||
void EditItemDialog::createContent() {
|
||||
if (m_contentContainer) {
|
||||
@ -26,10 +25,6 @@ void EditItemDialog::createContent() {
|
||||
m_detailMapper->setModelMappings(m_tableView);
|
||||
innerLayout->addWidget(m_detailMapper);
|
||||
|
||||
updateQRCode();
|
||||
connect(m_detailMapper, &ItemDetailMapper::contentChanged, this, &EditItemDialog::updateQRCode);
|
||||
innerLayout->addWidget(m_qrCodeDisplay);
|
||||
|
||||
m_outerLayout->insertWidget(0, m_contentContainer);
|
||||
}
|
||||
|
||||
@ -42,16 +37,3 @@ void EditItemDialog::reject() {
|
||||
m_detailMapper->revert();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void EditItemDialog::updateQRCode(const QString text) {
|
||||
QImage unscaledImage;
|
||||
if (text.isEmpty()) {
|
||||
unscaledImage = QImage("://no-picture-taking.png");
|
||||
} else {
|
||||
unscaledImage = m_generator.generateQr(text);
|
||||
}
|
||||
QImage image = unscaledImage.scaled(250, 250);
|
||||
|
||||
m_qrCodeDisplay->setPixmap(QPixmap::fromImage(image));
|
||||
m_qrCodeDisplay->setToolTip(text);
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#ifndef EDITITEMDIALOG_H
|
||||
#define EDITITEMDIALOG_H
|
||||
|
||||
#include "QrCodeGenerator.h"
|
||||
#include "abstractdialog.h"
|
||||
|
||||
class QDoubleSpinBox;
|
||||
@ -24,30 +23,9 @@ class EditItemDialog : public AbstractDialog {
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
|
||||
private slots:
|
||||
void updateQRCode(const QString text = "");
|
||||
|
||||
private:
|
||||
QTableView* m_tableView = nullptr;
|
||||
ItemDetailMapper* m_detailMapper;
|
||||
|
||||
QLabel* m_nameLabel = nullptr;
|
||||
QLineEdit* m_nameEdit = nullptr;
|
||||
|
||||
QLabel* m_descriptionLabel = nullptr;
|
||||
QLineEdit* m_descriptionEdit = nullptr;
|
||||
|
||||
QLabel* m_infoLabel = nullptr;
|
||||
QLineEdit* m_infoEdit = nullptr;
|
||||
|
||||
QLabel* m_amountLabel = nullptr;
|
||||
QSpinBox* m_amountBox = nullptr;
|
||||
|
||||
QLabel* m_factorLabel = nullptr;
|
||||
QDoubleSpinBox* m_factorBox = nullptr;
|
||||
|
||||
QLabel* m_qrCodeDisplay = nullptr;
|
||||
QrCodeGenerator m_generator;
|
||||
};
|
||||
|
||||
#endif // EDITITEMDIALOG_H
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
#include "model/metadata.h"
|
||||
|
||||
ItemDetailMapper::ItemDetailMapper(QWidget* parent)
|
||||
: QWidget{parent} {
|
||||
: QWidget{parent}
|
||||
, m_qrCodeDisplay(new QLabel("QR Code")) {
|
||||
/// model mapping
|
||||
m_mapper = std::make_unique<QDataWidgetMapper>(this);
|
||||
/// BUG: If multiple columns are changed not all changes are applied.
|
||||
@ -35,7 +36,8 @@ ItemDetailMapper::ItemDetailMapper(QWidget* parent)
|
||||
connect(m_nextButton, &QAbstractButton::clicked, this, &ItemDetailMapper::toNext);
|
||||
|
||||
/// the individual widgets
|
||||
// REFACTOR deduce label names and types from meta data & use a factory
|
||||
// REFACTOR deduce types from meta data & use a factory
|
||||
/// left layout
|
||||
m_numberLabel = new QLabel(GET_HEADER_FOR_COLUMN(0));
|
||||
m_numberBox = new QSpinBox();
|
||||
m_numberBox->setMaximum(1000);
|
||||
@ -86,36 +88,74 @@ ItemDetailMapper::ItemDetailMapper(QWidget* parent)
|
||||
m_mailEdit->setMinimumWidth(200);
|
||||
m_mailLabel->setBuddy(m_mailEdit);
|
||||
|
||||
QGridLayout* layout = new QGridLayout();
|
||||
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);
|
||||
/// right layout
|
||||
m_createOnlineAccountButton = new QPushButton(tr("&Create account"));
|
||||
m_sendInviteMailButton = new QPushButton(tr("&Send invite"));
|
||||
|
||||
layout->addWidget(m_previousButton, 12, 0, 1, 1);
|
||||
layout->addWidget(m_nextButton, 12, 1, 1, 1);
|
||||
m_onlineIdLabel = new QLabel(GET_HEADER_FOR_COLUMN(12));
|
||||
m_onlineIdDisplay = new QLineEdit();
|
||||
m_onlineIdDisplay->setReadOnly(true);
|
||||
m_onlineIdLabel->setBuddy(m_onlineIdDisplay);
|
||||
|
||||
setLayout(layout);
|
||||
m_accessCodeLabel = new QLabel(GET_HEADER_FOR_COLUMN(13));
|
||||
m_accessCodeDisplay = new QLineEdit();
|
||||
m_accessCodeDisplay->setReadOnly(true);
|
||||
m_accessCodeLabel->setBuddy(m_onlineIdDisplay);
|
||||
|
||||
updateQRCode();
|
||||
connect(this, &ItemDetailMapper::contentChanged, this, &ItemDetailMapper::updateQRCode);
|
||||
|
||||
m_accessUrlDisplay = new QLineEdit();
|
||||
m_accessUrlDisplay->setReadOnly(true);
|
||||
|
||||
QGridLayout* leftLayout = new QGridLayout();
|
||||
leftLayout->addWidget(m_numberLabel, 0, 0, 1, 1);
|
||||
leftLayout->addWidget(m_numberBox, 0, 1, 1, 1);
|
||||
leftLayout->addWidget(m_lastNameLabel, 1, 0, 1, 1);
|
||||
leftLayout->addWidget(m_lastNameEdit, 1, 1, 1, 1);
|
||||
leftLayout->addWidget(m_firstNameLabel, 2, 0, 1, 1);
|
||||
leftLayout->addWidget(m_firstNameEdit, 2, 1, 1, 1);
|
||||
leftLayout->addWidget(m_shareTypeLabel, 3, 0, 1, 1);
|
||||
leftLayout->addWidget(m_shareTypeBox, 3, 1, 1, 1);
|
||||
leftLayout->addWidget(m_amountLabel, 4, 0, 1, 1);
|
||||
leftLayout->addWidget(m_amountSpinBox, 4, 1, 1, 1);
|
||||
leftLayout->addWidget(m_biddingTypeLabel, 5, 0, 1, 1);
|
||||
leftLayout->addWidget(m_biddingTypeBox, 5, 1, 1, 1);
|
||||
leftLayout->addWidget(m_bidding1Label, 6, 0, 1, 1);
|
||||
leftLayout->addWidget(m_bidding1SpinBox, 6, 1, 1, 1);
|
||||
leftLayout->addWidget(m_bidding2Label, 7, 0, 1, 1);
|
||||
leftLayout->addWidget(m_bidding2SpinBox, 7, 1, 1, 1);
|
||||
leftLayout->addWidget(m_bidding3Label, 8, 0, 1, 1);
|
||||
leftLayout->addWidget(m_bidding3SpinBox, 8, 1, 1, 1);
|
||||
leftLayout->addWidget(m_depotWish1Label, 9, 0, 1, 1);
|
||||
leftLayout->addWidget(m_depotWish1Edit, 9, 1, 1, 1);
|
||||
leftLayout->addWidget(m_depotWish2Label, 10, 0, 1, 1);
|
||||
leftLayout->addWidget(m_depotWish2Edit, 10, 1, 1, 1);
|
||||
leftLayout->addWidget(m_mailLabel, 11, 0, 1, 1);
|
||||
leftLayout->addWidget(m_mailEdit, 11, 1, 1, 1);
|
||||
|
||||
leftLayout->addWidget(m_previousButton, 12, 0, 1, 1);
|
||||
leftLayout->addWidget(m_nextButton, 12, 1, 1, 1);
|
||||
|
||||
/// right layout
|
||||
QVBoxLayout* rightLayout = new QVBoxLayout;
|
||||
QHBoxLayout* onlineAccountControlLayout = new QHBoxLayout;
|
||||
onlineAccountControlLayout->addWidget(m_createOnlineAccountButton);
|
||||
onlineAccountControlLayout->addWidget(m_sendInviteMailButton);
|
||||
rightLayout->addLayout(onlineAccountControlLayout);
|
||||
QGridLayout* rightGridLayout = new QGridLayout();
|
||||
rightGridLayout->addWidget(m_onlineIdLabel, 0, 0, 1, 1);
|
||||
rightGridLayout->addWidget(m_onlineIdDisplay, 0, 1, 1, 1);
|
||||
rightGridLayout->addWidget(m_accessCodeLabel, 1, 0, 1, 1);
|
||||
rightGridLayout->addWidget(m_accessCodeDisplay, 1, 1, 1, 1);
|
||||
rightGridLayout->addWidget(m_qrCodeDisplay, 2, 0, 6, 2);
|
||||
rightGridLayout->addWidget(m_accessUrlDisplay, 9, 0, 1, 2);
|
||||
rightLayout->addLayout(rightGridLayout);
|
||||
|
||||
QHBoxLayout* outerLayout = new QHBoxLayout;
|
||||
outerLayout->addLayout(leftLayout);
|
||||
outerLayout->addLayout(rightLayout);
|
||||
setLayout(outerLayout);
|
||||
}
|
||||
|
||||
void ItemDetailMapper::setModelMappings(QTableView* tableView) {
|
||||
@ -138,6 +178,9 @@ void ItemDetailMapper::setModelMappings(QTableView* tableView) {
|
||||
m_mapper->addMapping(m_depotWish2Edit, 10);
|
||||
m_mapper->addMapping(m_mailEdit, 11);
|
||||
|
||||
m_mapper->addMapping(m_onlineIdDisplay, 12);
|
||||
m_mapper->addMapping(m_accessCodeDisplay, 13);
|
||||
|
||||
m_mapper->setCurrentIndex(m_selectionModel->currentIndex().row());
|
||||
|
||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &ItemDetailMapper::rowsInserted);
|
||||
@ -152,16 +195,6 @@ bool ItemDetailMapper::submit() { return m_mapper->submit(); }
|
||||
|
||||
void ItemDetailMapper::revert() { m_mapper->revert(); }
|
||||
|
||||
void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current,
|
||||
const QModelIndex& /*previous*/) {
|
||||
if (!isEnabled()) {
|
||||
setEnabled(true);
|
||||
}
|
||||
m_mapper->setCurrentModelIndex(current);
|
||||
updateButtons(current.row());
|
||||
emitContentChanged(current);
|
||||
}
|
||||
|
||||
void ItemDetailMapper::rowsInserted(const QModelIndex& parent, int start, int end) {
|
||||
updateButtons(m_mapper->currentIndex());
|
||||
}
|
||||
@ -209,3 +242,26 @@ void ItemDetailMapper::emitContentChanged(const QModelIndex& currentIndex) {
|
||||
}
|
||||
emit contentChanged(toStringText);
|
||||
}
|
||||
|
||||
void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current,
|
||||
const QModelIndex& /*previous*/) {
|
||||
if (!isEnabled()) {
|
||||
setEnabled(true);
|
||||
}
|
||||
m_mapper->setCurrentModelIndex(current);
|
||||
updateButtons(current.row());
|
||||
emitContentChanged(current);
|
||||
}
|
||||
|
||||
void ItemDetailMapper::updateQRCode(const QString text) {
|
||||
QImage unscaledImage;
|
||||
if (text.isEmpty()) {
|
||||
unscaledImage = QImage("://no-picture-taking.png");
|
||||
} else {
|
||||
unscaledImage = m_generator.generateQr(text);
|
||||
}
|
||||
QImage image = unscaledImage.scaled(250, 250);
|
||||
|
||||
m_qrCodeDisplay->setPixmap(QPixmap::fromImage(image));
|
||||
m_qrCodeDisplay->setToolTip(text);
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ class QItemSelectionModel;
|
||||
class QStringListModel;
|
||||
class QTableView;
|
||||
|
||||
#include "QrCodeGenerator.h"
|
||||
|
||||
class ItemDetailMapper : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -29,13 +31,14 @@ class ItemDetailMapper : public QWidget {
|
||||
void contentChanged(const QString text);
|
||||
|
||||
private slots:
|
||||
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||
void rowsInserted(const QModelIndex& parent, int start, int end);
|
||||
void rowsRemoved(const QModelIndex& parent, int start, int end);
|
||||
void toPrevious();
|
||||
void toNext();
|
||||
void updateButtons(int row);
|
||||
void emitContentChanged(const QModelIndex& currentIndex);
|
||||
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||
void updateQRCode(const QString text = "");
|
||||
|
||||
private:
|
||||
/// *** members ***
|
||||
@ -46,7 +49,8 @@ class ItemDetailMapper : public QWidget {
|
||||
|
||||
std::unique_ptr<QDataWidgetMapper> m_mapper;
|
||||
|
||||
/// GUI elements
|
||||
/// *** GUI elements ***
|
||||
/// left layout
|
||||
QLabel* m_numberLabel;
|
||||
QSpinBox* m_numberBox;
|
||||
|
||||
@ -82,7 +86,21 @@ class ItemDetailMapper : public QWidget {
|
||||
QLabel* m_mailLabel;
|
||||
QLineEdit* m_mailEdit;
|
||||
|
||||
/// Model mapper stuff
|
||||
/// right layout
|
||||
QPushButton* m_createOnlineAccountButton = nullptr;
|
||||
QPushButton* m_sendInviteMailButton = nullptr;
|
||||
|
||||
QLabel* m_onlineIdLabel;
|
||||
QLineEdit* m_onlineIdDisplay = nullptr;
|
||||
QLabel* m_accessCodeLabel;
|
||||
QLineEdit* m_accessCodeDisplay = nullptr;
|
||||
|
||||
QLabel* m_qrCodeDisplay = nullptr;
|
||||
QrCodeGenerator m_generator;
|
||||
|
||||
QLineEdit* m_accessUrlDisplay = nullptr;
|
||||
|
||||
/// *** Model mapper stuff ***
|
||||
QPushButton* m_nextButton;
|
||||
QPushButton* m_previousButton;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user