Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
1100:77afafd23a1b | 1101:2b3526ef2d69 |
---|---|
38 mCertificateWidgets << widget; | 38 mCertificateWidgets << widget; |
39 mLayout.addWidget(widget); | 39 mLayout.addWidget(widget); |
40 emit certListChanged(-1); | 40 emit certListChanged(-1); |
41 } | 41 } |
42 | 42 |
43 int CertificateListWidget::activeCertificates() | |
44 { | |
45 int ret = 0; | |
46 for (int i = 0; i < mCertificateWidgets.size(); i++) { | |
47 if (mCertificateWidgets[i]->certificate()->isActive()) { | |
48 ret++; | |
49 } | |
50 } | |
51 return ret; | |
52 } | |
53 | |
54 void CertificateListWidget::activateCertificate(const Certificate &cert) | |
55 { | |
56 for (int i = 0; i < mCertificateWidgets.size(); i++) { | |
57 if (*(mCertificateWidgets[i]->certificate()) == cert) { | |
58 mCertificateWidgets[i]->certificate()->setActive(true); | |
59 break; | |
60 } | |
61 } | |
62 emit certListChanged(-1); | |
63 } | |
64 | |
65 void CertificateListWidget::deactivateCertificate(const Certificate &cert) | |
66 { | |
67 for (int i = 0; i < mCertificateWidgets.size(); i++) { | |
68 if (*(mCertificateWidgets[i]->certificate()) == cert) { | |
69 mCertificateWidgets[i]->certificate()->setActive(false); | |
70 break; | |
71 } | |
72 } | |
73 emit certListChanged(-1); | |
74 } | |
75 | |
43 void CertificateListWidget::removeCertificate(const Certificate &cert) | 76 void CertificateListWidget::removeCertificate(const Certificate &cert) |
44 { | 77 { |
45 for (int i = 0; i < mCertificateWidgets.size(); i++) { | 78 for (int i = 0; i < mCertificateWidgets.size(); i++) { |
46 if (mCertificateWidgets[i]->certificate() == cert) { | 79 if (*(mCertificateWidgets[i]->certificate()) == cert) { |
47 mLayout.removeWidget(mCertificateWidgets[i]); | 80 mLayout.removeWidget(mCertificateWidgets[i]); |
48 mCertificateWidgets[i]->deleteLater(); | 81 mCertificateWidgets[i]->deleteLater(); |
49 mCertificateWidgets.removeAt(i); | 82 mCertificateWidgets.removeAt(i); |
50 break; | 83 break; |
51 } | 84 } |
64 | 97 |
65 QStringList CertificateListWidget::certificates() | 98 QStringList CertificateListWidget::certificates() |
66 { | 99 { |
67 QStringList list; | 100 QStringList list; |
68 foreach (CertificateItemWidget * item, mCertificateWidgets) { | 101 foreach (CertificateItemWidget * item, mCertificateWidgets) { |
69 list << item->certificate().base64Line(); | 102 list << item->certificate()->base64Line(); |
70 } | 103 } |
71 return list; | 104 return list; |
72 } | 105 } |
73 | 106 |
74 QStringList CertificateListWidget::selectedCertificates() { | 107 QStringList CertificateListWidget::selectedCertificates() { |
75 QStringList list; | 108 QStringList list; |
76 foreach (CertificateItemWidget * item, mCertificateWidgets) { | 109 foreach (CertificateItemWidget * item, mCertificateWidgets) { |
77 if (item->state()) { | 110 if (item->state()) { |
78 list << item->certificate().base64Line(); | 111 list << item->certificate()->base64Line(); |
79 } | 112 } |
80 } | 113 } |
81 return list; | 114 return list; |
82 } | 115 } |
83 | 116 |
84 QStringList CertificateListWidget::unselectedCertificates() { | 117 QStringList CertificateListWidget::unselectedCertificates() { |
85 QStringList list; | 118 QStringList list; |
86 foreach (CertificateItemWidget * item, mCertificateWidgets) { | 119 foreach (CertificateItemWidget * item, mCertificateWidgets) { |
87 if (!item->state()) { | 120 if (!item->state()) { |
88 list << item->certificate().base64Line(); | 121 list << item->certificate()->base64Line(); |
89 } | 122 } |
90 } | 123 } |
91 return list; | 124 return list; |
92 } | 125 } |
93 | 126 |
94 QList<Certificate> CertificateListWidget::certificateList() | 127 QList<Certificate> CertificateListWidget::certificateList() |
95 { | 128 { |
96 QList<Certificate> list; | 129 QList<Certificate> list; |
97 foreach (CertificateItemWidget * item, mCertificateWidgets) { | 130 foreach (CertificateItemWidget * item, mCertificateWidgets) { |
98 list << item->certificate(); | 131 list << *(item->certificate()); |
99 } | 132 } |
100 return list; | 133 return list; |
101 } | 134 } |
102 | 135 |
103 void CertificateListWidget::setCertState(bool state, const Certificate &cert) | 136 void CertificateListWidget::setCertState(bool state, const Certificate &cert) |
104 { | 137 { |
105 foreach (CertificateItemWidget * item, mCertificateWidgets) { | 138 foreach (CertificateItemWidget * item, mCertificateWidgets) { |
106 if (item->certificate() == cert && | 139 if (*(item->certificate()) == cert && |
107 item->state() != state) { | 140 item->state() != state) { |
108 item->setState(state); | 141 item->setState(state); |
109 } | 142 } |
110 } | 143 } |
111 } | 144 } |
129 } | 162 } |
130 | 163 |
131 bool CertificateListWidget::contains(const Certificate &cert) | 164 bool CertificateListWidget::contains(const Certificate &cert) |
132 { | 165 { |
133 foreach (CertificateItemWidget * item, mCertificateWidgets) { | 166 foreach (CertificateItemWidget * item, mCertificateWidgets) { |
134 if (item->certificate() == cert) { | 167 if (*(item->certificate()) == cert) { |
135 return true; | 168 return true; |
136 } | 169 } |
137 } | 170 } |
138 return false; | 171 return false; |
139 } | 172 } |