From 9dbe62fa6c30194f795bd6467624ba27c9b08193 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 15 Sep 2012 06:11:12 +0200 Subject: [PATCH] * Fixed sorting by duration. --- src/libtomahawk/playlist/PlayableProxyModel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index 0bdb821e5..67bc6ae5c 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -273,6 +273,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T const unsigned int albumpos2 = q2->albumpos(); const unsigned int discnumber1 = q1->discnumber(); const unsigned int discnumber2 = q2->discnumber(); + unsigned int duration1 = q1->duration(), duration2 = q2->duration(); unsigned int bitrate1 = 0, bitrate2 = 0; unsigned int mtime1 = 0, mtime2 = 0; unsigned int size1 = 0, size2 = 0; @@ -285,6 +286,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T { const Tomahawk::result_ptr& r = q1->results().at( 0 ); bitrate1 = r->bitrate(); + duration1 = r->duration(); mtime1 = r->modificationTime(); size1 = r->size(); score1 = r->score(); @@ -295,6 +297,7 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T { const Tomahawk::result_ptr& r = q2->results().at( 0 ); bitrate2 = r->bitrate(); + duration2 = r->duration(); mtime2 = r->modificationTime(); size2 = r->size(); score2 = r->score(); @@ -377,6 +380,13 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T return bitrate1 < bitrate2; } + else if ( column == PlayableModel::Duration ) // sort by duration + { + if ( duration1 == duration2 ) + return id1 < id2; + + return duration1 < duration2; + } else if ( column == PlayableModel::Age ) // sort by mtime { if ( mtime1 == mtime2 )