Mercurial > trustbridge
changeset 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 | 3a9c0f38bbad |
children | c1b35edb097f |
files | ui/certificateitemwidget.cpp ui/certificateitemwidget.h |
diffstat | 2 files changed, 49 insertions(+), 4 deletions(-) [+] |
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;
--- a/ui/certificateitemwidget.h Mon Jun 23 12:49:09 2014 +0200 +++ b/ui/certificateitemwidget.h Tue Jun 24 16:59:52 2014 +0200 @@ -22,15 +22,22 @@ { Q_OBJECT public: - CertificateItemWidget(QWidget *parent = 0, const Certificate &cert = Certificate()); + CertificateItemWidget( + QWidget *parent = 0, + const Certificate &cert = Certificate(), + bool state = false, + bool edtiable = true); bool state(); + void setState(bool state); Certificate certificate(); private: void setupGUI(); Certificate mCertificate; + bool mState; + bool mEditable; QLabel *mLabel; QComboBox *mComboBox;