changeset 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 4836537f87da
children e3f825a7257e
files ui/certificateitemdelegate.cpp ui/certificateitemdelegate.h ui/mainwindow.cpp ui/mainwindow.h
diffstat 4 files changed, 18 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ui/certificateitemdelegate.cpp	Tue Apr 15 12:05:22 2014 +0200
+++ b/ui/certificateitemdelegate.cpp	Tue Apr 15 12:06:03 2014 +0200
@@ -9,7 +9,7 @@
 {
     // Save the current painter.
     painter->save();
-    int status = index.data(MainWindow::StatusRole).toInt();
+    int status = index.data(StatusRole).toInt();
     if (status == 0) {
         // This status is not known, so draw the default item.
         QStyledItemDelegate::paint(painter, option, index);
--- a/ui/certificateitemdelegate.h	Tue Apr 15 12:05:22 2014 +0200
+++ b/ui/certificateitemdelegate.h	Tue Apr 15 12:06:03 2014 +0200
@@ -25,6 +25,13 @@
     void paint(QPainter *painter, const QStyleOptionViewItem &option,
         const QModelIndex &index) const;
 
+    /** @brief different roles for this tiem */
+    enum ItemRole {
+        DetailsRole = Qt::UserRole, /* The certificate details for the window */
+        StatusRole, /* Certificate status */
+        B64LineRole /* The I:/R: <cert> line */
+    };
+
 private:
 
     /**
--- a/ui/mainwindow.cpp	Tue Apr 15 12:05:22 2014 +0200
+++ b/ui/mainwindow.cpp	Tue Apr 15 12:06:03 2014 +0200
@@ -326,18 +326,18 @@
         }
         QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
         SeparatorItemDelegate *separator = new SeparatorItemDelegate();
-        item->setData(DetailsRole, cert.details());
-        item->setData(B64LineRole, cert.base64Line());
+        item->setData(CertificateItemDelegate::DetailsRole, cert.details());
+        item->setData(CertificateItemDelegate::B64LineRole, cert.base64Line());
         Qt::CheckState checkedState = mPreviouslyUnselected.contains(cert.base64Line()) ?
             Qt::Unchecked : Qt::Checked;
         if (cert.isInstallCert()) {
             // This if statements is for testing! @TODO Remove this!
             if (i <= 2) {
-                item->setData(StatusRole, Certificate::InstallOld);
+                item->setData(CertificateItemDelegate::StatusRole, Certificate::InstallOld);
                 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
             }
             else {
-                item->setData(StatusRole, Certificate::InstallNew);
+                item->setData(CertificateItemDelegate::StatusRole, Certificate::InstallNew);
                 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
             }
             if (i == 3) {
@@ -351,12 +351,12 @@
         else {
             // This if statements is for testing! @TODO Remove this!
             if (i > 35) {
-                item->setData(StatusRole, Certificate::RemoveNew);
+                item->setData(CertificateItemDelegate::StatusRole, Certificate::RemoveNew);
                 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
                 item->setCheckState(checkedState);
             }
             else {
-                item->setData(StatusRole, Certificate::RemoveOld);
+                item->setData(CertificateItemDelegate::StatusRole, Certificate::RemoveOld);
                 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
             }
         }
@@ -393,7 +393,7 @@
 
 void MainWindow::showDetails(QListWidgetItem *item)
 {
-    QString details = item->data(DetailsRole).toString();
+    QString details = item->data(CertificateItemDelegate::DetailsRole).toString();
     certificateDetails->setPlainText(details);
 }
 
@@ -413,10 +413,10 @@
     for (int i = 0; i < mCertListWidget->count(); i++) {
         QListWidgetItem *item = mCertListWidget->item(i);
         if (item->checkState() == Qt::Checked) {
-            choices << item->data(B64LineRole).toString();
+            choices << item->data(CertificateItemDelegate::B64LineRole).toString();
             continue;
         }
-        QString certLine = item->data(B64LineRole).toString();
+        QString certLine = item->data(CertificateItemDelegate::B64LineRole).toString();
         if (certLine.startsWith("I:")) {
             certLine[0] = 'R';
             choices << certLine;
@@ -466,7 +466,7 @@
         QListWidgetItem *item = mCertListWidget->item(i);
         if (item->checkState() != Qt::Checked) {
             mSettings.setValue(QString::fromLatin1("cert%1").arg(i),
-                    item->data(B64LineRole).toString());
+                    item->data(CertificateItemDelegate::B64LineRole).toString());
         }
     }
     mSettings.endGroup();
--- a/ui/mainwindow.h	Tue Apr 15 12:05:22 2014 +0200
+++ b/ui/mainwindow.h	Tue Apr 15 12:06:03 2014 +0200
@@ -45,13 +45,6 @@
         NewSoftwareAvailable,
         TransferError
     };
-
-    enum ItemRole {
-        DetailsRole = Qt::UserRole, /* The certificate details for the window */
-        StatusRole, /* Certificate status */
-        B64LineRole /* The I:/R: <cert> line */
-    };
-
     CurrentState getState() {return mCurState;}
     void setState(CurrentState state) {mCurState = state;}
 

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