mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6367 Improve the way we automatically name ensembles and cases
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -55,3 +56,29 @@ QString RiaTextStringTools::trimAndRemoveDoubleSpaces( const QString& s )
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaTextStringTools::findCommonRoot( const QStringList& stringList )
|
||||
{
|
||||
QString root = stringList.front();
|
||||
for ( const auto& item : stringList )
|
||||
{
|
||||
if ( root.length() > item.length() )
|
||||
{
|
||||
root.truncate( item.length() );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < root.length(); ++i )
|
||||
{
|
||||
if ( root[i] != item[i] )
|
||||
{
|
||||
root.truncate( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user