Added onlineID and accessUrl widgets to the edit item dialog layout. No functionality yet.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user