mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 09:34:53 +02:00
Sort album models by artist name first.
This commit is contained in:
@@ -384,15 +384,8 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
|
|||||||
const unsigned int albumpos2 = t2->albumpos();
|
const unsigned int albumpos2 = t2->albumpos();
|
||||||
const unsigned int discnumber1 = t1->discnumber();
|
const unsigned int discnumber1 = t1->discnumber();
|
||||||
const unsigned int discnumber2 = t2->discnumber();
|
const unsigned int discnumber2 = t2->discnumber();
|
||||||
qint64 id1 = 0, id2 = 0;
|
const qint64 id1 = (qint64)&q1;
|
||||||
|
const qint64 id2 = (qint64)&q2;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( column == PlayableModel::Artist ) // sort by artist
|
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
|
bool
|
||||||
PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
|
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() );
|
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;
|
return QString::localeAwareCompare( sourceModel()->data( left ).toString(), sourceModel()->data( right ).toString() ) < 0;
|
||||||
}
|
}
|
||||||
|
@@ -135,7 +135,9 @@ private:
|
|||||||
bool nameFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
|
bool nameFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
|
||||||
bool dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
|
bool dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
|
||||||
bool visibilityFilterAcceptsRow( int sourceRow, 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( 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;
|
QPointer<PlayableModel> m_model;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user