Mercurial > trustbridge
diff ui/listupdatedialog.cpp @ 249:6a7eb102716d
Remove code duplication by unifying the certificatelist.
You should now check for isInstallCert to determine wether this
certificate should be installed or removed.
Leaving the getInstallCertificates and getRemoveCertificates
in place for compatibilty would have been easier to keep the
tests stable.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 31 Mar 2014 08:06:17 +0000 |
parents | 431b058e903d |
children | 06089ba2614a |
line wrap: on
line diff
--- a/ui/listupdatedialog.cpp Mon Mar 31 08:03:20 2014 +0000 +++ b/ui/listupdatedialog.cpp Mon Mar 31 08:06:17 2014 +0000 @@ -59,7 +59,7 @@ QGroupBox *certGroup = new QGroupBox(tr("Select certificates")); certGroup->setLayout(listLayout); - foreach (const Certificate& cert, mCertificateList.getInstallCertificates()) { + foreach (const Certificate& cert, mCertificateList.getCertificates()) { if (!cert.isValid()) { qWarning() << "Invalid certificate in list"; continue; @@ -69,27 +69,13 @@ item->setData(Qt::ToolTipRole, cert.details()); item->setData(Qt::UserRole, cert.base64Line()); item->setCheckState(Qt::Checked); - QIcon *certIcon = new QIcon(":/img/list-add.png"); + QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png") : + new QIcon(":/img/list-remove.png"); item->setIcon(*certIcon); + mCertListWidget->addItem(item); } - foreach (const Certificate& cert, mCertificateList.getRemoveCertificates()) { - if (!cert.isValid()) { - qWarning() << "Invalid certificate in list"; - continue; - } - QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setData(Qt::ToolTipRole, cert.details()); - item->setData(Qt::UserRole, cert.base64Line()); - item->setCheckState(Qt::Checked); - QIcon *certIcon = new QIcon(":/img/list-remove.png"); - item->setIcon(*certIcon); - mCertListWidget->addItem(item); - } - - /* Fill top level layout */ topLayout->addLayout(headerLayout); topLayout->addWidget(certGroup);