diff --git a/Applications/ctkPluginBrowser/ctkQtResourcesTreeModel.h b/Applications/ctkPluginBrowser/ctkQtResourcesTreeModel.h index 49f5d8fcb3..6115a93388 100644 --- a/Applications/ctkPluginBrowser/ctkQtResourcesTreeModel.h +++ b/Applications/ctkPluginBrowser/ctkQtResourcesTreeModel.h @@ -29,6 +29,7 @@ class ctkQtResourceTreeItem; class ctkQtResourcesTreeModel : public QAbstractItemModel { + Q_OBJECT public: ctkQtResourcesTreeModel(QObject* parent = 0); diff --git a/Libs/CommandLineModules/Core/ctkCmdLineModuleCache.cpp b/Libs/CommandLineModules/Core/ctkCmdLineModuleCache.cpp index 8e495115e0..b6c1ad9c20 100644 --- a/Libs/CommandLineModules/Core/ctkCmdLineModuleCache.cpp +++ b/Libs/CommandLineModules/Core/ctkCmdLineModuleCache.cpp @@ -182,8 +182,8 @@ void ctkCmdLineModuleCache::removeCacheEntry(const QUrl& moduleLocation) void ctkCmdLineModuleCache::clearCache() { - foreach(const QUrl &url, d->LocationToXmlDescription.keys()) + for (auto it = d->LocationToXmlDescription.constBegin(); it != d->LocationToXmlDescription.constEnd(); ++it) { - removeCacheEntry(url); + removeCacheEntry(it.key()); } } diff --git a/Libs/Core/Testing/Cpp/ctkExampleWorkflowStepUsingSignalsAndSlots.h b/Libs/Core/Testing/Cpp/ctkExampleWorkflowStepUsingSignalsAndSlots.h index d3eedfad51..f9fbbf5e86 100644 --- a/Libs/Core/Testing/Cpp/ctkExampleWorkflowStepUsingSignalsAndSlots.h +++ b/Libs/Core/Testing/Cpp/ctkExampleWorkflowStepUsingSignalsAndSlots.h @@ -102,9 +102,9 @@ protected Q_SLOTS: /// /// Signals indicating to the workflow that these processes have /// completed - void validationComplete(bool validationSucceeded, const QString& branchId = "")const; - void onEntryComplete()const; - void onExitComplete()const; + void validationComplete(bool validationSucceeded, const QString& branchId = ""); + void onEntryComplete(); + void onExitComplete(); protected: QScopedPointer d_ptr; diff --git a/Libs/Core/Testing/Cpp/ctkUtilsCopyDirRecursivelyTest1.cpp b/Libs/Core/Testing/Cpp/ctkUtilsCopyDirRecursivelyTest1.cpp index a81d74be4a..423c149562 100644 --- a/Libs/Core/Testing/Cpp/ctkUtilsCopyDirRecursivelyTest1.cpp +++ b/Libs/Core/Testing/Cpp/ctkUtilsCopyDirRecursivelyTest1.cpp @@ -47,7 +47,11 @@ bool createFile(int line, const QDir& dir, const QString& relativePath, const QS newDir.cd(relativePath); QString filePath = QFileInfo(newDir, fileName).filePath(); QFile file(filePath); - file.open(QIODevice::Text | QIODevice::WriteOnly); + if (!file.open(QIODevice::Text | QIODevice::WriteOnly)) + { + std::cerr << "Failed to open file for writing: " << qPrintable(filePath) << std::endl; + return EXIT_FAILURE; + } QTextStream out(&file); out << "Generated by ctkUtilsCopyDirRecursivelyTest1" << ctk::endl; file.close(); diff --git a/Libs/Core/Testing/Cpp/ctkUtilsIsDirEmptyTest1.cpp b/Libs/Core/Testing/Cpp/ctkUtilsIsDirEmptyTest1.cpp index e464407e8c..6b9573f4be 100644 --- a/Libs/Core/Testing/Cpp/ctkUtilsIsDirEmptyTest1.cpp +++ b/Libs/Core/Testing/Cpp/ctkUtilsIsDirEmptyTest1.cpp @@ -51,7 +51,11 @@ int ctkUtilsIsDirEmptyTest1(int argc, char * argv [] ) // Create file QString filePath = tempDir.filePath("file.txt"); QFile file(filePath); - file.open(QIODevice::Text | QIODevice::WriteOnly); + if (!file.open(QIODevice::Text | QIODevice::WriteOnly)) + { + qWarning() << "Failed to open file for writing:" << filePath; + return EXIT_FAILURE; + } QTextStream out(&file); out << "Generated by ctkUtilsIsDirEmptyTest1" << ctk::endl; file.close(); diff --git a/Libs/Core/Testing/Cpp/ctkUtilsTest4.cpp b/Libs/Core/Testing/Cpp/ctkUtilsTest4.cpp index ba4c35f55a..cd8ecb795f 100644 --- a/Libs/Core/Testing/Cpp/ctkUtilsTest4.cpp +++ b/Libs/Core/Testing/Cpp/ctkUtilsTest4.cpp @@ -43,7 +43,11 @@ int createFile(int line, const QDir& dir, const QString& relativePath, const QSt newDir.cd(relativePath); QString filePath = QFileInfo(newDir, fileName).filePath(); QFile file(filePath); - file.open(QIODevice::Text | QIODevice::WriteOnly); + if (!file.open(QIODevice::Text | QIODevice::WriteOnly)) + { + std::cerr << "Failed to open file for writing: " << qPrintable(filePath) << std::endl; + return EXIT_FAILURE; + } QTextStream out(&file); out << "Generated by ctkUtilsTest4" << ctk::endl; file.close(); diff --git a/Libs/Core/Testing/Cpp/ctkWorkflowTest1.cpp b/Libs/Core/Testing/Cpp/ctkWorkflowTest1.cpp index 97be48f9a2..5edd7393ea 100644 --- a/Libs/Core/Testing/Cpp/ctkWorkflowTest1.cpp +++ b/Libs/Core/Testing/Cpp/ctkWorkflowTest1.cpp @@ -305,9 +305,9 @@ int ctkWorkflowTest1(int argc, char * argv [] ) } if (workflow->forwardSteps(step1).length() != 1 - || workflow->forwardSteps(step1).first() != step2 + || workflow->forwardSteps(step1).constFirst() != step2 || workflow->forwardSteps(step2).length() != 1 - || workflow->forwardSteps(step2).first() != step3 + || workflow->forwardSteps(step2).constFirst() != step3 || workflow->forwardSteps(step3).length() != 0) { std::cerr << "error in list of forward steps" << std::endl; @@ -316,9 +316,9 @@ int ctkWorkflowTest1(int argc, char * argv [] ) if (workflow->backwardSteps(step1).length() != 0 || workflow->backwardSteps(step2).length() != 1 - || workflow->backwardSteps(step2).first() != step1 + || workflow->backwardSteps(step2).constFirst() != step1 || workflow->backwardSteps(step3).length() != 1 - || workflow->backwardSteps(step3).first() != step2) + || workflow->backwardSteps(step3).constFirst() != step2) { std::cerr << "error in list of backward steps" << std::endl; return EXIT_FAILURE; diff --git a/Libs/Core/ctkErrorLogAbstractModel.cpp b/Libs/Core/ctkErrorLogAbstractModel.cpp index 868dd5b17d..6d07327141 100644 --- a/Libs/Core/ctkErrorLogAbstractModel.cpp +++ b/Libs/Core/ctkErrorLogAbstractModel.cpp @@ -92,10 +92,9 @@ ctkErrorLogAbstractModelPrivate::ctkErrorLogAbstractModelPrivate(ctkErrorLogAbst // -------------------------------------------------------------------------- ctkErrorLogAbstractModelPrivate::~ctkErrorLogAbstractModelPrivate() { - foreach(const QString& handlerName, this->RegisteredHandlers.keys()) + for (auto it = this->RegisteredHandlers.constBegin(); it != this->RegisteredHandlers.constEnd(); ++it) { - ctkErrorLogAbstractMessageHandler * msgHandler = - this->RegisteredHandlers.value(handlerName); + ctkErrorLogAbstractMessageHandler * msgHandler = it.value(); Q_ASSERT(msgHandler); msgHandler->setEnabled(false); delete msgHandler; @@ -162,7 +161,7 @@ bool ctkErrorLogAbstractModel::registerMsgHandler(ctkErrorLogAbstractMessageHand { return false; } - if (d->RegisteredHandlers.keys().contains(msgHandler->handlerName())) + if (d->RegisteredHandlers.contains(msgHandler->handlerName())) { return false; } @@ -187,7 +186,7 @@ QStringList ctkErrorLogAbstractModel::msgHandlerNames()const bool ctkErrorLogAbstractModel::msgHandlerEnabled(const QString& handlerName) const { Q_D(const ctkErrorLogAbstractModel); - if (!d->RegisteredHandlers.keys().contains(handlerName)) + if (!d->RegisteredHandlers.contains(handlerName)) { return false; } @@ -198,7 +197,7 @@ bool ctkErrorLogAbstractModel::msgHandlerEnabled(const QString& handlerName) con void ctkErrorLogAbstractModel::setMsgHandlerEnabled(const QString& handlerName, bool enabled) { Q_D(ctkErrorLogAbstractModel); - if (!d->RegisteredHandlers.keys().contains(handlerName)) + if (!d->RegisteredHandlers.contains(handlerName)) { // qCritical() << "Failed to enable/disable message handler " << handlerName // << "- Handler not registered !"; @@ -212,11 +211,11 @@ QStringList ctkErrorLogAbstractModel::msgHandlerEnabled() const { Q_D(const ctkErrorLogAbstractModel); QStringList msgHandlers; - foreach(const QString& handlerName, d->RegisteredHandlers.keys()) + for (auto it = d->RegisteredHandlers.constBegin(); it != d->RegisteredHandlers.constEnd(); ++it) { - if (d->RegisteredHandlers.value(handlerName)->enabled()) + if (it.value()->enabled()) { - msgHandlers << handlerName; + msgHandlers << it.key(); } } return msgHandlers; @@ -247,9 +246,9 @@ void ctkErrorLogAbstractModel::disableAllMsgHandler() void ctkErrorLogAbstractModel::setAllMsgHandlerEnabled(bool enabled) { Q_D(ctkErrorLogAbstractModel); - foreach(const QString& msgHandlerName, d->RegisteredHandlers.keys()) + for (auto it = d->RegisteredHandlers.constBegin(); it != d->RegisteredHandlers.constEnd(); ++it) { - this->setMsgHandlerEnabled(msgHandlerName, enabled); + this->setMsgHandlerEnabled(it.key(), enabled); } } @@ -478,10 +477,9 @@ void ctkErrorLogAbstractModel::setAsynchronousLogging(bool value) return; } - foreach(const QString& handlerName, d->RegisteredHandlers.keys()) + for (auto it = d->RegisteredHandlers.constBegin(); it != d->RegisteredHandlers.constEnd(); ++it) { - d->setMessageHandlerConnection( - d->RegisteredHandlers.value(handlerName), value); + d->setMessageHandlerConnection(it.value(), value); } QObject::disconnect(this, @@ -582,7 +580,7 @@ int ctkErrorLogAbstractModel::logEntryCount()const ctkErrorLogAbstractMessageHandler* ctkErrorLogAbstractModel::msgHandler(const QString& handlerName)const { Q_D(const ctkErrorLogAbstractModel); - if (!d->RegisteredHandlers.keys().contains(handlerName)) + if (!d->RegisteredHandlers.contains(handlerName)) { return nullptr; } diff --git a/Libs/Core/ctkWorkflow.cpp b/Libs/Core/ctkWorkflow.cpp index 971e3c369e..9ef3c4868c 100644 --- a/Libs/Core/ctkWorkflow.cpp +++ b/Libs/Core/ctkWorkflow.cpp @@ -296,12 +296,12 @@ void ctkWorkflowPrivate::createTransitionToPreviousStartingStep(ctkWorkflowStep* // -------------------------------------------------------------------------- ctkWorkflowStep* ctkWorkflowPrivate::stepFromId(const QString& id)const { - foreach(ctkWorkflowStep* step, this->StepToForwardAndBackwardStepMap.keys()) + for (auto it = this->StepToForwardAndBackwardStepMap.constBegin(); it != this->StepToForwardAndBackwardStepMap.constEnd(); ++it) { - Q_ASSERT(step); - if (QString::compare(step->id(), id, Qt::CaseInsensitive) == 0) + Q_ASSERT(it.key()); + if (QString::compare(it.key()->id(), id, Qt::CaseInsensitive) == 0) { - return step; + return it.key(); } } return 0; @@ -739,11 +739,11 @@ QList ctkWorkflow::finishSteps()const // iterate through our list of steps, and keep the steps that don't have anything following them QList finishSteps; - foreach (ctkWorkflowStep* step, d->StepToForwardAndBackwardStepMap.keys()) + for (auto it = d->StepToForwardAndBackwardStepMap.constBegin(); it != d->StepToForwardAndBackwardStepMap.constEnd(); ++it) { - if (!this->canGoForward(step)) + if (!this->canGoForward(it.key())) { - finishSteps.append(step); + finishSteps.append(it.key()); } } return finishSteps; diff --git a/Libs/Core/ctkWorkflowStep.cpp b/Libs/Core/ctkWorkflowStep.cpp index 7153c0dc0b..870d9b586a 100644 --- a/Libs/Core/ctkWorkflowStep.cpp +++ b/Libs/Core/ctkWorkflowStep.cpp @@ -82,37 +82,37 @@ ctkWorkflowStepPrivate::~ctkWorkflowStepPrivate() } // -------------------------------------------------------------------------- -void ctkWorkflowStepPrivate::validationCompleteInternal(bool validationResults, const QString& branchId)const +void ctkWorkflowStepPrivate::validationCompleteInternal(bool validationResults, const QString& branchId) { emit validationComplete(validationResults, branchId); } // -------------------------------------------------------------------------- -void ctkWorkflowStepPrivate::onEntryCompleteInternal()const +void ctkWorkflowStepPrivate::onEntryCompleteInternal() { emit onEntryComplete(); } // -------------------------------------------------------------------------- -void ctkWorkflowStepPrivate::onExitCompleteInternal()const +void ctkWorkflowStepPrivate::onExitCompleteInternal() { emit onExitComplete(); } // -------------------------------------------------------------------------- -void ctkWorkflowStepPrivate::invokeValidateCommandInternal(const QString& desiredBranchId)const +void ctkWorkflowStepPrivate::invokeValidateCommandInternal(const QString& desiredBranchId) { emit invokeValidateCommand(desiredBranchId); } // -------------------------------------------------------------------------- -void ctkWorkflowStepPrivate::invokeOnEntryCommandInternal(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const +void ctkWorkflowStepPrivate::invokeOnEntryCommandInternal(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType) { emit invokeOnEntryCommand(comingFrom, transitionType); } // -------------------------------------------------------------------------- -void ctkWorkflowStepPrivate::invokeOnExitCommandInternal(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const +void ctkWorkflowStepPrivate::invokeOnExitCommandInternal(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType) { emit invokeOnExitCommand(goingTo, transitionType); } @@ -210,44 +210,44 @@ QObject* ctkWorkflowStep::ctkWorkflowStepQObject() } // -------------------------------------------------------------------------- -void ctkWorkflowStep::validationComplete(bool validationResults, const QString& branchId)const +void ctkWorkflowStep::validationComplete(bool validationResults, const QString& branchId) { - Q_D(const ctkWorkflowStep); + Q_D(ctkWorkflowStep); d->validationCompleteInternal(validationResults, branchId); } // -------------------------------------------------------------------------- -void ctkWorkflowStep::onEntryComplete()const +void ctkWorkflowStep::onEntryComplete() { - Q_D(const ctkWorkflowStep); + Q_D(ctkWorkflowStep); d->onEntryCompleteInternal(); } // -------------------------------------------------------------------------- -void ctkWorkflowStep::onExitComplete()const +void ctkWorkflowStep::onExitComplete() { - Q_D(const ctkWorkflowStep); + Q_D(ctkWorkflowStep); d->onExitCompleteInternal(); } // -------------------------------------------------------------------------- -void ctkWorkflowStep::invokeValidateCommand(const QString& desiredBranchId)const +void ctkWorkflowStep::invokeValidateCommand(const QString& desiredBranchId) { - Q_D(const ctkWorkflowStep); + Q_D(ctkWorkflowStep); d->invokeValidateCommandInternal(desiredBranchId); } // -------------------------------------------------------------------------- -void ctkWorkflowStep::invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const +void ctkWorkflowStep::invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType) { - Q_D(const ctkWorkflowStep); + Q_D(ctkWorkflowStep); d->invokeOnEntryCommandInternal(comingFrom, transitionType); } // -------------------------------------------------------------------------- -void ctkWorkflowStep::invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const +void ctkWorkflowStep::invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType) { - Q_D(const ctkWorkflowStep); + Q_D(ctkWorkflowStep); d->invokeOnExitCommandInternal(goingTo, transitionType); } diff --git a/Libs/Core/ctkWorkflowStep.h b/Libs/Core/ctkWorkflowStep.h index d2836636cd..eb8fbc5f0f 100644 --- a/Libs/Core/ctkWorkflowStep.h +++ b/Libs/Core/ctkWorkflowStep.h @@ -208,37 +208,37 @@ class CTK_CORE_EXPORT ctkWorkflowStep /// step's processing should be performed. /// /// \sa validation() - void invokeValidateCommand(const QString& desiredBranchId = QString())const; + void invokeValidateCommand(const QString& desiredBranchId = QString()); /// \brief Signal (emitted by the private implementation) indicating that validation of this /// step's processing has completed. /// /// \sa validation() - void validationComplete(bool validationSuceeded, const QString& branchId = QString())const; + void validationComplete(bool validationSuceeded, const QString& branchId = QString()); /// \brief Signal (emitted by the private implementation) indicating that the step's 'onEntry' /// processing should be performed. /// /// \sa onEntry() - void invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; + void invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType); /// \brief Signal (emitted by the private implementation) indicating that the step's 'onEntry' /// processing has completed. /// /// \sa onEntry() - void onEntryComplete()const; + void onEntryComplete(); /// \brief Signal (emitted by the private implementation) indicating that the step's 'onExit' /// processing should be performed. /// /// \sa onExit() - void invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; + void invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType); /// \brief Signal (emitted by the private implementation) indicating that the step's 'onExit' /// processing has completed. /// /// \sa onExit() - void onExitComplete()const; + void onExitComplete(); protected: QScopedPointer d_ptr; diff --git a/Libs/Core/ctkWorkflowStep_p.h b/Libs/Core/ctkWorkflowStep_p.h index 994b50698f..53e402b37d 100644 --- a/Libs/Core/ctkWorkflowStep_p.h +++ b/Libs/Core/ctkWorkflowStep_p.h @@ -71,31 +71,31 @@ class CTK_CORE_EXPORT ctkWorkflowStepPrivate: public QObject bool HasOnEntryCommand; bool HasOnExitCommand; - void invokeValidateCommandInternal(const QString& desiredBranchId)const; + void invokeValidateCommandInternal(const QString& desiredBranchId); - void validationCompleteInternal(bool validationSuceeded, const QString& branchId)const; + void validationCompleteInternal(bool validationSuceeded, const QString& branchId); - void invokeOnEntryCommandInternal(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; + void invokeOnEntryCommandInternal(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType); - void onEntryCompleteInternal()const; + void onEntryCompleteInternal(); - void invokeOnExitCommandInternal(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; + void invokeOnExitCommandInternal(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType); - void onExitCompleteInternal()const; + void onExitCompleteInternal(); Q_SIGNALS: - void invokeValidateCommand(const QString& desiredBranchId)const; + void invokeValidateCommand(const QString& desiredBranchId); - void validationComplete(bool validationSuceeded, const QString& branchId)const; + void validationComplete(bool validationSuceeded, const QString& branchId); - void invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; + void invokeOnEntryCommand(const ctkWorkflowStep* comingFrom, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType); - void onEntryComplete()const; + void onEntryComplete(); - void invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)const; + void invokeOnExitCommand(const ctkWorkflowStep* goingTo, const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType); - void onExitComplete()const; + void onExitComplete(); private: friend class ctkWorkflowPrivate; // for access to invoke...Internal() methods diff --git a/Libs/DICOM/Core/ctkDICOMDatabase.cpp b/Libs/DICOM/Core/ctkDICOMDatabase.cpp index b43e59060e..a40152bd23 100644 --- a/Libs/DICOM/Core/ctkDICOMDatabase.cpp +++ b/Libs/DICOM/Core/ctkDICOMDatabase.cpp @@ -258,8 +258,7 @@ QString ctkDICOMDatabasePrivate::readValueFromFile(const QString& fileName, cons bool ctkDICOMDatabasePrivate::executeScript(const QString script) { QFile scriptFile(script); - scriptFile.open(QIODevice::ReadOnly); - if ( !scriptFile.isOpen() ) + if ( !scriptFile.open(QIODevice::ReadOnly) ) { qDebug() << "Script file " << script << " could not be opened!\n"; return false; @@ -1151,9 +1150,9 @@ QString ctkDICOMDatabasePrivate::getDisplayPatientFieldsKey(const QString& patie QString ctkDICOMDatabasePrivate::getDisplayStudyFieldsKey(QString studyInstanceUID, QMap > &displayedFieldsMapStudy) { // Look for the study in the displayed fields cache first - foreach (QString currentStudyInstanceUid, displayedFieldsMapStudy.keys()) + for (auto it = displayedFieldsMapStudy.constBegin(); it != displayedFieldsMapStudy.constEnd(); ++it) { - if ( !displayedFieldsMapStudy[currentStudyInstanceUid]["StudyInstanceUID"].compare(studyInstanceUID) ) + if ( !it.value()["StudyInstanceUID"].compare(studyInstanceUID) ) { return studyInstanceUID; } @@ -1192,9 +1191,9 @@ QString ctkDICOMDatabasePrivate::getDisplayStudyFieldsKey(QString studyInstanceU QString ctkDICOMDatabasePrivate::getDisplaySeriesFieldsKey(QString seriesInstanceUID, QMap > &displayedFieldsMapSeries) { // Look for the series in the displayed fields cache first - foreach (QString currentSeriesInstanceUid, displayedFieldsMapSeries.keys()) + for (auto it = displayedFieldsMapSeries.constBegin(); it != displayedFieldsMapSeries.constEnd(); ++it) { - if ( !displayedFieldsMapSeries[currentSeriesInstanceUid]["SeriesInstanceUID"].compare(seriesInstanceUID) ) + if ( !it.value()["SeriesInstanceUID"].compare(seriesInstanceUID) ) { return seriesInstanceUID; } @@ -1238,14 +1237,15 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap currentPatient = displayedFieldsMapPatient[compositeID]; + QMap currentPatient = it.value(); if (currentPatient["PatientID"].isEmpty() || currentPatient["PatientsName"].isEmpty()) { logger.error("Unable to locate the patient due to missing values for PatientsName and/or PatientID. " @@ -1267,14 +1267,14 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap boundValues; - foreach (QString tagName, currentPatient.keys()) + for (auto tagIt = currentPatient.constBegin(); tagIt != currentPatient.constEnd(); ++tagIt) { - if (tagName == "PatientCompositeID") + if (tagIt.key() == "PatientCompositeID") { continue; // Do not write patient index that is only used internally and temporarily } - displayPatientsFieldUpdateString.append( tagName + " = ? , " ); - boundValues << currentPatient[tagName]; + displayPatientsFieldUpdateString.append( tagIt.key() + " = ? , " ); + boundValues << tagIt.value(); } // Trim the separators from the end @@ -1307,13 +1307,14 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap currentStudy = displayedFieldsMapStudy[currentStudyInstanceUid]; + QMap currentStudy = studyIt.value(); QSqlQuery displayStudiesQuery(this->Database); displayStudiesQuery.prepare("SELECT StudyInstanceUID FROM Studies WHERE StudyInstanceUID = ? ;"); displayStudiesQuery.addBindValue(currentStudyInstanceUid); @@ -1326,8 +1327,9 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap boundValues; - foreach (QString tagName, currentStudy.keys()) + for (auto tagIt = currentStudy.constBegin(); tagIt != currentStudy.constEnd(); ++tagIt) { + const QString& tagName = tagIt.key(); if (!tagName.compare("PatientCompositeID")) { displayStudiesFieldUpdateString.append( "PatientsUID = ? , " ); @@ -1364,14 +1366,15 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap currentSeries = displayedFieldsMapSeries[currentSeriesInstanceUid]; + QMap currentSeries = seriesIt.value(); QSqlQuery displaySeriesQuery(this->Database); displaySeriesQuery.prepare("SELECT SeriesInstanceUID FROM Series WHERE SeriesInstanceUID = ? ;"); displaySeriesQuery.addBindValue(currentSeriesInstanceUid); @@ -1384,10 +1387,10 @@ bool ctkDICOMDatabasePrivate::applyDisplayedFieldsChanges( QMap boundValues; - foreach (QString tagName, currentSeries.keys()) + for (auto tagIt = currentSeries.constBegin(); tagIt != currentSeries.constEnd(); ++tagIt) { - displaySeriesFieldUpdateString.append( tagName + " = ? , " ); - boundValues << currentSeries[tagName]; + displaySeriesFieldUpdateString.append( tagIt.key() + " = ? , " ); + boundValues << tagIt.value(); } // Trim the separators from the end displaySeriesFieldUpdateString = displaySeriesFieldUpdateString.left(displaySeriesFieldUpdateString.size() - 3); @@ -3085,9 +3088,9 @@ ctkDICOMDatabase::InsertResult ctkDICOMDatabase::insert(const QListcopyFile(); QMap datasets = jobResponseSet->datasets(); - for(QString key : datasets.keys()) + for (auto it = datasets.constBegin(); it != datasets.constEnd(); ++it) { - ctkDICOMItem* dataset = datasets.value(key); + ctkDICOMItem* dataset = it.value(); if (!dataset) { continue; @@ -3102,7 +3105,7 @@ ctkDICOMDatabase::InsertResult ctkDICOMDatabase::insert(const QList ctkDICOMJobResponseSet::datasetShared() const void ctkDICOMJobResponseSet::setDatasets(const QMap& dcmItems, bool takeOwnership) { Q_D(ctkDICOMJobResponseSet); - for (const QString& key : dcmItems.keys()) + for (auto it = dcmItems.constBegin(); it != dcmItems.constEnd(); ++it) { - DcmItem* dcmItem = dcmItems.value(key); + DcmItem* dcmItem = it.value(); if (!dcmItem) { continue; @@ -227,7 +227,7 @@ void ctkDICOMJobResponseSet::setDatasets(const QMap& dcmItems QSharedPointer(new ctkDICOMItem); dataset->InitializeFromItem(dcmItem, takeOwnership); - d->Datasets.insert(key, dataset); + d->Datasets.insert(it.key(), dataset); } } @@ -237,15 +237,15 @@ QMap ctkDICOMJobResponseSet::datasets() const Q_D(const ctkDICOMJobResponseSet); QMap datasets; - for (const QString& key : d->Datasets.keys()) + for (auto it = d->Datasets.constBegin(); it != d->Datasets.constEnd(); ++it) { - QSharedPointer dcmItem = d->Datasets.value(key); + QSharedPointer dcmItem = it.value(); if (!dcmItem) { continue; } - datasets.insert(key, dcmItem.data()); + datasets.insert(it.key(), dcmItem.data()); } return datasets; @@ -276,16 +276,16 @@ ctkDICOMJobResponseSet* ctkDICOMJobResponseSet::clone() // Clone datasets QMap datasets = this->datasets(); - for (const QString& key : datasets.keys()) + for (auto it = datasets.constBegin(); it != datasets.constEnd(); ++it) { - ctkDICOMItem* dataset = datasets.value(key); + ctkDICOMItem* dataset = it.value(); if (!dataset) { continue; } QSharedPointer newDataset = QSharedPointer(dataset->Clone()); - newJobResponseSet->d_func()->Datasets.insert(key, newDataset); + newJobResponseSet->d_func()->Datasets.insert(it.key(), newDataset); } return newJobResponseSet; diff --git a/Libs/DICOM/Core/ctkDICOMQuery.cpp b/Libs/DICOM/Core/ctkDICOMQuery.cpp index def431c064..e0acd1e1e5 100644 --- a/Libs/DICOM/Core/ctkDICOMQuery.cpp +++ b/Libs/DICOM/Core/ctkDICOMQuery.cpp @@ -445,9 +445,10 @@ bool ctkDICOMQuery::query(ctkDICOMDatabase& database) float progressRatio = 25. / d->StudyDatasets.count(); int i = 0; - foreach(QString studyInstanceUID, d->StudyDatasets.keys()) + for (auto it = d->StudyDatasets.constBegin(); it != d->StudyDatasets.constEnd(); ++it) { - DcmDataset *studyDataset = d->StudyDatasets.value(studyInstanceUID); + const QString& studyInstanceUID = it.key(); + DcmDataset *studyDataset = it.value(); DcmElement *patientName, *patientID; studyDataset->findAndGetElement(DCM_PatientName, patientName); studyDataset->findAndGetElement(DCM_PatientID, patientID); @@ -1130,37 +1131,38 @@ QString ctkDICOMQuery::applyFilters(QMap filters) * Study Description, Modalities in Study, and Study Date are used. */ QString seriesDescription; - foreach(QString key, filters.keys()) + for (auto it = filters.constBegin(); it != filters.constEnd(); ++it) { - if (key == QString("Name") && !filters[key].toString().isEmpty()) + const QString& key = it.key(); + if (key == QString("Name") && !it.value().toString().isEmpty()) { // make the filter a wildcard in dicom style d->QueryDcmDataset->putAndInsertString(DCM_PatientName, - (QString("*") + filters[key].toString() + QString("*")).toLatin1().data()); + (QString("*") + it.value().toString() + QString("*")).toLatin1().data()); } - else if (key == QString("ID") && !filters[key].toString().isEmpty()) + else if (key == QString("ID") && !it.value().toString().isEmpty()) { // make the filter a wildcard in dicom style d->QueryDcmDataset->putAndInsertString(DCM_PatientID, - (QString("*") + filters[key].toString() + QString("*")).toLatin1().data()); + (QString("*") + it.value().toString() + QString("*")).toLatin1().data()); } - else if (key == QString("Study") && !filters[key].toString().isEmpty()) + else if (key == QString("Study") && !it.value().toString().isEmpty()) { // make the filter a wildcard in dicom style d->QueryDcmDataset->putAndInsertString(DCM_StudyDescription, - (QString("*") + filters[key].toString() + QString("*")).toLatin1().data()); + (QString("*") + it.value().toString() + QString("*")).toLatin1().data()); } - else if (key == QString("AccessionNumber") && !filters[key].toString().isEmpty()) + else if (key == QString("AccessionNumber") && !it.value().toString().isEmpty()) { // make the filter a wildcard in dicom style d->QueryDcmDataset->putAndInsertString(DCM_AccessionNumber, - (QString("*") + filters[key].toString() + QString("*")).toLatin1().data()); + (QString("*") + it.value().toString() + QString("*")).toLatin1().data()); } - else if (key == QString("Modalities") && filters[key].toStringList().count() != 0) + else if (key == QString("Modalities") && it.value().toStringList().count() != 0) { // make the filter be an "OR" of modalities using backslash (dicom-style) QString modalitySearch(""); - foreach (const QString& modality, filters[key].toStringList()) + foreach (const QString& modality, it.value().toStringList()) { modalitySearch += modality + QString("\\"); } @@ -1170,10 +1172,10 @@ QString ctkDICOMQuery::applyFilters(QMap filters) d->QueryDcmDataset->putAndInsertString(DCM_ModalitiesInStudy, modalitySearch.toLatin1().data()); } // Remember Series Description for later series query if we go through the keys now - else if (key == QString("Series") && !filters[key].toString().isEmpty()) + else if (key == QString("Series") && !it.value().toString().isEmpty()) { // make the filter a wildcard in dicom style - seriesDescription = "*" + filters[key].toString() + "*"; + seriesDescription = "*" + it.value().toString() + "*"; } else { @@ -1181,7 +1183,7 @@ QString ctkDICOMQuery::applyFilters(QMap filters) } } - if (filters.keys().contains("StartDate") && filters.keys().contains("EndDate") && + if (filters.contains("StartDate") && filters.contains("EndDate") && !filters["StartDate"].toString().isEmpty() && !filters["EndDate"].toString().isEmpty()) { QString dateRange = filters["StartDate"].toString() + diff --git a/Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMServerNodeWidgetTest1.cpp b/Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMServerNodeWidgetTest1.cpp index e0b0b769de..e54005003d 100644 --- a/Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMServerNodeWidgetTest1.cpp +++ b/Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMServerNodeWidgetTest1.cpp @@ -121,7 +121,7 @@ int ctkDICOMServerNodeWidgetTest1( int argc, char * argv [] ) serverNode["Port"] = 12345; widget.addServerNode(serverNode); if (widget.serverNodes().count() != 2 || - widget.serverNodes()[1] != "TestName" || + widget.serverNodes().at(1) != "TestName" || widget.selectedServerNodes().count() != 1 || widget.serverNodeParameters("TestName") != serverNode || widget.serverNodeParameters(1) != serverNode) @@ -129,7 +129,7 @@ int ctkDICOMServerNodeWidgetTest1( int argc, char * argv [] ) std::cout << "ctkDICOMServerNodeWidget::addServerNode() failed:" << widget.serverNodes().count() << " " << (widget.serverNodes().count() > 1? - qPrintable(widget.serverNodes()[1]) : "none") << " " + qPrintable(widget.serverNodes().at(1)) : "none") << " " << widget.selectedServerNodes().count() << " " << (widget.serverNodeParameters("TestName") == serverNode) << " " << (widget.serverNodeParameters(1) == serverNode) << std::endl; diff --git a/Libs/DICOM/Widgets/ctkDICOMItemTreeModel.h b/Libs/DICOM/Widgets/ctkDICOMItemTreeModel.h index 48e3519ef9..dfd4e495ff 100644 --- a/Libs/DICOM/Widgets/ctkDICOMItemTreeModel.h +++ b/Libs/DICOM/Widgets/ctkDICOMItemTreeModel.h @@ -32,6 +32,7 @@ class ctkDICOMItemTreeModelPrivate; /// \ingroup DICOM_Widgets class CTK_DICOM_WIDGETS_EXPORT ctkDICOMItemTreeModel : public QAbstractItemModel { + Q_OBJECT public: typedef QAbstractItemModel Superclass; explicit ctkDICOMItemTreeModel(QObject* parent=0); diff --git a/Libs/DICOM/Widgets/ctkDICOMQueryRetrieveWidget.cpp b/Libs/DICOM/Widgets/ctkDICOMQueryRetrieveWidget.cpp index 3fb469b7df..37eb991781 100644 --- a/Libs/DICOM/Widgets/ctkDICOMQueryRetrieveWidget.cpp +++ b/Libs/DICOM/Widgets/ctkDICOMQueryRetrieveWidget.cpp @@ -87,13 +87,13 @@ ctkDICOMQueryRetrieveWidgetPrivate::ctkDICOMQueryRetrieveWidgetPrivate( //---------------------------------------------------------------------------- ctkDICOMQueryRetrieveWidgetPrivate::~ctkDICOMQueryRetrieveWidgetPrivate() { - foreach(ctkDICOMQuery* query, this->QueriesByServer.values()) + for (auto it = this->QueriesByServer.constBegin(); it != this->QueriesByServer.constEnd(); ++it) { - delete query; + delete it.value(); } - foreach(ctkDICOMRetrieve* retrieval, this->RetrievalsByStudyUID.values()) + for (auto it = this->RetrievalsByStudyUID.constBegin(); it != this->RetrievalsByStudyUID.constEnd(); ++it) { - delete retrieval; + delete it.value(); } } @@ -279,7 +279,7 @@ void ctkDICOMQueryRetrieveWidget::query() d->dicomTableManager->setDICOMDatabase(&(d->QueryResultDatabase)); } - d->RetrieveButton->setEnabled(d->QueriesByStudyUID.keys().size() != 0); + d->RetrieveButton->setEnabled(!d->QueriesByStudyUID.isEmpty()); // We would need to call database.updateDisplayedFields() now, but currently // updateDisplayedFields requires entries in the Image table and tag cache @@ -380,12 +380,12 @@ void ctkDICOMQueryRetrieveWidget::retrieve() { // perform the retrieve QMap parameters; - foreach(QString server, d->QueriesByServer.keys()) + for (auto it = d->QueriesByServer.constBegin(); it != d->QueriesByServer.constEnd(); ++it) { - ctkDICOMQuery* query = d->QueriesByServer[server]; + ctkDICOMQuery* query = it.value(); if (query == currentQuery) { - parameters = d->ServerNodeWidget->serverNodeParameters(server); + parameters = d->ServerNodeWidget->serverNodeParameters(it.key()); break; } } diff --git a/Libs/DICOM/Widgets/ctkDICOMTableView.cpp b/Libs/DICOM/Widgets/ctkDICOMTableView.cpp index f864bf7432..09345c53d3 100644 --- a/Libs/DICOM/Widgets/ctkDICOMTableView.cpp +++ b/Libs/DICOM/Widgets/ctkDICOMTableView.cpp @@ -691,25 +691,25 @@ void ctkDICOMTableView::setQuery(const QStringList &uids) } ++filterIt; } - foreach (const QString& column, d->sqlGreaterWhereConditions.keys()) + for (auto it = d->sqlGreaterWhereConditions.constBegin(); it != d->sqlGreaterWhereConditions.constEnd(); ++it) { - queryString += " AND " + column + " > ?" ; - boundValues << d->sqlGreaterWhereConditions[column]; + queryString += " AND " + it.key() + " > ?" ; + boundValues << it.value(); } - foreach (const QString& column, d->sqlLessWhereConditions.keys()) + for (auto it = d->sqlLessWhereConditions.constBegin(); it != d->sqlLessWhereConditions.constEnd(); ++it) { - queryString += " AND " + column + " < ?" ; - boundValues << d->sqlLessWhereConditions[column]; + queryString += " AND " + it.key() + " < ?" ; + boundValues << it.value(); } - foreach (const QString& column, d->sqlGreaterEqualWhereConditions.keys()) + for (auto it = d->sqlGreaterEqualWhereConditions.constBegin(); it != d->sqlGreaterEqualWhereConditions.constEnd(); ++it) { - queryString += " AND " + column + " >= ?" ; - boundValues << d->sqlGreaterEqualWhereConditions[column]; + queryString += " AND " + it.key() + " >= ?" ; + boundValues << it.value(); } - foreach (const QString& column, d->sqlLessEqualWhereConditions.keys()) + for (auto it = d->sqlLessEqualWhereConditions.constBegin(); it != d->sqlLessEqualWhereConditions.constEnd(); ++it) { - queryString += " AND " + column + " <= ?" ; - boundValues << d->sqlLessEqualWhereConditions[column]; + queryString += " AND " + it.key() + " <= ?" ; + boundValues << it.value(); } if (d->dicomDatabase != 0 && d->dicomDatabase->isOpen() diff --git a/Libs/DICOM/Widgets/ctkDICOMVisualBrowserWidget.cpp b/Libs/DICOM/Widgets/ctkDICOMVisualBrowserWidget.cpp index 1d30cd891d..139b51ad33 100644 --- a/Libs/DICOM/Widgets/ctkDICOMVisualBrowserWidget.cpp +++ b/Libs/DICOM/Widgets/ctkDICOMVisualBrowserWidget.cpp @@ -1241,10 +1241,10 @@ QStringList ctkDICOMVisualBrowserWidgetPrivate::filterPatientList(const QStringL foreach (QString patientUID, patientList) { bool filtered = false; - for (QString key : filters.keys()) + for (auto it = filters.constBegin(); it != filters.constEnd(); ++it) { - QString filter = this->DicomDatabase->fieldForPatient(key, patientUID); - QString filterValue = filters.value(key).toString(); + QString filter = this->DicomDatabase->fieldForPatient(it.key(), patientUID); + QString filterValue = it.value().toString(); if (!filter.contains(filterValue, Qt::CaseInsensitive)) { filtered = true; @@ -1277,11 +1277,11 @@ QStringList ctkDICOMVisualBrowserWidgetPrivate::filterStudyList(const QStringLis foreach (QString studyItem, studyList) { bool filtered = false; - for (QString key : filters.keys()) + for (auto it = filters.constBegin(); it != filters.constEnd(); ++it) { - QString filter = this->DicomDatabase->fieldForStudy(key, studyItem); - QString filterValue = filters.value(key).toString(); - if (key == "StudyDate") + QString filter = this->DicomDatabase->fieldForStudy(it.key(), studyItem); + QString filterValue = it.value().toString(); + if (it.key() == QLatin1String("StudyDate")) { int nDays = filterValue.toInt(); if (nDays != -1) @@ -1329,12 +1329,12 @@ QStringList ctkDICOMVisualBrowserWidgetPrivate::filterSeriesList(const QStringLi foreach (QString seriesItem, seriesList) { bool filtered = false; - for (QString key : filters.keys()) + for (auto it = filters.constBegin(); it != filters.constEnd(); ++it) { - QString filter = this->DicomDatabase->fieldForSeries(key, seriesItem); - if (key == "Modality") + QString filter = this->DicomDatabase->fieldForSeries(it.key(), seriesItem); + if (it.key() == QLatin1String("Modality")) { - QStringList filterValues = filters.value(key).toStringList(); + QStringList filterValues = it.value().toStringList(); if (!filterValues.contains("Any") && !filterValues.contains(filter)) { filtered = true; @@ -1343,7 +1343,7 @@ QStringList ctkDICOMVisualBrowserWidgetPrivate::filterSeriesList(const QStringLi } else { - QString filterValue = filters.value(key).toString(); + QString filterValue = it.value().toString(); if (!filter.contains(filterValue, Qt::CaseInsensitive)) { filtered = true; @@ -3901,16 +3901,16 @@ void ctkDICOMVisualBrowserWidget::removeSeries(const QStringList& seriesInstance d->DicomDatabase->setLoadedSeriesInstanceUIDs(loadedSeriesInstanceUIDs); // Refresh the affected series models and update their views' viewports - foreach (const QString& studyUID, affectedSeriesModels.keys()) + for (auto it = affectedSeriesModels.constBegin(); it != affectedSeriesModels.constEnd(); ++it) { - ctkDICOMSeriesModel* seriesModel = affectedSeriesModels.value(studyUID, nullptr); + ctkDICOMSeriesModel* seriesModel = it.value(); if (seriesModel) { seriesModel->refresh(); } // Also refresh the series view and force layout recalculation - ctkDICOMSeriesTableView* seriesView = studyListView->getSeriesViewForStudy(studyUID); + ctkDICOMSeriesTableView* seriesView = studyListView->getSeriesViewForStudy(it.key()); if (seriesView) { // reset the model to force a full view update diff --git a/Libs/PluginFramework/ctkPluginFramework.cpp b/Libs/PluginFramework/ctkPluginFramework.cpp index 7312edc986..f652092786 100644 --- a/Libs/PluginFramework/ctkPluginFramework.cpp +++ b/Libs/PluginFramework/ctkPluginFramework.cpp @@ -215,7 +215,11 @@ QByteArray ctkPluginFramework::getResource(const QString& path) const resourcePath += QString("/") + path; QFile resourceFile(resourcePath); - resourceFile.open(QIODevice::ReadOnly); + if (!resourceFile.open(QIODevice::ReadOnly)) + { + qWarning() << "ctkPluginFramework: Failed to open resource:" << resourcePath; + return QByteArray(); + } return resourceFile.readAll(); } diff --git a/Libs/PluginFramework/ctkPluginFrameworkDebugOptions.cpp b/Libs/PluginFramework/ctkPluginFrameworkDebugOptions.cpp index 8bd46f3776..ea6bbd4a5a 100644 --- a/Libs/PluginFramework/ctkPluginFrameworkDebugOptions.cpp +++ b/Libs/PluginFramework/ctkPluginFrameworkDebugOptions.cpp @@ -197,11 +197,11 @@ void ctkPluginFrameworkDebugOptions::setOptions(const QHash& return; } // first check for removals - foreach (const QString& key, this->options.keys()) + for (auto it = this->options.constBegin(); it != this->options.constEnd(); ++it) { - if (!newOptions.contains(key)) + if (!newOptions.contains(it.key())) { - QString symbolicName = this->getSymbolicName(key); + QString symbolicName = this->getSymbolicName(it.key()); if (!symbolicName.isEmpty()) { fireChangesTo.insert(symbolicName); diff --git a/Libs/PluginFramework/ctkPluginStorageSQL.cpp b/Libs/PluginFramework/ctkPluginStorageSQL.cpp index 48e50134dd..139db1881f 100644 --- a/Libs/PluginFramework/ctkPluginStorageSQL.cpp +++ b/Libs/PluginFramework/ctkPluginStorageSQL.cpp @@ -439,7 +439,12 @@ void ctkPluginStorageSQL::insertArchive(QSharedPointer pa, } QFile manifestResource(resourcePrefix + "META-INF/MANIFEST.MF"); - manifestResource.open(QIODevice::ReadOnly); + if (!manifestResource.open(QIODevice::ReadOnly)) + { + ctkPluginDatabaseException exc( + QString("Failed to open MANIFEST.MF resource: %1").arg(manifestResource.fileName())); + throw exc; + } QByteArray manifest = manifestResource.readAll(); manifestResource.close(); @@ -478,7 +483,11 @@ void ctkPluginStorageSQL::insertArchive(QSharedPointer pa, if (QFileInfo(resourcePath).isDir()) continue; QFile resourceFile(resourcePath); - resourceFile.open(QIODevice::ReadOnly); + if (!resourceFile.open(QIODevice::ReadOnly)) + { + qWarning() << "ctkPluginStorageSQL: Failed to open resource:" << resourcePath; + continue; + } QByteArray resourceData = resourceFile.readAll(); resourceFile.close(); diff --git a/Libs/PluginFramework/ctkPlugin_p.cpp b/Libs/PluginFramework/ctkPlugin_p.cpp index 95649b3893..053e75aa59 100644 --- a/Libs/PluginFramework/ctkPlugin_p.cpp +++ b/Libs/PluginFramework/ctkPlugin_p.cpp @@ -145,7 +145,7 @@ ctkPluginPrivate::ctkPluginPrivate( const QMap& e = i.next(); const QStringList& res = e.value(ctkPluginConstants::RESOLUTION_DIRECTIVE); const QStringList& version = e.value(ctkPluginConstants::PLUGIN_VERSION_ATTRIBUTE); - ctkRequirePlugin* rp = new ctkRequirePlugin(this, e.value("$key").front(), + ctkRequirePlugin* rp = new ctkRequirePlugin(this, e.value("$key").constFirst(), res.empty() ? QString() : res.front(), version.empty() ? QString() : version.front()); require.push_back(rp); diff --git a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKDataSetModelTest1.cpp b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKDataSetModelTest1.cpp index 3cfa486f8d..ced6ff6100 100644 --- a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKDataSetModelTest1.cpp +++ b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKDataSetModelTest1.cpp @@ -21,7 +21,7 @@ // Qt includes #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ namespace bool checkItems(int line, const QList& expectedAttributeArrays, ctkVTKDataSetModel* dataSetModel, - QMap locations) + QHash locations) { foreach(vtkAbstractArray* expectedDataArray, expectedAttributeArrays) { @@ -89,7 +89,7 @@ int ctkVTKDataSetModelTest1(int argc, char * argv [] ) { QApplication app(argc, argv); - QMap locations; + QHash locations; vtkNew dataSet; diff --git a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKErrorLogModelFileLoggingTest1.cpp b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKErrorLogModelFileLoggingTest1.cpp index 97094269a1..37234567e5 100644 --- a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKErrorLogModelFileLoggingTest1.cpp +++ b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKErrorLogModelFileLoggingTest1.cpp @@ -50,7 +50,11 @@ int ctkVTKErrorLogModelFileLoggingTest1(int argc, char * argv []) // Create log file QTemporaryFile logFile(QDir::tempPath() + "/ctkVTKErrorLogModelFileLoggingTest1.XXXXXX"); logFile.setAutoRemove(false); - logFile.open(); + if (!logFile.open()) + { + qWarning() << "Failed to open temporary log file"; + return EXIT_FAILURE; + } logFile.close(); QString logFilePath = logFile.fileName(); diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.h b/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.h index 8cba60088f..91113f3ae1 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.h +++ b/Libs/Visualization/VTK/Widgets/ctkVTKAbstractView.h @@ -103,10 +103,6 @@ public Q_SLOTS: /// \sa setPauseRender virtual int resumeRender(); - /// Returns true if the current pause render count is greater than 0 - /// \sa setPauseRender - virtual bool isRenderPaused()const; - /// Set maximum rate for rendering (in frames per second). /// If rendering is requested more frequently than this rate using scheduleRender, /// actual rendering will happen at this rate. @@ -155,6 +151,10 @@ public Q_SLOTS: void setUseDepthPeeling(bool use); public: + /// Returns true if the current pause render count is greater than 0 + /// \sa setPauseRender + virtual bool isRenderPaused()const; + /// Get underlying RenderWindow Q_INVOKABLE vtkRenderWindow* renderWindow()const; diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.cpp index c53f39cb4c..33cada4a3c 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.cpp @@ -98,7 +98,7 @@ void ctkVTKVolumePropertyWidgetPrivate::setupUi(QWidget* widget) this->ScalarOpacityWidget->view()->addCompositeFunction(0, 0, true, true); vtkCompositeControlPointsItem* composite = vtkCompositeControlPointsItem::SafeDownCast( - this->ScalarOpacityWidget->view()->opacityFunctionPlots()[1]); + this->ScalarOpacityWidget->view()->opacityFunctionPlots().at(1)); composite->SetColorFill(true); composite->SetPointsFunction(vtkCompositeControlPointsItem::OpacityPointsFunction); this->ScalarColorWidget->view()->addColorTransferFunction(0); diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.h b/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.h index d7ed6c08bc..7aa159e2ed 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.h +++ b/Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.h @@ -83,6 +83,8 @@ class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKVolumePropertyWidget /// Get gradient extents of the chart. Q_INVOKABLE QList chartsGradientExtent()const; + int currentComponent() const; + public Q_SLOTS: void setVolumeProperty(vtkVolumeProperty* volumeProperty); @@ -124,7 +126,6 @@ public Q_SLOTS: void setChartsGradientExtent(double extent[2]); void setChartsGradientExtent(double min, double max); - int currentComponent() const; void setCurrentComponent(int component); Q_SIGNALS: diff --git a/Libs/Widgets/Testing/Cpp/ctkErrorLogModelTestHelper.cpp b/Libs/Widgets/Testing/Cpp/ctkErrorLogModelTestHelper.cpp index 830a1b2464..e60bc329ae 100644 --- a/Libs/Widgets/Testing/Cpp/ctkErrorLogModelTestHelper.cpp +++ b/Libs/Widgets/Testing/Cpp/ctkErrorLogModelTestHelper.cpp @@ -162,7 +162,11 @@ void appendToFile(const QString& fileName, const QString& text) { QMutexLocker locker(&AppendToFileMutex); QFile f(fileName); - f.open(QFile::Append); + if (!f.open(QFile::Append)) + { + qWarning() << "appendToFile: Failed to open" << fileName; + return; + } QTextStream s(&f); s << QDateTime::currentDateTime().toString() << " - " << text << "\n"; f.close(); diff --git a/Libs/Widgets/Testing/Cpp/ctkExampleWorkflowWidgetStepUsingSignalsAndSlots.h b/Libs/Widgets/Testing/Cpp/ctkExampleWorkflowWidgetStepUsingSignalsAndSlots.h index 9fb328e5ef..a06e12a811 100644 --- a/Libs/Widgets/Testing/Cpp/ctkExampleWorkflowWidgetStepUsingSignalsAndSlots.h +++ b/Libs/Widgets/Testing/Cpp/ctkExampleWorkflowWidgetStepUsingSignalsAndSlots.h @@ -124,10 +124,10 @@ public Q_SLOTS: /// Signals indicating to the workflow that these processes have /// completed - void validationComplete(bool validationSucceeded, const QString& branchId="")const; - void onEntryComplete()const; - void onExitComplete()const; - void createUserInterfaceComplete()const; + void validationComplete(bool validationSucceeded, const QString& branchId=""); + void onEntryComplete(); + void onExitComplete(); + void createUserInterfaceComplete(); protected: QScopedPointer d_ptr; diff --git a/Libs/Widgets/Testing/Cpp/ctkLayoutManagerTest1.cpp b/Libs/Widgets/Testing/Cpp/ctkLayoutManagerTest1.cpp index 67a46ea0eb..b7dea45a25 100644 --- a/Libs/Widgets/Testing/Cpp/ctkLayoutManagerTest1.cpp +++ b/Libs/Widgets/Testing/Cpp/ctkLayoutManagerTest1.cpp @@ -221,18 +221,18 @@ int ctkLayoutManagerTest1(int argc, char * argv [] ) app.exec(); if (tabToGridInstanciator->registeredViews().count() != 6 || - tabToGridInstanciator->registeredViews()[0]->isHidden() || - tabToGridInstanciator->registeredViews()[1]->isHidden() || - tabToGridInstanciator->registeredViews()[2]->isHidden() || - tabToGridInstanciator->registeredViews()[3]->isHidden()) + tabToGridInstanciator->registeredViews().at(0)->isHidden() || + tabToGridInstanciator->registeredViews().at(1)->isHidden() || + tabToGridInstanciator->registeredViews().at(2)->isHidden() || + tabToGridInstanciator->registeredViews().at(3)->isHidden()) { std::cout << __LINE__ << " TabToGrid: " << "ctkLayoutManager::setupLayout() failed to show/hide widgets" << tabToGridInstanciator->registeredViews().count() << " " - << tabToGridInstanciator->registeredViews()[0]->isHidden() << " " - << tabToGridInstanciator->registeredViews()[1]->isHidden() << " " - << tabToGridInstanciator->registeredViews()[2]->isHidden() << " " - << tabToGridInstanciator->registeredViews()[3]->isHidden() << std::endl; + << tabToGridInstanciator->registeredViews().at(0)->isHidden() << " " + << tabToGridInstanciator->registeredViews().at(1)->isHidden() << " " + << tabToGridInstanciator->registeredViews().at(2)->isHidden() << " " + << tabToGridInstanciator->registeredViews().at(3)->isHidden() << std::endl; return EXIT_FAILURE; } @@ -256,16 +256,16 @@ int ctkLayoutManagerTest1(int argc, char * argv [] ) app.exec(); if (tabToSimpleInstanciator->registeredViews().count() != 3 || - tabToSimpleInstanciator->registeredViews()[0]->isHidden() || - tabToSimpleInstanciator->registeredViews()[1]->isVisible() || - tabToSimpleInstanciator->registeredViews()[2]->isVisible()) + tabToSimpleInstanciator->registeredViews().at(0)->isHidden() || + tabToSimpleInstanciator->registeredViews().at(1)->isVisible() || + tabToSimpleInstanciator->registeredViews().at(2)->isVisible()) { std::cout << __LINE__ << " TabToSimple: " << "ctkLayoutManager::setupLayout() failed to show/hide widgets" << tabToSimpleInstanciator->registeredViews().count() << " " - << tabToSimpleInstanciator->registeredViews()[0]->isHidden() << " " - << tabToSimpleInstanciator->registeredViews()[1]->isVisible() << " " - << tabToSimpleInstanciator->registeredViews()[2]->isVisible() << std::endl; + << tabToSimpleInstanciator->registeredViews().at(0)->isHidden() << " " + << tabToSimpleInstanciator->registeredViews().at(1)->isVisible() << " " + << tabToSimpleInstanciator->registeredViews().at(2)->isVisible() << std::endl; return EXIT_FAILURE; } @@ -288,17 +288,17 @@ int ctkLayoutManagerTest1(int argc, char * argv [] ) QTimer::singleShot(200, &app, SLOT(quit())); app.exec(); - if (nestedToTabInstanciator->registeredViews()[0]->isHidden() || - nestedToTabInstanciator->registeredViews()[1]->isVisible() || - nestedToTabInstanciator->registeredViews()[2]->isVisible() || - nestedToTabInstanciator->registeredViews()[3]->isVisible()) + if (nestedToTabInstanciator->registeredViews().at(0)->isHidden() || + nestedToTabInstanciator->registeredViews().at(1)->isVisible() || + nestedToTabInstanciator->registeredViews().at(2)->isVisible() || + nestedToTabInstanciator->registeredViews().at(3)->isVisible()) { std::cout << __LINE__ << " NestedToTab: " << "ctkLayoutManager::setupLayout() failed to show/hide widgets" - << nestedToTabInstanciator->registeredViews()[0]->isHidden() << " " - << nestedToTabInstanciator->registeredViews()[1]->isVisible() << " " - << nestedToTabInstanciator->registeredViews()[2]->isVisible() << " " - << nestedToTabInstanciator->registeredViews()[3]->isVisible() << std::endl; + << nestedToTabInstanciator->registeredViews().at(0)->isHidden() << " " + << nestedToTabInstanciator->registeredViews().at(1)->isVisible() << " " + << nestedToTabInstanciator->registeredViews().at(2)->isVisible() << " " + << nestedToTabInstanciator->registeredViews().at(3)->isVisible() << std::endl; return EXIT_FAILURE; } @@ -312,16 +312,16 @@ int ctkLayoutManagerTest1(int argc, char * argv [] ) nestedToTabInstanciator->setUseCachedViews(false); nestedToTabLayoutManager.setLayout(tabMultipleLayoutDoc); if (nestedToTabInstanciator->registeredViews().count() != 2 * 4 || - nestedToTabInstanciator->registeredViews()[0]->isHidden() || - !nestedToTabInstanciator->registeredViews()[1]->isHidden() || - !nestedToTabInstanciator->registeredViews()[2]->isHidden()) + nestedToTabInstanciator->registeredViews().at(0)->isHidden() || + !nestedToTabInstanciator->registeredViews().at(1)->isHidden() || + !nestedToTabInstanciator->registeredViews().at(2)->isHidden()) { std::cout << __LINE__ << " tabMultiple: " << "ctkLayoutManager::setupLayout() failed to show/hide widgets " << nestedToTabInstanciator->registeredViews().count(); for (int i = 0; i < nestedToTabInstanciator->registeredViews().count(); i++) { - std::cout << " " << nestedToTabInstanciator->registeredViews()[i]->isHidden(); + std::cout << " " << nestedToTabInstanciator->registeredViews().at(i)->isHidden(); } std::cout << std::endl; return EXIT_FAILURE; diff --git a/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest1.cpp b/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest1.cpp index eb7de4bdc5..e78c367bca 100644 --- a/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest1.cpp +++ b/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest1.cpp @@ -196,7 +196,7 @@ int userInteractionSimulator1(QApplication& app, ctkExampleDerivedWorkflowWidget Q_ASSERT(nextButton); #ifndef QT_NO_DEBUG - QPushButton* finishButton = workflowWidget->buttonBoxWidget()->goToButtons().first(); + QPushButton* finishButton = workflowWidget->buttonBoxWidget()->goToButtons().constFirst(); Q_ASSERT(finishButton); #endif @@ -290,7 +290,7 @@ int userInteractionSimulator2(QApplication& app, ctkExampleDerivedWorkflowWidget QPushButton* backButton = workflowWidget->buttonBoxWidget()->backButton(); QPushButton* nextButton = workflowWidget->buttonBoxWidget()->nextButton(); - QPushButton* finishButton = workflowWidget->buttonBoxWidget()->goToButtons().first(); + QPushButton* finishButton = workflowWidget->buttonBoxWidget()->goToButtons().constFirst(); Q_ASSERT(backButton); Q_ASSERT(nextButton); Q_ASSERT(finishButton); diff --git a/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest2.cpp b/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest2.cpp index 915c1eeb14..53c99c2350 100644 --- a/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest2.cpp +++ b/Libs/Widgets/Testing/Cpp/ctkWorkflowWidgetTest2.cpp @@ -288,7 +288,7 @@ int userInteractionSimulator2(QApplication& app, ctkWorkflowWidgetStep* step1, c QPushButton* backButton = workflowWidget->buttonBoxWidget()->backButton(); QPushButton* nextButton = workflowWidget->buttonBoxWidget()->nextButton(); - QPushButton* finishButton = workflowWidget->buttonBoxWidget()->goToButtons().first(); + QPushButton* finishButton = workflowWidget->buttonBoxWidget()->goToButtons().constFirst(); Q_ASSERT(backButton); Q_ASSERT(nextButton); Q_ASSERT(finishButton); diff --git a/Libs/Widgets/ctkAxesWidget.h b/Libs/Widgets/ctkAxesWidget.h index 78f6935386..c21694af3c 100644 --- a/Libs/Widgets/ctkAxesWidget.h +++ b/Libs/Widgets/ctkAxesWidget.h @@ -64,6 +64,15 @@ public : /// False by default. bool autoReset() const; + /// Get the axes labels + QStringList axesLabels() const; + + /// Size hints + virtual QSize minimumSizeHint()const; + virtual QSize sizeHint()const; + virtual bool hasHeightForWidth()const; + virtual int heightForWidth(int width)const; + Q_SIGNALS: void currentAxisChanged(ctkAxesWidget::Axis axis); @@ -93,15 +102,6 @@ public slots : /// \sa axesLabels() bool setAxesLabels(const QStringList& labels); - /// Get the axes labels - QStringList axesLabels() const; - - /// Size hints - virtual QSize minimumSizeHint()const; - virtual QSize sizeHint()const; - virtual bool hasHeightForWidth()const; - virtual int heightForWidth(int width)const; - protected: void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent *mouseEvent); diff --git a/Libs/Widgets/ctkDoubleSpinBox.h b/Libs/Widgets/ctkDoubleSpinBox.h index 3f45ba8ef0..18143a601b 100644 --- a/Libs/Widgets/ctkDoubleSpinBox.h +++ b/Libs/Widgets/ctkDoubleSpinBox.h @@ -294,6 +294,14 @@ class CTK_WIDGETS_EXPORT ctkDoubleSpinBox : public QWidget /// \sa sizeHintPolicy virtual QSize minimumSizeHint()const; + /// Return true if the spinbox is in the progress of setting a value. + /// + /// Setting of value is performed in two steps: first the value is set in the spinbox + /// and then the valueChanged and decimalsChanged signals are emitted. + /// During this entire time, isSettingValue() returns true, because in some cases + /// it is important to know which of the sibling widgets initiated an update. + bool isSettingValue()const; + public Q_SLOTS: /// Set the value of the spinbox following the current mode. /// \sa setMode(), value(), setValueIfDifferent(), setValueAlways() @@ -322,14 +330,6 @@ public Q_SLOTS: /// \sa isReadOnly void setReadOnly(bool readOnly); - /// Return true if the spinbox is in the progress of setting a value. - /// - /// Setting of value is performed in two steps: first the value is set in the spinbox - /// and then the valueChanged and decimalsChanged signals are emitted. - /// During this entire time, isSettingValue() returns true, because in some cases - /// it is important to know which of the sibling widgets initiated an update. - bool isSettingValue()const; - Q_SIGNALS: /// Emitted every time the spinbox value is modified /// \sa QDoubleSpinBox::valueChanged() diff --git a/Libs/Widgets/ctkLayoutManager.cpp b/Libs/Widgets/ctkLayoutManager.cpp index 7764b3600f..112b59ff46 100644 --- a/Libs/Widgets/ctkLayoutManager.cpp +++ b/Libs/Widgets/ctkLayoutManager.cpp @@ -20,6 +20,7 @@ // Qt includes #include +#include #include #include #include @@ -250,7 +251,7 @@ void ctkLayoutManager::setSpacing(int spacing) void ctkLayoutManager::refresh() { Q_D(ctkLayoutManager); - QMap updatesEnabled; + QHash updatesEnabled; foreach(QWidget* viewport, d->Viewports) { if (!viewport) @@ -265,7 +266,7 @@ void ctkLayoutManager::refresh() this->setupLayout(); foreach(QWidget* viewport, d->Viewports) { - QMap::iterator updatesEnabledIt = updatesEnabled.find(viewport); + QHash::iterator updatesEnabledIt = updatesEnabled.find(viewport); if (updatesEnabledIt == updatesEnabled.end()) { continue; @@ -338,8 +339,9 @@ void ctkLayoutManager::setupLayout() { qWarning() << "Expected 'viewports' or 'layout' as XML root element, found" << d->Layout.documentElement().tagName(); } - foreach (const QString& viewportName, d->Viewports.keys()) + for (auto it = d->Viewports.constBegin(); it != d->Viewports.constEnd(); ++it) { + const QString& viewportName = it.key(); bool usedInLayout = viewportNamesUsedInLayout.contains(viewportName); QWidget* viewport = d->viewport(viewportName); if (d->isViewportUsedInLayout(viewport) == usedInLayout) diff --git a/Libs/Widgets/ctkModalityWidget.cpp b/Libs/Widgets/ctkModalityWidget.cpp index 719954c715..ab79c68fb3 100644 --- a/Libs/Widgets/ctkModalityWidget.cpp +++ b/Libs/Widgets/ctkModalityWidget.cpp @@ -146,9 +146,9 @@ void ctkModalityWidgetPrivate::updateAnyCheckBoxState() // None selected? bool foundSelectedModality = false; - foreach(const QString & modality, this->Modalities.keys()) + for (auto it = this->Modalities.constBegin(); it != this->Modalities.constEnd(); ++it) { - if (this->Modalities[modality]->isChecked()) + if (it.value()->isChecked()) { foundSelectedModality = true; break; @@ -168,9 +168,9 @@ void ctkModalityWidgetPrivate::updateAnyCheckBoxState() // All selected? bool allModalitiesSelected = true; - foreach(const QString & modality, this->Modalities.keys()) + for (auto it = this->Modalities.constBegin(); it != this->Modalities.constEnd(); ++it) { - if (!this->Modalities[modality]->isChecked()) + if (!it.value()->isChecked()) { allModalitiesSelected = false; break; @@ -217,12 +217,11 @@ QStringList ctkModalityWidget::selectedModalities()const { Q_D(const ctkModalityWidget); QStringList modalities; - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; - if (modalityBox->isChecked()) + if (it.value()->isChecked()) { - modalities << modality; + modalities << it.key(); } } return modalities; @@ -233,10 +232,10 @@ void ctkModalityWidget::setSelectedModalities(const QStringList& selectedModalit { Q_D(ctkModalityWidget); bool modified = false; - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; - bool selected = selectedModalities.contains(modality); + QCheckBox* modalityBox = it.value(); + bool selected = selectedModalities.contains(it.key()); if (modalityBox->isChecked() != selected) { #if QT_VERSION >= QT_VERSION_CHECK(5,3,0) @@ -263,13 +262,12 @@ QStringList ctkModalityWidget::visibleModalities()const { Q_D(const ctkModalityWidget); QStringList modalities; - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; // isHidden() means explicitly hidden (not the same as !isVisible()) - if (!modalityBox->isHidden()) + if (!it.value()->isHidden()) { - modalities << modality; + modalities << it.key(); } } return modalities; @@ -279,14 +277,13 @@ QStringList ctkModalityWidget::visibleModalities()const void ctkModalityWidget::setVisibleModalities(const QStringList& visibleModalities) { Q_D(ctkModalityWidget); - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; - bool visible = visibleModalities.contains(modality); + bool visible = visibleModalities.contains(it.key()); // isHidden() means explicitly hidden (not the same as !isVisible()) - if (modalityBox->isHidden() == visible) + if (it.value()->isHidden() == visible) { - modalityBox->setVisible(visible); + it.value()->setVisible(visible); } } } @@ -340,9 +337,9 @@ void ctkModalityWidget::selectAll() { Q_D(ctkModalityWidget); bool modified = false; - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; + QCheckBox* modalityBox = it.value(); if (!modalityBox->isChecked()) { #if QT_VERSION >= QT_VERSION_CHECK(5,3,0) @@ -369,9 +366,9 @@ void ctkModalityWidget::unselectAll() { Q_D(ctkModalityWidget); bool modified = false; - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; + QCheckBox* modalityBox = it.value(); if (modalityBox->isChecked()) { #if QT_VERSION >= QT_VERSION_CHECK(5,3,0) @@ -397,10 +394,9 @@ void ctkModalityWidget::unselectAll() void ctkModalityWidget::showAll() { Q_D(ctkModalityWidget); - foreach(const QString& modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; - modalityBox->setVisible(true); + it.value()->setVisible(true); } } @@ -408,10 +404,9 @@ void ctkModalityWidget::showAll() void ctkModalityWidget::hideAll() { Q_D(ctkModalityWidget); - foreach(const QString& modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; - modalityBox->setVisible(false); + it.value()->setVisible(false); } } @@ -419,10 +414,9 @@ void ctkModalityWidget::hideAll() bool ctkModalityWidget::areAllModalitiesSelected()const { Q_D(const ctkModalityWidget); - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; - if (!modalityBox->isChecked()) + if (!it.value()->isChecked()) { return false; } @@ -434,11 +428,10 @@ bool ctkModalityWidget::areAllModalitiesSelected()const bool ctkModalityWidget::areAllModalitiesVisible()const { Q_D(const ctkModalityWidget); - foreach(const QString & modality, d->Modalities.keys()) + for (auto it = d->Modalities.constBegin(); it != d->Modalities.constEnd(); ++it) { - QCheckBox* modalityBox = d->Modalities[modality]; // isHidden() means explicitly hidden (not the same as !isVisible()) - if (modalityBox->isHidden()) + if (it.value()->isHidden()) { return false; } diff --git a/Libs/Widgets/ctkPathLineEdit.cpp b/Libs/Widgets/ctkPathLineEdit.cpp index d7b6f0b40e..27a4d17a27 100644 --- a/Libs/Widgets/ctkPathLineEdit.cpp +++ b/Libs/Widgets/ctkPathLineEdit.cpp @@ -522,7 +522,7 @@ void ctkPathLineEditPrivate::_q_recomputeCompleterPopupSize() QVariant icon = model->data(model->index(i, 0), Qt::DecorationRole); if (icon.isValid() && icon.canConvert()) { - iconWidth = qMax(iconWidth, icon.value().availableSizes().front().width() + 4); + iconWidth = qMax(iconWidth, icon.value().availableSizes().constFirst().width() + 4); } textWidth = qMax(textWidth, fm.boundingRect(model->data(model->index(i, 0)).toString()).width()); } diff --git a/Libs/Widgets/ctkProxyStyle.h b/Libs/Widgets/ctkProxyStyle.h index c37d6d19ec..1d2e3f0d93 100644 --- a/Libs/Widgets/ctkProxyStyle.h +++ b/Libs/Widgets/ctkProxyStyle.h @@ -73,9 +73,7 @@ class CTK_WIDGETS_EXPORT ctkProxyStyle : public QProxyStyle protected: QScopedPointer d_ptr; virtual bool event(QEvent *e); - -protected Q_SLOTS: - virtual QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; + virtual QIcon standardIconImplementation(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; virtual int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option = 0, const QWidget *widget = 0) const; private: diff --git a/Libs/Widgets/ctkSettingsDialog.cpp b/Libs/Widgets/ctkSettingsDialog.cpp index 50a4b1cd2d..f34337541b 100644 --- a/Libs/Widgets/ctkSettingsDialog.cpp +++ b/Libs/Widgets/ctkSettingsDialog.cpp @@ -209,9 +209,9 @@ void ctkSettingsDialog::setSettings(QSettings* settings) d->SettingsButtonBox->button(QDialogButtonBox::Reset)->setEnabled(false); d->Settings = settings; - foreach(ctkSettingsPanel* panel, d->Panels.values()) + for (auto it = d->Panels.constBegin(); it != d->Panels.constEnd(); ++it) { - panel->setSettings(settings); + it.value()->setSettings(settings); } } @@ -282,11 +282,11 @@ ctkSettingsPanel* ctkSettingsDialog::currentPanel()const ctkSettingsPanel* ctkSettingsDialog::panel(const QString& label)const { Q_D(const ctkSettingsDialog); - foreach(ctkSettingsPanel* settingsPanel, d->Panels.values()) + for (auto it = d->Panels.constBegin(); it != d->Panels.constEnd(); ++it) { - if (settingsPanel->windowTitle() == label) + if (it.value()->windowTitle() == label) { - return settingsPanel; + return it.value(); } } return 0; @@ -331,9 +331,9 @@ void ctkSettingsDialog::reject() void ctkSettingsDialog::applySettings() { Q_D(ctkSettingsDialog); - foreach(ctkSettingsPanel* panel, d->Panels.values()) + for (auto it = d->Panels.constBegin(); it != d->Panels.constEnd(); ++it) { - panel->applySettings(); + it.value()->applySettings(); } d->SettingsButtonBox->button(QDialogButtonBox::Reset)->setEnabled(false); } @@ -342,9 +342,9 @@ void ctkSettingsDialog::applySettings() void ctkSettingsDialog::reloadSettings() { Q_D(ctkSettingsDialog); - foreach(ctkSettingsPanel* panel, d->Panels.values()) + for (auto it = d->Panels.constBegin(); it != d->Panels.constEnd(); ++it) { - panel->reloadSettings(); + it.value()->reloadSettings(); } d->SettingsButtonBox->button(QDialogButtonBox::Reset)->setEnabled(false); } @@ -353,9 +353,9 @@ void ctkSettingsDialog::reloadSettings() void ctkSettingsDialog::resetSettings() { Q_D(ctkSettingsDialog); - foreach(ctkSettingsPanel* panel, d->Panels.values()) + for (auto it = d->Panels.constBegin(); it != d->Panels.constEnd(); ++it) { - panel->resetSettings(); + it.value()->resetSettings(); } d->SettingsButtonBox->button(QDialogButtonBox::Reset)->setEnabled(false); } @@ -371,9 +371,9 @@ void ctkSettingsDialog::restoreDefaultSettings() d->Settings->clear(); } // ... and restore settings for the ones we can - foreach(ctkSettingsPanel* panel, d->Panels.values()) + for (auto it = d->Panels.constBegin(); it != d->Panels.constEnd(); ++it) { - panel->restoreDefaultSettings(); + it.value()->restoreDefaultSettings(); } } diff --git a/Libs/Widgets/ctkSettingsPanel.cpp b/Libs/Widgets/ctkSettingsPanel.cpp index 44cf034c4d..d46e19d3c6 100644 --- a/Libs/Widgets/ctkSettingsPanel.cpp +++ b/Libs/Widgets/ctkSettingsPanel.cpp @@ -231,8 +231,9 @@ void ctkSettingsPanel::setSettings(QSettings* settings) void ctkSettingsPanel::reloadSettings() { Q_D(ctkSettingsPanel); - foreach(const QString& key, d->Properties.keys()) + for (auto it = d->Properties.begin(); it != d->Properties.end(); ++it) { + const QString& key = it.key(); QSettings* settings = d->settings(key); if (!settings) { @@ -241,7 +242,7 @@ void ctkSettingsPanel::reloadSettings() if (settings->contains(key)) { QVariant value = settings->value(key); - PropertyType& prop = d->Properties[key]; + PropertyType& prop = it.value(); // Update object registered using registerProperty() prop.setValue(value); prop.setPreviousValue(value); @@ -388,12 +389,11 @@ QStringList ctkSettingsPanel::changedSettings()const { Q_D(const ctkSettingsPanel); QStringList settingsKeys; - foreach(const QString& key, d->Properties.keys()) + for (auto it = d->Properties.constBegin(); it != d->Properties.constEnd(); ++it) { - const PropertyType& prop = d->Properties[key]; - if (prop.previousValue() != prop.value()) + if (it.value().previousValue() != it.value().value()) { - settingsKeys << key; + settingsKeys << it.key(); } } return settingsKeys; @@ -418,13 +418,13 @@ ::settingOptions(const QString& settingKey)const void ctkSettingsPanel::applySettings() { Q_D(ctkSettingsPanel); - foreach(const QString& key, d->Properties.keys()) + for (auto it = d->Properties.begin(); it != d->Properties.end(); ++it) { - PropertyType& prop = d->Properties[key]; + PropertyType& prop = it.value(); if (prop.previousValue() != prop.value()) { prop.setPreviousValue(prop.value()); - emit settingChanged(key, prop.value()); + emit settingChanged(it.key(), prop.value()); } } } @@ -433,9 +433,9 @@ void ctkSettingsPanel::applySettings() void ctkSettingsPanel::resetSettings() { Q_D(ctkSettingsPanel); - foreach(const QString& key, d->Properties.keys()) + for (auto it = d->Properties.constBegin(); it != d->Properties.constEnd(); ++it) { - this->setSetting(key, d->Properties[key].previousValue()); + this->setSetting(it.key(), it.value().previousValue()); } } @@ -443,8 +443,8 @@ void ctkSettingsPanel::resetSettings() void ctkSettingsPanel::restoreDefaultSettings() { Q_D(ctkSettingsPanel); - foreach(const QString& key, d->Properties.keys()) + for (auto it = d->Properties.constBegin(); it != d->Properties.constEnd(); ++it) { - this->setSetting(key, d->Properties[key].DefaultValue); + this->setSetting(it.key(), it.value().DefaultValue); } } diff --git a/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp b/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp index df26dec510..3b36ae5004 100644 --- a/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp +++ b/Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp @@ -209,10 +209,10 @@ void ctkWorkflowButtonBoxWidgetPrivate::updateGoToButtons(ctkWorkflowStep* curre // Remove the buttons if the set of steps to have goTo buttons has changed if (goToStepsThatHaveButtons != goToStepsToHaveButtons) { - foreach (ctkPushButton* goToButton, this->GoToButtonToStepMap.keys()) + for (auto it = this->GoToButtonToStepMap.constBegin(); it != this->GoToButtonToStepMap.constEnd(); ++it) { - q->layout()->removeWidget(goToButton); - goToButton->deleteLater(); + q->layout()->removeWidget(it.key()); + it.key()->deleteLater(); } this->GoToButtonToStepMap.clear(); } @@ -236,13 +236,14 @@ void ctkWorkflowButtonBoxWidgetPrivate::updateGoToButtons(ctkWorkflowStep* curre // Show/hide the goTo buttons depending on whether they are accessible from the current step ctkWorkflowWidgetStep* step = dynamic_cast(currentStep); - foreach (ctkPushButton* goToButton, this->GoToButtonToStepMap.keys()) + for (auto it = this->GoToButtonToStepMap.constBegin(); it != this->GoToButtonToStepMap.constEnd(); ++it) { + ctkPushButton* goToButton = it.key(); // TODO enable and show the goTo button if we can go to it // ctkWorkflowStep* goToStep = this->GoToButtonToStepMap[goToButton]; // if (this->Workflow->canGoToStep(currentStep, goToStep)) // for now we'll assume we can go to the step - ctkWorkflowStep* goToStep = this->GoToButtonToStepMap[goToButton]; + ctkWorkflowStep* goToStep = it.value(); Q_ASSERT(goToStep); bool enable = currentStep && this->Workflow->canGoToStep(goToStep->id(), currentStep); bool visible = step ? !(step->buttonBoxHints() & ctkWorkflowWidgetStep::ButtonBoxHidden) : true; diff --git a/Libs/Widgets/ctkWorkflowWidgetStep.cpp b/Libs/Widgets/ctkWorkflowWidgetStep.cpp index 24e5c4e550..ac666d4d21 100644 --- a/Libs/Widgets/ctkWorkflowWidgetStep.cpp +++ b/Libs/Widgets/ctkWorkflowWidgetStep.cpp @@ -52,13 +52,13 @@ ctkWorkflowWidgetStepPrivate::~ctkWorkflowWidgetStepPrivate() } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStepPrivate::invokeShowUserInterfaceCommandInternal()const +void ctkWorkflowWidgetStepPrivate::invokeShowUserInterfaceCommandInternal() { emit invokeShowUserInterfaceCommand(); } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStepPrivate::showUserInterfaceCompleteInternal()const +void ctkWorkflowWidgetStepPrivate::showUserInterfaceCompleteInternal() { emit showUserInterfaceComplete(); } @@ -71,13 +71,13 @@ void ctkWorkflowWidgetStepPrivate::showUserInterface() } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStepPrivate::invokeCreateUserInterfaceCommandInternal()const +void ctkWorkflowWidgetStepPrivate::invokeCreateUserInterfaceCommandInternal() { emit invokeCreateUserInterfaceCommand(); } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStepPrivate::createUserInterfaceCompleteInternal()const +void ctkWorkflowWidgetStepPrivate::createUserInterfaceCompleteInternal() { emit createUserInterfaceComplete(); } @@ -206,29 +206,29 @@ void ctkWorkflowWidgetStep::showUserInterface() } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStep::invokeShowUserInterfaceCommand()const +void ctkWorkflowWidgetStep::invokeShowUserInterfaceCommand() { - Q_D(const ctkWorkflowWidgetStep); + Q_D(ctkWorkflowWidgetStep); d->invokeShowUserInterfaceCommandInternal(); } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStep::showUserInterfaceComplete()const +void ctkWorkflowWidgetStep::showUserInterfaceComplete() { - Q_D(const ctkWorkflowWidgetStep); + Q_D(ctkWorkflowWidgetStep); d->showUserInterfaceCompleteInternal(); } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStep::invokeCreateUserInterfaceCommand()const +void ctkWorkflowWidgetStep::invokeCreateUserInterfaceCommand() { - Q_D(const ctkWorkflowWidgetStep); + Q_D(ctkWorkflowWidgetStep); d->invokeCreateUserInterfaceCommandInternal(); } //----------------------------------------------------------------------------- -void ctkWorkflowWidgetStep::createUserInterfaceComplete()const +void ctkWorkflowWidgetStep::createUserInterfaceComplete() { - Q_D(const ctkWorkflowWidgetStep); + Q_D(ctkWorkflowWidgetStep); d->createUserInterfaceCompleteInternal(); } diff --git a/Libs/Widgets/ctkWorkflowWidgetStep.h b/Libs/Widgets/ctkWorkflowWidgetStep.h index 77c0b91c8b..e872c84e1e 100644 --- a/Libs/Widgets/ctkWorkflowWidgetStep.h +++ b/Libs/Widgets/ctkWorkflowWidgetStep.h @@ -131,22 +131,22 @@ class CTK_WIDGETS_EXPORT ctkWorkflowWidgetStep : public QWidget, public ctkWorkf /// \brief Signal (emitted by the private implementation) indicating that the step's /// createUserInterface() method should be called. /// \sa createUserInterface() - void invokeCreateUserInterfaceCommand()const; + void invokeCreateUserInterfaceCommand(); /// \brief Signal (emitted by the private implementation) indicating that the step's /// createUserInterface() method has completed. /// \sa createUserInterface() - void createUserInterfaceComplete()const; + void createUserInterfaceComplete(); /// \brief Signal (emitted by the private implementation) indicating that the step's /// 'showUserInterface() method should be called. /// \sa showUserInterface() - void invokeShowUserInterfaceCommand()const; + void invokeShowUserInterfaceCommand(); /// \brief Signal (emitted by the private implementation) indicating that the step's /// showUserInterface() method has completed. /// \sa showUserInterface() - void showUserInterfaceComplete()const; + void showUserInterfaceComplete(); private: diff --git a/Libs/Widgets/ctkWorkflowWidgetStep_p.h b/Libs/Widgets/ctkWorkflowWidgetStep_p.h index 1766e18c56..4b554e3f78 100644 --- a/Libs/Widgets/ctkWorkflowWidgetStep_p.h +++ b/Libs/Widgets/ctkWorkflowWidgetStep_p.h @@ -62,13 +62,13 @@ class ctkWorkflowWidgetStepPrivate : public ctkWorkflowStepPrivate bool created; - void invokeShowUserInterfaceCommandInternal()const; + void invokeShowUserInterfaceCommandInternal(); - void showUserInterfaceCompleteInternal()const; + void showUserInterfaceCompleteInternal(); - void invokeCreateUserInterfaceCommandInternal()const; + void invokeCreateUserInterfaceCommandInternal(); - void createUserInterfaceCompleteInternal()const; + void createUserInterfaceCompleteInternal(); protected Q_SLOTS: @@ -79,13 +79,13 @@ protected Q_SLOTS: Q_SIGNALS: - void invokeShowUserInterfaceCommand()const; + void invokeShowUserInterfaceCommand(); - void showUserInterfaceComplete()const; + void showUserInterfaceComplete(); - void invokeCreateUserInterfaceCommand()const; + void invokeCreateUserInterfaceCommand(); - void createUserInterfaceComplete()const; + void createUserInterfaceComplete(); };