mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
sort chart dropdowns
This commit is contained in:
@@ -102,6 +102,10 @@ BreadcrumbButton::sizeHint() const
|
|||||||
return m_combo->sizeHint() + QSize( padding, 0 );
|
return m_combo->sizeHint() + QSize( padding, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool caseInsensitiveLessThan( const QString &s1, const QString &s2 )
|
||||||
|
{
|
||||||
|
return s1.toLower() < s2.toLower();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BreadcrumbButton::setParentIndex( const QModelIndex& idx )
|
BreadcrumbButton::setParentIndex( const QModelIndex& idx )
|
||||||
@@ -112,12 +116,19 @@ BreadcrumbButton::setParentIndex( const QModelIndex& idx )
|
|||||||
QStringList list;
|
QStringList list;
|
||||||
int count = m_model->rowCount( m_parentIndex );
|
int count = m_model->rowCount( m_parentIndex );
|
||||||
int defaultIndex = -1, userSelected = -1;
|
int defaultIndex = -1, userSelected = -1;
|
||||||
|
|
||||||
|
// Two-pass so we can sort the list first
|
||||||
|
for ( int i = 0; i < count; ++i )
|
||||||
|
{
|
||||||
|
list << m_model->index( i, 0, m_parentIndex ).data().toString();
|
||||||
|
}
|
||||||
|
qSort( list.begin(), list.end(), caseInsensitiveLessThan );
|
||||||
|
|
||||||
for ( int i = 0; i < count; ++i )
|
for ( int i = 0; i < count; ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = m_model->index( i, 0, m_parentIndex );
|
QModelIndex idx = m_model->index( i, 0, m_parentIndex );
|
||||||
if ( idx.isValid() )
|
if ( idx.isValid() )
|
||||||
{
|
{
|
||||||
list << idx.data().toString();
|
|
||||||
if ( idx.data( Breadcrumb::DefaultRole ).toBool() )
|
if ( idx.data( Breadcrumb::DefaultRole ).toBool() )
|
||||||
defaultIndex = i;
|
defaultIndex = i;
|
||||||
if ( idx.data( Breadcrumb::UserSelectedRole ).toBool() )
|
if ( idx.data( Breadcrumb::UserSelectedRole ).toBool() )
|
||||||
|
Reference in New Issue
Block a user