rrenkert@582: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik rrenkert@582: * Software engineering by Intevation GmbH rrenkert@582: * rrenkert@582: * This file is Free Software under the GNU GPL (v>=2) rrenkert@582: * and comes with ABSOLUTELY NO WARRANTY! rrenkert@582: * See LICENSE.txt for details. rrenkert@582: */ rrenkert@582: #include "certificateitemwidget.h" rrenkert@582: rrenkert@582: #include rrenkert@582: #include rrenkert@582: rrenkert@582: CertificateItemWidget::CertificateItemWidget( rrenkert@582: QWidget *parent, rrenkert@582: const Certificate &cert) : QWidget(parent) rrenkert@582: { rrenkert@582: mCertificate = cert; rrenkert@582: setupGUI(); rrenkert@582: } rrenkert@582: rrenkert@582: void CertificateItemWidget::setupGUI() rrenkert@582: { rrenkert@582: mLabel = new QLabel(mCertificate.subjectCN()); rrenkert@582: mComboBox = new QComboBox; rrenkert@582: mComboBox->setFixedWidth(46); rrenkert@627: connect(mComboBox, SIGNAL(currentIndexChanged(int)), rrenkert@627: this, SLOT(currentStateChanged(int))); rrenkert@582: rrenkert@582: if (mCertificate.isInstallCert()) { rrenkert@582: mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true")); rrenkert@582: mComboBox->addItem(QIcon(":/img/list-remove.png"), rrenkert@582: tr("remove"), QVariant("false")); rrenkert@582: } rrenkert@582: else { rrenkert@582: mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true")); rrenkert@582: mComboBox->addItem(QIcon(":/img/list-remove.png"), rrenkert@582: tr("remove"), QVariant("false")); rrenkert@582: } rrenkert@582: QHBoxLayout *layout = new QHBoxLayout; rrenkert@582: layout->addWidget(mComboBox); rrenkert@582: layout->addWidget(mLabel); rrenkert@582: this->setLayout(layout); rrenkert@582: } rrenkert@627: rrenkert@627: bool CertificateItemWidget::state() rrenkert@627: { rrenkert@627: return mComboBox->currentData().toBool(); rrenkert@627: } rrenkert@627: rrenkert@627: Certificate CertificateItemWidget::certificate() rrenkert@627: { rrenkert@627: return mCertificate; rrenkert@627: } rrenkert@627: rrenkert@627: void CertificateItemWidget::currentStateChanged(int) rrenkert@627: { rrenkert@627: bool state = mComboBox->currentData().toBool(); rrenkert@627: emit stateChanged(state, mCertificate); rrenkert@627: }