annotate ui/certificateitemwidget.cpp @ 627:566ee111e331 trustbridge-refactor

Added state to certificate list item and updated certificate list widget.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 23 Jun 2014 12:46:53 +0200
parents 88c9bdc74175
children 9d806f140bd5
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 "certificateitemwidget.h"
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 #include <QHBoxLayout>
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QDebug>
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 CertificateItemWidget::CertificateItemWidget(
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 QWidget *parent,
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 const Certificate &cert) : QWidget(parent)
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 mCertificate = cert;
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 setupGUI();
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
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 void CertificateItemWidget::setupGUI()
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 mLabel = new QLabel(mCertificate.subjectCN());
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 mComboBox = new QComboBox;
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 mComboBox->setFixedWidth(46);
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
26 connect(mComboBox, SIGNAL(currentIndexChanged(int)),
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
27 this, SLOT(currentStateChanged(int)));
582
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 if (mCertificate.isInstallCert()) {
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true"));
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 mComboBox->addItem(QIcon(":/img/list-remove.png"),
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 tr("remove"), QVariant("false"));
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 else {
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true"));
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 mComboBox->addItem(QIcon(":/img/list-remove.png"),
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 tr("remove"), QVariant("false"));
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 QHBoxLayout *layout = new QHBoxLayout;
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 layout->addWidget(mComboBox);
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 layout->addWidget(mLabel);
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 this->setLayout(layout);
88c9bdc74175 New widgets to display certificates in lists.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 }
627
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
44
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
45 bool CertificateItemWidget::state()
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
46 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
47 return mComboBox->currentData().toBool();
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
48 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
49
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
50 Certificate CertificateItemWidget::certificate()
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
51 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
52 return mCertificate;
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
53 }
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
54
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
55 void CertificateItemWidget::currentStateChanged(int)
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
56 {
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
57 bool state = mComboBox->currentData().toBool();
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
58 emit stateChanged(state, mCertificate);
566ee111e331 Added state to certificate list item and updated certificate list widget.
Raimund Renkert <rrenkert@intevation.de>
parents: 582
diff changeset
59 }

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