[PATCH 1 of 3] Added state and editable flag to certificate list items
Wald Commits
scm-commit at wald.intevation.org
Tue Jun 24 17:21:09 CEST 2014
# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1403621992 -7200
# Branch trustbridge-refactor
# Node ID 9d806f140bd5ce65d5b543cff602722228d0b578
# Parent 3a9c0f38bbad904de1d2fc2336d0bdec69e3feef
Added state and editable flag to certificate list items.
diff -r 3a9c0f38bbad -r 9d806f140bd5 ui/certificateitemwidget.cpp
--- 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;
diff -r 3a9c0f38bbad -r 9d806f140bd5 ui/certificateitemwidget.h
--- 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;
More information about the Trustbridge-commits
mailing list