mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Qt6: Adjustments (#11804)
* Qt6: Avoid insertWidget, use addWidget In Qt6, the insertWidget function checks if the index parameter is valid based on current widgets present in the layout. This is error prone, and use addWidget to avoid manual counting of index. * Disable use of Qt keyword foreach * Replace use of QRegExp with QRegularExpression Replace use of QRegExp with QRegularExpression Remove dependency on qt5compat module Simplify an expression based on review * Remove Qt5 ifdefs * Guard access out of bounds seen in debug build * Avoid reuse of string variable * Disconnect all signals from the QOpenGLContext The call stack when this assert happens indicates that there are more signals to be disconnected from the object. Crash is fixed by disconnecting all signals. Assert seen in debug build: ASSERT failure in caf::Viewer: "Called object is not of the correct type (class destructor may have already run)", file C:\Qt\6.6.3\msvc2019_64\include\QtCore/qobjectdefs_impl.h, line 130 * Fix issue related to delete of a linked view Guard null pointer use in view linker. Remove complicated cleanup in destructor in Rim3dVew.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
@@ -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<QString, QString>& valueMap );
|
||||
bool isTextEqual( QStringView text, QStringView compareText );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QString>
|
||||
#include <QValidator>
|
||||
|
||||
@@ -36,4 +35,4 @@ public:
|
||||
|
||||
private:
|
||||
QString m_defaultPattern;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>>
|
||||
|
||||
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<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>>
|
||||
{
|
||||
// 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<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>>
|
||||
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<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RiaSummaryStringTools::splitIntoWords( const QString& text )
|
||||
{
|
||||
return RiaTextStringTools::splitSkipEmptyParts( text, QRegExp( "\\s+" ) );
|
||||
return RiaTextStringTools::splitSkipEmptyParts( text );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user