Mercurial > trustbridge
annotate ui/certificatelistwidget.cpp @ 720:3d669400104a
(Issue23) Fix certificate selection
On show always the first certificate was selected and setSelected
also only set the first certificate.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 17:03:44 +0200 |
parents | 0f4c480c41f4 |
children | a467204a35f5 |
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 *validFrom = new QLabel(tr("Valid from:")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 QLabel *validTo = new QLabel(tr("Valid to:")); |
661
320a64d58e62
(UI) Updated English strings. Removed Issuer fields.
Emanuel Schuetze <emanuel@intevation.de>
parents:
653
diff
changeset
|
42 QLabel *fingerprint = new QLabel(tr("Fingerprint (SHA1):")); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 detailLabelLayout->addWidget(subjectCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 detailLabelLayout->addWidget(subjectOU); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 detailLabelLayout->addWidget(validFrom); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 detailLabelLayout->addWidget(validTo); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 detailLabelLayout->addWidget(fingerprint); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 mSubjectCN = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 mSubjectO = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 mValidFrom = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 mValidTo = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 mFingerprint = new QLabel(tr("")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 mFingerprint->setFont(QFont("DejaVu Sans Mono")); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 detailContentLayout->addWidget(mSubjectCN); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 detailContentLayout->addWidget(mSubjectO); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 detailContentLayout->addWidget(mValidFrom); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 detailContentLayout->addWidget(mValidTo); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 detailContentLayout->addWidget(mFingerprint); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 detailLayout->addLayout(detailLabelLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 detailLayout->addLayout(detailContentLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 detailBox->setLayout(detailLayout); |
651
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
62 detailMainLayout->addWidget(detailBox); |
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
63 detailMainLayout->addStretch(1); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 mainLayout->addWidget(mCertificateList); |
651
7cd6602e3fa2
Updated certificate list/details layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
639
diff
changeset
|
66 mainLayout->addLayout(detailMainLayout); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 this->setLayout(mainLayout); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 } |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
70 void CertificateListWidget::addCertificate( |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
71 const Certificate &certificate, |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
72 bool state, |
687
973a7ce19658
(issue24) Let the string for install / remove be set for each item individually
Andre Heinecke <andre.heinecke@intevation.de>
parents:
661
diff
changeset
|
73 bool editable, |
973a7ce19658
(issue24) Let the string for install / remove be set for each item individually
Andre Heinecke <andre.heinecke@intevation.de>
parents:
661
diff
changeset
|
74 const QString &installLabel, |
973a7ce19658
(issue24) Let the string for install / remove be set for each item individually
Andre Heinecke <andre.heinecke@intevation.de>
parents:
661
diff
changeset
|
75 const QString &removeLabel) |
582
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 QListWidgetItem* item = new QListWidgetItem(mCertificateList); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 item->setData(Qt::UserRole, |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 QVariant::fromValue(certificate)); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 mCertificateList->addItem(item); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 CertificateItemWidget *widget = |
687
973a7ce19658
(issue24) Let the string for install / remove be set for each item individually
Andre Heinecke <andre.heinecke@intevation.de>
parents:
661
diff
changeset
|
82 new CertificateItemWidget(mCertificateList, certificate, state, editable, |
973a7ce19658
(issue24) Let the string for install / remove be set for each item individually
Andre Heinecke <andre.heinecke@intevation.de>
parents:
661
diff
changeset
|
83 installLabel, removeLabel); |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
84 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
|
85 this, SLOT(certStateChanged(bool, const Certificate&))); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 item->setSizeHint(widget->minimumSizeHint()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 mCertificateList->setItemWidget(item, widget); |
695
0f4c480c41f4
Emit list changed when certificates are added or removed
Andre Heinecke <andre.heinecke@intevation.de>
parents:
687
diff
changeset
|
88 emit certListChanged(-1); |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 } |
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 void CertificateListWidget::addCertificates(const QList<Certificate> &list) |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 { |
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 |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
96 void CertificateListWidget::removeCertificate(const Certificate &cert) |
582
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 { |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
98 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
|
99 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
100 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
101 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
|
102 if (itemWidget->certificate() == cert) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
103 QListWidgetItem* item = mCertificateList->takeItem(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
104 delete(item); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
105 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
106 } |
695
0f4c480c41f4
Emit list changed when certificates are added or removed
Andre Heinecke <andre.heinecke@intevation.de>
parents:
687
diff
changeset
|
107 emit certListChanged(-1); |
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 mValidFrom->setText(cert.validFrom().toString()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
188 mValidTo->setText(cert.validTo().toString()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
189 mFingerprint->setText(cert.fingerprint()); |
88c9bdc74175
New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
190 } |
627
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
191 |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
192 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
|
193 { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
194 int selected = 0; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
195 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
|
196 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
|
197 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
198 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
|
199 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
200 selected++; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
201 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
202 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
203 emit certListChanged(selected); |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
204 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
|
205 } |
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 int CertificateListWidget::selectedCertCount() |
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 selected = 0; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
210 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
|
211 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
|
212 CertificateItemWidget *itemWidget = |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
213 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
|
214 if (itemWidget->state()) { |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
215 selected++; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
216 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
217 } |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
218 return selected; |
566ee111e331
Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents:
582
diff
changeset
|
219 } |
639
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
220 |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
221 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
|
222 { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
223 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
|
224 QListWidgetItem *item = mCertificateList->item(i); |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
225 CertificateItemWidget *itemWidget = |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
226 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
|
227 if (itemWidget->certificate() == cert) { |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
228 return true; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
229 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
230 } |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
231 return false; |
c1b35edb097f
New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
627
diff
changeset
|
232 } |
653
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
233 |
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
234 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
|
235 { |
720
3d669400104a
(Issue23) Fix certificate selection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
695
diff
changeset
|
236 if (index <= 0) { |
3d669400104a
(Issue23) Fix certificate selection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
695
diff
changeset
|
237 index = 0; |
3d669400104a
(Issue23) Fix certificate selection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
695
diff
changeset
|
238 } |
653
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
239 mCertificateList->setFocus(); |
720
3d669400104a
(Issue23) Fix certificate selection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
695
diff
changeset
|
240 mCertificateList->item(index)->setSelected(true); |
3d669400104a
(Issue23) Fix certificate selection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
695
diff
changeset
|
241 mCertificateList->setCurrentRow(index); |
653
39f03316f675
Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents:
651
diff
changeset
|
242 } |