mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
sort chart dropdowns
This commit is contained in:
parent
cd04d027a0
commit
44fa85af6b
@ -102,6 +102,10 @@ BreadcrumbButton::sizeHint() const
|
||||
return m_combo->sizeHint() + QSize( padding, 0 );
|
||||
}
|
||||
|
||||
bool caseInsensitiveLessThan( const QString &s1, const QString &s2 )
|
||||
{
|
||||
return s1.toLower() < s2.toLower();
|
||||
}
|
||||
|
||||
void
|
||||
BreadcrumbButton::setParentIndex( const QModelIndex& idx )
|
||||
@ -112,12 +116,19 @@ BreadcrumbButton::setParentIndex( const QModelIndex& idx )
|
||||
QStringList list;
|
||||
int count = m_model->rowCount( m_parentIndex );
|
||||
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 )
|
||||
{
|
||||
QModelIndex idx = m_model->index( i, 0, m_parentIndex );
|
||||
if ( idx.isValid() )
|
||||
{
|
||||
list << idx.data().toString();
|
||||
if ( idx.data( Breadcrumb::DefaultRole ).toBool() )
|
||||
defaultIndex = i;
|
||||
if ( idx.data( Breadcrumb::UserSelectedRole ).toBool() )
|
||||
|
Loading…
x
Reference in New Issue
Block a user