annotate ui/certificatediffdialog.cpp @ 1316:ff9cd05e861e

(issue166) Fix certificiate removal The index that should be removed came from the filter proxy model and did not map to the real index. This was broken.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 13 Oct 2014 17:23:35 +0200
parents 8728ae882b6a
children
rev   line source
566
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 *
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6 * See LICENSE.txt for details.
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 */
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 #include "certificatediffdialog.h"
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 #include "administratorwindow.h"
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QDebug>
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QPushButton>
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 #include <QHBoxLayout>
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QVBoxLayout>
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 #include <QScrollArea>
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 #include <QLabel>
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 CertificateDiffDialog::CertificateDiffDialog(AdministratorWindow *parent) :
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 QDialog(parent),
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 mAdminWindow(parent)
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 {
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 setWindowTitle(tr("TrustBridge - List changes"));
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 setupGUI();
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 resize(560, 200);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 }
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 void CertificateDiffDialog::setupGUI()
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 {
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 /* Top level layout / widgets */
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 QVBoxLayout *topLayout = new QVBoxLayout;
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 QHBoxLayout *buttonLayout = new QHBoxLayout;
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 QLabel *header = new QLabel(tr("The following certificates are changed:"));
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 QScrollArea *content = new QScrollArea;
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 QList<Certificate> changes = mAdminWindow->currentChanges();
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 QLabel *certLabel = new QLabel;
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 certLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 QString certString;
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 foreach(const Certificate& cert, changes) {
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 QString status = cert.isInstallCert() ? tr("New") : tr("Remove");
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 certString += status + ": " +
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 cert.subjectCN() + " " +
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 cert.fingerprint() + "\n";
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 certLabel->setText(certString);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 content->setWidget(certLabel);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 QPushButton *accept = new QPushButton(tr("Ok"));
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 QPushButton *reject = new QPushButton(tr("Cancel"));
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 connect(accept, SIGNAL(clicked()), this, SLOT(accept()));
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 connect(reject, SIGNAL(clicked()), this, SLOT(reject()));
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 buttonLayout->insertStretch(0, 10);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 buttonLayout->addWidget(accept);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 buttonLayout->addWidget(reject);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 QFrame *bottomSeparator = new QFrame();
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 bottomSeparator->setFrameShape(QFrame::HLine);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 bottomSeparator->setFrameShadow(QFrame::Sunken);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 topLayout->addWidget(header);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 topLayout->addWidget(content);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 topLayout->addWidget(bottomSeparator);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 topLayout->addLayout(buttonLayout);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 setLayout(topLayout);
8728ae882b6a Added dialog to show the differences before saving a certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 }

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