comparison ui/certificatelistwidget.cpp @ 627:566ee111e331 trustbridge-refactor

Added state to certificate list item and updated certificate list widget.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 23 Jun 2014 12:46:53 +0200
parents 88c9bdc74175
children c1b35edb097f
comparison
equal deleted inserted replaced
584:ebfe1128ee97 627:566ee111e331
78 item->setData(Qt::UserRole, 78 item->setData(Qt::UserRole,
79 QVariant::fromValue(certificate)); 79 QVariant::fromValue(certificate));
80 mCertificateList->addItem(item); 80 mCertificateList->addItem(item);
81 CertificateItemWidget *widget = 81 CertificateItemWidget *widget =
82 new CertificateItemWidget(mCertificateList, certificate); 82 new CertificateItemWidget(mCertificateList, certificate);
83 connect(widget, SIGNAL(stateChanged(bool, const Certificate&)),
84 this, SLOT(certStateChanged(bool, const Certificate&)));
83 item->setSizeHint(widget->minimumSizeHint()); 85 item->setSizeHint(widget->minimumSizeHint());
84 mCertificateList->setItemWidget(item, widget); 86 mCertificateList->setItemWidget(item, widget);
85 } 87 }
86 88
87 void CertificateListWidget::addCertificates(const QList<Certificate> &list) 89 void CertificateListWidget::addCertificates(const QList<Certificate> &list)
92 void CertificateListWidget::removeCertificate(int ndx) 94 void CertificateListWidget::removeCertificate(int ndx)
93 { 95 {
94 96
95 } 97 }
96 98
97 QList<Certificate> CertificateListWidget::getCertificates() 99 void CertificateListWidget::clear()
98 { 100 {
99 return QList<Certificate>(); 101 mCertificateList->clear();
102 }
103
104 QStringList CertificateListWidget::certificates()
105 {
106 QStringList list;
107 for (int i = 0; i < mCertificateList->count(); i++) {
108 QListWidgetItem *item = mCertificateList->item(i);
109 CertificateItemWidget *itemWidget =
110 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item));
111 if (itemWidget->state()) {
112 list << itemWidget->certificate().base64Line();
113 continue;
114 }
115 QString b64Line = itemWidget->certificate().base64Line();
116 if (b64Line.startsWith("I:")) {
117 b64Line[0] = 'R';
118 list << b64Line;
119 }
120 }
121 return list;
100 } 122 }
101 123
102 void CertificateListWidget::updateDetails(QListWidgetItem *item) 124 void CertificateListWidget::updateDetails(QListWidgetItem *item)
103 { 125 {
104 if (item == NULL) { 126 if (item == NULL) {
111 mIssuerO->setText(cert.issuerO()); 133 mIssuerO->setText(cert.issuerO());
112 mValidFrom->setText(cert.validFrom().toString()); 134 mValidFrom->setText(cert.validFrom().toString());
113 mValidTo->setText(cert.validTo().toString()); 135 mValidTo->setText(cert.validTo().toString());
114 mFingerprint->setText(cert.fingerprint()); 136 mFingerprint->setText(cert.fingerprint());
115 } 137 }
138
139 void CertificateListWidget::certStateChanged(bool state, const Certificate &cert)
140 {
141 int selected = 0;
142 for (int i = 0; i < mCertificateList->count(); i++) {
143 QListWidgetItem *item = mCertificateList->item(i);
144 CertificateItemWidget *itemWidget =
145 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item));
146 if (itemWidget->state()) {
147 selected++;
148 }
149 }
150 emit certListChanged(selected);
151 }
152
153 int CertificateListWidget::selectedCertCount()
154 {
155 int selected = 0;
156 for (int i = 0; i < mCertificateList->count(); i++) {
157 QListWidgetItem *item = mCertificateList->item(i);
158 CertificateItemWidget *itemWidget =
159 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item));
160 if (itemWidget->state()) {
161 selected++;
162 }
163 }
164 return selected;
165 }

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