1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

* Fixed TWK-442: Provide stable sort ordering in Track- / TreeProxyModel.

This commit is contained in:
Christian Muehlhaeuser 2011-08-21 03:51:26 +02:00
parent 1653e16e7d
commit 99e3e06716
2 changed files with 9 additions and 2 deletions

View File

@ -318,8 +318,8 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
unsigned int albumpos1 = 0, albumpos2 = 0;
unsigned int bitrate1 = 0, bitrate2 = 0;
unsigned int mtime1 = 0, mtime2 = 0;
unsigned int id1 = 0, id2 = 0;
unsigned int size1 = 0, size2 = 0;
qint64 id1 = 0, id2 = 0;
if ( q1->numResults() )
{
@ -346,6 +346,13 @@ TrackProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) c
size2 = r->size();
}
// This makes it a stable sorter and prevents items from randomly jumping about.
if ( id1 == id2 )
{
id1 = (qint64)&q1;
id2 = (qint64)&q2;
}
if ( left.column() == TrackModel::Artist ) // sort by artist
{
if ( artist1 == artist2 )

View File

@ -145,7 +145,7 @@ TreeProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) co
return p1->result()->albumpos() < p2->result()->albumpos();
if ( lefts == rights )
return p1->result()->dbid() < p2->result()->dbid();
return (qint64)&p1 < (qint64)&p2;
}
return QString::localeAwareCompare( lefts, rights ) < 0;