1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 01:24:11 +02:00

Sort album models by artist name first.

This commit is contained in:
Christian Muehlhaeuser
2014-11-12 06:28:24 +01:00
parent c2b842ef9c
commit 1f69b43bdd
2 changed files with 20 additions and 9 deletions

View File

@@ -384,15 +384,8 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
const unsigned int albumpos2 = t2->albumpos();
const unsigned int discnumber1 = t1->discnumber();
const unsigned int discnumber2 = t2->discnumber();
qint64 id1 = 0, id2 = 0;
// This makes it a stable sorter and prevents items from randomly jumping about.
// FIXME: This always true.
if ( id1 == id2 )
{
id1 = (qint64)&q1;
id2 = (qint64)&q2;
}
const qint64 id1 = (qint64)&q1;
const qint64 id2 = (qint64)&q2;
if ( column == PlayableModel::Artist ) // sort by artist
{
@@ -566,6 +559,18 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
}
bool
PlayableProxyModel::lessThan( const Tomahawk::album_ptr& album1, const Tomahawk::album_ptr& album2 ) const
{
if ( album1->artist() == album2->artist() )
{
return QString::localeAwareCompare( album1->sortname(), album2->sortname() ) < 0;
}
return QString::localeAwareCompare( album1->artist()->sortname(), album2->artist()->sortname() ) < 0;
}
bool
PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
{
@@ -581,6 +586,10 @@ PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right
{
return lessThan( left.column(), p1->query(), p2->query() );
}
if ( p1->album() && p2->album() )
{
return lessThan( p1->album(), p2->album() );
}
return QString::localeAwareCompare( sourceModel()->data( left ).toString(), sourceModel()->data( right ).toString() ) < 0;
}

View File

@@ -135,7 +135,9 @@ private:
bool nameFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
bool dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
bool lessThan( const Tomahawk::album_ptr& album1, const Tomahawk::album_ptr& album2 ) const;
QPointer<PlayableModel> m_model;