changeset 1318:45082ec23e76

(issue166) Only acticate removal if all selected certificates can be remvoed
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 13 Oct 2014 17:41:55 +0200
parents d009da9cfa10
children 137a0686de7b
files ui/administratorwindow.cpp
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ui/administratorwindow.cpp	Mon Oct 13 17:41:12 2014 +0200
+++ b/ui/administratorwindow.cpp	Mon Oct 13 17:41:55 2014 +0200
@@ -198,8 +198,7 @@
     QModelIndexList list = certificateView->selectionModel()->selectedRows();
     foreach (QModelIndex idx, list) {
         QModelIndex realidx = mFilterModel->mapToSource(idx);
-        qDebug() << "About to remove row: " << realidx.row();
-        if (certificateModel->data(idx, Qt::UserRole).toBool()) {
+        if (!idx.data(Qt::UserRole).toBool()) {
             certificateModel->removeRow(realidx.row(), realidx.parent());
         } else {
             qDebug() << "Tried to remove old certificate at idx: " << realidx.row();;
@@ -237,12 +236,15 @@
 
 void AdministratorWindow::clickedCertificate(const QModelIndex &index)
 {
-    if (index.data(Qt::UserRole).toBool()) {
-        removeButton->setEnabled(false);
+    QModelIndexList list = certificateView->selectionModel()->selectedRows();
+    bool all_are_removable = true;
+    foreach (QModelIndex idx, list) {
+        if (idx.data(Qt::UserRole).toBool()) {
+            all_are_removable = false;
+            break;
+        }
     }
-    else {
-        removeButton->setEnabled(true);
-    }
+    removeButton->setEnabled(all_are_removable);
 }
 
 void AdministratorWindow::logChanges(const QString &currentCerts, const QString& keyFingerprint)

http://wald.intevation.org/projects/trustbridge/