Well Path Groups

This commit is contained in:
Gaute Lindkvist
2020-10-14 18:55:17 +02:00
parent 5ec3e2a7d7
commit 7684596829
10 changed files with 381 additions and 137 deletions

View File

@@ -62,24 +62,27 @@ QString RiaTextStringTools::trimAndRemoveDoubleSpaces( const QString& s )
//--------------------------------------------------------------------------------------------------
QString RiaTextStringTools::commonRoot( const QStringList& stringList )
{
QString root = stringList.front();
for ( const auto& item : stringList )
QString root;
if ( !stringList.isEmpty() )
{
if ( root.length() > item.length() )
root = stringList.front();
for ( const auto& item : stringList )
{
root.truncate( item.length() );
}
for ( int i = 0; i < root.length(); ++i )
{
if ( root[i] != item[i] )
if ( root.length() > item.length() )
{
root.truncate( i );
break;
root.truncate( item.length() );
}
for ( int i = 0; i < root.length(); ++i )
{
if ( root[i] != item[i] )
{
root.truncate( i );
break;
}
}
}
}
return root;
}