comparison 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
comparison
equal deleted inserted replaced
248:9f0865dc8b14 249:6a7eb102716d
57 listLayout->addWidget(mCertListWidget); 57 listLayout->addWidget(mCertListWidget);
58 listLayout->addWidget(mDetailWidget); 58 listLayout->addWidget(mDetailWidget);
59 QGroupBox *certGroup = new QGroupBox(tr("Select certificates")); 59 QGroupBox *certGroup = new QGroupBox(tr("Select certificates"));
60 certGroup->setLayout(listLayout); 60 certGroup->setLayout(listLayout);
61 61
62 foreach (const Certificate& cert, mCertificateList.getInstallCertificates()) { 62 foreach (const Certificate& cert, mCertificateList.getCertificates()) {
63 if (!cert.isValid()) { 63 if (!cert.isValid()) {
64 qWarning() << "Invalid certificate in list"; 64 qWarning() << "Invalid certificate in list";
65 continue; 65 continue;
66 } 66 }
67 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 67 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
68 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 68 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
69 item->setData(Qt::ToolTipRole, cert.details()); 69 item->setData(Qt::ToolTipRole, cert.details());
70 item->setData(Qt::UserRole, cert.base64Line()); 70 item->setData(Qt::UserRole, cert.base64Line());
71 item->setCheckState(Qt::Checked); 71 item->setCheckState(Qt::Checked);
72 QIcon *certIcon = new QIcon(":/img/list-add.png"); 72 QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png") :
73 new QIcon(":/img/list-remove.png");
73 item->setIcon(*certIcon); 74 item->setIcon(*certIcon);
75
74 mCertListWidget->addItem(item); 76 mCertListWidget->addItem(item);
75 } 77 }
76
77 foreach (const Certificate& cert, mCertificateList.getRemoveCertificates()) {
78 if (!cert.isValid()) {
79 qWarning() << "Invalid certificate in list";
80 continue;
81 }
82 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
83 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
84 item->setData(Qt::ToolTipRole, cert.details());
85 item->setData(Qt::UserRole, cert.base64Line());
86 item->setCheckState(Qt::Checked);
87 QIcon *certIcon = new QIcon(":/img/list-remove.png");
88 item->setIcon(*certIcon);
89 mCertListWidget->addItem(item);
90 }
91
92 78
93 /* Fill top level layout */ 79 /* Fill top level layout */
94 topLayout->addLayout(headerLayout); 80 topLayout->addLayout(headerLayout);
95 topLayout->addWidget(certGroup); 81 topLayout->addWidget(certGroup);
96 topLayout->addLayout(bottomLayout); 82 topLayout->addLayout(bottomLayout);

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