From 91a57c53054523ad5f7bd36588adcce319d3ff77 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 16 Jun 2013 23:22:33 +0200 Subject: [PATCH] Revert "Add icon() method to ViewPage api and use that and title() for sidebar items" We can't lazy load the page when we need its members to show the sidebar entry... This reverts commit 1821b24391c33b2ea14fc0d094142395588075d9. --- src/libtomahawk/ViewPage.cpp | 5 ----- src/libtomahawk/ViewPage.h | 1 - src/tomahawk/sourcetree/SourcesModel.cpp | 16 ++++++---------- src/tomahawk/sourcetree/SourcesModel.h | 7 +++++-- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/libtomahawk/ViewPage.cpp b/src/libtomahawk/ViewPage.cpp index 5e989745e..9b1704471 100644 --- a/src/libtomahawk/ViewPage.cpp +++ b/src/libtomahawk/ViewPage.cpp @@ -28,11 +28,6 @@ ViewPage::~ViewPage() tDebug( LOGVERBOSE ) << Q_FUNC_INFO; } -QIcon ViewPage::icon() const -{ - return QIcon(); -} - bool ViewPage::setFilter( const QString& filter ) diff --git a/src/libtomahawk/ViewPage.h b/src/libtomahawk/ViewPage.h index 5d9530aaf..9608770ba 100644 --- a/src/libtomahawk/ViewPage.h +++ b/src/libtomahawk/ViewPage.h @@ -49,7 +49,6 @@ public: virtual QWidget* widget() = 0; virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0; - virtual QIcon icon() const; virtual QString title() const = 0; virtual DescriptionType descriptionType() { return TextType; } diff --git a/src/tomahawk/sourcetree/SourcesModel.cpp b/src/tomahawk/sourcetree/SourcesModel.cpp index a00d2e594..56b61b0ab 100644 --- a/src/tomahawk/sourcetree/SourcesModel.cpp +++ b/src/tomahawk/sourcetree/SourcesModel.cpp @@ -348,17 +348,13 @@ SourcesModel::appendGroups() } void -SourcesModel::appendPageItem( const QString& pageName ) +SourcesModel::appendPageItem( const QIcon& pageIcon, const QString& pageTitle, const QString& pageName ) { QModelIndex parentIndex = indexFromItem( m_browse ); beginInsertRows( parentIndex, rowCount( parentIndex ), rowCount( parentIndex ) ); - GenericPageItem* pageItem = new GenericPageItem( this, - m_browse, - ViewManager::instance()->dynamicPageWidget( pageName )->title(), - ViewManager::instance()->dynamicPageWidget( pageName )->icon(), - boost::bind( &ViewManager::showDynamicPage, ViewManager::instance(), pageName ), - boost::bind( &ViewManager::dynamicPageWidget, ViewManager::instance(), pageName ) ); - + GenericPageItem* pageItem = new GenericPageItem( this, m_browse, pageTitle, pageIcon, + boost::bind( &ViewManager::showDynamicPage, ViewManager::instance(), pageName ), + boost::bind( &ViewManager::dynamicPageWidget, ViewManager::instance(), pageName ) ); pageItem->setSortValue( rowCount( parentIndex ) ); endInsertRows(); @@ -677,9 +673,9 @@ SourcesModel::onWidgetDestroyed( QWidget* w ) void -SourcesModel::onViewPageAdded( const QString& pageName ) +SourcesModel::onViewPageAdded( const QString& name ) { - appendPageItem( pageName ); + appendPageItem( ImageRegistry::instance()->icon( RESPATH "images/new-releases.svg" ), name, name); } diff --git a/src/tomahawk/sourcetree/SourcesModel.h b/src/tomahawk/sourcetree/SourcesModel.h index 4ba534f28..48172e57d 100644 --- a/src/tomahawk/sourcetree/SourcesModel.h +++ b/src/tomahawk/sourcetree/SourcesModel.h @@ -103,7 +103,10 @@ public: void appendGroups(); - void appendPageItem( const QString& pageName ); + /* + * pageIcon and pageTitle are visible in the source tree, pageName is the internal name in the ViewManager + */ + void appendPageItem( const QIcon& pageIcon, const QString& pageTitle, const QString& pageName ); void appendItem( const Tomahawk::source_ptr& source ); bool removeItem( const Tomahawk::source_ptr& source ); @@ -148,7 +151,7 @@ private slots: void onWidgetDestroyed( QWidget* w ); - void onViewPageAdded( const QString& pageName ); + void onViewPageAdded( const QString& name ); private: SourceTreeItem* itemFromIndex( const QModelIndex& idx ) const;