annotate ui/certificatelistwidget.cpp @ 689:6df31cb47d54

Updated translations.
author Emanuel Schuetze <emanuel@intevation.de>
date Tue, 01 Jul 2014 14:37:45 +0200
parents 973a7ce19658
children 0f4c480c41f4
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);
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 }
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 void CertificateListWidget::addCertificates(const QList<Certificate> &list)
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
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
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
95 void CertificateListWidget::removeCertificate(const Certificate &cert)
582
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 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
98 QListWidgetItem *item = mCertificateList->item(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
99 CertificateItemWidget *itemWidget =
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
100 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
101 if (itemWidget->certificate() == cert) {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
102 QListWidgetItem* item = mCertificateList->takeItem(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
103 delete(item);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
104 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
105 }
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
108 void CertificateListWidget::clear()
582
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 mCertificateList->clear();
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
111 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
112
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
113 QStringList CertificateListWidget::certificates()
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 list;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
116 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
117 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
118 CertificateItemWidget *itemWidget =
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
119 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
120 list << itemWidget->certificate().base64Line();
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
121 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
122 return list;
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
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
125 QStringList CertificateListWidget::selectedCertificates() {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
126 QStringList list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
127 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
128 QListWidgetItem *item = mCertificateList->item(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
129 CertificateItemWidget *itemWidget =
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
130 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
131 if (itemWidget->state()) {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
132 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
133 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
134 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
135 return list;
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
138 QStringList CertificateListWidget::unselectedCertificates() {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
139 QStringList list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
140 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
141 QListWidgetItem *item = mCertificateList->item(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
142 CertificateItemWidget *itemWidget =
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
143 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
144 if (!itemWidget->state()) {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
145 list << itemWidget->certificate().base64Line();
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
146 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
147 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
148 return list;
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
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
151 QList<Certificate> CertificateListWidget::certificateList()
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> list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
154 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
155 QListWidgetItem *item = mCertificateList->item(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
156 CertificateItemWidget *itemWidget =
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
157 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
158 list << itemWidget->certificate();
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
159 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
160
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
161 return list;
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
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
164 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
165 {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
166 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
167 QListWidgetItem *item = mCertificateList->item(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
168 CertificateItemWidget *itemWidget =
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
169 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
170 if (itemWidget->certificate() == cert &&
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
171 itemWidget->state() != state) {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
172 itemWidget->setState(state);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
173 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
174 }
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
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
177 void CertificateListWidget::updateDetails(QListWidgetItem *item)
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
178 {
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
179 if (item == NULL) {
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
180 return;
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
181 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
182 Certificate cert = item->data(Qt::UserRole).value<Certificate>();
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
183 mSubjectCN->setText(cert.subjectCN());
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
184 mSubjectO->setText(cert.subjectO());
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
185 mValidFrom->setText(cert.validFrom().toString());
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
186 mValidTo->setText(cert.validTo().toString());
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
187 mFingerprint->setText(cert.fingerprint());
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
188 }
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
189
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
190 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
191 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
192 int selected = 0;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
193 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
194 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
195 CertificateItemWidget *itemWidget =
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
196 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
197 if (itemWidget->state()) {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
198 selected++;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
199 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
200 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
201 emit certListChanged(selected);
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
202 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
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 int CertificateListWidget::selectedCertCount()
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 selected = 0;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
208 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
209 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
210 CertificateItemWidget *itemWidget =
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
211 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
212 if (itemWidget->state()) {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
213 selected++;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
214 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
215 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
216 return selected;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
217 }
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
218
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
219 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
220 {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
221 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
222 QListWidgetItem *item = mCertificateList->item(i);
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
223 CertificateItemWidget *itemWidget =
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
224 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
225 if (itemWidget->certificate() == cert) {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
226 return true;
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 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
229 return false;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
230 }
653
39f03316f675 Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents: 651
diff changeset
231
39f03316f675 Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents: 651
diff changeset
232 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
233 {
39f03316f675 Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents: 651
diff changeset
234 mCertificateList->setFocus();
39f03316f675 Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents: 651
diff changeset
235 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
236 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
237 }
39f03316f675 Change button text when toggling details and select the first list item.
Raimund Renkert <rrenkert@intevation.de>
parents: 651
diff changeset
238 }

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