From a974bb1b998dd95b57a97959ea99083ea4f6e1ef Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 25 Oct 2024 09:06:51 +0200 Subject: [PATCH] Replace use of QRegExp with QRegularExpression Replace use of QRegExp with QRegularExpression Remove dependency on qt5compat module --- .../Application/RiaPreferences.cpp | 1 - .../Application/Tools/RiaTextStringTools.cpp | 23 ++++----- .../Application/Tools/RiaTextStringTools.h | 6 +-- .../Tools/RiaValidRegExpValidator.cpp | 8 +-- .../Tools/RiaValidRegExpValidator.h | 3 +- .../Tools/Summary/RiaSummaryStringTools.cpp | 23 +++++---- ApplicationLibCode/CMakeLists.txt | 2 - .../RifCaseRealizationParametersReader.cpp | 19 ++++--- .../FileInterface/RifColorLegendData.cpp | 2 +- .../FileInterface/RifCsvUserDataParser.cpp | 18 ++++--- .../RifEclipseSummaryAddress.cpp | 12 ++--- .../FileInterface/RifFileParseTools.cpp | 10 +--- .../FileInterface/RifFileParseTools.h | 4 +- .../FileInterface/RifPolygonReader.cpp | 2 +- .../RimPolylinesFromFileAnnotation.cpp | 2 +- .../RimWellPathCompletionSettings.cpp | 5 +- .../RimWellPathCompletionSettings.h | 4 +- .../Summary/RimSummaryPlotManager.cpp | 2 +- .../WellPath/RimWellPathCollection.cpp | 7 +-- .../RigReservoirBuilderMock.cpp | 10 ++-- .../RifTextDataTableFormatter-Test.cpp | 6 +-- .../UserInterface/RiuGuiTheme.cpp | 50 ++++++++++--------- CMakeLists.txt | 11 +--- 23 files changed, 110 insertions(+), 120 deletions(-) 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/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/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationLibCode/FileInterface/RifCaseRealizationParametersReader.cpp index ba945f1cd2..3a087fc75e 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 ) { @@ -289,19 +289,18 @@ int RifCaseRealizationParametersFileLocator::realizationNumber( const QString& m 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( absolutePath ); - QRegExp regexp( pattern, Qt::CaseInsensitive ); - if ( regexp.indexIn( absolutePath ) ) + if ( match.hasMatch() ) { - QString tempText = regexp.cap( 1 ); + QString tempText = match.captured( 1 ); - QRegExp rx( "(\\d+)" ); // Find number - int digitPos = rx.indexIn( tempText ); - if ( digitPos > -1 ) + QRegularExpression rx( "(\\d+)" ); + QRegularExpressionMatch digitMatch = rx.match( tempText ); + if ( digitMatch.hasMatch() ) { - resultIndex = rx.cap( 0 ).toInt(); + resultIndex = digitMatch.captured( 1 ).toInt(); } } 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/RifEclipseSummaryAddress.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp index 224620949e..248e5ec893 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -24,7 +24,6 @@ #include "RifEclEclipseSummary.h" #include "RiuSummaryQuantityNameInfoProvider.h" -#include #include #include @@ -783,9 +782,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 +1226,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 +1248,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/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/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/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 5a8ce9e899..09bd3f4ef9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellPathCollection.cpp @@ -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/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..e0c7dd3f35 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( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp( 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( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp( 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( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp( 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( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp( 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( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp( 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( match.captured( "plotName" ) ); + QRegularExpression itemNameRegExp( 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/CMakeLists.txt b/CMakeLists.txt index 97035ceaf6..cc5ce1abe6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -550,16 +550,9 @@ 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()