enable/disable delete button

This commit is contained in:
Martin Brodbeck 2018-07-23 12:58:27 +02:00
parent 609003fc06
commit 42c5f35576
4 changed files with 21 additions and 1 deletions

View File

@ -206,7 +206,7 @@
<item>
<widget class="QPushButton" name="cancleAllArticlesButton">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Alles stornieren</string>

View File

@ -8,6 +8,7 @@
SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
{
ui_.setupUi(this);
ui_.editButton->setVisible(false);
SellerModel* model =
new SellerModel(dynamic_cast<MainWindow*>(parent)->getMarketplace(), ui_.tableView);
ui_.tableView->setModel(model);
@ -16,6 +17,8 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
connect(ui_.deleteButton, &QPushButton::clicked, this, &SellerDialog::on_deleteButton_clicked);
connect(model, &SellerModel::duplicateSellerNo, this,
&SellerDialog::on_model_duplicateSellerNo);
connect(ui_.tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
&SellerDialog::onSellerViewSelectionChanged);
}
void SellerDialog::on_newButton_clicked()
@ -73,3 +76,13 @@ void SellerDialog::accept()
}
QDialog::accept();
}
void SellerDialog::onSellerViewSelectionChanged(const QItemSelection& selected,
[[maybe_unused]] const QItemSelection& deselected)
{
if (selected.size() > 0) {
ui_.deleteButton->setEnabled(true);
} else {
ui_.deleteButton->setEnabled(false);
}
}

View File

@ -15,6 +15,10 @@ class SellerDialog : public QDialog
SellerDialog(QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
private slots:
void onSellerViewSelectionChanged(const QItemSelection& selected,
const QItemSelection& deselected);
private:
void on_newButton_clicked();
void on_deleteButton_clicked();

View File

@ -65,6 +65,9 @@
</item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Löschen</string>
</property>