Bläddra i källkod

Merge branch 'fix-uint-conversion-to-int-warnings'

* fix-uint-conversion-to-int-warnings:
  Fix Qt::Checked and Qt::Unchecked automatic conversion to QVariant
Julien Finet 13 år sedan
förälder
incheckning
f232e9861a

+ 11 - 8
Libs/Core/ctkCheckableModelHelper.cpp

@@ -120,11 +120,13 @@ void ctkCheckableModelHelperPrivate::setCheckState(
     }
   else if (modelIndex != q->rootIndex())
     {
-    q->model()->setData(modelIndex, newCheckState, Qt::CheckStateRole);
+    q->model()->setData(modelIndex, static_cast<int>(newCheckState),
+                        Qt::CheckStateRole);
     }
   else
     {
-    q->model()->setHeaderData(0, q->orientation(), newCheckState, Qt::CheckStateRole);
+    q->model()->setHeaderData(0, q->orientation(), static_cast<int>(newCheckState),
+                              Qt::CheckStateRole);
     }
 }
 
@@ -455,11 +457,11 @@ void ctkCheckableModelHelper::setHeaderCheckState(int section, Qt::CheckState ch
 {
   QAbstractItemModel *current = this->model();
   if(current == 0)
-    {    
+    {
     return;
     }
   current->setHeaderData(section, this->orientation(),
-                         checkState, Qt::CheckStateRole);
+                         static_cast<int>(checkState), Qt::CheckStateRole);
 }
 
 //-----------------------------------------------------------------------------
@@ -467,10 +469,10 @@ void ctkCheckableModelHelper::setCheckState(const QModelIndex& index, Qt::CheckS
 {
   QAbstractItemModel *current = this->model();
   if(current == 0)
-    {    
+    {
     return;
     }
-  current->setData(index, checkState, Qt::CheckStateRole);
+  current->setData(index, static_cast<int>(checkState), Qt::CheckStateRole);
 }
 //-----------------------------------------------------------------------------
 void ctkCheckableModelHelper::toggleCheckState(const QModelIndex& modelIndex)
@@ -496,8 +498,9 @@ void ctkCheckableModelHelper::toggleHeaderCheckState(int section)
     }
   // I've no strong feeling to turn the state checked or unchecked when the 
   // state is PartiallyChecked.
-  this->setHeaderCheckState(section,
-    this->headerCheckState(section) == Qt::Checked ? Qt::Unchecked : Qt::Checked);
+  this->setHeaderCheckState(
+    section, this->headerCheckState(section) == Qt::Checked ?
+    Qt::Unchecked : Qt::Checked);
 }
 
 //-----------------------------------------------------------------------------

+ 7 - 7
Libs/DICOM/Core/ctkDICOMModel.cpp

@@ -740,15 +740,15 @@ bool ctkDICOMModel::setParentData(const QModelIndex &index, const QVariant &valu
     for(int i=0; i<index.model()->rowCount(index); i++)
       {
       Node* childNode = d->nodeFromIndex(index.child(i,0));
-      if(childNode->Data[Qt::CheckStateRole] ==  Qt::Checked)
+      if(childNode->Data[Qt::CheckStateRole].toUInt() == Qt::Checked)
         {
         checkedExist = true;
         }
-      else if(childNode->Data[Qt::CheckStateRole] ==  Qt::PartiallyChecked)
+      else if(childNode->Data[Qt::CheckStateRole].toUInt() ==  Qt::PartiallyChecked)
         {
         partiallyCheckedExist = true;
         }
-      else if(childNode->Data[Qt::CheckStateRole] ==  Qt::Unchecked)
+      else if(childNode->Data[Qt::CheckStateRole].toUInt() ==  Qt::Unchecked)
         {
         uncheckedExist = true;
         }
@@ -757,19 +757,19 @@ bool ctkDICOMModel::setParentData(const QModelIndex &index, const QVariant &valu
 #ifdef CHECKABLE_COLUMNS
     if(partiallyCheckedExist || (checkedExist && uncheckedExist))
       {
-      node->Data[Qt::CheckStateRole] = Qt::PartiallyChecked;
+      node->Data[Qt::CheckStateRole].toUInt() = Qt::PartiallyChecked;
       }
     else if(checkedExist)
       {
-      node->Data[Qt::CheckStateRole] = Qt::Checked;
+      node->Data[Qt::CheckStateRole].toUInt() = Qt::Checked;
       }
     else if(uncheckedExist)
       {
-      node->Data[Qt::CheckStateRole] = Qt::Unchecked;
+      node->Data[Qt::CheckStateRole].toUInt() = Qt::Unchecked;
       }
     else
       {
-      node->Data[Qt::CheckStateRole] = Qt::Unchecked;
+      node->Data[Qt::CheckStateRole].toUInt() = Qt::Unchecked;
       }
 #endif
 

+ 10 - 7
Libs/DICOM/Widgets/ctkDICOMServerNodeWidget.cpp

@@ -60,7 +60,8 @@ ctkDICOMServerNodeWidget::ctkDICOMServerNodeWidget(QWidget* parentWidget)
   d->setupUi(this);
 
   // checkable headers.
-  d->NodeTable->model()->setHeaderData(NameColumn, Qt::Horizontal, Qt::Unchecked, Qt::CheckStateRole);
+  d->NodeTable->model()->setHeaderData(
+    NameColumn, Qt::Horizontal, static_cast<int>(Qt::Unchecked), Qt::CheckStateRole);
   QHeaderView* previousHeaderView = d->NodeTable->horizontalHeader();
   ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, d->NodeTable);
   headerView->setClickable(previousHeaderView->isClickable());
@@ -196,21 +197,21 @@ void ctkDICOMServerNodeWidget::readSettings()
     // a dummy example
     QMap<QString, QVariant> defaultServerNode;
     defaultServerNode["Name"] = QString("ExampleHost");
-    defaultServerNode["CheckState"] = Qt::Unchecked;
+    defaultServerNode["CheckState"] = static_cast<int>(Qt::Unchecked);
     defaultServerNode["AETitle"] = QString("AETITLE");
     defaultServerNode["Address"] = QString("dicom.example.com");
     defaultServerNode["Port"] = QString("11112");
-    defaultServerNode["CGET"] = Qt::Unchecked;
+    defaultServerNode["CGET"] = static_cast<int>(Qt::Unchecked);
     this->addServerNode(defaultServerNode);
 
     // the uk example - see http://www.dicomserver.co.uk/ 
     // and http://www.medicalconnections.co.uk/
     defaultServerNode["Name"] = QString("MedicalConnections");
-    defaultServerNode["CheckState"] = Qt::Unchecked;
+    defaultServerNode["CheckState"] = static_cast<int>(Qt::Unchecked);
     defaultServerNode["AETitle"] = QString("ANYAE");
     defaultServerNode["Address"] = QString("dicomserver.co.uk");
     defaultServerNode["Port"] = QString("11112");
-    defaultServerNode["CGET"] = Qt::Checked;
+    defaultServerNode["CGET"] = static_cast<int>(Qt::Checked);
     this->addServerNode(defaultServerNode);
 
     return;
@@ -344,8 +345,10 @@ QMap<QString, QVariant> ctkDICOMServerNodeWidget::serverNodeParameters(int row)c
     node[label] = d->NodeTable->item(row, column)->data(Qt::DisplayRole);
     }
   node["CheckState"] = d->NodeTable->item(row, NameColumn) ?
-    d->NodeTable->item(row,NameColumn)->checkState() : Qt::Unchecked;
+    d->NodeTable->item(row,NameColumn)->checkState() :
+    static_cast<int>(Qt::Unchecked);
   node["CGET"] = d->NodeTable->item(row, CGETColumn) ?
-    d->NodeTable->item(row,CGETColumn)->checkState() : Qt::Unchecked;
+    d->NodeTable->item(row,CGETColumn)->checkState() :
+    static_cast<int>(Qt::Unchecked);
   return node;
 }

+ 4 - 2
Libs/Widgets/ctkCheckableComboBox.cpp

@@ -164,7 +164,8 @@ QModelIndexList ctkCheckableComboBoxPrivate::checkedIndexes()const
 {
   Q_Q(const ctkCheckableComboBox);
   return q->model()->match(
-    q->rootModelIndex().child(0,0), Qt::CheckStateRole, Qt::Checked, -1, Qt::MatchRecursive);
+    q->rootModelIndex().child(0,0), Qt::CheckStateRole,
+    static_cast<int>(Qt::Checked), -1, Qt::MatchRecursive);
 }
 
 //-----------------------------------------------------------------------------
@@ -172,7 +173,8 @@ QModelIndexList ctkCheckableComboBoxPrivate::uncheckedIndexes()const
 {
   Q_Q(const ctkCheckableComboBox);
   return q->model()->match(
-    q->rootModelIndex().child(0,0), Qt::CheckStateRole, Qt::Unchecked, -1, Qt::MatchRecursive);
+    q->rootModelIndex().child(0,0), Qt::CheckStateRole,
+    static_cast<int>(Qt::Unchecked), -1, Qt::MatchRecursive);
 }
 
 //-----------------------------------------------------------------------------