From c6a104af93119f49d00a6a43988e2ea01f7c5e25 Mon Sep 17 00:00:00 2001 From: Casey Link Date: Sun, 21 Aug 2011 13:48:07 -0500 Subject: [PATCH] Use a proxy model that doesn't sort, so we preserve the ranking order --- src/libtomahawk/widgets/whatshotwidget.cpp | 12 +++++++++++- src/libtomahawk/widgets/whatshotwidget.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/widgets/whatshotwidget.cpp b/src/libtomahawk/widgets/whatshotwidget.cpp index 91c06151a..83badbaa3 100644 --- a/src/libtomahawk/widgets/whatshotwidget.cpp +++ b/src/libtomahawk/widgets/whatshotwidget.cpp @@ -28,6 +28,7 @@ #include "audio/audioengine.h" #include "playlist/playlistmodel.h" +#include "playlist/treeproxymodel.h" #include "widgets/overlaywidget.h" #include "utils/tomahawkutils.h" #include "utils/logger.h" @@ -62,9 +63,18 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent ) ui->tracksView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - m_artistsModel = new TreeModel( ui->artistsView); + m_artistsModel = new TreeModel( ui->artistsView ); m_artistsModel->setColumnStyle( TreeModel::TrackOnly ); + + m_artistsProxy = new TreeProxyModel( ui->artistsView ); + m_artistsProxy->setFilterCaseSensitivity( Qt::CaseInsensitive ); + m_artistsProxy->setDynamicSortFilter( true ); + + ui->artistsView->setProxyModel( m_artistsProxy ); ui->artistsView->setTreeModel( m_artistsModel ); + + m_artistsProxy->sort( -1 ); // disable sorting, must be called after artistsView->setTreeModel + ui->artistsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->artistsView->header()->setVisible( false ); diff --git a/src/libtomahawk/widgets/whatshotwidget.h b/src/libtomahawk/widgets/whatshotwidget.h index b9e719dda..2839c2eef 100644 --- a/src/libtomahawk/widgets/whatshotwidget.h +++ b/src/libtomahawk/widgets/whatshotwidget.h @@ -36,6 +36,7 @@ class TreeModel; class PlaylistModel; class OverlayWidget; +class TreeProxyModel; namespace Ui { @@ -79,6 +80,7 @@ private: PlaylistModel* m_tracksModel; TreeModel* m_artistsModel; + TreeProxyModel* m_artistsProxy; QTimer* m_timer; };