Commit a358770b authored by Peter Amidon's avatar Peter Amidon Committed by Edward Hades
Browse files

Fix duplicate-name bug in creating playlist folders

Previously, the code sorted numbers as string when determining the
current largest number of duplicate folders. The code now uses
std::max_element on a list of integers to circumvent that problem

BUG: 312461
FIXED-IN: 2.7
REVIEW: 108245
parent 647192b6
......@@ -276,15 +276,18 @@ PlaylistBrowserCategory::createNewFolder()
QString groupName = name;
if( !folderIndices.isEmpty() )
{
QStringList names;
foreach( const QModelIndex &folder, folderIndices )
names << folder.data( Qt::DisplayRole ).toString();
names.sort();
QRegExp regex( "\\((\\d+)\\)" );
int folderCount( 0 );
int matchIndex = regex.indexIn( names.last() );
if( matchIndex != -1 )
folderCount = regex.cap( 1 ).toInt();
foreach( const QModelIndex &folder, folderIndices )
{
QRegExp regex( name + " \\((\\d+)\\)" );
int matchIndex = regex.indexIn( folder.data( Qt::DisplayRole ).toString() );
if (matchIndex != -1)
{
int newNumber = regex.cap( 1 ).toInt();
if (newNumber > folderCount)
folderCount = newNumber;
}
}
groupName += QString( " (%1)" ).arg( folderCount + 1 );
}
QModelIndex idx = m_filterProxy->mapFromSource( m_byFolderProxy->createNewFolder( groupName ) );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment