enable/disable delete button

allow_new_sellers
Martin Brodbeck 4 years ago
parent 609003fc06
commit 42c5f35576
  1. 2
      src/gui/mainwindow.ui
  2. 13
      src/gui/sellerdialog.cpp
  3. 4
      src/gui/sellerdialog.h
  4. 3
      src/gui/sellerdialog.ui

@ -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>

@ -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()
@ -72,4 +75,14 @@ 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);
}
}

@ -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();

@ -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>

Loading…
Cancel
Save