comparison ui/mainwindow.cpp @ 375:9e38a4bcd44e

Move certificateitem role into the certificateitemdelagate where it belongs.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 15 Apr 2014 12:06:03 +0200
parents 6cc124e79066
children 3be838c3e4d8
comparison
equal deleted inserted replaced
374:4836537f87da 375:9e38a4bcd44e
324 qWarning() << "Invalid certificate in list"; 324 qWarning() << "Invalid certificate in list";
325 continue; 325 continue;
326 } 326 }
327 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 327 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
328 SeparatorItemDelegate *separator = new SeparatorItemDelegate(); 328 SeparatorItemDelegate *separator = new SeparatorItemDelegate();
329 item->setData(DetailsRole, cert.details()); 329 item->setData(CertificateItemDelegate::DetailsRole, cert.details());
330 item->setData(B64LineRole, cert.base64Line()); 330 item->setData(CertificateItemDelegate::B64LineRole, cert.base64Line());
331 Qt::CheckState checkedState = mPreviouslyUnselected.contains(cert.base64Line()) ? 331 Qt::CheckState checkedState = mPreviouslyUnselected.contains(cert.base64Line()) ?
332 Qt::Unchecked : Qt::Checked; 332 Qt::Unchecked : Qt::Checked;
333 if (cert.isInstallCert()) { 333 if (cert.isInstallCert()) {
334 // This if statements is for testing! @TODO Remove this! 334 // This if statements is for testing! @TODO Remove this!
335 if (i <= 2) { 335 if (i <= 2) {
336 item->setData(StatusRole, Certificate::InstallOld); 336 item->setData(CertificateItemDelegate::StatusRole, Certificate::InstallOld);
337 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 337 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
338 } 338 }
339 else { 339 else {
340 item->setData(StatusRole, Certificate::InstallNew); 340 item->setData(CertificateItemDelegate::StatusRole, Certificate::InstallNew);
341 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 341 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
342 } 342 }
343 if (i == 3) { 343 if (i == 3) {
344 QListWidgetItem *sep = new QListWidgetItem("New certificates"); 344 QListWidgetItem *sep = new QListWidgetItem("New certificates");
345 mCertListWidget->setItemDelegateForRow(i, separator); 345 mCertListWidget->setItemDelegateForRow(i, separator);
349 item->setCheckState(checkedState); 349 item->setCheckState(checkedState);
350 } 350 }
351 else { 351 else {
352 // This if statements is for testing! @TODO Remove this! 352 // This if statements is for testing! @TODO Remove this!
353 if (i > 35) { 353 if (i > 35) {
354 item->setData(StatusRole, Certificate::RemoveNew); 354 item->setData(CertificateItemDelegate::StatusRole, Certificate::RemoveNew);
355 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 355 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
356 item->setCheckState(checkedState); 356 item->setCheckState(checkedState);
357 } 357 }
358 else { 358 else {
359 item->setData(StatusRole, Certificate::RemoveOld); 359 item->setData(CertificateItemDelegate::StatusRole, Certificate::RemoveOld);
360 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 360 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
361 } 361 }
362 } 362 }
363 mCertListWidget->addItem(item); 363 mCertListWidget->addItem(item);
364 i++; 364 i++;
391 about->show(); 391 about->show();
392 } 392 }
393 393
394 void MainWindow::showDetails(QListWidgetItem *item) 394 void MainWindow::showDetails(QListWidgetItem *item)
395 { 395 {
396 QString details = item->data(DetailsRole).toString(); 396 QString details = item->data(CertificateItemDelegate::DetailsRole).toString();
397 certificateDetails->setPlainText(details); 397 certificateDetails->setPlainText(details);
398 } 398 }
399 399
400 void MainWindow::resizeButtons() 400 void MainWindow::resizeButtons()
401 { 401 {
411 QStringList choices; 411 QStringList choices;
412 412
413 for (int i = 0; i < mCertListWidget->count(); i++) { 413 for (int i = 0; i < mCertListWidget->count(); i++) {
414 QListWidgetItem *item = mCertListWidget->item(i); 414 QListWidgetItem *item = mCertListWidget->item(i);
415 if (item->checkState() == Qt::Checked) { 415 if (item->checkState() == Qt::Checked) {
416 choices << item->data(B64LineRole).toString(); 416 choices << item->data(CertificateItemDelegate::B64LineRole).toString();
417 continue; 417 continue;
418 } 418 }
419 QString certLine = item->data(B64LineRole).toString(); 419 QString certLine = item->data(CertificateItemDelegate::B64LineRole).toString();
420 if (certLine.startsWith("I:")) { 420 if (certLine.startsWith("I:")) {
421 certLine[0] = 'R'; 421 certLine[0] = 'R';
422 choices << certLine; 422 choices << certLine;
423 } 423 }
424 } 424 }
464 mSettings.remove(""); /* Clears old choices */ 464 mSettings.remove(""); /* Clears old choices */
465 for (int i = 0; i < mCertListWidget->count(); i++) { 465 for (int i = 0; i < mCertListWidget->count(); i++) {
466 QListWidgetItem *item = mCertListWidget->item(i); 466 QListWidgetItem *item = mCertListWidget->item(i);
467 if (item->checkState() != Qt::Checked) { 467 if (item->checkState() != Qt::Checked) {
468 mSettings.setValue(QString::fromLatin1("cert%1").arg(i), 468 mSettings.setValue(QString::fromLatin1("cert%1").arg(i),
469 item->data(B64LineRole).toString()); 469 item->data(CertificateItemDelegate::B64LineRole).toString());
470 } 470 }
471 } 471 }
472 mSettings.endGroup(); 472 mSettings.endGroup();
473 mSettings.sync(); 473 mSettings.sync();
474 return mSettings.status() == QSettings::NoError; 474 return mSettings.status() == QSettings::NoError;

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