Mercurial > trustbridge
annotate ui/certificatelistwidget.cpp @ 660:392ec26de687
Updated German translations.
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Thu, 26 Jun 2014 15:58:11 +0200 |
parents | 39f03316f675 |
children | 320a64d58e62 |
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; |
651
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
26 QVBoxLayout *detailMainLayout = new QVBoxLayout; |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 mCertificateList = new QListWidget; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 mCertificateList->setFixedWidth(250); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 connect(mCertificateList, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 this, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 SLOT(updateDetails(QListWidgetItem*))); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 QHBoxLayout *detailLayout = new QHBoxLayout; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 QVBoxLayout *detailLabelLayout = new QVBoxLayout; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 QVBoxLayout *detailContentLayout = new QVBoxLayout; |
651
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
37 QGroupBox *detailBox = new QGroupBox(tr("Details")); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 QLabel *subjectCN = new QLabel(tr("Subject Common Name:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 QLabel *subjectOU = new QLabel(tr("Subject Organisation:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 QLabel *issuerCN = new QLabel(tr("Issuer Common Name:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 QLabel *issuerOU = new QLabel(tr("Issuer Organisation:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 QLabel *validFrom = new QLabel(tr("Valid from:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 QLabel *validTo = new QLabel(tr("Valid to:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 QLabel *fingerprint = new QLabel(tr("Fingerprint:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 detailLabelLayout->addWidget(subjectCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 detailLabelLayout->addWidget(subjectOU); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 detailLabelLayout->addWidget(issuerCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 detailLabelLayout->addWidget(issuerOU); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 detailLabelLayout->addWidget(validFrom); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 detailLabelLayout->addWidget(validTo); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 detailLabelLayout->addWidget(fingerprint); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 mSubjectCN = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 mSubjectO = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 mIssuerCN = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 mIssuerO = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 mValidFrom = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 mValidTo = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 mFingerprint = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 mFingerprint->setFont(QFont("DejaVu Sans Mono")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 detailContentLayout->addWidget(mSubjectCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 detailContentLayout->addWidget(mSubjectO); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 detailContentLayout->addWidget(mIssuerCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 detailContentLayout->addWidget(mIssuerO); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 detailContentLayout->addWidget(mValidFrom); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 detailContentLayout->addWidget(mValidTo); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 detailContentLayout->addWidget(mFingerprint); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 detailLayout->addLayout(detailLabelLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 detailLayout->addLayout(detailContentLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 detailBox->setLayout(detailLayout); |
651
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
70 detailMainLayout->addWidget(detailBox); |
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
71 detailMainLayout->addStretch(1); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 mainLayout->addWidget(mCertificateList); |
651
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
74 mainLayout->addLayout(detailMainLayout); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 this->setLayout(mainLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
78 void CertificateListWidget::addCertificate( |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
79 const Certificate &certificate, |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
80 bool state, |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
81 bool editable) |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 QListWidgetItem* item = new QListWidgetItem(mCertificateList); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 item->setData(Qt::UserRole, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 QVariant::fromValue(certificate)); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 mCertificateList->addItem(item); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 CertificateItemWidget *widget = |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
88 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
|
89 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
|
90 this, SLOT(certStateChanged(bool, const Certificate&))); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 item->setSizeHint(widget->minimumSizeHint()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 mCertificateList->setItemWidget(item, widget); |
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 void CertificateListWidget::addCertificates(const QList<Certificate> &list) |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
99 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
100 void CertificateListWidget::removeCertificate(const Certificate &cert) |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
101 { |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
102 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
|
103 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
104 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
105 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
|
106 if (itemWidget->certificate() == cert) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
107 QListWidgetItem* item = mCertificateList->takeItem(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
108 delete(item); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
109 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
110 } |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
113 void CertificateListWidget::clear() |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 { |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
115 mCertificateList->clear(); |
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 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
118 QStringList CertificateListWidget::certificates() |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
119 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
120 QStringList list; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
121 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
|
122 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
|
123 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
124 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
|
125 list << itemWidget->certificate().base64Line(); |
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 return list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
128 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
129 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
130 QStringList CertificateListWidget::selectedCertificates() { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
131 QStringList list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
132 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
|
133 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
134 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
135 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
|
136 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
137 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
|
138 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
139 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
140 return list; |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
141 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
143 QStringList CertificateListWidget::unselectedCertificates() { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
144 QStringList list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
145 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
|
146 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
147 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
148 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
|
149 if (!itemWidget->state()) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
150 list << itemWidget->certificate().base64Line(); |
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 return list; |
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 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
156 QList<Certificate> CertificateListWidget::certificateList() |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
157 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
158 QList<Certificate> list; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
159 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
|
160 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
161 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
162 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
|
163 list << itemWidget->certificate(); |
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 return list; |
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 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
169 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
|
170 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
171 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
|
172 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
173 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
174 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
|
175 if (itemWidget->certificate() == cert && |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
176 itemWidget->state() != state) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
177 itemWidget->setState(state); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
178 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
179 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
180 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
181 |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
182 void CertificateListWidget::updateDetails(QListWidgetItem *item) |
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 if (item == NULL) { |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
185 return; |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
186 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
187 Certificate cert = item->data(Qt::UserRole).value<Certificate>(); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
188 mSubjectCN->setText(cert.subjectCN()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
189 mSubjectO->setText(cert.subjectO()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
190 mIssuerCN->setText(cert.issuerCN()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
191 mIssuerO->setText(cert.issuerO()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
192 mValidFrom->setText(cert.validFrom().toString()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
193 mValidTo->setText(cert.validTo().toString()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
194 mFingerprint->setText(cert.fingerprint()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
195 } |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
196 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
197 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
|
198 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
199 int selected = 0; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
200 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
|
201 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
|
202 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
203 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
|
204 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
205 selected++; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
206 } |
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 emit certListChanged(selected); |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
209 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
|
210 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
211 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
212 int CertificateListWidget::selectedCertCount() |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
213 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
214 int selected = 0; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
215 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
|
216 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
|
217 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
218 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
|
219 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
220 selected++; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
221 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
222 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
223 return selected; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
224 } |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
225 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
226 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
|
227 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
228 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
|
229 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
230 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
231 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
|
232 if (itemWidget->certificate() == cert) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
233 return true; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
234 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
235 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
236 return false; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
237 } |
653
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
238 |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
239 void CertificateListWidget::setSelected(int index) |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
240 { |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
241 mCertificateList->setFocus(); |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
242 if (mCertificateList->count() > 0) { |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
243 mCertificateList->item(0)->setSelected(true); |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
244 } |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
245 } |