#6367 Improve the way we automatically name ensembles and cases

This commit is contained in:
Gaute Lindkvist
2020-09-02 15:04:48 +02:00
parent f38d119cc8
commit 7cf24d02ff
17 changed files with 416 additions and 110 deletions

View File

@@ -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;
}