Mercurial > trustbridge
diff ui/certificateitemwidget.cpp @ 638:9d806f140bd5 trustbridge-refactor
Added state and editable flag to certificate list items.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 24 Jun 2014 16:59:52 +0200 |
parents | 566ee111e331 |
children | 9c3e7754b76b |
line wrap: on
line diff
--- a/ui/certificateitemwidget.cpp Mon Jun 23 12:49:09 2014 +0200 +++ b/ui/certificateitemwidget.cpp Tue Jun 24 16:59:52 2014 +0200 @@ -12,9 +12,13 @@ CertificateItemWidget::CertificateItemWidget( QWidget *parent, - const Certificate &cert) : QWidget(parent) + const Certificate &cert, + bool state, + bool editable) : QWidget(parent) { mCertificate = cert; + mState = state; + mEditable = editable; setupGUI(); } @@ -26,18 +30,37 @@ connect(mComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentStateChanged(int))); + QHBoxLayout *layout = new QHBoxLayout; 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")); + if (mState) + mComboBox->setCurrentIndex(0); + else { + mComboBox->setCurrentIndex(1); + } + layout->addWidget(mComboBox); + } + else if (!mCertificate.isInstallCert() && !mEditable){ + QImage *img = new QImage(":/img/list-remove.png"); + QLabel *imgLabel = new QLabel; + imgLabel->setPixmap(QPixmap::fromImage(*img)); + imgLabel->setFixedSize(25, 25); + imgLabel->setMargin(5); + layout->addWidget(imgLabel); } else { mComboBox->addItem(QIcon(":/img/list-add.png"), tr("add"), QVariant("true")); mComboBox->addItem(QIcon(":/img/list-remove.png"), tr("remove"), QVariant("false")); + if (mState) + mComboBox->setCurrentIndex(0); + else { + mComboBox->setCurrentIndex(1); + } + layout->addWidget(mComboBox); } - QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(mComboBox); layout->addWidget(mLabel); this->setLayout(layout); } @@ -47,6 +70,21 @@ return mComboBox->currentData().toBool(); } +void CertificateItemWidget::setState(bool state) +{ + disconnect(mComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(currentStateChanged(int))); + + if (state) { + mComboBox->setCurrentIndex(0); + } + else { + mComboBox->setCurrentIndex(1); + } + connect(mComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(currentStateChanged(int))); +} + Certificate CertificateItemWidget::certificate() { return mCertificate;