diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index ff64446bc2..a592fd4e8d 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include diff --git a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp index 1749252556..3bef749e9c 100644 --- a/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp +++ b/ApplicationLibCode/Application/Tools/Cloud/RiaSumoConnector.cpp @@ -276,7 +276,7 @@ void RiaSumoConnector::parseEnsembleNames( QNetworkReply* reply, const SumoCaseI QJsonObject aggregationColumnsObject = aggregationsObject["iteration_names"].toObject(); QJsonArray bucketsArray = aggregationColumnsObject["buckets"].toArray(); - foreach ( const QJsonValue& bucket, bucketsArray ) + for ( const QJsonValue& bucket : bucketsArray ) { QJsonObject bucketObj = bucket.toObject(); auto ensembleName = bucketObj["key"].toString(); @@ -825,7 +825,7 @@ void RiaSumoConnector::parseCases( QNetworkReply* reply ) m_cases.clear(); - foreach ( const QJsonValue& value, hitsObjects ) + for ( const QJsonValue& value : hitsObjects ) { QJsonObject resultObj = value.toObject(); QJsonObject sourceObj = resultObj["_source"].toObject(); @@ -931,7 +931,7 @@ void RiaSumoConnector::parseBlobIds( QNetworkReply* reply, QJsonObject rootHits = jsonObj["hits"].toObject(); QJsonArray hitsObjects = rootHits["hits"].toArray(); - foreach ( const QJsonValue& value, hitsObjects ) + for ( const QJsonValue& value : hitsObjects ) { QJsonObject resultObj = value.toObject(); QJsonObject sourceObj = resultObj["_source"].toObject(); diff --git a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp index f9bb01ef86..897c962cad 100644 --- a/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaQDateTimeTools.cpp @@ -203,11 +203,7 @@ QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaDefines::Da //-------------------------------------------------------------------------------------------------- QDateTime RiaQDateTimeTools::createDateTime( const QDate& date, Qt::TimeSpec timeSpec /*= Qt::LocalTime*/ ) { -#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) return date.startOfDay( timeSpec ); -#else - return QDateTime( date, QTime( 0, 0 ), timeSpec ); -#endif } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp b/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp index 11058d2073..5612ddbc2c 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.cpp @@ -133,6 +133,15 @@ QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const return splitString( text, sep, skipEmptyParts ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const QRegularExpression& regularExpression ) +{ + bool skipEmptyParts = true; + return splitString( text, regularExpression, skipEmptyParts ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -144,9 +153,9 @@ QStringList RiaTextStringTools::splitString( const QString& text, const QString& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RiaTextStringTools::splitString( const QString& text, const QRegExp& regExp, bool skipEmptyParts ) +QStringList RiaTextStringTools::splitString( const QString& text, const QRegularExpression& regularExpression, bool skipEmptyParts ) { - return regExp.splitString( text, skipEmptyParts ? Qt::SkipEmptyParts : Qt::KeepEmptyParts ); + return text.split( regularExpression, skipEmptyParts ? Qt::SkipEmptyParts : Qt::KeepEmptyParts ); } //-------------------------------------------------------------------------------------------------- @@ -197,16 +206,6 @@ bool RiaTextStringTools::isNumber( const QString& text, const QString& decimalPo return RiaStdStringTools::isNumber( stdString, decimalChar ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const QRegExp& regExp ) -{ - bool skipEmptyParts = true; - - return splitString( text, regExp, skipEmptyParts ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h index 34710045f9..5c4b1ee9a2 100644 --- a/ApplicationLibCode/Application/Tools/RiaTextStringTools.h +++ b/ApplicationLibCode/Application/Tools/RiaTextStringTools.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include @@ -36,10 +36,10 @@ QString commonSuffix( const QStringList& stringList ); QString trimNonAlphaNumericCharacters( const QString& s ); QStringList splitSkipEmptyParts( const QString& text, const QString& sep = " " ); -QStringList splitSkipEmptyParts( const QString& text, const QRegExp& regExp ); +QStringList splitSkipEmptyParts( const QString& text, const QRegularExpression& regularExpression ); QStringList splitString( const QString& text, const QString& sep, bool skipEmptyParts ); -QStringList splitString( const QString& text, const QRegExp& regExp, bool skipEmptyParts ); +QStringList splitString( const QString& text, const QRegularExpression& regularExpression, bool skipEmptyParts ); QString replaceTemplateTextWithValues( const QString& templateText, const std::map& valueMap ); bool isTextEqual( QStringView text, QStringView compareText ); diff --git a/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.cpp b/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.cpp index d7e1b64eed..40c4a4dff2 100644 --- a/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.cpp +++ b/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.cpp @@ -41,8 +41,10 @@ bool RiaValidRegExpValidator::isValidCharacter( const QChar& character ) //-------------------------------------------------------------------------------------------------- QValidator::State RiaValidRegExpValidator::validate( QString& inputString, int& position ) const { - QRegExp inputRe( inputString, Qt::CaseInsensitive, QRegExp::Wildcard ); - if ( inputRe.isValid() ) // A valid wildcard pattern is always acceptable + QString regexPattern = QRegularExpression::wildcardToRegularExpression( inputString ); + QRegularExpression regex( regexPattern, QRegularExpression::CaseInsensitiveOption ); + + if ( regex.isValid() ) { return QValidator::Acceptable; } @@ -70,4 +72,4 @@ QValidator::State RiaValidRegExpValidator::validate( QString& inputString, int& void RiaValidRegExpValidator::fixup( QString& inputString ) const { inputString = m_defaultPattern; -} \ No newline at end of file +} diff --git a/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.h b/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.h index 62ee01aa80..997c4bb393 100644 --- a/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.h +++ b/ApplicationLibCode/Application/Tools/RiaValidRegExpValidator.h @@ -17,7 +17,6 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include #include #include @@ -36,4 +35,4 @@ class RiaValidRegExpValidator : public QValidator private: QString m_defaultPattern; -}; \ No newline at end of file +}; diff --git a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryStringTools.cpp b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryStringTools.cpp index b81c0dbdf7..7d1f0a57d0 100644 --- a/ApplicationLibCode/Application/Tools/Summary/RiaSummaryStringTools.cpp +++ b/ApplicationLibCode/Application/Tools/Summary/RiaSummaryStringTools.cpp @@ -121,11 +121,12 @@ void RiaSummaryStringTools::splitUsingDataSourceNames( const QStringList& filter bool foundDataSource = false; - QRegExp searcher( pureDataSourceCandidate, Qt::CaseInsensitive, QRegExp::WildcardUnix ); + QString regexPattern = QRegularExpression::wildcardToRegularExpression( pureDataSourceCandidate ); + QRegularExpression searcher( regexPattern, QRegularExpression::CaseInsensitiveOption ); for ( const auto& ds : dataSourceNames ) { - if ( !foundDataSource && searcher.exactMatch( ds ) ) + if ( !foundDataSource && searcher.match( ds ).hasMatch() ) { dataSourceFilters.push_back( s ); foundDataSource = true; @@ -166,13 +167,14 @@ std::pair, std::vector> for ( const auto& dsFilter : dataSourceFilters ) { - QString searchString = dsFilter.left( dsFilter.indexOf( ':' ) ); - QRegExp searcher( searchString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); + QString searchString = dsFilter.left( dsFilter.indexOf( ':' ) ); + QString regexPattern = QRegularExpression::wildcardToRegularExpression( searchString ); + QRegularExpression searcher( regexPattern, QRegularExpression::CaseInsensitiveOption ); for ( const auto& ensemble : allEnsembles ) { auto ensembleName = ensemble->name(); - if ( searcher.exactMatch( ensembleName ) ) + if ( searcher.match( ensembleName ).hasMatch() ) { if ( searchString == dsFilter ) { @@ -184,13 +186,14 @@ std::pair, std::vector> { // Match on subset of realisations in ensemble - QString realizationSearchString = dsFilter.right( dsFilter.size() - dsFilter.indexOf( ':' ) - 1 ); - QRegExp realizationSearcher( realizationSearchString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); + QString realizationSearchString = dsFilter.right( dsFilter.size() - dsFilter.indexOf( ':' ) - 1 ); + QString regexPattern = QRegularExpression::wildcardToRegularExpression( realizationSearchString ); + QRegularExpression realizationSearcher( regexPattern, QRegularExpression::CaseInsensitiveOption ); for ( const auto& summaryCase : ensemble->allSummaryCases() ) { auto realizationName = summaryCase->displayCaseName(); - if ( realizationSearcher.exactMatch( realizationName ) ) + if ( realizationSearcher.match( realizationName ).hasMatch() ) { matchingSummaryCases.push_back( summaryCase ); } @@ -202,7 +205,7 @@ std::pair, std::vector> for ( const auto& summaryCase : allSummaryCases ) { auto summaryCaseName = summaryCase->displayCaseName(); - if ( searcher.exactMatch( summaryCaseName ) ) + if ( searcher.match( summaryCaseName ).hasMatch() ) { matchingSummaryCases.push_back( summaryCase ); } @@ -217,7 +220,7 @@ std::pair, std::vector> //-------------------------------------------------------------------------------------------------- QStringList RiaSummaryStringTools::splitIntoWords( const QString& text ) { - return RiaTextStringTools::splitSkipEmptyParts( text, QRegExp( "\\s+" ) ); + return RiaTextStringTools::splitSkipEmptyParts( text ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index bd2c1cdb61..e76de70324 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -36,7 +36,6 @@ find_package( PrintSupport Svg Sql - Core5Compat OPTIONAL_COMPONENTS Charts ) set(QT_LIBRARIES @@ -51,7 +50,6 @@ set(QT_LIBRARIES Qt6::PrintSupport Qt6::Svg Qt6::Sql - Qt6::Core5Compat Qt6::Charts ) qt_standard_project_setup() diff --git a/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp b/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp index 67436ada78..4b85800c38 100644 --- a/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp +++ b/ApplicationLibCode/Commands/RicCalculatorWidgetCreator.cpp @@ -152,8 +152,8 @@ QWidget* RicCalculatorWidgetCreator::createWidget( QWidget* parent ) rowSplitter->setContentsMargins( 0, 0, 0, 0 ); rowSplitter->setHandleWidth( 6 ); rowSplitter->setStyleSheet( "QSplitter::handle { image: url(:/SplitterV.png); }" ); - rowSplitter->insertWidget( 0, firstRowLeftFrame ); - rowSplitter->insertWidget( 1, firstRowRightFrame ); + rowSplitter->addWidget( firstRowLeftFrame ); + rowSplitter->addWidget( firstRowRightFrame ); rowSplitter->setSizes( QList() << 1 << 1 ); firstRowLayout->addWidget( rowSplitter ); diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp index fc46dd7cf4..09ef5657e4 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorWidgetCreator.cpp @@ -105,16 +105,16 @@ void RicSummaryPlotEditorWidgetCreator::recursivelyConfigureAndUpdateTopLevelUiO caf::PdmUiGroup* appearanceGroup = findGroupByKeyword( topLevelUiItems, RiuSummaryCurveDefinitionKeywords::appearance(), uiConfigName ); auto appearanceGroupBox = createGroupBoxWithContent( appearanceGroup, uiConfigName ); - m_lowerLeftLayout->insertWidget( 0, appearanceGroupBox ); + m_lowerLeftLayout->addWidget( appearanceGroupBox ); caf::PdmUiGroup* nameConfigGroup = findGroupByKeyword( topLevelUiItems, RiuSummaryCurveDefinitionKeywords::nameConfig(), uiConfigName ); auto nameConfigGroupBox = createGroupBoxWithContent( nameConfigGroup, uiConfigName ); - m_lowerLeftLayout->insertWidget( 1, nameConfigGroupBox ); + m_lowerLeftLayout->addWidget( nameConfigGroupBox ); QMinimizePanel* curveGroup = getOrCreateCurveTreeGroup(); - m_lowerLeftLayout->insertWidget( 2, curveGroup, 1 ); + m_lowerLeftLayout->addWidget( curveGroup, 1 ); m_lowerLeftLayout->addStretch( 0 ); - m_lowerRightLayout->insertWidget( 0, getOrCreatePlotWidget() ); + m_lowerRightLayout->addWidget( getOrCreatePlotWidget() ); // Fields at bottom of dialog configureAndUpdateFields( 1, m_bottomFieldLayout, topLevelUiItems, uiConfigName ); @@ -155,8 +155,8 @@ QWidget* RicSummaryPlotEditorWidgetCreator::createWidget( QWidget* parent ) m_firstColumnSplitter->setHandleWidth( 6 ); m_firstColumnSplitter->setStyleSheet( "QSplitter::handle { image: url(:/SplitterH.png); }" ); - m_firstColumnSplitter->insertWidget( 0, firstRowFrame ); - m_firstColumnSplitter->insertWidget( 1, secondRowFrame ); + m_firstColumnSplitter->addWidget( firstRowFrame ); + m_firstColumnSplitter->addWidget( secondRowFrame ); const int firstRowPixelHeight = 500; const int secondRowPixelHeight = 300; diff --git a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp index ba945f1cd2..c5156b8fcd 100644 --- a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp +++ b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -121,7 +121,7 @@ void RifCaseRealizationParametersReader::parse() QString line = dataStream.readLine(); lineNo++; - QStringList cols = RifFileParseTools::splitLineAndTrim( line, QRegExp( "[ \t]" ), true ); + QStringList cols = RifFileParseTools::splitLineAndTrim( line, QRegularExpression( "[ \t]" ), true ); if ( cols.size() != 2 ) { @@ -287,22 +287,22 @@ int RifCaseRealizationParametersFileLocator::realizationNumber( const QString& m QDir dir( modelPath ); QString absolutePath = dir.absolutePath(); + return realizationNumberFromFullPath( absolutePath ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifCaseRealizationParametersFileLocator::realizationNumberFromFullPath( const QString& path ) +{ int resultIndex = -1; - // Use parenthesis to indicate capture of sub string - QString pattern = "(realization-\\d+)"; + QRegularExpression pattern( "realization-(\\d+)", QRegularExpression::CaseInsensitiveOption ); + QRegularExpressionMatch match = pattern.match( path ); - QRegExp regexp( pattern, Qt::CaseInsensitive ); - if ( regexp.indexIn( absolutePath ) ) + if ( match.hasMatch() ) { - QString tempText = regexp.cap( 1 ); - - QRegExp rx( "(\\d+)" ); // Find number - int digitPos = rx.indexIn( tempText ); - if ( digitPos > -1 ) - { - resultIndex = rx.cap( 0 ).toInt(); - } + resultIndex = match.captured( 1 ).toInt(); } return resultIndex; diff --git a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h index 231a3fa6f1..8dc6302d6c 100644 --- a/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h +++ b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.h @@ -94,4 +94,5 @@ class RifCaseRealizationParametersFileLocator public: static QString locate( const QString& modelPath ); static int realizationNumber( const QString& modelPath ); + static int realizationNumberFromFullPath( const QString& path ); }; diff --git a/ApplicationLibCode/FileInterface/RifColorLegendData.cpp b/ApplicationLibCode/FileInterface/RifColorLegendData.cpp index 4713c43bd8..e6957f3fb2 100644 --- a/ApplicationLibCode/FileInterface/RifColorLegendData.cpp +++ b/ApplicationLibCode/FileInterface/RifColorLegendData.cpp @@ -91,7 +91,7 @@ cvf::ref RifColorLegendData::readLyrFormationNameFile( const if ( QColor::isValidColorName( colorWord ) ) numberString.remove( colorWord ); // remove color if present as last word on line // extract words containing formation number(s) - QStringList numberWords = RiaTextStringTools::splitSkipEmptyParts( numberString, QRegExp( "-" ) ); + QStringList numberWords = RiaTextStringTools::splitSkipEmptyParts( numberString, QRegularExpression( "-" ) ); if ( numberWords.size() == 2 ) // formation range with or without color at end of line { diff --git a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp index 048ae252ad..8f2250ffd3 100644 --- a/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationLibCode/FileInterface/RifCsvUserDataParser.cpp @@ -392,11 +392,12 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream* // "VECTOR_NAME [unit]" { // "VECTORNAME (unit)" ==> "(unit)" - QRegExp exp( "[[]([^]]+)[]]" ); - if ( exp.indexIn( colName ) >= 0 ) + QRegularExpression exp( R"(\[([^\]]+)\])" ); + QRegularExpressionMatch match = exp.match( colName ); + if ( match.hasMatch() ) { - QString fullCapture = exp.cap( 0 ); - QString unitCapture = exp.cap( 1 ); + QString fullCapture = match.captured( 0 ); + QString unitCapture = match.captured( 1 ); unit = unitCapture; colName = RiaTextStringTools::trimAndRemoveDoubleSpaces( colName.remove( fullCapture ) ); @@ -405,11 +406,12 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream* { // "VECTOR_NAME [unit]" ==> "[unit]" - QRegExp exp( "[(]([^)]+)[)]" ); - if ( exp.indexIn( colName ) >= 0 ) + QRegularExpression exp( R"(\(([^)]+)\))" ); + QRegularExpressionMatch match = exp.match( colName ); + if ( match.hasMatch() ) { - QString fullCapture = exp.cap( 0 ); - QString unitCapture = exp.cap( 1 ); + QString fullCapture = match.captured( 0 ); + QString unitCapture = match.captured( 1 ); unit = unitCapture; colName = RiaTextStringTools::trimAndRemoveDoubleSpaces( colName.remove( fullCapture ) ); diff --git a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp index c13e4e6060..13d151f24d 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseInputFileTools.cpp @@ -1419,31 +1419,31 @@ void RifEclipseInputFileTools::readKeywordDataContent( QFile& data, qint64 fileP QString line = data.readLine(); line = line.trimmed(); - if ( line.startsWith( "--", Qt::CaseInsensitive ) ) - { - // Skip comment lines - continue; - } - else if ( line.startsWith( "/", Qt::CaseInsensitive ) ) - { - // Detected end of keyword data section - return; - } - else if ( line.startsWith( editKeyword, Qt::CaseInsensitive ) ) + if ( !line.isEmpty() ) { - // End parsing when edit keyword is detected - isStopParsingKeywordDetected = true; + if ( line.startsWith( "--", Qt::CaseInsensitive ) ) + { + // Skip comment lines + continue; + } + else if ( line.startsWith( "/", Qt::CaseInsensitive ) ) + { + // Detected end of keyword data section + return; + } + else if ( line.startsWith( editKeyword, Qt::CaseInsensitive ) ) + { + // End parsing when edit keyword is detected + isStopParsingKeywordDetected = true; - return; - } - else if ( line[0].isLetter() ) - { - // If a letter is starting the line, this is a new keyword - return; - } + return; + } + else if ( line[0].isLetter() ) + { + // If a letter is starting the line, this is a new keyword + return; + } - if ( !line.isEmpty() ) - { textContent.push_back( line ); } diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp index 224620949e..bdb0131efd 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -24,7 +24,6 @@ #include "RifEclEclipseSummary.h" #include "RiuSummaryQuantityNameInfoProvider.h" -#include #include #include @@ -190,8 +189,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromEclipseTextAddressParseEr if ( tokens.size() > 1 ) { - auto firstToken = RiaStdStringTools::trimString( tokens[0] ); - firstToken = RiaStdStringTools::toUpper( firstToken ); + auto firstToken = RiaStdStringTools::toUpper( RiaStdStringTools::trimString( tokens[0] ) ); if ( ( firstToken == "ER" ) || ( firstToken == "ERR" ) || ( firstToken == "ERROR" ) ) { @@ -783,9 +781,10 @@ bool RifEclipseSummaryAddress::isUiTextMatchingFilterText( const QString& filter if ( filterString.isEmpty() ) return true; if ( filterString.trimmed() == "*" ) return !value.empty(); - QRegExp searcher( filterString, Qt::CaseInsensitive, QRegExp::WildcardUnix ); - QString qstrValue = QString::fromStdString( value ); - return searcher.exactMatch( qstrValue ); + QString pattern = QRegularExpression::wildcardToRegularExpression( filterString ); + QRegularExpression searcher( pattern, QRegularExpression::CaseInsensitiveOption ); + QString qstrValue = QString::fromStdString( value ); + return searcher.match( qstrValue ).hasMatch(); } //-------------------------------------------------------------------------------------------------- @@ -1226,7 +1225,7 @@ std::string RifEclipseSummaryAddress::blockAsString() const //-------------------------------------------------------------------------------------------------- std::tuple RifEclipseSummaryAddress::ijkTupleFromUiText( const std::string& s ) { - auto ijk = RiaTextStringTools::splitSkipEmptyParts( QString::fromStdString( s ).trimmed(), QRegExp( "[,]" ) ); + auto ijk = RiaTextStringTools::splitSkipEmptyParts( QString::fromStdString( s ).trimmed(), QRegularExpression( "[,]" ) ); if ( ijk.size() != 3 ) return std::make_tuple( -1, -1, -1 ); @@ -1248,7 +1247,7 @@ std::string RifEclipseSummaryAddress::formatUiTextRegionToRegion() const //-------------------------------------------------------------------------------------------------- std::pair RifEclipseSummaryAddress::regionToRegionPairFromUiText( const std::string& s ) { - auto r2r = RiaTextStringTools::splitSkipEmptyParts( QString::fromStdString( s ).trimmed(), QRegExp( "[-]" ) ); + auto r2r = RiaTextStringTools::splitSkipEmptyParts( QString::fromStdString( s ).trimmed(), QRegularExpression( "[-]" ) ); if ( r2r.size() != 2 ) return std::make_pair( -1, -1 ); diff --git a/ApplicationLibCode/FileInterface/RifFileParseTools.cpp b/ApplicationLibCode/FileInterface/RifFileParseTools.cpp index 963e45b2dc..64dbdc702f 100644 --- a/ApplicationLibCode/FileInterface/RifFileParseTools.cpp +++ b/ApplicationLibCode/FileInterface/RifFileParseTools.cpp @@ -19,14 +19,6 @@ #include "RifFileParseTools.h" #include "RiaTextStringTools.h" -// Disable deprecation warning for QString::SkipEmptyParts -#ifdef _MSC_VER -#pragma warning( disable : 4996 ) -#endif -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -43,7 +35,7 @@ QStringList RifFileParseTools::splitLineAndTrim( const QString& line, const QStr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RifFileParseTools::splitLineAndTrim( const QString& line, const QRegExp& regexp, bool skipEmptyParts ) +QStringList RifFileParseTools::splitLineAndTrim( const QString& line, const QRegularExpression& regexp, bool skipEmptyParts ) { auto cols = RiaTextStringTools::splitString( line.trimmed(), regexp, skipEmptyParts ); for ( QString& col : cols ) diff --git a/ApplicationLibCode/FileInterface/RifFileParseTools.h b/ApplicationLibCode/FileInterface/RifFileParseTools.h index 378d005b74..3008497398 100644 --- a/ApplicationLibCode/FileInterface/RifFileParseTools.h +++ b/ApplicationLibCode/FileInterface/RifFileParseTools.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include @@ -29,7 +29,7 @@ class RifFileParseTools { public: static QStringList splitLineAndTrim( const QString& line, const QString& separator, bool skipEmptyParts = false ); - static QStringList splitLineAndTrim( const QString& line, const QRegExp& regexp, bool skipEmptyParts = false ); + static QStringList splitLineAndTrim( const QString& line, const QRegularExpression& regexp, bool skipEmptyParts = false ); }; //================================================================================================== diff --git a/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp b/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp index ef8d568474..0b40a14dd3 100644 --- a/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp +++ b/ApplicationLibCode/FileInterface/RifPerforationIntervalReader.cpp @@ -32,7 +32,7 @@ std::map> RifPerforationIntervalRea { std::map> perforationIntervals; - foreach ( QString filePath, filePaths ) + for ( const QString& filePath : filePaths ) { readFileIntoMap( filePath, &perforationIntervals ); } diff --git a/ApplicationLibCode/FileInterface/RifPolygonReader.cpp b/ApplicationLibCode/FileInterface/RifPolygonReader.cpp index 5b1a652e5d..a5ed3905c7 100644 --- a/ApplicationLibCode/FileInterface/RifPolygonReader.cpp +++ b/ApplicationLibCode/FileInterface/RifPolygonReader.cpp @@ -79,7 +79,7 @@ std::vector> RifPolygonReader::parseText( const QString& QStringList commentLineSegs = line.split( "#" ); if ( commentLineSegs.empty() ) continue; // Empty line - QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegExp( "\\s+" ) ); + QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegularExpression( "\\s+" ) ); if ( lineSegs.empty() ) continue; // No data diff --git a/ApplicationLibCode/FileInterface/RifWellPathImporter.cpp b/ApplicationLibCode/FileInterface/RifWellPathImporter.cpp index 80d6c595ac..c18ccf9fef 100644 --- a/ApplicationLibCode/FileInterface/RifWellPathImporter.cpp +++ b/ApplicationLibCode/FileInterface/RifWellPathImporter.cpp @@ -161,7 +161,7 @@ RifWellPathImporter::WellData RifWellPathImporter::readJsonWellData( const QStri wellData.m_wellPathGeometry->setDatumElevation( datumElevation ); wellData.m_name = jsonMap["name"].toString(); - foreach ( QVariant point, pathList ) + for ( const QVariant& point : pathList ) { QMap coordinateMap = point.toMap(); cvf::Vec3d vec3d( coordinateMap["east"].toDouble(), diff --git a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp index ca7a0c6efc..56f18ea3b4 100644 --- a/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp +++ b/ApplicationLibCode/ProjectDataModel/Annotations/RimPolylinesFromFileAnnotation.cpp @@ -91,7 +91,7 @@ void RimPolylinesFromFileAnnotation::readPolyLinesFile( QString* errorMessage ) QStringList commentLineSegs = line.split( "#" ); if ( commentLineSegs.empty() ) continue; // Empty line - QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegExp( "\\s+" ) ); + QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegularExpression( "\\s+" ) ); if ( lineSegs.empty() ) continue; // No data diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp index 38e292d358..332c42ce57 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp @@ -264,10 +264,9 @@ QString RimWellPathCompletionSettings::fluidInPlaceRegionForExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QRegExp RimWellPathCompletionSettings::wellNameForExportRegExp() +QRegularExpression RimWellPathCompletionSettings::wellNameForExportRegExp() { - QRegExp rx( "[\\w\\-\\_]{1,8}" ); - return rx; + return QRegularExpression( "[\\w\\-\\_]{1,8}" ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h index b5866fe875..876492a576 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.h @@ -22,7 +22,7 @@ #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" -#include +#include class RimMswCompletionParameters; class RimWellPathCompletionsLegacy; @@ -84,7 +84,7 @@ class RimWellPathCompletionSettings : public caf::PdmObject QString hydrostaticDensityForExport() const; QString fluidInPlaceRegionForExport() const; - static QRegExp wellNameForExportRegExp(); + static QRegularExpression wellNameForExportRegExp(); RimMswCompletionParameters* mswCompletionParameters() const; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp index 9aa90a641f..00d27d02ab 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dView.cpp @@ -21,20 +21,16 @@ #include "RiaApplication.h" #include "RiaFieldHandleTools.h" -#include "RiaGuiApplication.h" #include "RiaOptionItemFactory.h" #include "RiaPreferences.h" #include "RiaPreferencesSystem.h" #include "RiaViewRedrawScheduler.h" -#include "RicfCommandObject.h" - #include "Rim2dIntersectionView.h" #include "Rim3dWellLogCurve.h" #include "RimAnnotationCollection.h" #include "RimAnnotationInViewCollection.h" #include "RimCase.h" -#include "RimCellFilterCollection.h" #include "RimGridView.h" #include "RimLegendConfig.h" #include "RimMainPlotCollection.h" @@ -45,7 +41,6 @@ #include "RimTools.h" #include "RimViewController.h" #include "RimViewLinker.h" -#include "RimViewLinkerCollection.h" #include "RimViewManipulator.h" #include "RimViewNameConfig.h" #include "RimWellPathCollection.h" @@ -63,7 +58,6 @@ #include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapabilityCvfColor3.h" #include "cafPdmUiComboBoxEditor.h" - #include "cvfCamera.h" #include "cvfModelBasicList.h" #include "cvfPart.h" @@ -190,44 +184,6 @@ Rim3dView::Rim3dView() //-------------------------------------------------------------------------------------------------- Rim3dView::~Rim3dView() { - // When a 3d view is destructed, make sure that all other views using this as a comparison view is reset and - // redrawn. A crash was seen for test case - // "\ResInsight-regression-test\ProjectFiles\ProjectFilesSmallTests\TestCase_CoViz-Simple" when a view used as - // comparison view was deleted. - - if ( auto proj = RimProject::current() ) - { - for ( auto v : proj->allViews() ) - { - if ( v->activeComparisonView() == this ) - { - v->setComparisonView( nullptr ); - v->scheduleCreateDisplayModelAndRedraw(); - } - } - - if ( this->isMasterView() ) - { - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - viewLinker->setMasterView( nullptr ); - - delete proj->viewLinkerCollection->viewLinker(); - proj->viewLinkerCollection->viewLinker = nullptr; - - proj->uiCapability()->updateConnectedEditors(); - } - - RimViewController* vController = this->viewController(); - if ( vController ) - { - vController->setManagedView( nullptr ); - vController->ownerViewLinker()->removeViewController( vController ); - delete vController; - - proj->uiCapability()->updateConnectedEditors(); - } - } - if ( RiaApplication::instance()->activeReservoirView() == this ) { RiaApplication::instance()->setActiveReservoirView( nullptr ); diff --git a/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp index a9e45617b6..f5c806a41f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewLinker.cpp @@ -518,6 +518,8 @@ void RimViewLinker::updateCursorPosition( const Rim3dView* sourceView, const cvf for ( Rim3dView* destinationView : viewsToUpdate ) { + if ( !destinationView ) continue; + if ( destinationView == sourceView ) continue; if ( destinationView != m_masterView ) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp index 8572c593ca..a13716691f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlotManager.cpp @@ -500,7 +500,7 @@ std::set RimSummaryPlotManager::filteredAddresses() if ( nativeAddresses.empty() ) return {}; - QStringList allCurveAddressFilters = RiaTextStringTools::splitSkipEmptyParts( m_filterText(), QRegExp( "\\s+" ) ); + QStringList allCurveAddressFilters = RiaTextStringTools::splitSkipEmptyParts( m_filterText(), QRegularExpression( "\\s+" ) ); return RiaSummaryStringTools::computeFilteredAddresses( allCurveAddressFilters, nativeAddresses, m_includeDiffCurves ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp index c6c69e8db8..09bd3f4ef9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -397,7 +397,7 @@ std::vector RimWellPathCollection::addWellLogs( const QStrin std::vector logFileInfos; - foreach ( QString filePath, filePaths ) + for ( const QString& filePath : filePaths ) { QString errorMessage; RimWellLogLasFile* logFileInfo = RimWellLogLasFile::readWellLogFile( filePath, &errorMessage ); @@ -943,13 +943,14 @@ std::map> { std::map> rootWells; - QString multiLateralWellPathPattern = RiaPreferences::current()->multiLateralWellNamePattern(); - QRegExp re( multiLateralWellPathPattern, Qt::CaseInsensitive, QRegExp::Wildcard ); + QString multiLateralWellPathPattern = RiaPreferences::current()->multiLateralWellNamePattern(); + QString regexPattern = QRegularExpression::wildcardToRegularExpression( multiLateralWellPathPattern ); + QRegularExpression re( regexPattern, QRegularExpression::CaseInsensitiveOption ); for ( auto wellPath : sourceWellPaths ) { QString name = wellPath->name(); - if ( re.exactMatch( name ) ) + if ( re.match( name ).hasMatch() ) { int indexOfLateralStart = name.indexOf( 'Y' ); if ( indexOfLateralStart > 0 ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 6897c90bf8..222a9ddd03 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -29,7 +29,7 @@ #include "RigWellResultFrame.h" #include "RigWellResultPoint.h" -#include +#include /* rand example: guess the number */ #include @@ -147,11 +147,11 @@ bool RigReservoirBuilderMock::dynamicResult( RigEclipseCaseData* eclipseCase, co { int resultIndex = 1; - QRegExp rx( "[0-9]{1,2}" ); // Find number 0-99 - int digitPos = rx.indexIn( result ); - if ( digitPos > -1 ) + QRegularExpression rx( "[0-9]{1,2}" ); // Find number 0-99 + QRegularExpressionMatch match = rx.match( result ); + if ( match.hasMatch() ) { - resultIndex = rx.cap( 0 ).toInt() + 1; + resultIndex = match.captured( 0 ).toInt() + 1; } double scaleValue = 1.0 + resultIndex * 0.1; diff --git a/ApplicationLibCode/UnitTests/RiaMedianCalculator-Test.h b/ApplicationLibCode/UnitTests/RiaMedianCalculator-Test.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ApplicationLibCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp b/ApplicationLibCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp index 660544b3d2..d6b212aa86 100644 --- a/ApplicationLibCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp @@ -70,7 +70,7 @@ TEST( RifCaseRealizationParametersReaderTest, FindRealizationNumber ) QString filePath = "d:/gitroot-ceesol/ResInsight-regression-test/ModelData/ensemble_reek_with_params/realization-" "7/iter-0/eclipse/model/3_R001_REEK-7.SMSPEC"; - int realisationNumber = RifCaseRealizationParametersFileLocator::realizationNumber( filePath ); + int realisationNumber = RifCaseRealizationParametersFileLocator::realizationNumberFromFullPath( filePath ); EXPECT_EQ( 7, realisationNumber ); } diff --git a/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp b/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp index 4fc7da0395..60f16ea6c2 100644 --- a/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifEclipseInputFileTools-Test.cpp @@ -25,7 +25,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << "i+"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::POS_I, faceType ); @@ -40,7 +40,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << "i-"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::NEG_I, faceType ); @@ -59,7 +59,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << "j+"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::POS_J, faceType ); @@ -74,7 +74,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << "j-"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::NEG_J, faceType ); @@ -93,7 +93,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << "k+"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::POS_K, faceType ); @@ -108,7 +108,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << "k-"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::NEG_K, faceType ); @@ -124,7 +124,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << " y /"; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_NE( cvf::StructGridInterface::NO_FACE, faceType ); @@ -139,7 +139,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << " +k- "; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::NO_FACE, faceType ); @@ -155,7 +155,7 @@ TEST( RifEclipseInputFileToolsTest, FaultFaces ) << " i+ "; cvf::StructGridInterface::FaceEnum faceType; - foreach ( QString text, faceTexts ) + for ( const QString& text : faceTexts ) { faceType = RifEclipseInputFileTools::faceEnumFromText( text ); EXPECT_EQ( cvf::StructGridInterface::POS_I, faceType ); diff --git a/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp b/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp index 5eadf20be0..dcc55d286a 100644 --- a/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp +++ b/ApplicationLibCode/UnitTests/RifTextDataTableFormatter-Test.cpp @@ -108,7 +108,7 @@ TEST( RifTextDataTableFormatter, LongLine ) formatter.rowCompleted(); formatter.tableCompleted(); - QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) ); + QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegularExpression( "[\r\n]" ) ); for ( QString line : tableLines ) { std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl; @@ -155,7 +155,7 @@ TEST( RifTextDataTableFormatter, LongLine132 ) formatter.rowCompleted(); formatter.tableCompleted(); - QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) ); + QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegularExpression( "[\r\n]" ) ); for ( QString line : tableLines ) { std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl; @@ -202,7 +202,7 @@ TEST( RifTextDataTableFormatter, LongLine133 ) formatter.rowCompleted(); formatter.tableCompleted(); - QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) ); + QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegularExpression( "[\r\n]" ) ); for ( QString line : tableLines ) { std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl; diff --git a/ApplicationLibCode/UserInterface/RiuGuiTheme.cpp b/ApplicationLibCode/UserInterface/RiuGuiTheme.cpp index 4f7fb46b2c..76bc1087a8 100644 --- a/ApplicationLibCode/UserInterface/RiuGuiTheme.cpp +++ b/ApplicationLibCode/UserInterface/RiuGuiTheme.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -57,8 +56,8 @@ QMap RiuGuiTheme: "\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ), []( QRegularExpressionMatch& match ) { - QRegExp plotNameRegExp( match.captured( "plotName" ) ); - QRegExp itemNameRegExp( match.captured( "itemName" ) ); + QRegularExpression plotNameRegExp = QRegularExpression::fromWildcard( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp = QRegularExpression::fromWildcard( match.captured( "itemName" ) ); QRegularExpression lineColorRegExp( "line-color:\\s*([#0-9a-zA-Z]+)" ); QString lineColor = lineColorRegExp.match( match.captured( "properties" ) ).captured( 1 ); @@ -84,13 +83,13 @@ QMap RiuGuiTheme: { for ( QwtPlot* plotWidget : widget->findChildren() ) { - if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) ) + if ( plotNameRegExp.match( plotWidget->property( "qss-class" ).toString() ).hasMatch() ) { for ( QwtPlotItem* item : plotWidget->itemList() ) { if ( QwtPlotCurve* curve = dynamic_cast( item ) ) { - if ( itemNameRegExp.exactMatch( item->title().text() ) || match.captured( "itemName" ) == "*" ) + if ( itemNameRegExp.match( item->title().text() ).hasMatch() || match.captured( "itemName" ) == "*" ) { QPen pen = curve->pen(); pen.setColor( QColor( lineColor ) ); @@ -117,8 +116,8 @@ QMap RiuGuiTheme: "\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ), []( QRegularExpressionMatch& match ) { - QRegExp plotNameRegExp( match.captured( "plotName" ) ); - QRegExp itemNameRegExp( match.captured( "itemName" ) ); + QRegularExpression plotNameRegExp = QRegularExpression::fromWildcard( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp = QRegularExpression::fromWildcard( match.captured( "itemName" ) ); QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" ); QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 ); const QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); @@ -131,13 +130,14 @@ QMap RiuGuiTheme: { for ( QwtPlot* plotWidget : widget->findChildren() ) { - if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) || match.captured( "plotName" ) == "*" ) + if ( plotNameRegExp.match( plotWidget->property( "qss-class" ).toString() ).hasMatch() || + match.captured( "plotName" ) == "*" ) { for ( QwtPlotItem* item : plotWidget->itemList() ) { if ( QwtPlotGrid* grid = dynamic_cast( item ) ) { - if ( itemNameRegExp.exactMatch( item->title().text() ) || match.captured( "itemName" ) == "*" ) + if ( itemNameRegExp.match( item->title().text() ).hasMatch() || match.captured( "itemName" ) == "*" ) { QPen pen = grid->majorPen(); pen.setColor( QColor( color ) ); @@ -155,8 +155,8 @@ QMap RiuGuiTheme: "\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ), []( QRegularExpressionMatch& match ) { - QRegExp plotNameRegExp( match.captured( "plotName" ) ); - QRegExp itemNameRegExp( match.captured( "itemName" ) ); + QRegularExpression plotNameRegExp = QRegularExpression::fromWildcard( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp = QRegularExpression::fromWildcard( match.captured( "itemName" ) ); QRegularExpression colorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" ); QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 ); const QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); @@ -169,7 +169,8 @@ QMap RiuGuiTheme: { for ( QwtPlot* plotWidget : widget->findChildren() ) { - if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) || match.captured( "plotName" ) == "*" ) + if ( plotNameRegExp.match( plotWidget->property( "qss-class" ).toString() ).hasMatch() || + match.captured( "plotName" ) == "*" ) { for ( QwtLegendLabel* label : plotWidget->findChildren() ) { @@ -189,8 +190,8 @@ QMap RiuGuiTheme: "\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ), []( QRegularExpressionMatch& match ) { - QRegExp plotNameRegExp( match.captured( "plotName" ) ); - QRegExp itemNameRegExp( match.captured( "itemName" ) ); + QRegularExpression plotNameRegExp = QRegularExpression::fromWildcard( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp = QRegularExpression::fromWildcard( match.captured( "itemName" ) ); QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" ); QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 ); QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" ); @@ -214,7 +215,8 @@ QMap RiuGuiTheme: { for ( QwtPlot* plotWidget : widget->findChildren() ) { - if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) || match.captured( "plotName" ) == "*" ) + if ( plotNameRegExp.match( plotWidget->property( "qss-class" ).toString() ).hasMatch() || + match.captured( "plotName" ) == "*" ) { for ( QwtPlotItem* item : plotWidget->itemList() ) { @@ -222,7 +224,7 @@ QMap RiuGuiTheme: { if ( marker->symbol() == nullptr || marker->symbol()->style() == QwtSymbol::NoSymbol ) { - if ( itemNameRegExp.exactMatch( item->title().text() ) || match.captured( "itemName" ) == "*" ) + if ( itemNameRegExp.match( item->title().text() ).hasMatch() || match.captured( "itemName" ) == "*" ) { QPen pen = marker->linePen(); pen.setColor( QColor( color ) ); @@ -243,8 +245,8 @@ QMap RiuGuiTheme: "\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ), []( QRegularExpressionMatch& match ) { - QRegExp plotNameRegExp( match.captured( "plotName" ) ); - QRegExp itemNameRegExp( match.captured( "itemName" ) ); + QRegularExpression plotNameRegExp = QRegularExpression::fromWildcard( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp = QRegularExpression::fromWildcard( match.captured( "itemName" ) ); QRegularExpression colorRegExp( "color:\\s*([#0-9a-zA-Z]+)" ); QString color = colorRegExp.match( match.captured( "properties" ) ).captured( 1 ); QRegularExpression textColorRegExp( "text-color:\\s*([#0-9a-zA-Z]+)" ); @@ -268,7 +270,8 @@ QMap RiuGuiTheme: { for ( QwtPlot* plotWidget : widget->findChildren() ) { - if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) || match.captured( "plotName" ) == "*" ) + if ( plotNameRegExp.match( plotWidget->property( "qss-class" ).toString() ).hasMatch() || + match.captured( "plotName" ) == "*" ) { for ( QwtPlotItem* item : plotWidget->itemList() ) { @@ -276,7 +279,7 @@ QMap RiuGuiTheme: { if ( marker->symbol() && marker->symbol()->style() != QwtSymbol::NoSymbol ) { - if ( itemNameRegExp.exactMatch( item->title().text() ) || match.captured( "itemName" ) == "*" ) + if ( itemNameRegExp.match( item->title().text() ).hasMatch() || match.captured( "itemName" ) == "*" ) { QPen pen = marker->symbol()->pen(); pen.setColor( QColor( color ) ); @@ -299,8 +302,8 @@ QMap RiuGuiTheme: "\\s*([a-zA-Z0-9#]+)\\s*;))*)[\\n\\r]*\\s*\\}" ), []( QRegularExpressionMatch& match ) { - QRegExp plotNameRegExp( match.captured( "plotName" ) ); - QRegExp itemNameRegExp( match.captured( "itemName" ) ); + QRegularExpression plotNameRegExp = QRegularExpression::fromWildcard( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp = QRegularExpression::fromWildcard( match.captured( "itemName" ) ); QRegularExpression textColorRegExp( "text-color:\\s*([#a-zA-Z0-9]+)" ); QString textColor = textColorRegExp.match( match.captured( "properties" ) ).captured( 1 ); @@ -314,7 +317,8 @@ QMap RiuGuiTheme: { for ( QwtPlot* plotWidget : widget->findChildren() ) { - if ( plotNameRegExp.exactMatch( plotWidget->property( "qss-class" ).toString() ) || match.captured( "plotName" ) == "*" ) + if ( plotNameRegExp.match( plotWidget->property( "qss-class" ).toString() ).hasMatch() || + match.captured( "plotName" ) == "*" ) { QWidget* canvas = plotWidget->canvas(); if ( canvas ) diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp index 566a720f5e..ff98639628 100644 --- a/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp @@ -433,12 +433,11 @@ void RiuQtChartsPlotWidget::setAutoTickIntervalCounts( RiuPlotAxis axis, int max //-------------------------------------------------------------------------------------------------- double RiuQtChartsPlotWidget::majorTickInterval( RiuPlotAxis axis ) const { -#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 ) - // QValueAxis::tickInterval was introduced in 5.12 - QAbstractAxis* ax = plotAxis( axis ); - QValueAxis* valueAxis = dynamic_cast( ax ); - if ( valueAxis ) return valueAxis->tickInterval(); -#endif + if ( QValueAxis* valueAxis = dynamic_cast( plotAxis( axis ) ) ) + { + return valueAxis->tickInterval(); + } + return 0.0; } diff --git a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp index beafa7a200..8ceefe88c5 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryVectorSelectionWidgetCreator.cpp @@ -129,8 +129,8 @@ QWidget* RiuSummaryVectorSelectionWidgetCreator::createWidget( QWidget* parent ) rowSplitter->setContentsMargins( 0, 0, 0, 0 ); rowSplitter->setHandleWidth( 6 ); rowSplitter->setStyleSheet( "QSplitter::handle { image: url(:/SplitterV.png); }" ); - rowSplitter->insertWidget( 0, firstRowLeftFrame ); - rowSplitter->insertWidget( 1, firstRowRightFrame ); + rowSplitter->addWidget( firstRowLeftFrame ); + rowSplitter->addWidget( firstRowRightFrame ); rowSplitter->setSizes( QList() << 1 << 1 ); firstRowLayout->addWidget( rowSplitter ); diff --git a/ApplicationLibCode/UserInterface/RiuTextDialog.cpp b/ApplicationLibCode/UserInterface/RiuTextDialog.cpp index 7829f4e18d..fa22df1378 100644 --- a/ApplicationLibCode/UserInterface/RiuTextDialog.cpp +++ b/ApplicationLibCode/UserInterface/RiuTextDialog.cpp @@ -211,11 +211,7 @@ RiuTabbedTextDialog::RiuTabbedTextDialog( RiuTabbedTextProvider* textProvider, Q textEdit->setContextMenuPolicy( Qt::NoContextMenu ); auto fontWidth = QFontMetrics( font ).boundingRect( "m" ).width(); -#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 ) textEdit->setTabStopDistance( fontWidth * 4 ); -#else - textEdit->setTabStopWidth( fontWidth * 4 ); -#endif m_tabWidget->addTab( textEdit, tabTitle ); } diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d87519208..3a4dc75f1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -550,19 +550,15 @@ find_package( Network Widgets Charts - Core5Compat ) -set(QT_LIBRARIES - Qt6::Core - Qt6::Gui - Qt6::OpenGL - Qt6::Network - Qt6::Widgets - Qt6::Charts - Qt6::Core5Compat +set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::Network Qt6::Widgets + Qt6::Charts ) qt_standard_project_setup() +# Disable use of foreach +add_definitions(-DQT_NO_FOREACH) + # Open GL find_package(OpenGL) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp index 67cb44948d..3bc29528df 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp @@ -72,7 +72,7 @@ void NotificationCenter::notifyObserversOfDataChange( caf::PdmObjectHandle* item { CAF_ASSERT( itemThatChanged ); - foreach ( DataModelObserver* o, m_observers ) + for ( DataModelObserver* o : m_observers ) { o->handleModelNotification( itemThatChanged ); } @@ -83,7 +83,7 @@ void NotificationCenter::notifyObserversOfDataChange( caf::PdmObjectHandle* item //-------------------------------------------------------------------------------------------------- void NotificationCenter::notifyObservers() { - foreach ( DataModelObserver* o, m_observers ) + for ( DataModelObserver* o : m_observers ) { o->handleModelNotification( nullptr ); } @@ -94,7 +94,7 @@ void NotificationCenter::notifyObservers() //-------------------------------------------------------------------------------------------------- void NotificationCenter::notifyObserversOfSelectionChange() { - foreach ( DataModelObserver* o, m_observers ) + for ( DataModelObserver* o : m_observers ) { o->handleModelSelectionChange(); } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp index c2f6aec6bf..681f65ba84 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp @@ -311,13 +311,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference( PdmFieldHandle* f if ( reference.isEmpty() ) return nullptr; if ( reference.trimmed().isEmpty() ) return nullptr; -#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) ) - auto SkipEmptyParts = QString::SkipEmptyParts; -#else - auto SkipEmptyParts = Qt::SkipEmptyParts; -#endif - - QStringList decodedReference = reference.split( QRegularExpression( "\\s+" ), SkipEmptyParts ); + QStringList decodedReference = reference.split( QRegularExpression( "\\s+" ), Qt::SkipEmptyParts ); PdmObjectHandle* lastCommonAnchestor = fromField->ownerObject(); CAF_ASSERT( lastCommonAnchestor ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/caf.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/caf.cpp index 63544caf05..e34e8430b4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/caf.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/caf.cpp @@ -46,12 +46,8 @@ namespace caf //-------------------------------------------------------------------------------------------------- QLocale norwegianLocale() { -#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) return QLocale::NorwegianBokmal; -#else - return QLocale::Norwegian; -#endif -} // namespace caf::norwegianLocale() +} //-------------------------------------------------------------------------------------------------- /// @@ -59,11 +55,7 @@ QLocale norwegianLocale() QTextStream& endl( QTextStream& s ) { // https: // github.com/qt/qtbase/blob/dev/src/corelib/serialization/qtextstream.cpp#L2845 -#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) return s << QLatin1Char( '\n' ) << Qt::flush; -#else - return s << QLatin1Char( '\n' ) << flush; -#endif } //-------------------------------------------------------------------------------------------------- @@ -71,11 +63,7 @@ QTextStream& endl( QTextStream& s ) //-------------------------------------------------------------------------------------------------- QPointF position( QWheelEvent* wheelEvent ) { -#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) return wheelEvent->position(); -#else - return wheelEvent->pos(); -#endif } } // namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp index 12e8d251de..93d935f62a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp @@ -41,10 +41,6 @@ #include -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) -#include -#endif - #include namespace caf @@ -95,15 +91,6 @@ int FontTools::absolutePointSize( FontSize normalPointSize, RelativeSize relativ //-------------------------------------------------------------------------------------------------- int FontTools::pointSizeToPixelSize( int pointSize ) { -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) - auto app = dynamic_cast( QCoreApplication::instance() ); - if ( app ) - { - int dpi = app->desktop()->logicalDpiX(); - double inches = pointSize / 72.0; - return static_cast( std::ceil( inches * dpi ) ); - } -#endif return pointSize; } @@ -120,15 +107,6 @@ int FontTools::pointSizeToPixelSize( FontSize pointSize ) //-------------------------------------------------------------------------------------------------- int FontTools::pixelSizeToPointSize( int pixelSize ) { -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) - auto app = dynamic_cast( QCoreApplication::instance() ); - if ( app ) - { - int dpi = app->desktop()->logicalDpiX(); - double inches = pixelSize / dpi; - return static_cast( std::ceil( inches * 72.0 ) ); - } -#endif return pixelSize; } diff --git a/Fwk/AppFwk/cafUserInterface/cafAboutDialog.cpp b/Fwk/AppFwk/cafUserInterface/cafAboutDialog.cpp index 982b0e3de3..9b6d248219 100644 --- a/Fwk/AppFwk/cafUserInterface/cafAboutDialog.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafAboutDialog.cpp @@ -42,10 +42,6 @@ #include #include -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) -#include -#endif - namespace caf { //================================================================================================== @@ -302,48 +298,6 @@ QString AboutDialog::versionStringForcurrentOpenGLContext() { QString versionString( "OpenGL " ); -#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) - QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags(); - - if ( flags & QGLFormat::OpenGL_Version_4_0 ) - versionString += "4.0"; - else if ( flags & QGLFormat::OpenGL_Version_3_3 ) - versionString += "3.3"; - else if ( flags & QGLFormat::OpenGL_Version_3_2 ) - versionString += "3.2"; - else if ( flags & QGLFormat::OpenGL_Version_3_1 ) - versionString += "3.1"; - else if ( flags & QGLFormat::OpenGL_Version_3_0 ) - versionString += "3.0"; - else if ( flags & QGLFormat::OpenGL_ES_Version_2_0 ) - versionString += "ES_Version 2.0"; - else if ( flags & QGLFormat::OpenGL_ES_CommonLite_Version_1_1 ) - versionString += "ES_CommonLite_Version 1.1"; - else if ( flags & QGLFormat::OpenGL_ES_Common_Version_1_1 ) - versionString += "ES_Common_Version 1.1"; - else if ( flags & QGLFormat::OpenGL_ES_CommonLite_Version_1_0 ) - versionString += "ES_CommonLite_Version 1.0"; - else if ( flags & QGLFormat::OpenGL_ES_Common_Version_1_0 ) - versionString += "ES_Common_Version 1.0"; - else if ( flags & QGLFormat::OpenGL_Version_2_1 ) - versionString += "2.1"; - else if ( flags & QGLFormat::OpenGL_Version_2_0 ) - versionString += "2.0"; - else if ( flags & QGLFormat::OpenGL_Version_1_5 ) - versionString += "1.5"; - else if ( flags & QGLFormat::OpenGL_Version_1_4 ) - versionString += "1.4"; - else if ( flags & QGLFormat::OpenGL_Version_1_3 ) - versionString += "1.3"; - else if ( flags & QGLFormat::OpenGL_Version_1_2 ) - versionString += "1.2"; - else if ( flags & QGLFormat::OpenGL_Version_1_1 ) - versionString += "1.1"; - else if ( flags & QGLFormat::OpenGL_Version_None ) - versionString += "None"; - else - versionString += "Unknown"; -#endif return versionString; } diff --git a/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp b/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp index 686a75e0c0..7213efcf8a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafMemoryInspector.cpp @@ -25,11 +25,6 @@ #ifdef __linux__ -#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) ) - auto SkipEmptyParts = QString::SkipEmptyParts; -#else - auto SkipEmptyParts = Qt::SkipEmptyParts; -#endif //-------------------------------------------------------------------------------------------------- /// Read bytes of memory of different types for current process from /proc/self/statm @@ -47,7 +42,7 @@ std::map readProcessBytesLinux() if (procSelfStatus.open(QIODevice::ReadOnly | QIODevice::Text)) { QString line(procSelfStatus.readLine(256)); - QStringList lineWords = line.split(QRegularExpression("\\s+"), SkipEmptyParts); + QStringList lineWords = line.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts); quantities["VmSize"] = static_cast(lineWords[0].toLongLong() * pageSize); quantities["RSS"] = static_cast(lineWords[1].toLongLong() * pageSize); quantities["Shared"] = static_cast(lineWords[2].toLongLong() * pageSize); @@ -75,7 +70,7 @@ std::map readMemInfoLinuxMiB() if (lineLength > 0) { QString line = QString::fromLatin1(buf, lineLength); - QStringList words = line.split(QRegularExpression(":*\\s+"), SkipEmptyParts); + QStringList words = line.split(QRegularExpression(":*\\s+"), Qt::SkipEmptyParts); if (words.size() > 1) { bool ok = true; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index 428674510e..b4b04b74fb 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -191,8 +191,8 @@ void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) m_nextItemButton->setToolTip( "Next" ); } - m_layout->insertWidget( 1, m_previousItemButton ); - m_layout->insertWidget( 2, m_nextItemButton ); + m_layout->addWidget( m_previousItemButton ); + m_layout->addWidget( m_nextItemButton ); { QIcon toolButtonIcon; @@ -283,7 +283,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi( const QString& uiConfigName ) QString tooltipText = uiField()->isAutoValueEnabled() ? UiAppearanceSettings::globaleValueButtonText() : UiAppearanceSettings::localValueButtonText(); m_autoValueToolButton->setToolTip( tooltipText ); - m_layout->insertWidget( 3, m_autoValueToolButton ); + m_layout->addWidget( m_autoValueToolButton ); m_autoValueToolButton->show(); } else diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index c8259369c0..e41572017f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -172,7 +172,7 @@ void PdmUiLineEditor::configureAndUpdateUi( const QString& uiConfigName ) : UiAppearanceSettings::localValueButtonText(); m_autoValueToolButton->setToolTip( tooltipText ); - m_layout->insertWidget( 1, m_autoValueToolButton ); + m_layout->addWidget( m_autoValueToolButton ); m_autoValueToolButton->show(); } else diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp index 42cb5dc353..2f1e25060e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp @@ -194,7 +194,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object ) CAF_ASSERT( propertyWidget ); - this->m_placeHolderLayout->insertWidget( 0, propertyWidget ); + this->m_placeHolderLayout->addWidget( propertyWidget ); // Add stretch to make sure the property widget is not stretched this->m_placeHolderLayout->insertStretch( -1, 1 ); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index c2bc9df8f3..14db565afe 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -620,11 +620,7 @@ void PdmUiTreeSelectionEditor::slotInvertCheckedStateOfAll() //-------------------------------------------------------------------------------------------------- void PdmUiTreeSelectionEditor::setCheckedStateForIntegerItemsMatchingFilter() { -#if ( QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 ) ) - auto SkipEmptyParts = QString::SkipEmptyParts; -#else auto SkipEmptyParts = Qt::SkipEmptyParts; -#endif std::set filterValues; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUniqueIdValidator.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUniqueIdValidator.cpp index 37d34c0838..ad56887ee0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUniqueIdValidator.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUniqueIdValidator.cpp @@ -88,7 +88,7 @@ QValidator::State PdmUniqueIdValidator::validate( QString& currentString, int& ) if ( m_usedIds.find( currentValue ) != m_usedIds.end() ) { - foreach ( QWidget* widget, QApplication::topLevelWidgets() ) + for ( QWidget* widget : QApplication::topLevelWidgets() ) { if ( widget->inherits( "QMainWindow" ) ) { diff --git a/Fwk/AppFwk/cafUserInterface/cafQTreeViewStateSerializer.cpp b/Fwk/AppFwk/cafUserInterface/cafQTreeViewStateSerializer.cpp index ffb85c02e2..cf84146039 100644 --- a/Fwk/AppFwk/cafUserInterface/cafQTreeViewStateSerializer.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafQTreeViewStateSerializer.cpp @@ -107,7 +107,7 @@ QModelIndex caf::QTreeViewStateSerializer::getModelIndexFromString( QAbstractIte QModelIndex mi; - foreach ( QString modelIndexString, modelIndexStringList ) + for ( const QString& modelIndexString : modelIndexStringList ) { QStringList items = modelIndexString.split( " " ); diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index 9ea86459e4..35388de11e 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -144,12 +144,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) { QWheelEvent* we = static_cast( inputEvent ); -#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) - QPoint cursorPosition = we->pos(); -#else QPoint cursorPosition = we->position().toPoint(); -#endif - updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() ); if ( m_isRotCenterInitialized ) diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index 42d385e7c3..7fced56000 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -202,12 +202,8 @@ void caf::CeetronNavigation::wheelEvent( QWheelEvent* event ) int navDelta = vpHeight / 5; if ( event->angleDelta().y() < 0 ) navDelta *= -1; -#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) - QPoint cursorPosition = event->pos(); -#else QPoint cursorPosition = event->position().toPoint(); -#endif - int posY = m_viewer->height() - cursorPosition.y(); + int posY = m_viewer->height() - cursorPosition.y(); m_trackball->startNavigation( ManipulatorTrackball::WALK, cursorPosition.x(), posY ); diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index 6165014011..7120e46a6b 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -185,12 +185,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) { QWheelEvent* we = static_cast( inputEvent ); -#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) - QPoint cursorPosition = we->pos(); -#else QPoint cursorPosition = we->position().toPoint(); -#endif - updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() ); if ( m_isRotCenterInitialized ) diff --git a/Fwk/VizFwk/LibGuiQt/cvfqtOpenGLWidget.cpp b/Fwk/VizFwk/LibGuiQt/cvfqtOpenGLWidget.cpp index 7de4e4c06e..21a1b37432 100644 --- a/Fwk/VizFwk/LibGuiQt/cvfqtOpenGLWidget.cpp +++ b/Fwk/VizFwk/LibGuiQt/cvfqtOpenGLWidget.cpp @@ -146,12 +146,11 @@ OpenGLWidget::~OpenGLWidget() if (m_initializationState == IS_INITIALIZED) { - // Make sure we disconnect from the aboutToBeDestroyed signal since after this destructor has been - // called, our object is dangling and the call to the slot will cause a crash - QOpenGLContext* myQtOpenGLContext = context(); - if (myQtOpenGLContext) + if (QOpenGLContext* myQtOpenGLContext = context()) { - disconnect(myQtOpenGLContext, &QOpenGLContext::aboutToBeDestroyed, this, &OpenGLWidget::qtOpenGLContextAboutToBeDestroyed); + // Make sure we disconnect from the all signals since after this destructor has been + // called, our object is dangling and the call to any of the slots will cause a crash + myQtOpenGLContext->disconnect(); } } diff --git a/Fwk/VizFwk/LibGuiQt/cvfqtUtils.cpp b/Fwk/VizFwk/LibGuiQt/cvfqtUtils.cpp index 9ec41e04ad..3b4063525f 100644 --- a/Fwk/VizFwk/LibGuiQt/cvfqtUtils.cpp +++ b/Fwk/VizFwk/LibGuiQt/cvfqtUtils.cpp @@ -119,7 +119,7 @@ std::vector Utils::toStringVector(const QStringList& stringList) { std::vector strVec; - foreach (QString s, stringList) + for (const QString& s : stringList) { strVec.push_back(toString(s)); } @@ -136,7 +136,7 @@ QStringList Utils::toQStringList(const std::vector& stringVector) { QStringList strList; - foreach (cvf::String s, stringVector) + for (const cvf::String& s : stringVector) { strList.push_back(toQString(s)); } diff --git a/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMWidget.cpp b/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMWidget.cpp index 72996cea2f..87f2b0ad4b 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMWidget.cpp +++ b/Fwk/VizFwk/TestApps/Qt/QtMinimal/QMWidget.cpp @@ -145,13 +145,8 @@ void QMWidget::mouseMoveEvent(QMouseEvent* event) if (m_renderSequence.isNull()) return; Qt::MouseButtons mouseBn = event->buttons(); -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) const int posX = event->position().toPoint().x(); const int posY = height() - event->position().toPoint().y(); -#else - const int posX = event->x(); - const int posY = height() - event->y(); -#endif cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE; if (mouseBn == Qt::LeftButton) @@ -186,13 +181,8 @@ void QMWidget::mousePressEvent(QMouseEvent* event) { if (m_renderSequence.isNull()) return; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) const int posX = event->position().toPoint().x(); const int posY = height() - event->position().toPoint().y(); -#else - const int posX = event->x(); - const int posY = height() - event->y(); -#endif if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier) diff --git a/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVWidget.cpp b/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVWidget.cpp index fb8e6ba51c..f7ef57e6db 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVWidget.cpp +++ b/Fwk/VizFwk/TestApps/Qt/QtMultiView/QMVWidget.cpp @@ -172,13 +172,8 @@ void QMVWidget::mouseMoveEvent(QMouseEvent* event) if (m_renderSequence.isNull()) return; Qt::MouseButtons mouseBn = event->buttons(); -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) const int posX = event->position().toPoint().x(); const int posY = height() - event->position().toPoint().y(); -#else - const int posX = event->x(); - const int posY = height() - event->y(); -#endif cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE; if (mouseBn == Qt::LeftButton) @@ -214,13 +209,8 @@ void QMVWidget::mousePressEvent(QMouseEvent* event) { if (m_renderSequence.isNull()) return; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) const int posX = event->position().toPoint().x(); const int posY = height() - event->position().toPoint().y(); -#else - const int posX = event->x(); - const int posY = height() - event->y(); -#endif if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier) { diff --git a/Fwk/VizFwk/TestApps/Qt/QtTestBenchOpenGLWidget/QTBVizWidget.cpp b/Fwk/VizFwk/TestApps/Qt/QtTestBenchOpenGLWidget/QTBVizWidget.cpp index 7edf1cfc5e..e1769f45f2 100644 --- a/Fwk/VizFwk/TestApps/Qt/QtTestBenchOpenGLWidget/QTBVizWidget.cpp +++ b/Fwk/VizFwk/TestApps/Qt/QtTestBenchOpenGLWidget/QTBVizWidget.cpp @@ -245,13 +245,8 @@ void QTBVizWidget::mouseMoveEvent(QMouseEvent* event) if (m_renderSequence.isNull()) return; Qt::MouseButtons mouseBn = event->buttons(); -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) const int posX = event->position().toPoint().x(); const int posY = height() - event->position().toPoint().y(); -#else - const int posX = event->x(); - const int posY = height() - event->y(); -#endif cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE; if (mouseBn == Qt::LeftButton) @@ -286,13 +281,8 @@ void QTBVizWidget::mousePressEvent(QMouseEvent* event) { if (m_renderSequence.isNull()) return; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) const int posX = event->position().toPoint().x(); const int posY = height() - event->position().toPoint().y(); -#else - const int posX = event->x(); - const int posY = height() - event->y(); -#endif if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier) {