view 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
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */
#include "certificateitemwidget.h"

#include <QHBoxLayout>
#include <QDebug>

CertificateItemWidget::CertificateItemWidget(
    QWidget *parent,
    const Certificate &cert) : QWidget(parent)
{
    mCertificate = cert;
    setupGUI();
}

void CertificateItemWidget::setupGUI()
{
    mLabel = new QLabel(mCertificate.subjectCN());
    mComboBox = new QComboBox;
    mComboBox->setFixedWidth(46);
    connect(mComboBox, SIGNAL(currentIndexChanged(int)),
        this, SLOT(currentStateChanged(int)));

    if (mCertificate.isInstallCert()) {
        mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true"));
        mComboBox->addItem(QIcon(":/img/list-remove.png"),
            tr("remove"), QVariant("false"));
    }
    else {
        mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true"));
        mComboBox->addItem(QIcon(":/img/list-remove.png"),
            tr("remove"), QVariant("false"));
    }
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(mComboBox);
    layout->addWidget(mLabel);
    this->setLayout(layout);
}

bool CertificateItemWidget::state()
{
    return mComboBox->currentData().toBool();
}

Certificate CertificateItemWidget::certificate()
{
    return mCertificate;
}

void CertificateItemWidget::currentStateChanged(int)
{
    bool state = mComboBox->currentData().toBool();
    emit stateChanged(state, mCertificate);
}

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