Ok button on ReceiptSaveForm is now disabled if nothing is selected in

grid or name field is empty.
print
Josef Rokos 9 years ago committed by Rokos Josef
parent 4593161261
commit 6f84de2b6c

@ -4,6 +4,7 @@
#include <QList>
#include <QCompleter>
#include <QSortFilterProxyModel>
#include <QPushButton>
#include <service.h>
#include <iplugin.h>
@ -35,6 +36,14 @@ ReceiptSaveForm::ReceiptSaveForm(QWidget *parent) :
ui->tabVouchers->setColumnWidth(0, 190);
ui->tabVouchers->setColumnWidth(2, 200);
connect(ui->tabVouchers->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](QModelIndex, QModelIndex){
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
});
connect(ui->name, &QLineEdit::textChanged, [this](QString text){
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
});
AddressBookService srvAdb;
QList<ComboData> comboData;
foreach (QSharedPointer<AddressbookData> adb, srvAdb.all()) {
@ -50,6 +59,8 @@ ReceiptSaveForm::ReceiptSaveForm(QWidget *parent) :
m_saveAsNew = false;
ui->groupBox_2->setEnabled(false);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
ReceiptSaveForm::~ReceiptSaveForm()
@ -68,6 +79,7 @@ void ReceiptSaveForm::on_lineEdit_textChanged(const QString &text)
if(matchingIndex.isValid()){
ui->tabVouchers->scrollTo(matchingIndex,QAbstractItemView::EnsureVisible);
ui->tabVouchers->setCurrentIndex(matchingIndex);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
}
}
@ -78,11 +90,15 @@ void ReceiptSaveForm::on_radioAdd_toggled(bool checked)
m_saveAsNew = false;
ui->groupBox_2->setEnabled(false);
ui->groupBox->setEnabled(true);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->tabVouchers->currentIndex().isValid());
}
else
{
m_saveAsNew = true;
ui->groupBox_2->setEnabled(true);
ui->groupBox->setEnabled(false);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->name->text().isEmpty());
}
}

Loading…
Cancel
Save