# HG changeset patch # User Raimund Renkert # Date 1396423644 -7200 # Node ID 89e8783866f8278b13eccffa588f76773de1ffba # Parent dd6a09d2699f44bf588a52d08fd3820f57e20fa5 Use the certificate item delegate in the mainwind list view. diff -r dd6a09d2699f -r 89e8783866f8 ui/mainwindow.cpp --- a/ui/mainwindow.cpp Wed Apr 02 09:26:38 2014 +0200 +++ b/ui/mainwindow.cpp Wed Apr 02 09:27:24 2014 +0200 @@ -32,6 +32,7 @@ #include "helpdialog.h" #include "aboutdialog.h" #include "statusdialog.h" +#include "certificateitemdelegate.h" MainWindow::MainWindow() { createActions(); @@ -246,6 +247,7 @@ // The certificate list QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); certificateList = new QListWidget; + certificateList->setItemDelegate(new CertificateItemDelegate); connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(showDetails(QListWidgetItem*))); certLayout->addWidget(certificateList); @@ -302,6 +304,7 @@ { qDebug() << "display certificates"; certificateList->clear(); + int i = 0; foreach (const Certificate &cert, mListToInstall.getCertificates()) { if (!cert.isValid()) { qWarning() << "Invalid certificate in list"; @@ -309,10 +312,33 @@ } QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); item->setData(Qt::UserRole, cert.details()); - QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png"): - new QIcon(":/img/list-remove.png"); - item->setIcon(*certIcon); + if (cert.isInstallCert()) { + // This if statements is for testing! @TODO Remove this! + if (i <= 2) { + item->setData(Qt::UserRole + 1, Certificate::InstallOld); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); + } + else { + item->setData(Qt::UserRole + 1, Certificate::InstallNew); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); + } + } + else { + // This if statements is for testing! @TODO Remove this! + if (i > 35) { + item->setData(Qt::UserRole + 1, Certificate::RemoveNew); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); + } + else { + item->setData(Qt::UserRole + 1, Certificate::RemoveOld); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + } + } certificateList->addItem(item); + i++; } }