Kaynağa Gözat

Fix various warnings, unused variables, bad casts...

It shouldn't affect any behavior. For some reasons ctkDICOMQueryTest1
doesn't recognize EXIT_FAILURE (while all the other tests do), no sure why
but adding the C header cstdlib fixes the issue.
Julien Finet 14 yıl önce
ebeveyn
işleme
717599f39d

+ 2 - 0
Libs/DICOM/Core/Testing/Cpp/ctkDICOMDatasetTest1.cpp

@@ -26,6 +26,8 @@
 
 int ctkDICOMDatasetTest1( int argc, char * argv [] )
 {
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
   ctkDICOMDataset dataset;
   dataset.InitializeFromDataset(0);
   dataset.InitializeFromFile(QString());

+ 1 - 0
Libs/DICOM/Core/Testing/Cpp/ctkDICOMQueryTest1.cpp

@@ -27,6 +27,7 @@
 #include "ctkDICOMQuery.h"
 
 // STD includes
+#include <cstdlib>
 #include <iostream>
 
 // Simple test that check the values are correctly set

+ 0 - 2
Libs/DICOM/Core/ctkDICOMDatabase.cpp

@@ -462,8 +462,6 @@ bool ctkDICOMDatabase::isInMemory() const
 
 QString ctkDICOMDatabase::pathForDataset( DcmDataset *dataset)
 {
-  Q_D(ctkDICOMDatabase);
-
   if (!dataset)
     {
     return QString();

+ 21 - 10
Libs/DICOM/Core/ctkDICOMDataset.cpp

@@ -95,12 +95,13 @@ void ctkDICOMDataset::InitializeFromDataset(DcmDataset* dataset)
 }
 
 
-void ctkDICOMDataset::InitializeFromFile(const QString& filename,const E_TransferSyntax readXfer,
-                    const E_GrpLenEncoding groupLength,
-                    const Uint32 maxReadLength,
-                    const E_FileReadMode readMode)
+void ctkDICOMDataset::InitializeFromFile(const QString& filename,
+                                         const E_TransferSyntax readXfer,
+                                         const E_GrpLenEncoding groupLength,
+                                         const Uint32 maxReadLength,
+                                         const E_FileReadMode readMode)
 {
-  Q_D(ctkDICOMDataset);
+  Q_UNUSED(maxReadLength);
   DcmDataset *dataset;
   
   DcmFileFormat fileformat;
@@ -203,10 +204,17 @@ void ctkDICOMDataset::Deserialize()
 
   if ( condition.bad() )
   {
-    std::cerr << "** Condition code of Dataset::read() is " << condition.code() << std::endl;
-    std::cerr << "** Buffer state: " << dcmbuffer.status().code() << " " <<  dcmbuffer.good() << " " << dcmbuffer.eos() << " tell " << dcmbuffer.tell() << " avail " << dcmbuffer.avail() << std::endl;
-    std::cerr << "** Dataset state: " << (int)dataset.transferState() << std::endl;
-    std::cerr << std::string("Could not DcmDataset::read(..): ") + condition.text() << std::endl;
+    std::cerr << "** Condition code of Dataset::read() is "
+              << condition.code() << std::endl;
+    std::cerr << "** Buffer state: " << dcmbuffer.status().code()
+              << " " <<  dcmbuffer.good()
+              << " " << dcmbuffer.eos()
+              << " tell " << dcmbuffer.tell()
+              << " avail " << dcmbuffer.avail() << std::endl;
+    std::cerr << "** Dataset state: "
+              << static_cast<int>(dataset.transferState()) << std::endl;
+    std::cerr << "Could not DcmDataset::read(..): "
+              << condition.text() << std::endl;
     //throw std::invalid_argument( std::string("Could not DcmDataset::read(..): ") + condition.text() );
   }
 }
@@ -385,7 +393,7 @@ QString ctkDICOMDataset::Decode( const DcmTag& tag, const OFString& raw ) const
 OFString ctkDICOMDataset::Encode( const DcmTag& tag, const QString& qstring ) const
 {
   // TODO: respect given character-set when encoding; see Decode()
-
+  Q_UNUSED(tag);
   return OFString( qstring.toLatin1().data() ); // Latin1 is ISO 8859, which is the default character set of DICOM (PS 3.5-2008, Page 18)
 }
     
@@ -659,6 +667,8 @@ bool ctkDICOMDataset::SetElementAsPersonName( const DcmTag& tag, ctkDICOMPersonN
 
 bool ctkDICOMDataset::SetElementAsPersonNameList( const DcmTag& tag, ctkDICOMPersonNameList personNameList )
 {
+  Q_UNUSED(tag);
+  Q_UNUSED(personNameList);
   this->EnsureDcmDataSetIsInitialized();
   // TODO: Find out how this can be implemented with DcmDataset methods; there is no method for
   // setting an element at a given position
@@ -888,6 +898,7 @@ QString ctkDICOMDataset::GetStoredSerialization()
 
 void ctkDICOMDataset::SetStoredSerialization(QString serializedDataset)
 {
+  Q_UNUSED(serializedDataset);
   throw std::runtime_error("No serialization implemented for this object!");
 }
 

+ 0 - 2
Libs/DICOM/Core/ctkDICOMTester.cpp

@@ -148,7 +148,6 @@ ctkDICOMTester::ctkDICOMTester(QObject* parentObject)
   : QObject(parentObject)
   , d_ptr(new ctkDICOMTesterPrivate(*this))
 {
-  Q_D(ctkDICOMTester);
 }
 
 //------------------------------------------------------------------------------
@@ -158,7 +157,6 @@ ctkDICOMTester::ctkDICOMTester(const QString& dcmqrscp,
   : QObject(parentObject)
   , d_ptr(new ctkDICOMTesterPrivate(*this))
 {
-  Q_D(ctkDICOMTester);
   this->setDCMQRSCPExecutable(dcmqrscp);
   this->setDCMQRSCPConfigFile(configFile);
 }

+ 4 - 4
Libs/Widgets/Testing/Cpp/ctkAxesWidgetTest1.cpp

@@ -39,7 +39,7 @@ int ctkAxesWidgetTest1(int argc, char * argv [] )
   if (axes.currentAxis() != ctkAxesWidget::None)
     {
     std::cerr << "ctkAxesWidget default axis is wrong: "
-              << axes.currentAxis() << std::endl;
+              << static_cast<int>(axes.currentAxis()) << std::endl;
     return EXIT_FAILURE;
     }
   
@@ -50,7 +50,7 @@ int ctkAxesWidgetTest1(int argc, char * argv [] )
       spy.count() != 1)
     {
     std::cerr << "ctkAxesWidget default axis is wrong: "
-              << axes.currentAxis() << " " << spy.count() << std::endl;
+              << static_cast<int>(axes.currentAxis()) << " " << spy.count() << std::endl;
     return EXIT_FAILURE;
     }
   if ( qvariant_cast<ctkAxesWidget::Axis>(spy.takeFirst().at(0)) != ctkAxesWidget::Anterior)
@@ -65,7 +65,7 @@ int ctkAxesWidgetTest1(int argc, char * argv [] )
       (axes.currentAxis() != ctkAxesWidget::None))
     {
     std::cerr << "ctkAxesWidget::setAutoReset failed: "
-              << axes.currentAxis() << std::endl;
+              << static_cast<int>(axes.currentAxis()) << std::endl;
     return EXIT_FAILURE;
     }
   spy.clear();
@@ -74,7 +74,7 @@ int ctkAxesWidgetTest1(int argc, char * argv [] )
       spy.count() != 2)
     {
     std::cerr << "ctkAxesWidget::setCurrentAxis() with autoReset ON failed: "
-              << axes.currentAxis() << " " << spy.count() << std::endl;
+              << static_cast<int>(axes.currentAxis()) << " " << spy.count() << std::endl;
     return EXIT_FAILURE;
     }
   if (qvariant_cast<ctkAxesWidget::Axis>(spy[0].at(0)) != ctkAxesWidget::Right ||

+ 34 - 34
Libs/Widgets/Testing/Cpp/ctkCheckableHeaderViewTest1.cpp

@@ -87,14 +87,14 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
   if (headerView->checkState(0) == Qt::Unchecked)
     {
     std::cerr << "ctkCheckableHeaderView::checkstate() failed: "
-              << headerView->checkState(0) << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << std::endl;
     return EXIT_FAILURE;
     }
   Qt::CheckState checkstate;
   if (!headerView->checkState(0, checkstate))
     {
     std::cerr << "ctkCheckableHeaderView::checkstate() failed: "
-              << headerView->checkState(0, checkstate) << std::endl;
+              << static_cast<int>(headerView->checkState(0, checkstate)) << std::endl;
     return EXIT_FAILURE;
     }
   QFocusEvent focus(QEvent::FocusIn,Qt::TabFocusReason);
@@ -120,7 +120,7 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
   if (headerView->checkState(0) != Qt::Unchecked)
     {
     std::cerr << "ctkCheckableHeaderView::toggleCheckState() failed: "
-              << headerView->checkState(0) << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << std::endl;
     return EXIT_FAILURE;
     }
     
@@ -130,9 +130,9 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "ctkCheckableHeaderView::toggleCheckState() failed: "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -144,10 +144,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "QStandardItem::setCheckState() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -160,10 +160,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "ctkCheckableHeaderView::setPropagateToItems() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -175,10 +175,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "QStandardItem::setCheckState() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -191,10 +191,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "QStandardItem::setCheckState() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -207,10 +207,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "QStandardItem::setCheckState() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -224,10 +224,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Unchecked)
     {
     std::cerr << "QStandardItem::setCheckState() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 
@@ -239,10 +239,10 @@ int ctkCheckableHeaderViewTest1(int argc, char * argv [] )
       row2[0]->checkState() != Qt::Checked)
     {
     std::cerr << "ctkCheckableHeaderView::setCheckState() failed: "
-              << headerView->checkState(0) << " "
-              << row0[0]->checkState() << " "
-              << row1[0]->checkState() << " "
-              << row2[0]->checkState() << std::endl;
+              << static_cast<int>(headerView->checkState(0)) << " "
+              << static_cast<int>(row0[0]->checkState()) << " "
+              << static_cast<int>(row1[0]->checkState()) << " "
+              << static_cast<int>(row2[0]->checkState()) << std::endl;
     return EXIT_FAILURE;
     }
 

+ 1 - 4
Libs/Widgets/ctkCheckableHeaderView.cpp

@@ -462,9 +462,6 @@ void ctkCheckableHeaderView::updateHeaders(int firstSection, int lastSection)
     {
     active = this->parentWidget()->hasFocus();
     }
-  int maxJ = this->orientation() == Qt::Horizontal ? 
-    current->rowCount() : current->columnCount();
-  
   for(int i = firstSection; i <= lastSection; i++)
     {
     QVariant decoration;
@@ -506,7 +503,7 @@ void ctkCheckableHeaderView::updateHeadersFromItems(const QModelIndex & topLeft,
     }
   bool checkable = false;
   QVariant topLeftCheckState = this->model()->data(topLeft, Qt::CheckStateRole);
-  int topLeftState = topLeftCheckState.toInt(&checkable);
+  topLeftCheckState.toInt(&checkable);
   if (!checkable)
     {
     return;