diff ui/certificatelistwidget.cpp @ 1101:2b3526ef2d69

(issue111) Keep manually changed certificates in the manually changed list. This invents the new property "active certificate" an inactive certificate is a certificate that is displayed but has no impact on the store.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 15 Sep 2014 13:55:47 +0200
parents bd33c6585cd0
children 6f7b7d88f048
line wrap: on
line diff
--- a/ui/certificatelistwidget.cpp	Mon Sep 15 12:50:26 2014 +0200
+++ b/ui/certificatelistwidget.cpp	Mon Sep 15 13:55:47 2014 +0200
@@ -40,10 +40,43 @@
     emit certListChanged(-1);
 }
 
+int CertificateListWidget::activeCertificates()
+{
+    int ret = 0;
+    for (int i = 0; i < mCertificateWidgets.size(); i++) {
+        if (mCertificateWidgets[i]->certificate()->isActive()) {
+            ret++;
+        }
+    }
+    return ret;
+}
+
+void CertificateListWidget::activateCertificate(const Certificate &cert)
+{
+    for (int i = 0; i < mCertificateWidgets.size(); i++) {
+        if (*(mCertificateWidgets[i]->certificate()) == cert) {
+            mCertificateWidgets[i]->certificate()->setActive(true);
+            break;
+        }
+    }
+    emit certListChanged(-1);
+}
+
+void CertificateListWidget::deactivateCertificate(const Certificate &cert)
+{
+    for (int i = 0; i < mCertificateWidgets.size(); i++) {
+        if (*(mCertificateWidgets[i]->certificate()) == cert) {
+            mCertificateWidgets[i]->certificate()->setActive(false);
+            break;
+        }
+    }
+    emit certListChanged(-1);
+}
+
 void CertificateListWidget::removeCertificate(const Certificate &cert)
 {
     for (int i = 0; i < mCertificateWidgets.size(); i++) {
-        if (mCertificateWidgets[i]->certificate() == cert) {
+        if (*(mCertificateWidgets[i]->certificate()) == cert) {
             mLayout.removeWidget(mCertificateWidgets[i]);
             mCertificateWidgets[i]->deleteLater();
             mCertificateWidgets.removeAt(i);
@@ -66,7 +99,7 @@
 {
     QStringList list;
     foreach (CertificateItemWidget * item, mCertificateWidgets) {
-        list <<  item->certificate().base64Line();
+        list <<  item->certificate()->base64Line();
     }
     return list;
 }
@@ -75,7 +108,7 @@
     QStringList list;
     foreach (CertificateItemWidget * item, mCertificateWidgets) {
         if (item->state()) {
-            list << item->certificate().base64Line();
+            list << item->certificate()->base64Line();
         }
     }
     return list;
@@ -85,7 +118,7 @@
     QStringList list;
     foreach (CertificateItemWidget * item, mCertificateWidgets) {
         if (!item->state()) {
-            list << item->certificate().base64Line();
+            list << item->certificate()->base64Line();
         }
     }
     return list;
@@ -95,7 +128,7 @@
 {
     QList<Certificate> list;
     foreach (CertificateItemWidget * item, mCertificateWidgets) {
-        list <<  item->certificate();
+        list <<  *(item->certificate());
     }
     return list;
 }
@@ -103,7 +136,7 @@
 void CertificateListWidget::setCertState(bool state, const Certificate &cert)
 {
     foreach (CertificateItemWidget * item, mCertificateWidgets) {
-        if (item->certificate() == cert &&
+        if (*(item->certificate()) == cert &&
             item->state() != state) {
             item->setState(state);
         }
@@ -131,7 +164,7 @@
 bool CertificateListWidget::contains(const Certificate &cert)
 {
     foreach (CertificateItemWidget * item, mCertificateWidgets) {
-        if (item->certificate() == cert) {
+        if (*(item->certificate()) == cert) {
             return true;
         }
     }

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