annotate ui/certificatelistwidget.cpp @ 1070:f110a3f6e387

(issue114) Fine tune ACL propagation using mkdir_p the ACL of the parent directories would propagate to all subdirectories and objects in the directory. Now we only use ACL propagation in the last directory to make sure that files we might create in that directory inherit the correct (resitricted) ACL
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 10 Sep 2014 16:41:36 +0200
parents bd33c6585cd0
children 2b3526ef2d69
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,
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
28 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
29 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
30 const QString &removeLabel)
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 {
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 CertificateItemWidget *widget =
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
33 new CertificateItemWidget(this, certificate, state, editable,
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
34 installLabel, removeLabel);
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
35 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
36 this, SLOT(certStateChanged(bool, const Certificate&)));
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
37
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
38 mCertificateWidgets << widget;
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
39 mLayout.addWidget(widget);
695
0f4c480c41f4 Emit list changed when certificates are added or removed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 687
diff changeset
40 emit certListChanged(-1);
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
43 void CertificateListWidget::removeCertificate(const Certificate &cert)
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
45 for (int i = 0; i < mCertificateWidgets.size(); i++) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
46 if (mCertificateWidgets[i]->certificate() == cert) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
47 mLayout.removeWidget(mCertificateWidgets[i]);
757
9bfaced5cf59 (issue56) Do not delete the certificate immediately
Andre Heinecke <andre.heinecke@intevation.de>
parents: 743
diff changeset
48 mCertificateWidgets[i]->deleteLater();
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
49 mCertificateWidgets.removeAt(i);
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
50 break;
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
51 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
52 }
695
0f4c480c41f4 Emit list changed when certificates are added or removed
Andre Heinecke <andre.heinecke@intevation.de>
parents: 687
diff changeset
53 emit certListChanged(-1);
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
56 void CertificateListWidget::clear()
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
58 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
59 mLayout.removeWidget(item);
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
60 delete item;
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
61 }
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
62 mCertificateWidgets.clear();
627
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
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
65 QStringList CertificateListWidget::certificates()
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
66 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
67 QStringList list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
68 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
69 list << item->certificate().base64Line();
639
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 return list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
72 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
73
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
74 QStringList CertificateListWidget::selectedCertificates() {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
75 QStringList list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
76 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
77 if (item->state()) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
78 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
79 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
80 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
81 return list;
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 }
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
84 QStringList CertificateListWidget::unselectedCertificates() {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
85 QStringList list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
86 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
87 if (!item->state()) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
88 list << item->certificate().base64Line();
639
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 return list;
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
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
94 QList<Certificate> CertificateListWidget::certificateList()
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
95 {
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
96 QList<Certificate> list;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
97 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
98 list << item->certificate();
639
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 return list;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
101 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
102
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
103 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
104 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
105 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
106 if (item->certificate() == cert &&
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
107 item->state() != state) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
108 item->setState(state);
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
109 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
110 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
111 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
112
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
113
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
114 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
115 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
116 emit certListChanged(-1);
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
117 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
118 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
119
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
120 int CertificateListWidget::selectedCertCount()
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
121 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
122 int selected = 0;
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
123 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
124 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
125 selected++;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
126 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
127 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
128 return selected;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
129 }
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
130
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
131 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
132 {
743
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
133 foreach (CertificateItemWidget * item, mCertificateWidgets) {
a467204a35f5 Rework User Interface.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 720
diff changeset
134 if (item->certificate() == cert) {
639
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
135 return true;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
136 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
137 }
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
138 return false;
c1b35edb097f New methods to modify and use the certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 627
diff changeset
139 }

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