Mercurial > trustbridge
annotate ui/certificatelistwidget.cpp @ 649:ba0434cd12e1 trustbridge-refactor
Added new icons.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 25 Jun 2014 14:49:36 +0200 |
parents | c1b35edb097f |
children | 7cd6602e3fa2 |
rev | line source |
---|---|
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 * |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=2) |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 * See LICENSE.txt for details. |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 */ |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 #include "certificatelistwidget.h" |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 #include <QDebug> |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 #include <QVBoxLayout> |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 #include <QHBoxLayout> |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 #include <QGroupBox> |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 #include <QLabel> |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 #include "certificateitemwidget.h" |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 CertificateListWidget::CertificateListWidget(QWidget *parent, Qt::WindowFlags flags) : |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 QWidget(parent, flags) |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 setupGUI(); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 void CertificateListWidget::setupGUI() |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 QHBoxLayout *mainLayout = new QHBoxLayout; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 mCertificateList = new QListWidget; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 mCertificateList->setFixedWidth(250); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 connect(mCertificateList, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 this, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 SLOT(updateDetails(QListWidgetItem*))); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 QHBoxLayout *detailLayout = new QHBoxLayout; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 QVBoxLayout *detailLabelLayout = new QVBoxLayout; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 QVBoxLayout *detailContentLayout = new QVBoxLayout; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 QGroupBox *detailBox = new QGroupBox(); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 QLabel *subjectCN = new QLabel(tr("Subject Common Name:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 QLabel *subjectOU = new QLabel(tr("Subject Organisation:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 QLabel *issuerCN = new QLabel(tr("Issuer Common Name:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 QLabel *issuerOU = new QLabel(tr("Issuer Organisation:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 QLabel *validFrom = new QLabel(tr("Valid from:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 QLabel *validTo = new QLabel(tr("Valid to:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 QLabel *fingerprint = new QLabel(tr("Fingerprint:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 detailLabelLayout->addWidget(subjectCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 detailLabelLayout->addWidget(subjectOU); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 detailLabelLayout->addWidget(issuerCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 detailLabelLayout->addWidget(issuerOU); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 detailLabelLayout->addWidget(validFrom); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 detailLabelLayout->addWidget(validTo); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 detailLabelLayout->addWidget(fingerprint); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 mSubjectCN = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 mSubjectO = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 mIssuerCN = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 mIssuerO = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 mValidFrom = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 mValidTo = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 mFingerprint = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 mFingerprint->setFont(QFont("DejaVu Sans Mono")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 detailContentLayout->addWidget(mSubjectCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 detailContentLayout->addWidget(mSubjectO); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 detailContentLayout->addWidget(mIssuerCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 detailContentLayout->addWidget(mIssuerO); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 detailContentLayout->addWidget(mValidFrom); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 detailContentLayout->addWidget(mValidTo); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 detailContentLayout->addWidget(mFingerprint); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 detailLayout->addLayout(detailLabelLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 detailLayout->addLayout(detailContentLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 detailBox->setLayout(detailLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 mainLayout->addWidget(mCertificateList); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 mainLayout->addWidget(detailBox); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 this->setLayout(mainLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
75 void CertificateListWidget::addCertificate( |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
76 const Certificate &certificate, |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
77 bool state, |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
78 bool editable) |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 QListWidgetItem* item = new QListWidgetItem(mCertificateList); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 item->setData(Qt::UserRole, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 QVariant::fromValue(certificate)); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 mCertificateList->addItem(item); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 CertificateItemWidget *widget = |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
85 new CertificateItemWidget(mCertificateList, certificate, state, editable); |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
86 connect(widget, SIGNAL(stateChanged(bool, const Certificate&)), |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
87 this, SLOT(certStateChanged(bool, const Certificate&))); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 item->setSizeHint(widget->minimumSizeHint()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 mCertificateList->setItemWidget(item, widget); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 void CertificateListWidget::addCertificates(const QList<Certificate> &list) |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
93 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
97 void CertificateListWidget::removeCertificate(const Certificate &cert) |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 { |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
99 for (int i = 0; i < mCertificateList->count(); i++) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
100 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
101 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
102 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
103 if (itemWidget->certificate() == cert) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
104 QListWidgetItem* item = mCertificateList->takeItem(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
105 delete(item); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
106 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
107 } |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
110 void CertificateListWidget::clear() |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 { |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
112 mCertificateList->clear(); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
113 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
114 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
115 QStringList CertificateListWidget::certificates() |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
116 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
117 QStringList list; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
118 for (int i = 0; i < mCertificateList->count(); i++) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
119 QListWidgetItem *item = mCertificateList->item(i); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
120 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
121 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
122 list << itemWidget->certificate().base64Line(); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
123 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
124 return list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
125 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
126 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
127 QStringList CertificateListWidget::selectedCertificates() { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
128 QStringList list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
129 for (int i = 0; i < mCertificateList->count(); i++) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
130 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
131 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
132 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
133 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
134 list << itemWidget->certificate().base64Line(); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
135 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
136 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
137 return list; |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
138 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
139 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
140 QStringList CertificateListWidget::unselectedCertificates() { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
141 QStringList list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
142 for (int i = 0; i < mCertificateList->count(); i++) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
143 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
144 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
145 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
146 if (!itemWidget->state()) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
147 list << itemWidget->certificate().base64Line(); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
148 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
149 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
150 return list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
151 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
152 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
153 QList<Certificate> CertificateListWidget::certificateList() |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
154 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
155 QList<Certificate> list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
156 for (int i = 0; i < mCertificateList->count(); i++) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
157 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
158 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
159 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
160 list << itemWidget->certificate(); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
161 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
162 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
163 return list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
164 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
165 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
166 void CertificateListWidget::setCertState(bool state, const Certificate &cert) |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
167 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
168 for (int i = 0; i < mCertificateList->count(); i++) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
169 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
170 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
171 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
172 if (itemWidget->certificate() == cert && |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
173 itemWidget->state() != state) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
174 itemWidget->setState(state); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
175 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
176 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
177 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
178 |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
179 void CertificateListWidget::updateDetails(QListWidgetItem *item) |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
180 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
181 if (item == NULL) { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
182 return; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
183 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
184 Certificate cert = item->data(Qt::UserRole).value<Certificate>(); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
185 mSubjectCN->setText(cert.subjectCN()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
186 mSubjectO->setText(cert.subjectO()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
187 mIssuerCN->setText(cert.issuerCN()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
188 mIssuerO->setText(cert.issuerO()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
189 mValidFrom->setText(cert.validFrom().toString()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
190 mValidTo->setText(cert.validTo().toString()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
191 mFingerprint->setText(cert.fingerprint()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
192 } |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
193 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
194 void CertificateListWidget::certStateChanged(bool state, const Certificate &cert) |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
195 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
196 int selected = 0; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
197 for (int i = 0; i < mCertificateList->count(); i++) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
198 QListWidgetItem *item = mCertificateList->item(i); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
199 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
200 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
201 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
202 selected++; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
203 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
204 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
205 emit certListChanged(selected); |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
206 emit certChanged(state, cert); |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
207 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
208 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
209 int CertificateListWidget::selectedCertCount() |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
210 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
211 int selected = 0; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
212 for (int i = 0; i < mCertificateList->count(); i++) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
213 QListWidgetItem *item = mCertificateList->item(i); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
214 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
215 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
216 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
217 selected++; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
218 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
219 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
220 return selected; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
221 } |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
222 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
223 bool CertificateListWidget::contains(const Certificate &cert) |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
224 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
225 for (int i = 0; i < mCertificateList->count(); i++) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
226 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
227 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
228 static_cast<CertificateItemWidget*>(mCertificateList->itemWidget(item)); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
229 if (itemWidget->certificate() == cert) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
230 return true; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
231 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
232 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
233 return false; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
234 } |