Item is added to voucher if found and on enter key pressed in search edit (barcode reader optimization).

master
Josef Rokos 8 years ago
parent 4b3a2e1dd7
commit 03fd0adf12

@ -32,12 +32,10 @@ void PayDialog::on_recieved_valueChanged(double value)
{
if (value >= m_total.toDouble())
{
ui->buttonBox->setEnabled(true);
ui->labelReturn->setText(QString::number(value - m_total.toDouble(), 'f', 2));
}
else
{
ui->buttonBox->setEnabled(false);
ui->labelReturn->setText(QString::number(0, 'f', 2));
}
}

@ -108,7 +108,7 @@
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>

@ -102,7 +102,7 @@ void ShopSettingsForm::loadEntity()
ui->tableItems->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->tableItems->setColumnHidden(0, true);
ui->tableItems->setColumnHidden(2, true);
ui->tableItems->setColumnHidden(3, true);
ui->tableItems->setColumnHidden(4, true);
Service<FavoritItem> srvFav;

@ -26,6 +26,7 @@ QWidget *Shop::ui()
QWidget *uiWidget = IPlugin::ui();
qobject_cast<ShopForm*>(uiWidget)->loadLast();
qobject_cast<ShopForm*>(uiWidget)->fillRaceiptCombo();
qobject_cast<ShopForm*>(uiWidget)->loadButtons();
return uiWidget;
}

@ -25,6 +25,7 @@ ShopForm::ShopForm(QWidget *parent) :
ui->setupUi(this);
m_itemsModel = NULL;
m_commodityModel = NULL;
m_itemFound = false;
ui->temporarySaveButton->setEnabled(false);
ui->saveButton->setEnabled(false);
@ -38,8 +39,6 @@ ShopForm::~ShopForm()
void ShopForm::loadLast()
{
loadButtons();
if (m_itemsModel == NULL)
{
m_itemsModel = new AutoTableModel<VoucherItem>(this);
@ -82,7 +81,7 @@ void ShopForm::loadLast()
m_commodityModel->setData(srv.allSellableItems());
ui->commodityTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
ui->commodityTable->setColumnHidden(3, true);
ui->commodityTable->setColumnHidden(4, true);
ui->commodityTable->setColumnHidden(2, true);
if (srv.isEetEnabled())
@ -141,6 +140,8 @@ void ShopForm::loadButtons()
}
}
}
ui->commoditySearch->setFocus();
}
void ShopForm::fillRaceiptCombo()
@ -365,6 +366,8 @@ void ShopForm::addItem(QSharedPointer<IShopItem> item, int count)
onCountChanged();
ui->actualReceipt->scrollToBottom();
ui->commoditySearch->setFocus();
ui->commoditySearch->setText("");
}
void ShopForm::on_receiptCombo_currentIndexChanged(int)
@ -464,6 +467,7 @@ void ShopForm::on_commoditySearch_textChanged(const QString &text)
QModelIndex matchingIndex = proxy.mapToSource(proxy.index(0,0));
if(matchingIndex.isValid()) {
moveToIndex(matchingIndex);
m_itemFound = true;
}
else
{
@ -473,6 +477,11 @@ void ShopForm::on_commoditySearch_textChanged(const QString &text)
if (matchingIndex.isValid())
{
moveToIndex(matchingIndex);
m_itemFound = true;
}
else
{
m_itemFound = false;
}
}
}
@ -484,3 +493,12 @@ void ShopForm::on_lblEetState_linkActivated(const QString &)
ui->lblEetState->setText(srv.isEetOnline() ? tr("<a href=\"#eet\">Online</a>") : tr("<a href=\"#eet\">Offline</a>"));
}
void ShopForm::on_commoditySearch_returnPressed()
{
if (m_itemFound)
{
ShopItemPtr item = m_commodityModel->itemFromIndex(ui->commodityTable->currentIndex());
addItem(item, ui->spnCount->value());
}
}

@ -47,11 +47,14 @@ private slots:
void on_lblEetState_linkActivated(const QString &link);
void on_commoditySearch_returnPressed();
private:
Ui::ShopForm *ui;
QSharedPointer<Voucher> m_voucher;
AutoTableModel<VoucherItem> *m_itemsModel;
AutoTableModel<ShopItem> *m_commodityModel;
bool m_itemFound;
void createVoucher();
void doTempSave(bool comboChanged);

Loading…
Cancel
Save