diff ui/mainwindow.cpp @ 249:6a7eb102716d

Remove code duplication by unifying the certificatelist. You should now check for isInstallCert to determine wether this certificate should be installed or removed. Leaving the getInstallCertificates and getRemoveCertificates in place for compatibilty would have been easier to keep the tests stable.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 31 Mar 2014 08:06:17 +0000
parents f7176140d20d
children 1e112cf41e92
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Mon Mar 31 08:03:20 2014 +0000
+++ b/ui/mainwindow.cpp	Mon Mar 31 08:06:17 2014 +0000
@@ -283,25 +283,15 @@
 {
     qDebug() << "display certificates";
     certificateList->clear();
-    foreach (const Certificate &cert, mListToInstall.getInstallCertificates()) {
+    foreach (const Certificate &cert, mListToInstall.getCertificates()) {
         if (!cert.isValid()) {
             qWarning() << "Invalid certificate in list";
             continue;
         }
         QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
         item->setData(Qt::UserRole, cert.details());
-        QIcon *certIcon = new QIcon(":/img/list-add.png");
-        item->setIcon(*certIcon);
-        certificateList->addItem(item);
-    }
-    foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) {
-        if (!cert.isValid()) {
-            qWarning() << "Invalid certificate in list";
-            continue;
-        }
-        QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
-        item->setData(Qt::UserRole, cert.details());
-        QIcon *certIcon = new QIcon(":/img/list-remove.png");
+        QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png"):
+                                                 new QIcon(":/img/list-remove.png");
         item->setIcon(*certIcon);
         certificateList->addItem(item);
     }

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