comparison ui/mainwindow.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 f7176140d20d
children 1e112cf41e92
comparison
equal deleted inserted replaced
248:9f0865dc8b14 249:6a7eb102716d
281 281
282 void MainWindow::loadCertificateList() 282 void MainWindow::loadCertificateList()
283 { 283 {
284 qDebug() << "display certificates"; 284 qDebug() << "display certificates";
285 certificateList->clear(); 285 certificateList->clear();
286 foreach (const Certificate &cert, mListToInstall.getInstallCertificates()) { 286 foreach (const Certificate &cert, mListToInstall.getCertificates()) {
287 if (!cert.isValid()) { 287 if (!cert.isValid()) {
288 qWarning() << "Invalid certificate in list"; 288 qWarning() << "Invalid certificate in list";
289 continue; 289 continue;
290 } 290 }
291 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 291 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
292 item->setData(Qt::UserRole, cert.details()); 292 item->setData(Qt::UserRole, cert.details());
293 QIcon *certIcon = new QIcon(":/img/list-add.png"); 293 QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png"):
294 item->setIcon(*certIcon); 294 new QIcon(":/img/list-remove.png");
295 certificateList->addItem(item);
296 }
297 foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) {
298 if (!cert.isValid()) {
299 qWarning() << "Invalid certificate in list";
300 continue;
301 }
302 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
303 item->setData(Qt::UserRole, cert.details());
304 QIcon *certIcon = new QIcon(":/img/list-remove.png");
305 item->setIcon(*certIcon); 295 item->setIcon(*certIcon);
306 certificateList->addItem(item); 296 certificateList->addItem(item);
307 } 297 }
308 } 298 }
309 299

http://wald.intevation.org/projects/trustbridge/