Qt: Update UAT OK button enabled on delete.
authorStig Bjørlykke <stig@bjorlykke.org>
Sun, 27 Nov 2016 19:08:26 +0000 (20:08 +0100)
committerPeter Wu <peter@lekensteyn.nl>
Mon, 28 Nov 2016 19:41:39 +0000 (19:41 +0000)
Check if the OK button should be enabled when removing a row in a
UAT dialog.  Also update the error hint.

Change-Id: Icb5c47c2b2e65ed266fd2c7e3a1535f6a3a50279
Reviewed-on: https://code.wireshark.org/review/18967
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
ui/qt/uat_dialog.cpp
ui/qt/uat_dialog.h

index 4d039bd33f49af2a2490004b1bc3cdc7162e3310..b9978b9f16f5545beefa9a915327fc942d3c2e6e 100644 (file)
@@ -113,6 +113,8 @@ void UatDialog::setUat(epan_uat *uat)
 
         connect(uat_model_, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                 this, SLOT(modelDataChanged(QModelIndex)));
+        connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
+                this, SLOT(modelRowsRemoved()));
         connect(ui->uatTreeView, SIGNAL(currentItemChanged(QModelIndex,QModelIndex)),
                 this, SLOT(viewCurrentChanged(QModelIndex,QModelIndex)));
         ok_button_->setEnabled(!uat_model_->hasErrors());
@@ -135,6 +137,14 @@ void UatDialog::modelDataChanged(const QModelIndex &topLeft)
     ok_button_->setEnabled(!uat_model_->hasErrors());
 }
 
+// Invoked after a row has been removed from the model.
+void UatDialog::modelRowsRemoved()
+{
+    const QModelIndex &current = ui->uatTreeView->currentIndex();
+    checkForErrorHint(current, QModelIndex());
+    ok_button_->setEnabled(!uat_model_->hasErrors());
+}
+
 // Invoked when a different field is selected. Note: when selecting a different
 // field after editing, this event is triggered after modelDataChanged.
 void UatDialog::viewCurrentChanged(const QModelIndex &current, const QModelIndex &previous)
index 9bfa49a8b0c80cf96deec016a82607f3052c872a..68d92cb2e52e0093faac04bcf47e7eace03785cb 100644 (file)
@@ -51,6 +51,7 @@ public:
 
 private slots:
     void modelDataChanged(const QModelIndex &topLeft);
+    void modelRowsRemoved();
     void viewCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
     void acceptChanges();
     void rejectChanges();