Fix several deprecation warnings (#8657)

* Use constructor instead of nullptr for WindowFlags
* Use constructor instead of nullptr for Alignment
* Disable deprecation warning for QProcess
* Add string split method to RaTextStringTools
* Add caf.cpp used to manage Qt function deprecations
* Use position()
This commit is contained in:
Magne Sjaastad 2022-03-11 13:24:01 +01:00 committed by GitHub
parent 72fc47e003
commit 806a149809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 472 additions and 206 deletions

View File

@ -23,6 +23,10 @@
#include <QDir>
#include <QProcess>
// Disable deprecation warning for QProcess::start()
#ifdef _MSC_VER
#pragma warning( disable : 4996 )
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -19,6 +19,11 @@
#include "RiaImageFileCompare.h"
#include <QtCore/QProcess>
// Disable deprecation warning for QProcess::start()
#ifdef _MSC_VER
#pragma warning( disable : 4996 )
#endif
//==================================================================================================
//
//

View File

@ -210,6 +210,18 @@ QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaQDateTimeTo
return subtractSpan( dt, timeSpan( period ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::createDateTime( const QDate& date )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
return date.startOfDay();
#else
return QDateTime( date, QTime( 0, 0 ) );
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -239,7 +251,7 @@ QDateTime RiaQDateTimeTools::createUtcDateTime()
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::createUtcDateTime( const QDate& date )
{
auto qdt = QDateTime( date );
auto qdt = createDateTime( date );
qdt.setTimeSpec( currentTimeSpec() );
return qdt;
}

View File

@ -97,6 +97,8 @@ public:
static QDateTime addPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period );
static QDateTime subtractPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period );
static QDateTime createDateTime( const QDate& date );
static QDateTime epoch();
static QDateTime createUtcDateTime();

View File

@ -26,6 +26,7 @@
#include "RiaProjectModifier.h"
#include "RiaRegressionTest.h"
#include "RiaTextFileCompare.h"
#include "RiaTextStringTools.h"
#include "RicfCommandFileExecutor.h"
@ -538,7 +539,7 @@ QString RiaRegressionTestRunner::diff2htmlHeaderText( const QString& testRootPat
QString html;
QString oldProjPath = QDir::fromNativeSeparators( testRootPath );
QStringList pathFolders = oldProjPath.split( "/", QString::KeepEmptyParts );
QStringList pathFolders = oldProjPath.split( "/" );
QString path;
for ( const auto& f : pathFolders )
@ -611,7 +612,7 @@ void RiaRegressionTestRunner::executeRegressionTests()
testConfig.readSettingsFromApplicationStore();
QString testPath = testConfig.regressionTestFolder();
QStringList testFilter = testConfig.testFilter().split( ";", QString::SkipEmptyParts );
QStringList testFilter = RiaTextStringTools::splitSkipEmptyParts( testConfig.testFilter(), ";" );
if ( testConfig.appendTestsAfterTestFilter )
{

View File

@ -21,6 +21,7 @@
#include "RiaLogging.h"
#include "RiaStdStringTools.h"
#include "RiaSummaryTools.h"
#include "RiaTextStringTools.h"
#include "RifEclipseSummaryAddress.h"
#include "RifReaderEclipseSummary.h"
@ -217,9 +218,7 @@ std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>>
//--------------------------------------------------------------------------------------------------
QStringList RiaSummaryStringTools::splitIntoWords( const QString& text )
{
QStringList words = text.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
return words;
return RiaTextStringTools::splitSkipEmptyParts( text, QRegExp( "\\s+" ) );
}
//--------------------------------------------------------------------------------------------------

View File

@ -22,6 +22,11 @@
#include <QProcess>
// Disable deprecation warning for QProcess::start()
#ifdef _MSC_VER
#pragma warning( disable : 4996 )
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -127,3 +127,27 @@ QString RiaTextStringTools::trimNonAlphaNumericCharacters( const QString& s )
trimmedString.replace( trimRe, "" );
return trimmedString;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const QString& sep /*= " " */ )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
return text.split( sep, Qt::SkipEmptyParts, Qt::CaseInsensitive );
#else
return text.split( sep, QString::SkipEmptyParts, Qt::CaseInsensitive );
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RiaTextStringTools::splitSkipEmptyParts( const QString& text, const QRegExp& regExp )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
return text.split( regExp, Qt::SkipEmptyParts );
#else
return text.split( regExp, QString::SkipEmptyParts );
#endif
}

View File

@ -18,7 +18,8 @@
#pragma once
class QString;
#include <QString>
class QStringList;
//--------------------------------------------------------------------------------------------------
@ -31,4 +32,8 @@ QString trimAndRemoveDoubleSpaces( const QString& s );
QString commonRoot( const QStringList& stringList );
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 );
} // namespace RiaTextStringTools

View File

@ -85,7 +85,7 @@ std::vector<RimStimPlanFractureTemplate*> RicNewStimPlanFractureTemplateFeature:
defaultDir,
"StimPlan XML File (*.xml);;All files(*.*)" );
auto templates = createNewTemplatesFromFiles( fileNames.toVector().toStdVector() );
auto templates = createNewTemplatesFromFiles( std::vector<QString>( fileNames.begin(), fileNames.end() ) );
if ( !fileNames.isEmpty() )
{

View File

@ -84,7 +84,8 @@ void RicCreateEnsembleSurfaceFeature::openDialogAndExecuteCommand()
if ( propertyDialog.exec() == QDialog::Accepted )
{
executeCommand( *ui, result.files.toVector().toStdVector() );
auto stdVector = std::vector<QString>( result.files.begin(), result.files.end() );
executeCommand( *ui, stdVector );
}
}

View File

@ -106,7 +106,8 @@ void RicCreateEnsembleWellLogFeature::openDialogAndExecuteCommand()
if ( propertyDialog.exec() == QDialog::Accepted && !ui->properties().empty() )
{
executeCommand( *ui, result.files.toStdList() );
auto stdList = std::list<QString>( result.files.begin(), result.files.end() );
executeCommand( *ui, stdList );
}
}

View File

@ -21,6 +21,7 @@
#include "RiaColorTables.h"
#include "RiaGuiApplication.h"
#include "RiaPreferencesSummary.h"
#include "RiaTextStringTools.h"
#include "RiaSummaryTools.h"
#include "RimEnsembleCurveFilter.h"
@ -62,7 +63,7 @@ std::vector<RimEnsembleCurveSet*>
RiaPreferencesSummary* prefs = RiaPreferencesSummary::current();
QString curvesTextFilter = prefs->defaultSummaryCurvesTextFilter();
QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts );
QStringList curveFilters = RiaTextStringTools::splitSkipEmptyParts( curvesTextFilter, ";" );
std::set<RifEclipseSummaryAddress> addrs = ensemble->ensembleSummaryAddresses();

View File

@ -18,6 +18,7 @@
#include "RicPasteAsciiDataToSummaryPlotFeatureUi.h"
#include "RiaTextStringTools.h"
#include "RifCsvUserDataParser.h"
#include "cafPdmUiItem.h"
@ -329,7 +330,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat
std::vector<int> values;
{
QStringList split = dateString.split( ".", QString::SkipEmptyParts );
QStringList split = RiaTextStringTools::splitSkipEmptyParts( dateString, "." );
if ( split.size() == 3 )
{
values.push_back( split.at( 0 ).toInt() );
@ -342,7 +343,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat
}
{
QStringList split = dateString.split( "-", QString::SkipEmptyParts );
QStringList split = RiaTextStringTools::splitSkipEmptyParts( dateString, "-" );
if ( split.size() == 3 )
{
values.push_back( split.at( 0 ).toInt() );
@ -355,7 +356,7 @@ RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormat
}
{
QStringList split = dateString.split( "/", QString::SkipEmptyParts );
QStringList split = RiaTextStringTools::splitSkipEmptyParts( dateString, "/" );
if ( split.size() == 3 )
{
values.push_back( split.at( 0 ).toInt() );

View File

@ -27,6 +27,7 @@
#include "RiaLogging.h"
#include "RiaPreferencesSummary.h"
#include "RiaSummaryStringTools.h"
#include "RiaTextStringTools.h"
#include "RicCreateSummaryCaseCollectionFeature.h"
#include "RicImportGeneralDataFeature.h"
@ -70,7 +71,7 @@ std::vector<RimSummaryCurve*> RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot(
RiaPreferencesSummary* prefs = RiaPreferencesSummary::current();
QString curvesTextFilter = prefs->defaultSummaryCurvesTextFilter();
QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts );
QStringList curveFilters = RiaTextStringTools::splitSkipEmptyParts( curvesTextFilter, ";" );
bool addHistoryCurve = false;

View File

@ -18,7 +18,7 @@
#include "RicAppendPointsToPolygonFilterFeature.h"
CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" );
#include "RiaTextStringTools.h"
#include "RimPolygonFilter.h"
#include "RimPolylineTarget.h"
@ -30,6 +30,8 @@ CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPo
#include <QAction>
#include <QClipboard>
CAF_CMD_SOURCE_INIT( RicAppendPointsToPolygonFilterFeature, "RicAppendPointsToPolygonFilterFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -62,7 +64,7 @@ void RicAppendPointsToPolygonFilterFeature::onActionTriggered( bool isChecked )
if ( clipboard )
{
QString content = clipboard->text();
listOfThreeDoubles = content.split( "\n", QString::SkipEmptyParts );
listOfThreeDoubles = RiaTextStringTools::splitSkipEmptyParts( content, "\n" );
}
std::vector<cvf::Vec3d> points;

View File

@ -18,6 +18,7 @@
#include "RifColorLegendData.h"
#include "RiaTextStringTools.h"
#include "RigFormationNames.h"
#include "cafAssert.h"
@ -66,7 +67,7 @@ cvf::ref<RigFormationNames> RifColorLegendData::readLyrFormationNameFile( const
while ( !stream.atEnd() )
{
QString line = stream.readLine();
QStringList lineSegs = line.split( "'", QString::KeepEmptyParts );
QStringList lineSegs = line.split( "'" );
if ( lineSegs.size() == 0 ) continue; // Empty line
if ( lineSegs.size() == 1 ) continue; // No name present. Comment line ?
@ -84,16 +85,14 @@ cvf::ref<RigFormationNames> RifColorLegendData::readLyrFormationNameFile( const
QString numberString = lineSegs[2];
if ( commentMarkPos >= 0 ) numberString.truncate( commentMarkPos );
QString colorWord = numberString.split( " ", QString::SkipEmptyParts ).last(); // extract last word which may
// contain formation color
// extract last word which may contain formation color
QString colorWord = RiaTextStringTools::splitSkipEmptyParts( numberString ).last();
if ( QColor::isValidColor( colorWord ) )
numberString.remove( colorWord ); // remove color if present as last word on line
QStringList numberWords = numberString.split( QRegExp( "-" ), QString::SkipEmptyParts ); // extract words
// containing
// formation
// number(s)
// extract words containing formation number(s)
QStringList numberWords = RiaTextStringTools::splitSkipEmptyParts( numberString, QRegExp( "-" ) );
if ( numberWords.size() == 2 ) // formation range with or without color at end of line
{

View File

@ -23,6 +23,7 @@
#include "RiaDateStringParser.h"
#include "RiaLogging.h"
#include "RiaTextStringTools.h"
#include "cvfAssert.h"
@ -116,7 +117,7 @@ void RifColumnBasedUserDataParser::parseTableData( const QString& data )
do
{
QString qLine = QString::fromStdString( line );
QStringList entries = qLine.split( " ", QString::SkipEmptyParts );
QStringList entries = RiaTextStringTools::splitSkipEmptyParts( qLine );
if ( stepTypeIndex > -1 && (unsigned int)entries.size() < columnInfos.size() )
{

View File

@ -30,6 +30,7 @@
#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h"
#include "caf.h"
#include "cvfAssert.h"
#include <QFile>
@ -733,7 +734,7 @@ QLocale RifCsvUserDataParser::localeFromDecimalSeparator( const QString& decimal
{
if ( decimalSeparator == "," )
{
return QLocale::Norwegian;
return caf::norwegianLocale();
}
return QLocale::c();
}

View File

@ -48,6 +48,7 @@
#include <QFileInfo>
#include <QTextStream>
#include "RiaTextStringTools.h"
#include "ert/ecl/ecl_box.hpp"
#include "ert/ecl/ecl_grid.hpp"
#include "ert/ecl/ecl_kw.h"
@ -813,7 +814,7 @@ void RifEclipseInputFileTools::parseAndReadPathAliasKeyword( const QString&
// definition; 'I+'
line.remove( "'" );
QStringList entries = line.split( " ", QString::SkipEmptyParts );
QStringList entries = RiaTextStringTools::splitSkipEmptyParts( line );
if ( entries.size() < 2 )
{
continue;

View File

@ -673,7 +673,7 @@ void RifEclipseOutputFileTools::createReportStepsMetaData( std::vector<ecl_file_
// Set Date
{
QDateTime reportDateTime(
QDateTime reportDateTime = RiaQDateTimeTools::createDateTime(
QDate( restart_header->year, restart_header->month, restart_header->day ) );
reportStep.dateTime = reportDateTime;
}

View File

@ -18,11 +18,10 @@
#include "RifEnsembleFractureStatisticsExporter.h"
// #include "RiaEclipseUnitTools.h"
// #include "RimStimPlanModel.h"
#include "RiaDefines.h"
#include "RigSlice2D.h"
#include "caf.h"
#include "cafAssert.h"
#include <QFile>
@ -61,7 +60,7 @@ bool RifEnsembleFractureStatisticsExporter::writeAsStimPlanXml( const std::vecto
//--------------------------------------------------------------------------------------------------
void RifEnsembleFractureStatisticsExporter::appendHeaderToStream( QTextStream& stream )
{
stream << "<?xml version=\"1.0\" ?>" << endl << "<contours>" << endl;
stream << "<?xml version=\"1.0\" ?>" << caf::endl << "<contours>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -76,15 +75,15 @@ void RifEnsembleFractureStatisticsExporter::appendPropertiesToStream(
{
CAF_ASSERT( statistics.size() == properties.size() );
stream << "<properties>" << endl;
stream << "<properties>" << caf::endl;
for ( size_t s = 0; s < statistics.size(); s++ )
{
QString propertyName = properties[s].first;
QString propertyUnit = properties[s].second;
stream << QString( "<property name=\"%1\" uom=\"%2\">" ).arg( propertyName ).arg( propertyUnit ) << endl;
stream << QString( "<time value=\"%1\">" ).arg( time ) << endl;
stream << QString( "<property name=\"%1\" uom=\"%2\">" ).arg( propertyName ).arg( propertyUnit ) << caf::endl;
stream << QString( "<time value=\"%1\">" ).arg( time ) << caf::endl;
CAF_ASSERT( statistics[s]->ny() == gridYs.size() );
@ -92,19 +91,19 @@ void RifEnsembleFractureStatisticsExporter::appendPropertiesToStream(
// in the reader (depths from <grid><ys> are used).
for ( int i = static_cast<int>( gridYs.size() ) - 1; i >= 0; i-- )
{
stream << "<depth>" << gridYs[i] << "</depth>" << endl;
stream << "<depth>" << gridYs[i] << "</depth>" << caf::endl;
stream << "<data>[";
for ( size_t x = 0; x < statistics[s]->nx(); x++ )
{
stream << statistics[s]->getValue( x, i ) << " ";
}
stream << "]</data>" << endl;
stream << "]</data>" << caf::endl;
}
stream << "</time>" << endl;
stream << "</property>" << endl;
stream << "</time>" << caf::endl;
stream << "</property>" << caf::endl;
}
stream << "</properties>" << endl;
stream << "</properties>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -116,7 +115,7 @@ void RifEnsembleFractureStatisticsExporter::appendOrientationToStream( QTextStre
if ( orientation != RigStimPlanFractureDefinition::Orientation::UNDEFINED )
{
QString orientationString = getStringForOrientation( orientation );
stream << QString( "<orientation>%1</orientation>" ).arg( orientationString ) << endl;
stream << QString( "<orientation>%1</orientation>" ).arg( orientationString ) << caf::endl;
}
}
@ -130,19 +129,19 @@ void RifEnsembleFractureStatisticsExporter::appendGridDimensionsToStream( QTextS
{
QString unitString = getStringForUnitSystem( unitSystem );
stream << QString( "<grid xCount=\"%1\" yCount=\"%2\" uom=\"%3\">" ).arg( gridXs.size() ).arg( gridYs.size() ).arg( unitString )
<< endl;
<< caf::endl;
stream << "<xs>[";
for ( auto x : gridXs )
stream << x << " ";
stream << "]</xs>" << endl;
stream << "]</xs>" << caf::endl;
stream << "<ys>[";
for ( auto y : gridYs )
stream << y << " ";
stream << "]</ys>" << endl;
stream << "]</ys>" << caf::endl;
stream << "</grid>" << endl;
stream << "</grid>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -150,7 +149,7 @@ void RifEnsembleFractureStatisticsExporter::appendGridDimensionsToStream( QTextS
//--------------------------------------------------------------------------------------------------
void RifEnsembleFractureStatisticsExporter::appendFooterToStream( QTextStream& stream )
{
stream << "</contours>" << endl;
stream << "</contours>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,8 @@
#include "RimGenericParameter.h"
#include "RimParameterGroup.h"
#include "caf.h"
#include <QFile>
#include <QTextStream>
@ -40,12 +42,12 @@ bool RifFaultRAJSonWriter::writeToPreprocFile( RimFaultRAPreprocSettings& settin
{
QTextStream stream( &file );
stream << "{" << endl;
stream << "\"odb_path\": \"" + settings.geomechCaseFilename() + "\"," << endl;
stream << "\"time_start\": \"" + settings.startTimeStepGeoMech() + "\"," << endl;
stream << "\"time_end\": \"" + settings.endTimeStepGeoMech() + "\"," << endl;
stream << "\"out_path\": \"" + settings.outputAbaqusDirectory() + "\"" << endl;
stream << "}" << endl;
stream << "{" << caf::endl;
stream << "\"odb_path\": \"" + settings.geomechCaseFilename() + "\"," << caf::endl;
stream << "\"time_start\": \"" + settings.startTimeStepGeoMech() + "\"," << caf::endl;
stream << "\"time_end\": \"" + settings.endTimeStepGeoMech() + "\"," << caf::endl;
stream << "\"out_path\": \"" + settings.outputAbaqusDirectory() + "\"" << caf::endl;
stream << "}" << caf::endl;
file.close();
}
@ -73,26 +75,26 @@ bool RifFaultRAJSonWriter::writeToPostprocFile( int faultID, RimFaultRAPostprocS
{
QTextStream stream( &file );
stream << "{" << endl;
stream << "{" << caf::endl;
if ( settings->geomechEnabled() )
{
if ( QFile::exists( settings->advancedMacrisDatabase() ) )
stream << "\"MacrisCalcCalibration_path\": \"" + settings->advancedMacrisDatabase() + "\"," << endl;
stream << "\"MacrisCalcCalibration_path\": \"" + settings->advancedMacrisDatabase() + "\"," << caf::endl;
}
if ( QFile::exists( settings->basicMacrisDatabase() ) )
stream << "\"MacrisCalc_path\": \"" + settings->basicMacrisDatabase() + "\"," << endl;
stream << "\"MacrisCalc_path\": \"" + settings->basicMacrisDatabase() + "\"," << caf::endl;
stream << "\"base_directory_path\": \"" + settings->outputBaseDirectory() + "\"," << endl;
stream << "\"base_directory_path\": \"" + settings->outputBaseDirectory() + "\"," << caf::endl;
for ( auto p : settings->parameters()->parameters() )
{
stream << "\"" + p->name() + "\" : " + p->stringValue() + "," << endl;
stream << "\"" + p->name() + "\" : " + p->stringValue() + "," << caf::endl;
}
stream << "\"tsurf_loadsteps\": [ " + settings->stepsToLoad().join( ',' ) + " ]" << endl;
stream << "}" << endl;
stream << "\"tsurf_loadsteps\": [ " + settings->stepsToLoad().join( ',' ) + " ]" << caf::endl;
stream << "}" << caf::endl;
file.close();
}

View File

@ -21,6 +21,8 @@
#include "RimFaultRASettings.h"
#include "RimGenericParameter.h"
#include "caf.h"
#include <QFile>
#include <QXmlStreamReader>
@ -56,15 +58,15 @@ bool RifFaultRAXmlWriter::writeParametersToXML( QString filename, std::list<RimG
{
QTextStream stream( &file );
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
stream << "<project type_id=\"0\">" << endl;
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << caf::endl;
stream << "<project type_id=\"0\">" << caf::endl;
for ( auto& p : params )
{
QString tmpStr = QString( "<%1>%2</%1>" ).arg( p->name(), p->stringValue() );
stream << tmpStr << endl;
stream << tmpStr << caf::endl;
}
stream << "</project>" << endl;
stream << "</project>" << caf::endl;
bResult = true;
}

View File

@ -18,6 +18,10 @@
#include "RifFileParseTools.h"
// Disable deprecation warning for QString::SkipEmptyParts
#ifdef _MSC_VER
#pragma warning( disable : 4996 )
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -18,6 +18,8 @@
#include "RifPerforationIntervalReader.h"
#include "RiaTextStringTools.h"
#include <QDate>
#include <QFile>
@ -79,7 +81,7 @@ void RifPerforationIntervalReader::readFileIntoMap( const QString&
// Replace any tabs with spaces to enable splitting on spaces
line.replace( "\t", " " );
QStringList parts = line.split( " ", QString::SkipEmptyParts );
QStringList parts = RiaTextStringTools::splitSkipEmptyParts( line );
if ( line.startsWith( "WELLNAME" ) )
{

View File

@ -18,6 +18,7 @@
#include "RifReaderFmuRft.h"
#include "RiaLogging.h"
#include "RiaQDateTimeTools.h"
#include "cafAssert.h"
@ -438,7 +439,7 @@ RifReaderFmuRft::WellObservationMap RifReaderFmuRft::loadWellDates( QDir& dir, Q
return WellObservationMap();
}
QDateTime dateTime( QDate( year, month, day ) );
QDateTime dateTime = RiaQDateTimeTools::createDateTime( QDate( year, month, day ) );
dateTime.setTimeSpec( Qt::UTC );
WellObservationSet observationSet( dateTime, measurementIndex );
validObservations.insert( std::make_pair( wellName, observationSet ) );

View File

@ -20,6 +20,8 @@
#include "RifReaderMockModel.h"
#include "RiaQDateTimeTools.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseResultInfo.h"
@ -43,7 +45,7 @@ bool RifReaderMockModel::open( const QString& fileName, RigEclipseCaseData* ecli
for ( int i = 0; i < static_cast<int>( m_reservoirBuilder.timeStepCount() ); i++ )
{
dates.push_back( QDateTime( QDate( 2012 + i, 6, 1 ) ) );
dates.push_back( RiaQDateTimeTools::createDateTime( QDate( 2012 + i, 6, 1 ) ) );
days.push_back( i );
repNumbers.push_back( i );
}

View File

@ -18,6 +18,8 @@
#include "RifReaderObservedData.h"
#include "caf.h"
#include "RifCsvUserDataParser.h"
#include "RifEclipseSummaryAddress.h"
@ -50,7 +52,7 @@ bool RifReaderObservedData::open( const QString& h
AsciiDataParseOptions parseOptions;
parseOptions.dateFormat = "yyyy-MM-dd";
parseOptions.cellSeparator = "\t";
parseOptions.locale = QLocale::Norwegian;
parseOptions.locale = caf::norwegianLocale();
QString data;
QTextStream out( &data );

View File

@ -29,6 +29,8 @@
#include "RimStimPlanModel.h"
#include "RimStimPlanModelCalculator.h"
#include "caf.h"
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
@ -273,7 +275,7 @@ bool RifStimPlanModelGeologicalFrkExporter::writeToCsvFile( const QString&
//--------------------------------------------------------------------------------------------------
void RifStimPlanModelGeologicalFrkExporter::appendHeaderToStream( QTextStream& stream )
{
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n' << "<geologic>" << endl;
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n' << "<geologic>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -283,23 +285,23 @@ void RifStimPlanModelGeologicalFrkExporter::appendToStream( QTextStream&
const QString& label,
const std::vector<double>& values )
{
stream << "<cNamedSet>" << endl
<< "<name>" << endl
<< label << endl
<< "</name>" << endl
<< "<dimCount>" << endl
<< 1 << endl
<< "</dimCount>" << endl
<< "<sizes>" << endl
<< values.size() << endl
<< "</sizes>" << endl
<< "<data>" << endl;
stream << "<cNamedSet>" << caf::endl
<< "<name>" << caf::endl
<< label << caf::endl
<< "</name>" << caf::endl
<< "<dimCount>" << caf::endl
<< 1 << caf::endl
<< "</dimCount>" << caf::endl
<< "<sizes>" << caf::endl
<< values.size() << caf::endl
<< "</sizes>" << caf::endl
<< "<data>" << caf::endl;
for ( auto val : values )
{
stream << val << endl;
stream << val << caf::endl;
}
stream << "</data>" << '\n' << "</cNamedSet>" << endl;
stream << "</data>" << '\n' << "</cNamedSet>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -307,7 +309,7 @@ void RifStimPlanModelGeologicalFrkExporter::appendToStream( QTextStream&
//--------------------------------------------------------------------------------------------------
void RifStimPlanModelGeologicalFrkExporter::appendFooterToStream( QTextStream& stream )
{
stream << "</geologic>" << endl;
stream << "</geologic>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,8 @@
#include "RigWellPath.h"
#include "RigWellPathGeometryTools.h"
#include "caf.h"
#include <QFile>
#include <QTextStream>
@ -75,7 +77,7 @@ bool RifStimPlanModelPerfsFrkExporter::writeToFile( RimStimPlanModel* stimPlanMo
//--------------------------------------------------------------------------------------------------
void RifStimPlanModelPerfsFrkExporter::appendHeaderToStream( QTextStream& stream )
{
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n' << "<perfs>" << endl;
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << '\n' << "<perfs>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -83,7 +85,7 @@ void RifStimPlanModelPerfsFrkExporter::appendHeaderToStream( QTextStream& stream
//--------------------------------------------------------------------------------------------------
void RifStimPlanModelPerfsFrkExporter::appendFractureOrientationToStream( QTextStream& stream, bool isTransverse )
{
stream << "<transverse>" << '\n' << static_cast<int>( isTransverse ) << '\n' << "</transverse>" << endl;
stream << "<transverse>" << '\n' << static_cast<int>( isTransverse ) << '\n' << "</transverse>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -91,14 +93,14 @@ void RifStimPlanModelPerfsFrkExporter::appendFractureOrientationToStream( QTextS
//--------------------------------------------------------------------------------------------------
void RifStimPlanModelPerfsFrkExporter::appendPerforationToStream( QTextStream& stream, int index, double topMD, double bottomMD )
{
stream << "<perf frac=\"" << index << "\">" << endl
<< "<topMD>" << endl
<< topMD << endl
<< "</topMD>" << endl
<< "<bottomMD>" << endl
<< bottomMD << endl
<< "</bottomMD>" << endl
<< "</perf>" << endl;
stream << "<perf frac=\"" << index << "\">" << caf::endl
<< "<topMD>" << caf::endl
<< topMD << caf::endl
<< "</topMD>" << caf::endl
<< "<bottomMD>" << caf::endl
<< bottomMD << caf::endl
<< "</bottomMD>" << caf::endl
<< "</perf>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------
@ -106,7 +108,7 @@ void RifStimPlanModelPerfsFrkExporter::appendPerforationToStream( QTextStream& s
//--------------------------------------------------------------------------------------------------
void RifStimPlanModelPerfsFrkExporter::appendFooterToStream( QTextStream& stream )
{
stream << "</perfs>" << endl;
stream << "</perfs>" << caf::endl;
}
//--------------------------------------------------------------------------------------------------

View File

@ -22,6 +22,8 @@
#include "RiaEclipseUnitTools.h"
#include "RiaFractureDefines.h"
#include "RiaLogging.h"
#include "RiaTextStringTools.h"
#include "RigStimPlanFractureDefinition.h"
#include <QFile>
@ -474,7 +476,7 @@ void RifStimPlanXmlReader::getGriddingValues( QXmlStreamReader& xmlStream,
QString gridValuesString = xmlStream.readElementText().replace( '\n', ' ' );
gridValuesString = gridValuesString.replace( '[', ' ' ).replace( ']', ' ' );
for ( const QString& value : gridValuesString.split( ' ', QString::SkipEmptyParts ) )
for ( const QString& value : RiaTextStringTools::splitSkipEmptyParts( gridValuesString ) )
{
if ( value.size() > 0 )
{

View File

@ -24,6 +24,8 @@
#include "RimWellIAModelData.h"
#include "RimWellIASettings.h"
#include "caf.h"
#include <QFile>
#include <QTextStream>
@ -41,11 +43,11 @@ bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString&
{
QTextStream stream( &file );
stream << "{" << endl;
stream << "{" << caf::endl;
stream << "\"comments\": \"All units are SI unless mentioned otherwise; temperature is in Celcius; use forward "
"slash (/) in 'directory' definition\","
<< endl;
stream << "\"directory\": \"" + settings.outputBaseDirectory() + "\"," << endl;
<< caf::endl;
stream << "\"directory\": \"" + settings.outputBaseDirectory() + "\"," << caf::endl;
stream << "\"output_name\": \"" + settings.name() + "\"";
RimParameterGroups mergedGroups;
@ -63,9 +65,9 @@ bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString&
for ( auto& group : mergedGroups.groups() )
{
stream << "," << endl;
stream << "," << caf::endl;
stream << "\"" + group->name() + "\": {" << endl;
stream << "\"" + group->name() + "\": {" << caf::endl;
const auto& parameters = group->parameters();
@ -78,13 +80,13 @@ bool RifWellIAFileWriter::writeToJsonFile( RimWellIASettings& settings, QString&
{
stream << ",";
}
stream << endl;
stream << caf::endl;
}
stream << " }";
}
stream << endl << "}" << endl;
stream << caf::endl << "}" << caf::endl;
file.close();
}
else
@ -114,7 +116,7 @@ bool RifWellIAFileWriter::writeToCSVFile( RimWellIASettings& settings, QString&
stream << "Time_days, Pcasing_Pa, P_form_Pa, Temp_C,"
"U1-1,U2,U3,U1-2,U2,U3,U1-3,U2,U3,U1-4,U2,U3,U1-5,U2,U3,U1-6,U2,U3,U1-7,U2,U3,U1-8,U2,U3,"
"X,Y,Z,X2,Y,Z,X3,Y,Z,X4,Y,Z,X5,Y,Z,X6,Y,Z,X7,Y,Z,X8,Y,Z";
stream << endl;
stream << caf::endl;
for ( auto& modeldata : settings.modelData() )
{
@ -145,7 +147,7 @@ bool RifWellIAFileWriter::writeToCSVFile( RimWellIASettings& settings, QString&
stream << ",";
stream << pos.z();
}
stream << endl;
stream << caf::endl;
}
}
else

View File

@ -155,7 +155,7 @@ void RifWellPathFormationReader::readFile( const QString& filePath,
QString line = data.readLine().toLower();
removeWhiteSpaces( &line );
header = line.split( ';', QString::KeepEmptyParts );
header = line.split( ';' );
}
static const QString wellNameText = "wellname";
@ -172,7 +172,7 @@ void RifWellPathFormationReader::readFile( const QString& filePath,
{
QString line = data.readLine();
QStringList dataLine = line.split( ';', QString::KeepEmptyParts );
QStringList dataLine = line.split( ';' );
if ( dataLine.size() != header.size() ) continue;
bool conversionOk;
@ -224,7 +224,7 @@ void RifWellPathFormationReader::readFile( const QString& filePath,
{
QString line = data.readLine();
QStringList dataLine = line.split( ';', QString::KeepEmptyParts );
QStringList dataLine = line.split( ';' );
if ( dataLine.size() != header.size() ) continue;
QString wellName = dataLine[wellNameIndex];

View File

@ -19,7 +19,9 @@
#include "RimPolylinesFromFileAnnotation.h"
#include "RiaLogging.h"
#include "RiaTextStringTools.h"
#include "RigPolyLinesData.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationLineAppearance.h"
@ -86,10 +88,10 @@ void RimPolylinesFromFileAnnotation::readPolyLinesFile( QString* errorMessage )
while ( !stream.atEnd() )
{
QString line = stream.readLine();
QStringList commentLineSegs = line.split( "#", QString::KeepEmptyParts );
QStringList commentLineSegs = line.split( "#" );
if ( commentLineSegs.empty() ) continue; // Empty line
QStringList lineSegs = commentLineSegs[0].split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
QStringList lineSegs = RiaTextStringTools::splitSkipEmptyParts( commentLineSegs[0], QRegExp( "\\s+" ) );
if ( lineSegs.empty() ) continue; // No data

View File

@ -18,6 +18,8 @@
#include "RimCellFilterIntervalTool.h"
#include "RiaTextStringTools.h"
#include <QStringList>
//--------------------------------------------------------------------------------------------------
@ -104,11 +106,11 @@ void RimCellFilterIntervalTool::setInterval( bool enabled, QString intervalText
if ( !enabled ) return;
QStringList parts = intervalText.split( ',', QString::SkipEmptyParts );
QStringList parts = RiaTextStringTools::splitSkipEmptyParts( intervalText, "," );
for ( auto& part : parts )
{
QStringList minmax = part.split( '-', QString::SkipEmptyParts );
QStringList minmax = RiaTextStringTools::splitSkipEmptyParts( part, "-" );
switch ( minmax.size() )
{
case 1:

View File

@ -21,6 +21,7 @@
#include "RiaColorTables.h"
#include "RiaEclipseUnitTools.h"
#include "RiaQDateTimeTools.h"
#include "RigCaseCellResultsData.h"
#include "RigWellPath.h"
@ -99,7 +100,7 @@ void RimPerforationInterval::setCustomStartDate( const QDate& date )
{
if ( date.isValid() )
{
m_startDate = QDateTime( date );
m_startDate = RiaQDateTimeTools::createDateTime( date );
}
}
@ -110,7 +111,7 @@ void RimPerforationInterval::setCustomEndDate( const QDate& date )
{
if ( date.isValid() )
{
m_endDate = QDateTime( date );
m_endDate = RiaQDateTimeTools::createDateTime( date );
}
}

View File

@ -25,6 +25,11 @@
#include <QProcess>
// Disable deprecation warning for QProcess::start()
#ifdef _MSC_VER
#pragma warning( disable : 4996 )
#endif
CAF_PDM_SOURCE_INIT( RimProcess, "RimProcess" );
int RimProcess::m_nextProcessId = 1;

View File

@ -29,14 +29,10 @@
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
// #include "RigEclipseMultiPropertyStatCalc.h"
// #include "RigEclipseNativeVisibleCellsStatCalc.h"
// #include "RigFemNativeVisibleCellsStatCalc.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
#include "RigFlowDiagResults.h"
// #include "RigFlowDiagVisibleCellsStatCalc.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
@ -64,6 +60,8 @@
#include "RiuViewer.h"
#include "caf.h"
#include <QLocale>
CAF_PDM_SOURCE_INIT( Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig" );
@ -289,7 +287,7 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
{
QString caseName = eclipseView->eclipseCase()->caseUserDescription();
QLocale localeWithSpaceAsGroupSeparator( QLocale::Norwegian );
QLocale localeWithSpaceAsGroupSeparator( caf::norwegianLocale() );
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>( eclipseView );
if ( contourMap && contourMap->contourMapProjection() )

View File

@ -25,6 +25,7 @@
#include "RiaFilePathTools.h"
#include "RiaGuiApplication.h"
#include "RiaProjectFileVersionTools.h"
#include "RiaTextStringTools.h"
#include "RiaVersionInfo.h"
#include "RicfCommandObject.h"
@ -1517,7 +1518,7 @@ public:
GlobalPathListMapper( const QString& globalPathListTable )
{
m_maxUsedIdNumber = 0;
QStringList pathPairs = globalPathListTable.split( ";", QString::SkipEmptyParts );
QStringList pathPairs = RiaTextStringTools::splitSkipEmptyParts( globalPathListTable, ";" );
for ( const QString& pathIdPathPair : pathPairs )
{

View File

@ -125,13 +125,13 @@ QString RimTools::relocateFile( const QString& originalFileName,
QFileInfo fileNameFileInfo( QDir::fromNativeSeparators( fileName ) );
QString fileNamePath = fileNameFileInfo.path();
QString fileNameWithoutPath = fileNameFileInfo.fileName();
QStringList fileNamePathElements = fileNamePath.split( "/", QString::KeepEmptyParts );
QStringList fileNamePathElements = fileNamePath.split( "/" );
QString oldProjPath = QDir::fromNativeSeparators( oldProjectPath );
QStringList oldProjPathElements = oldProjPath.split( "/", QString::KeepEmptyParts );
QStringList oldProjPathElements = oldProjPath.split( "/" );
QString newProjPath = QDir::fromNativeSeparators( newProjectPath );
QStringList newProjPathElements = newProjPath.split( "/", QString::KeepEmptyParts );
QStringList newProjPathElements = newProjPath.split( "/" );
// Find the possible equal start of the old project path, and the referenced file

View File

@ -739,8 +739,8 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
}
else if ( changedField == &m_minDateRange || changedField == &m_maxDateRange )
{
m_minTimeStep = RiaTimeTTools::fromQDateTime( QDateTime( m_minDateRange() ) );
m_maxTimeStep = RiaTimeTTools::fromQDateTime( QDateTime( m_maxDateRange() ) );
m_minTimeStep = RiaTimeTTools::fromQDateTime( RiaQDateTimeTools::createDateTime( m_minDateRange() ) );
m_maxTimeStep = RiaTimeTTools::fromQDateTime( RiaQDateTimeTools::createDateTime( m_maxDateRange() ) );
updateCurveColors();
updateTimeAnnotations();
}

View File

@ -23,6 +23,7 @@
#include "RiaStdStringTools.h"
#include "RiaStringListSerializer.h"
#include "RiaSummaryCurveDefinition.h"
#include "RiaTextStringTools.h"
#include "RifReaderEclipseSummary.h"
#include "RifSummaryReaderInterface.h"
@ -183,7 +184,7 @@ void RimSummaryPlotFilterTextCurveSetEditor::updateTextFilter()
// Todo: possibly check grid time history curves also
QStringList allCurveAddressFilters =
curveFilterTextWithoutOutdatedLabel().split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
RiaTextStringTools::splitSkipEmptyParts( curveFilterTextWithoutOutdatedLabel(), QRegExp( "\\s+" ) );
std::vector<bool> usedFilters;
std::set<RifEclipseSummaryAddress> filteredAddressesFromSource;
@ -440,7 +441,7 @@ void RimSummaryPlotFilterTextCurveSetEditor::updateParentPlot()
std::set<RiaSummaryCurveDefinition> curveDefinitions;
QStringList allCurveAddressFilters =
curveFilterTextWithoutOutdatedLabel().split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
RiaTextStringTools::splitSkipEmptyParts( curveFilterTextWithoutOutdatedLabel(), QRegExp( "\\s+" ) );
std::vector<bool> accumulatedUsedFilters( allCurveAddressFilters.size(), false );
for ( SummarySource* currSource : selectedSummarySources() )

View File

@ -22,6 +22,7 @@
#include "RiaStringListSerializer.h"
#include "RiaSummaryStringTools.h"
#include "RiaSummaryTools.h"
#include "RiaTextStringTools.h"
#include "RifReaderEclipseSummary.h"
#include "RifSummaryReaderInterface.h"
@ -507,7 +508,7 @@ std::set<RifEclipseSummaryAddress> RimSummaryPlotManager::filteredAddresses()
if ( nativeAddresses.empty() ) return {};
QStringList allCurveAddressFilters = m_filterText().split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
QStringList allCurveAddressFilters = RiaTextStringTools::splitSkipEmptyParts( m_filterText(), QRegExp( "\\s+" ) );
return RiaSummaryStringTools::computeFilteredAddresses( allCurveAddressFilters, nativeAddresses, m_includeDiffCurves );
}

View File

@ -92,6 +92,7 @@
#include "cafPdmUiSliderEditor.h"
#include "cafSelectionManager.h"
#include "caf.h"
#include "cvfAssert.h"
#include <QWheelEvent>
@ -2108,29 +2109,30 @@ RimDepthTrackPlot* RimWellLogTrack::parentWellLogPlot() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::handleWheelEvent( QWheelEvent* event )
void RimWellLogTrack::handleWheelEvent( QWheelEvent* wheelEvent )
{
RimDepthTrackPlot* wellLogPlot = nullptr;
this->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
if ( event->modifiers() & Qt::ControlModifier )
if ( wheelEvent->modifiers() & Qt::ControlModifier )
{
double zoomCenter = 0.0;
auto position = caf::position( wheelEvent );
if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
QwtScaleMap scaleMap = m_plotWidget->qwtPlot()->canvasMap( QwtPlot::yLeft );
zoomCenter = scaleMap.invTransform( event->pos().y() );
zoomCenter = scaleMap.invTransform( position.y() );
}
else
{
QwtScaleMap scaleMap = m_plotWidget->qwtPlot()->canvasMap( QwtPlot::xTop );
zoomCenter = scaleMap.invTransform( event->pos().x() );
zoomCenter = scaleMap.invTransform( position.x() );
}
if ( event->delta() > 0 )
if ( wheelEvent->angleDelta().y() > 0 )
{
wellLogPlot->setDepthAxisRangeByFactorAndCenter( RI_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
}
@ -2141,8 +2143,8 @@ void RimWellLogTrack::handleWheelEvent( QWheelEvent* event )
}
else
{
wellLogPlot->setDepthAxisRangeByPanDepth( event->delta() < 0 ? RI_SCROLLWHEEL_PANFACTOR
: -RI_SCROLLWHEEL_PANFACTOR );
wellLogPlot->setDepthAxisRangeByPanDepth( wheelEvent->angleDelta().y() < 0 ? RI_SCROLLWHEEL_PANFACTOR
: -RI_SCROLLWHEEL_PANFACTOR );
}
}
}

View File

@ -23,6 +23,8 @@
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
#include "RiaTextStringTools.h"
#include "RimSummaryCase.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
@ -56,7 +58,7 @@ RimcSummaryPlotCollection_newSummaryPlot::RimcSummaryPlotCollection_newSummaryPl
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcSummaryPlotCollection_newSummaryPlot::execute()
{
QStringList addressStrings = m_addressString().split( ";", QString::SkipEmptyParts );
QStringList addressStrings = RiaTextStringTools::splitSkipEmptyParts( m_addressString(), ";" );
RimSummaryPlot* newPlot = nullptr;
if ( m_ensemble )

View File

@ -18,6 +18,8 @@
#include "RigEquil.h"
#include "RiaTextStringTools.h"
#include <QStringList>
//--------------------------------------------------------------------------------------------------
@ -133,7 +135,7 @@ RigEquil RigEquil::parseString( const QString& keywordData )
QString line( keywordData );
line.replace( "\t", " " );
QStringList items = line.split( " ", QString::SkipEmptyParts );
QStringList items = RiaTextStringTools::splitSkipEmptyParts( line );
if ( items.size() > 0 )
{
datumDepth = items.at( 0 ).toDouble();

View File

@ -1,16 +1,19 @@
#include "gtest/gtest.h"
#include "RiaQDateTimeTools.h"
#include "RifColumnBasedUserData.h"
#include "RifColumnBasedUserDataParser.h"
#include "RifCsvUserDataParser.h"
#include "RifEclipseUserDataKeywordTools.h"
#include "RifEclipseUserDataParserTools.h"
#include "RifKeywordVectorParser.h"
#include "SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeatureUi.h"
#include "RiaQDateTimeTools.h"
#include "RifEclipseUserDataKeywordTools.h"
#include <QDebug>
#include <QTextStream>
#include "caf.h"
#include <vector>
//--------------------------------------------------------------------------------------------------
@ -21,7 +24,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatYyyymmddWithDash )
AsciiDataParseOptions parseOptions;
parseOptions.dateFormat = "yyyy-MM-dd";
parseOptions.cellSeparator = "\t";
parseOptions.locale = QLocale::Norwegian;
parseOptions.locale = caf::norwegianLocale();
parseOptions.timeSeriesColumnName = "Date";
QString data;
@ -78,7 +81,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatYymmddWithDot )
AsciiDataParseOptions parseOptions;
parseOptions.dateFormat = "yy.MM.dd";
parseOptions.cellSeparator = "\t";
parseOptions.locale = QLocale::Norwegian;
parseOptions.locale = caf::norwegianLocale();
parseOptions.timeSeriesColumnName = "Date";
QString data;
@ -133,7 +136,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDateFormatDdmmyyWithDot )
AsciiDataParseOptions parseOptions;
parseOptions.dateFormat = "dd.MM.yy";
parseOptions.cellSeparator = "\t";
parseOptions.locale = QLocale::Norwegian;
parseOptions.locale = caf::norwegianLocale();
parseOptions.timeSeriesColumnName = "Date";
QString data;
@ -188,7 +191,7 @@ TEST( RifColumnBasedAsciiParserTest, TestDecimalLocaleNorwegian )
parseOptions.dateFormat = "yy.MM.dd";
parseOptions.cellSeparator = "\t";
parseOptions.decimalSeparator = ",";
parseOptions.locale = QLocale::Norwegian;
parseOptions.locale = caf::norwegianLocale();
parseOptions.timeSeriesColumnName = "Date";
QString data;

View File

@ -14,7 +14,7 @@
//--------------------------------------------------------------------------------------------------
TEST( RiaDateStringParserTest, ParseYearFirstWithSeparators )
{
QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) );
QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) );
may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> may2ndStrings = { "2011 05 02",
@ -33,7 +33,7 @@ TEST( RiaDateStringParserTest, ParseYearFirstWithSeparators )
EXPECT_TRUE( may2ndDT == parsedDate );
}
QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) );
QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) );
nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> nov24thStrings = { "1992-11-24", "1992-Nov-24", "1992-nov-24", "1992.11.24" };
@ -48,7 +48,7 @@ TEST( RiaDateStringParserTest, ParseYearFirstWithSeparators )
//--------------------------------------------------------------------------------------------------
TEST( RiaDateStringParserTest, ParseDayFirstWithSeparators )
{
QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) );
QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) );
may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> may2ndStrings = { "02 05 2011",
@ -66,7 +66,7 @@ TEST( RiaDateStringParserTest, ParseDayFirstWithSeparators )
EXPECT_TRUE( may2ndDT == parsedDate );
}
QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) );
QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) );
nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> nov24thStrings = { "24-11-1992", "24-Nov-1992", "24.Nov 1992", "24.11.1992" };
@ -81,7 +81,7 @@ TEST( RiaDateStringParserTest, ParseDayFirstWithSeparators )
//--------------------------------------------------------------------------------------------------
TEST( RiaDateStringParserTest, ParseMonthFirstWithSeparators )
{
QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) );
QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) );
may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> may2ndStrings = { "May 02 2011", "may 02 2011", "May_02_2011", "May.02.2011", "May 02. 2011" };
@ -91,7 +91,7 @@ TEST( RiaDateStringParserTest, ParseMonthFirstWithSeparators )
EXPECT_TRUE( may2ndDT == parsedDate );
}
QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) );
QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) );
nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> nov24thStrings = { "11-24-1992", "Nov-24-1992", "Nov 24. 1992", "11.24.1992", "11 24 1992" };
@ -106,8 +106,8 @@ TEST( RiaDateStringParserTest, ParseMonthFirstWithSeparators )
//--------------------------------------------------------------------------------------------------
TEST( RiaDateStringParserTest, ParseWithoutSeparators )
{
QDateTime may2ndDT = QDateTime( QDate( 2011, 05, 02 ) );
QDateTime feb5thDT = QDateTime( QDate( 2011, 02, 05 ) );
QDateTime may2ndDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 05, 02 ) );
QDateTime feb5thDT = RiaQDateTimeTools::createDateTime( QDate( 2011, 02, 05 ) );
may2ndDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
feb5thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
@ -122,7 +122,7 @@ TEST( RiaDateStringParserTest, ParseWithoutSeparators )
EXPECT_FALSE( may2ndDT == RiaDateStringParser::parseDateString( may2ndMonthFirstString ) );
EXPECT_TRUE( feb5thDT == RiaDateStringParser::parseDateString( may2ndMonthFirstString ) );
QDateTime nov24thDT = QDateTime( QDate( 1992, 11, 24 ) );
QDateTime nov24thDT = RiaQDateTimeTools::createDateTime( QDate( 1992, 11, 24 ) );
nov24thDT.setTimeSpec( RiaQDateTimeTools::currentTimeSpec() );
std::vector<std::string> nov24thStrings = { "19921124", "24111992", "921124", "241192", "11241992", "112492" };

View File

@ -1,5 +1,7 @@
#include "gtest/gtest.h"
#include "RiaTextStringTools.h"
#include "RifTextDataTableFormatter.h"
#include <QString>
@ -106,7 +108,7 @@ TEST( RifTextDataTableFormatter, LongLine )
formatter.rowCompleted();
formatter.tableCompleted();
QStringList tableLines = tableText.split( QRegExp( "[\r\n]" ), QString::SkipEmptyParts );
QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) );
for ( QString line : tableLines )
{
std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl;
@ -153,7 +155,7 @@ TEST( RifTextDataTableFormatter, LongLine132 )
formatter.rowCompleted();
formatter.tableCompleted();
QStringList tableLines = tableText.split( QRegExp( "[\r\n]" ), QString::SkipEmptyParts );
QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) );
for ( QString line : tableLines )
{
std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl;
@ -200,7 +202,7 @@ TEST( RifTextDataTableFormatter, LongLine133 )
formatter.rowCompleted();
formatter.tableCompleted();
QStringList tableLines = tableText.split( QRegExp( "[\r\n]" ), QString::SkipEmptyParts );
QStringList tableLines = RiaTextStringTools::splitSkipEmptyParts( tableText, QRegExp( "[\r\n]" ) );
for ( QString line : tableLines )
{
std::cout << QString( "Line: \"%1\"" ).arg( line ).toStdString() << std::endl;

View File

@ -18,8 +18,10 @@
#include "gtest/gtest.h"
#include "QDateTime"
#include "QDebug"
#include <QDateTime>
#include <QDebug>
#include <QElapsedTimer>
#include "RigHexIntersectionTools.h"
//--------------------------------------------------------------------------------------------------
@ -74,12 +76,12 @@ TEST( RigHexIntersectionTools, DISABLED_planeHexCellIntersectionPerformanceTest
fracturePlaneNotIntersecting.setFromPointAndNormal( cvf::Vec3d( 1.5, 1.5, 1.5 ), cvf::Vec3d( 1, 0, 0 ) );
fracturePlaneIntersecting.setFromPointAndNormal( cvf::Vec3d( 0.5, 0.5, 0.5 ), cvf::Vec3d( 1, 0, 0 ) );
QTime timeTotal;
QElapsedTimer timeTotal;
timeTotal.start();
for ( int run = 0; run < 5; run++ )
{
QTime timeLocal;
QElapsedTimer timeLocal;
timeLocal.start();
for ( int i = 0; i < 2000000; i++ )

View File

@ -18,7 +18,10 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuCadNavigation.h"
#include "caf.h"
#include "cafViewer.h"
#include "cvfCamera.h"
#include "cvfHitItemCollection.h"
#include "cvfManipulatorTrackball.h"
@ -121,18 +124,19 @@ bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent )
{
if ( inputEvent->modifiers() == Qt::NoModifier )
{
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
auto position = caf::position( we );
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
updatePointOfInterestDuringZoomIfNecessary( position.x(), position.y() );
if ( m_isRotCenterInitialized )
{
int translatedMousePosX, translatedMousePosY;
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
cvfEventPos( position.x(), position.y(), &translatedMousePosX, &translatedMousePosY );
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
zoomAlongRay( ray.p(), -we->delta() );
zoomAlongRay( ray.p(), -we->angleDelta().y() );
}
isEventHandled = true;
}

View File

@ -1,5 +1,7 @@
#include "RiuCategoryLegendFrame.h"
#include "RiaTextStringTools.h"
#include "cafCategoryLegend.h"
#include "cvfqtUtils.h"
@ -29,7 +31,7 @@ RiuCategoryLegendFrame::~RiuCategoryLegendFrame()
void RiuCategoryLegendFrame::layoutInfo( LayoutInfo* layout ) const
{
QFontMetrics fontMetrics( this->font() );
QStringList titleLines = m_title.split( "\n", QString::SkipEmptyParts );
QStringList titleLines = RiaTextStringTools::splitSkipEmptyParts( m_title, "\n" );
layout->charHeight = fontMetrics.height();
layout->charAscent = fontMetrics.ascent();

View File

@ -235,7 +235,7 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const
//--------------------------------------------------------------------------------------------------
Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
{
Qt::ItemFlags itemflags = nullptr;
Qt::ItemFlags itemflags;
if ( index.isValid() && RiaGuiApplication::activeMainWindow() )
{

View File

@ -19,6 +19,8 @@
#include "RiuFemTimeHistoryResultAccessor.h"
#include "RiaNumberFormat.h"
#include "RigFemClosestResultIndexCalculator.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
@ -26,6 +28,7 @@
#include "RigFemPartResultsCollection.h"
#include "RigFemTypes.h"
#include "RigGeoMechCaseData.h"
#include "RiuGeoMechXfTensorResultAccessor.h"
#include <cmath> // Needed for HUGE_VAL on Linux
@ -101,11 +104,12 @@ QString RiuFemTimeHistoryResultAccessor::geometrySelectionText() const
cvf::Vec3d domainCoord = m_intersectionPointInDomain;
text += QString( ", ijk[%1, %2, %3] " ).arg( i ).arg( j ).arg( k );
QString formattedText;
formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]",
domainCoord.x(),
domainCoord.y(),
-domainCoord.z() );
auto xTxt = RiaNumberFormat::valueToText( domainCoord.x(), RiaNumberFormat::NumberFormatType::FIXED, 2 );
auto yTxt = RiaNumberFormat::valueToText( domainCoord.y(), RiaNumberFormat::NumberFormatType::FIXED, 2 );
auto zTxt = RiaNumberFormat::valueToText( -domainCoord.z(), RiaNumberFormat::NumberFormatType::FIXED, 2 );
QString formattedText =
QString( "Intersection point : [E: %1, N: %2, Depth: %3]" ).arg( xTxt ).arg( yTxt ).arg( zTxt );
text += formattedText;
}

View File

@ -18,7 +18,10 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuGeoQuestNavigation.h"
#include "caf.h"
#include "cafViewer.h"
#include "cvfCamera.h"
#include "cvfHitItemCollection.h"
#include "cvfManipulatorTrackball.h"
@ -132,18 +135,19 @@ bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent )
{
if ( inputEvent->modifiers() == Qt::NoModifier )
{
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
auto position = caf::position( we );
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
updatePointOfInterestDuringZoomIfNecessary( position.x(), position.y() );
if ( m_isRotCenterInitialized )
{
int translatedMousePosX, translatedMousePosY;
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
cvfEventPos( position.x(), position.y(), &translatedMousePosX, &translatedMousePosY );
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
zoomAlongRay( ray.p(), -we->delta() );
zoomAlongRay( ray.p(), -we->angleDelta().y() );
}
isEventHandled = true;
}

View File

@ -29,7 +29,7 @@ class QStringList;
class RiuGridStatisticsHistogramWidget : public QWidget
{
public:
RiuGridStatisticsHistogramWidget( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
RiuGridStatisticsHistogramWidget( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
void setHistogramData( double min, double max, const std::vector<size_t>& histogram );
void setPercentiles( double pmin, double pmax );

View File

@ -627,17 +627,12 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
plotWidgets[visibleIndex]->setAxesFontsAndAlignment( m_axisTitleFontSize, m_axisValueFontSize );
{
int left = 0;
int top = 0;
int right = 0;
int bot = 0;
plotWidgets[visibleIndex]->getContentsMargins( &left, &top, &right, &bot );
bot = 40;
auto margins = plotWidgets[visibleIndex]->contentsMargins();
margins.setBottom( 40 );
// Adjust the space below a graph to make sure the heading of the row below is closest to the
// corresponding graph
plotWidgets[visibleIndex]->setContentsMargins( left, top, right, bot );
plotWidgets[visibleIndex]->setContentsMargins( margins );
}
plotWidgets[visibleIndex]->show();

View File

@ -129,7 +129,7 @@ QRect RiuPlotCurveSymbol::labelBoundingRect( const QPainter* painter, const QRec
int symbolWidth = symbolRect.width();
int symbolHeight = symbolRect.height();
int labelWidth = painter->fontMetrics().width( label );
int labelWidth = painter->fontMetrics().horizontalAdvance( label );
int labelHeight = painter->fontMetrics().height();
QPoint labelPosition;

View File

@ -33,7 +33,7 @@ class PdmObjectHandle;
class RiuProjectAndPropertyView : public QWidget
{
public:
RiuProjectAndPropertyView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
RiuProjectAndPropertyView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
void setPdmItem( caf::PdmUiItem* object );
void showProperties( caf::PdmObjectHandle* object );
@ -41,4 +41,4 @@ public:
private:
caf::PdmUiTreeView* m_projectTreeView;
caf::PdmUiPropertyView* m_propertyView;
};
};

View File

@ -33,6 +33,7 @@
#include "RiuQtChartsPlotCurve.h"
#include "RiuQwtDateScaleWrapper.h"
#include "caf.h"
#include "cafAssert.h"
#include "cvfTrace.h"
@ -1160,9 +1161,9 @@ void RiuQtChartsPlotWidget::dropEvent( QDropEvent* event )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQtChartsPlotWidget::wheelEvent( QWheelEvent* event )
void RiuQtChartsPlotWidget::wheelEvent( QWheelEvent* wheelEvent )
{
float factor = event->angleDelta().y() > 0 ? 0.9 : 1.1;
float factor = wheelEvent->angleDelta().y() > 0 ? 0.9 : 1.1;
QRectF plotAreaRect = m_viewer->chart()->plotArea();
QPointF centerPoint = plotAreaRect.center();
@ -1171,14 +1172,16 @@ void RiuQtChartsPlotWidget::wheelEvent( QWheelEvent* event )
plotAreaRect.setWidth( plotAreaRect.width() * factor );
plotAreaRect.setHeight( plotAreaRect.height() * factor );
auto position = caf::position( wheelEvent );
// Find new center which keeps the mouse location in the same place in the plot
QPointF newCenterPoint( ( 2 * centerPoint - event->pos() ) - ( centerPoint - event->pos() ) / factor );
QPointF newCenterPoint( ( 2 * centerPoint - position ) - ( centerPoint - position ) / factor );
plotAreaRect.moveCenter( newCenterPoint );
// Zoom in on the adjusted plot area
m_viewer->chart()->zoomIn( plotAreaRect );
event->accept();
wheelEvent->accept();
}
//--------------------------------------------------------------------------------------------------

View File

@ -18,6 +18,8 @@
#include "RiuQwtPlotWheelZoomer.h"
#include "caf.h"
#include "qwt_plot.h"
#include "qwt_scale_div.h"
@ -86,15 +88,16 @@ bool RiuQwtPlotWheelZoomer::eventFilter( QObject* watched, QEvent* event )
if ( wheelEvent )
{
double zoomFactor = 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR;
if ( wheelEvent->delta() > 0 )
if ( wheelEvent->angleDelta().y() > 0 )
{
zoomFactor = RIU_SCROLLWHEEL_ZOOMFACTOR;
}
zoomOnAxis( m_plot, QwtPlot::xBottom, zoomFactor, wheelEvent->pos().x() );
zoomOnAxis( m_plot, QwtPlot::xTop, zoomFactor, wheelEvent->pos().x() );
zoomOnAxis( m_plot, QwtPlot::yLeft, zoomFactor, wheelEvent->pos().y() );
zoomOnAxis( m_plot, QwtPlot::yRight, zoomFactor, wheelEvent->pos().y() );
auto position = caf::position( wheelEvent );
zoomOnAxis( m_plot, QwtPlot::xBottom, zoomFactor, position.x() );
zoomOnAxis( m_plot, QwtPlot::xTop, zoomFactor, position.x() );
zoomOnAxis( m_plot, QwtPlot::yLeft, zoomFactor, position.y() );
zoomOnAxis( m_plot, QwtPlot::yRight, zoomFactor, position.y() );
m_plot->replot();
emit zoomUpdated();

View File

@ -18,7 +18,10 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuRmsNavigation.h"
#include "caf.h"
#include "cafViewer.h"
#include "cvfCamera.h"
#include "cvfHitItemCollection.h"
#include "cvfManipulatorTrackball.h"
@ -157,18 +160,19 @@ bool RiuRmsNavigation::handleInputEvent( QInputEvent* inputEvent )
{
if ( inputEvent->modifiers() == Qt::NoModifier )
{
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
auto position = caf::position( we );
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
updatePointOfInterestDuringZoomIfNecessary( position.x(), position.y() );
if ( m_isRotCenterInitialized )
{
int translatedMousePosX, translatedMousePosY;
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
cvfEventPos( position.x(), position.y(), &translatedMousePosX, &translatedMousePosY );
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
zoomAlongRay( ray.p(), -we->delta() );
zoomAlongRay( ray.p(), -we->angleDelta().y() );
}
isEventHandled = true;
}

View File

@ -17,6 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuScalarMapperLegendFrame.h"
#include "RiaTextStringTools.h"
#include "cvfScalarMapperDiscreteLinear.h"
#include "cvfScalarMapperDiscreteLog.h"
#include "cvfString.h"
@ -72,7 +74,7 @@ void RiuScalarMapperLegendFrame::setTickFormat( NumberFormat format )
void RiuScalarMapperLegendFrame::layoutInfo( LayoutInfo* layout ) const
{
QFontMetrics fontMetrics( this->font() );
QStringList titleLines = m_title.split( "\n", QString::SkipEmptyParts );
QStringList titleLines = RiaTextStringTools::splitSkipEmptyParts( m_title, "\n" );
layout->charHeight = fontMetrics.height();
layout->charAscent = fontMetrics.ascent();

View File

@ -29,7 +29,7 @@ class QStringList;
class RiuSimpleHistogramWidget : public QWidget
{
public:
RiuSimpleHistogramWidget( const QString& objectName, QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
RiuSimpleHistogramWidget( const QString& objectName, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
void setHistogramData( double min, double max, const std::vector<size_t>& histogram );
void setPercentiles( double pmin, double pmax );

View File

@ -18,6 +18,8 @@
#include "RiuTextContentFrame.h"
#include "RiaTextStringTools.h"
#include "RiaFontCache.h"
#include "RiaPreferences.h"
@ -168,7 +170,7 @@ void RiuTextContentFrame::paintEvent( QPaintEvent* e )
void RiuTextContentFrame::layoutInfo( LayoutInfo* layout ) const
{
QFontMetrics fontMetrics( this->font() );
QStringList titleLines = m_text.split( "\n", QString::SkipEmptyParts );
QStringList titleLines = RiaTextStringTools::splitSkipEmptyParts( m_text, "\n" );
layout->charHeight = fontMetrics.height();
layout->charAscent = fontMetrics.ascent();

View File

@ -16,6 +16,8 @@ find_package(
set(QT_LIBRARIES Qt5::Core)
set(PROJECT_FILES
caf.h
caf.cpp
cafAssert.h
cafAppEnum.h
cafClassTypeName.h

View File

@ -0,0 +1,81 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2020- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "caf.h"
#include "QtGui/qevent.h"
#include <QLocale>
#include <QTextStream>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QLocale norwegianLocale()
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
return QLocale::NorwegianBokmal;
#else
return QLocale::Norwegian;
#endif
} // namespace caf::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
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QPointF position( QWheelEvent* wheelEvent )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
return wheelEvent->position();
#else
return wheelEvent->pos();
#endif
}
} // namespace caf

View File

@ -0,0 +1,48 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2020- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
class QLocale;
class QTextStream;
class QPointF;
class QWheelEvent;
namespace caf
{
QLocale norwegianLocale();
QTextStream& endl( QTextStream& s );
QPointF position( QWheelEvent* wheelEvent );
}; // namespace caf

View File

@ -69,7 +69,7 @@ public:
void defineGridLayout(int rowCount, int columnCount);
// See QGridLayout::addWidget
void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = nullptr);
void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = Qt::Alignment());
void removeWidget(QWidget* widget);
void addBlankCell(int row, int column);

View File

@ -10,7 +10,7 @@ class WidgetLayoutTest : public QWidget
Q_OBJECT
public:
WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr);
WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~WidgetLayoutTest() override;
private:

View File

@ -52,7 +52,7 @@ class PdmUiListView : public QWidget
{
Q_OBJECT
public:
PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~PdmUiListView() override;
void setPdmObject( caf::PdmObjectCollection* object );

View File

@ -59,7 +59,7 @@ class PdmUiTableView : public QWidget
{
Q_OBJECT
public:
PdmUiTableView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
PdmUiTableView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~PdmUiTableView() override;
void setChildArrayField( PdmChildArrayFieldHandle* childArrayField );

View File

@ -64,7 +64,7 @@ class PdmUiTreeView : public QWidget
{
Q_OBJECT
public:
PdmUiTreeView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
PdmUiTreeView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~PdmUiTreeView() override;
void enableDefaultContextMenu( bool enable );

View File

@ -59,7 +59,7 @@ public:
QWidget* parent,
OpenGLWidget* shareWidget = nullptr,
Qt::WindowFlags f = nullptr );
OpenGLWidget( OpenGLWidget* shareWidget, QWidget* parent, Qt::WindowFlags f = nullptr );
OpenGLWidget( OpenGLWidget* shareWidget, QWidget* parent, Qt::WindowFlags f = Qt::WindowFlags() );
cvf::OpenGLContext* cvfOpenGLContext() const;
void cvfShutdownOpenGLContext();