annotate ui/certificatelistwidget.cpp @ 1305:c56d2618aabe

Added tag 0.9.3 for changeset 82fab0c689bf
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 16:53:49 +0200
parents 9bb9932bb819
children
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 <QGroupBox>
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QLabel>
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
13 #include <QApplication>
582
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 {
842
bd33c6585cd0 UI improvements (issue18, 60)
Emanuel Schuetze <emanuel@intevation.de>
parents: 757
diff changeset
20 QVBoxLayout *outerLayout = new QVBoxLayout(this);
bd33c6585cd0 UI improvements (issue18, 60)
Emanuel Schuetze <emanuel@intevation.de>
parents: 757
diff changeset
21 outerLayout->addLayout(&mLayout);
bd33c6585cd0 UI improvements (issue18, 60)
Emanuel Schuetze <emanuel@intevation.de>
parents: 757
diff changeset
22 outerLayout->addStretch();
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
25 void CertificateListWidget::addCertificate(
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
26 const Certificate &certificate,
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
27 bool state,
1106
6f7b7d88f048 (issue115) Rework CertificateListWidgets to have a ToolButton instead of a combobox
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1101
diff changeset
28 QToolButton *button)
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 {
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 CertificateItemWidget *widget =
1106
6f7b7d88f048 (issue115) Rework CertificateListWidgets to have a ToolButton instead of a combobox
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1101
diff changeset
31 new CertificateItemWidget(this, certificate, state, button);
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
32 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
33 this, SLOT(certStateChanged(bool, const Certificate&)));
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
34
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
35 mCertificateWidgets << widget;
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
36 mLayout.addWidget(widget);
695
0f4c480c41f4 Emit list changed when certificates are added or removed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 687
diff changeset
37 emit certListChanged(-1);
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
40 void CertificateListWidget::removeCertificate(const Certificate &cert)
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
42 for (int i = 0; i < mCertificateWidgets.size(); i++) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
43 if (mCertificateWidgets[i]->certificate() == cert) {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
44 mLayout.removeWidget(mCertificateWidgets[i]);
757
9bfaced5cf59 (issue56) Do not delete the certificate immediately
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
45 mCertificateWidgets[i]->deleteLater();
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
46 mCertificateWidgets.removeAt(i);
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
47 break;
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
48 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
49 }
695
0f4c480c41f4 Emit list changed when certificates are added or removed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 687
diff changeset
50 emit certListChanged(-1);
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
53 void CertificateListWidget::clear()
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
55 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
56 mLayout.removeWidget(item);
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
57 delete item;
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
58 }
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
59 mCertificateWidgets.clear();
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
60 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
61
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
62 QStringList CertificateListWidget::certificates()
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
63 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
64 QStringList list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
65 foreach (CertificateItemWidget * item, mCertificateWidgets) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
66 list << item->certificate().base64Line();
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
67 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
68 return list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
69 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
70
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
71 QStringList CertificateListWidget::selectedCertificates() {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
72 QStringList list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
73 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
74 if (item->state()) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
75 list << item->certificate().base64Line();
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
76 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
77 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
78 return list;
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
81 QStringList CertificateListWidget::unselectedCertificates() {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
82 QStringList list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
83 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
84 if (!item->state()) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
85 list << item->certificate().base64Line();
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
86 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
87 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
88 return list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
89 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
90
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
91 QList<Certificate> CertificateListWidget::certificateList()
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
92 {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
93 QList<Certificate> list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
94 foreach (CertificateItemWidget * item, mCertificateWidgets) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
95 list << item->certificate();
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
96 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
97 return list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
98 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
99
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
100 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
101 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
102 foreach (CertificateItemWidget * item, mCertificateWidgets) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
103 if (item->certificate() == cert &&
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
104 item->state() != state) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
105 item->setState(state);
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
106 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
107 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
108 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
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
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
111 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
112 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
113 emit certListChanged(-1);
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
114 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
115 }
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 int CertificateListWidget::selectedCertCount()
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
118 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
119 int selected = 0;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
120 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
121 if (item->state()) {
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
122 selected++;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
123 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
124 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
125 return selected;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
126 }
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
127
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
128 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
129 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
130 foreach (CertificateItemWidget * item, mCertificateWidgets) {
1108
9bb9932bb819 Revert commit 1101 the inactive manual changes were a bad idea
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1106
diff changeset
131 if (item->certificate() == cert) {
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
132 return true;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
133 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
134 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
135 return false;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
136 }

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