comparison ui/mainwindow.cpp @ 267:89e8783866f8

Use the certificate item delegate in the mainwind list view.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 02 Apr 2014 09:27:24 +0200
parents ffd47b045d19
children 1ae15ea73850
comparison
equal deleted inserted replaced
266:dd6a09d2699f 267:89e8783866f8
30 #include "downloader.h" 30 #include "downloader.h"
31 #include "listupdatedialog.h" 31 #include "listupdatedialog.h"
32 #include "helpdialog.h" 32 #include "helpdialog.h"
33 #include "aboutdialog.h" 33 #include "aboutdialog.h"
34 #include "statusdialog.h" 34 #include "statusdialog.h"
35 #include "certificateitemdelegate.h"
35 36
36 MainWindow::MainWindow() { 37 MainWindow::MainWindow() {
37 createActions(); 38 createActions();
38 createTrayIcon(); 39 createTrayIcon();
39 createMenuBar(); 40 createMenuBar();
244 QHBoxLayout *toolButtonLayout = new QHBoxLayout; 245 QHBoxLayout *toolButtonLayout = new QHBoxLayout;
245 246
246 // The certificate list 247 // The certificate list
247 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); 248 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
248 certificateList = new QListWidget; 249 certificateList = new QListWidget;
250 certificateList->setItemDelegate(new CertificateItemDelegate);
249 connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)), 251 connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)),
250 this, SLOT(showDetails(QListWidgetItem*))); 252 this, SLOT(showDetails(QListWidgetItem*)));
251 certLayout->addWidget(certificateList); 253 certLayout->addWidget(certificateList);
252 certBox->setLayout(certLayout); 254 certBox->setLayout(certLayout);
253 255
300 302
301 void MainWindow::loadCertificateList() 303 void MainWindow::loadCertificateList()
302 { 304 {
303 qDebug() << "display certificates"; 305 qDebug() << "display certificates";
304 certificateList->clear(); 306 certificateList->clear();
307 int i = 0;
305 foreach (const Certificate &cert, mListToInstall.getCertificates()) { 308 foreach (const Certificate &cert, mListToInstall.getCertificates()) {
306 if (!cert.isValid()) { 309 if (!cert.isValid()) {
307 qWarning() << "Invalid certificate in list"; 310 qWarning() << "Invalid certificate in list";
308 continue; 311 continue;
309 } 312 }
310 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 313 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
311 item->setData(Qt::UserRole, cert.details()); 314 item->setData(Qt::UserRole, cert.details());
312 QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png"): 315 if (cert.isInstallCert()) {
313 new QIcon(":/img/list-remove.png"); 316 // This if statements is for testing! @TODO Remove this!
314 item->setIcon(*certIcon); 317 if (i <= 2) {
318 item->setData(Qt::UserRole + 1, Certificate::InstallOld);
319 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
320 item->setCheckState(Qt::Checked);
321 }
322 else {
323 item->setData(Qt::UserRole + 1, Certificate::InstallNew);
324 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
325 item->setCheckState(Qt::Checked);
326 }
327 }
328 else {
329 // This if statements is for testing! @TODO Remove this!
330 if (i > 35) {
331 item->setData(Qt::UserRole + 1, Certificate::RemoveNew);
332 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
333 item->setCheckState(Qt::Checked);
334 }
335 else {
336 item->setData(Qt::UserRole + 1, Certificate::RemoveOld);
337 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
338 }
339 }
315 certificateList->addItem(item); 340 certificateList->addItem(item);
341 i++;
316 } 342 }
317 } 343 }
318 344
319 void MainWindow::showSettings() 345 void MainWindow::showSettings()
320 { 346 {

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