Mercurial > trustbridge
comparison ui/certificatelistwidget.cpp @ 582:88c9bdc74175 trustbridge-refactor
New widgets to display certificates in lists.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 27 May 2014 16:16:21 +0200 |
parents | |
children | 566ee111e331 |
comparison
equal
deleted
inserted
replaced
581:ab622e094786 | 582:88c9bdc74175 |
---|---|
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
8 #include "certificatelistwidget.h" | |
9 #include <QDebug> | |
10 #include <QVBoxLayout> | |
11 #include <QHBoxLayout> | |
12 #include <QGroupBox> | |
13 #include <QLabel> | |
14 | |
15 #include "certificateitemwidget.h" | |
16 | |
17 CertificateListWidget::CertificateListWidget(QWidget *parent, Qt::WindowFlags flags) : | |
18 QWidget(parent, flags) | |
19 { | |
20 setupGUI(); | |
21 } | |
22 | |
23 void CertificateListWidget::setupGUI() | |
24 { | |
25 QHBoxLayout *mainLayout = new QHBoxLayout; | |
26 mCertificateList = new QListWidget; | |
27 mCertificateList->setFixedWidth(250); | |
28 connect(mCertificateList, | |
29 SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), | |
30 this, | |
31 SLOT(updateDetails(QListWidgetItem*))); | |
32 | |
33 QHBoxLayout *detailLayout = new QHBoxLayout; | |
34 QVBoxLayout *detailLabelLayout = new QVBoxLayout; | |
35 QVBoxLayout *detailContentLayout = new QVBoxLayout; | |
36 QGroupBox *detailBox = new QGroupBox(); | |
37 QLabel *subjectCN = new QLabel(tr("Subject Common Name:")); | |
38 QLabel *subjectOU = new QLabel(tr("Subject Organisation:")); | |
39 QLabel *issuerCN = new QLabel(tr("Issuer Common Name:")); | |
40 QLabel *issuerOU = new QLabel(tr("Issuer Organisation:")); | |
41 QLabel *validFrom = new QLabel(tr("Valid from:")); | |
42 QLabel *validTo = new QLabel(tr("Valid to:")); | |
43 QLabel *fingerprint = new QLabel(tr("Fingerprint:")); | |
44 detailLabelLayout->addWidget(subjectCN); | |
45 detailLabelLayout->addWidget(subjectOU); | |
46 detailLabelLayout->addWidget(issuerCN); | |
47 detailLabelLayout->addWidget(issuerOU); | |
48 detailLabelLayout->addWidget(validFrom); | |
49 detailLabelLayout->addWidget(validTo); | |
50 detailLabelLayout->addWidget(fingerprint); | |
51 mSubjectCN = new QLabel(tr("")); | |
52 mSubjectO = new QLabel(tr("")); | |
53 mIssuerCN = new QLabel(tr("")); | |
54 mIssuerO = new QLabel(tr("")); | |
55 mValidFrom = new QLabel(tr("")); | |
56 mValidTo = new QLabel(tr("")); | |
57 mFingerprint = new QLabel(tr("")); | |
58 mFingerprint->setFont(QFont("DejaVu Sans Mono")); | |
59 detailContentLayout->addWidget(mSubjectCN); | |
60 detailContentLayout->addWidget(mSubjectO); | |
61 detailContentLayout->addWidget(mIssuerCN); | |
62 detailContentLayout->addWidget(mIssuerO); | |
63 detailContentLayout->addWidget(mValidFrom); | |
64 detailContentLayout->addWidget(mValidTo); | |
65 detailContentLayout->addWidget(mFingerprint); | |
66 detailLayout->addLayout(detailLabelLayout); | |
67 detailLayout->addLayout(detailContentLayout); | |
68 detailBox->setLayout(detailLayout); | |
69 | |
70 mainLayout->addWidget(mCertificateList); | |
71 mainLayout->addWidget(detailBox); | |
72 this->setLayout(mainLayout); | |
73 } | |
74 | |
75 void CertificateListWidget::addCertificate(const Certificate &certificate) | |
76 { | |
77 QListWidgetItem* item = new QListWidgetItem(mCertificateList); | |
78 item->setData(Qt::UserRole, | |
79 QVariant::fromValue(certificate)); | |
80 mCertificateList->addItem(item); | |
81 CertificateItemWidget *widget = | |
82 new CertificateItemWidget(mCertificateList, certificate); | |
83 item->setSizeHint(widget->minimumSizeHint()); | |
84 mCertificateList->setItemWidget(item, widget); | |
85 } | |
86 | |
87 void CertificateListWidget::addCertificates(const QList<Certificate> &list) | |
88 { | |
89 | |
90 } | |
91 | |
92 void CertificateListWidget::removeCertificate(int ndx) | |
93 { | |
94 | |
95 } | |
96 | |
97 QList<Certificate> CertificateListWidget::getCertificates() | |
98 { | |
99 return QList<Certificate>(); | |
100 } | |
101 | |
102 void CertificateListWidget::updateDetails(QListWidgetItem *item) | |
103 { | |
104 if (item == NULL) { | |
105 return; | |
106 } | |
107 Certificate cert = item->data(Qt::UserRole).value<Certificate>(); | |
108 mSubjectCN->setText(cert.subjectCN()); | |
109 mSubjectO->setText(cert.subjectO()); | |
110 mIssuerCN->setText(cert.issuerCN()); | |
111 mIssuerO->setText(cert.issuerO()); | |
112 mValidFrom->setText(cert.validFrom().toString()); | |
113 mValidTo->setText(cert.validTo().toString()); | |
114 mFingerprint->setText(cert.fingerprint()); | |
115 } |