mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
Fix sort order of viewpages in the sidebar
This commit is contained in:
parent
1575174ab1
commit
b78769c0f9
@ -878,7 +878,7 @@ ViewManager::dynamicPageWidget( const QString& pageName ) const
|
||||
|
||||
|
||||
void
|
||||
ViewManager::addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function<Tomahawk::ViewPage*()> instanceLoader )
|
||||
ViewManager::addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function<Tomahawk::ViewPage*()> instanceLoader, int sortValue )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Trying to add " << pageName;
|
||||
|
||||
@ -889,7 +889,7 @@ ViewManager::addDynamicPage( const QString& pageName, const QString& text, const
|
||||
}
|
||||
|
||||
m_dynamicPagesInstanceLoaders.insert( pageName, instanceLoader );
|
||||
emit viewPageAdded( pageName, text, icon );
|
||||
emit viewPageAdded( pageName, text, icon, sortValue );
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ signals:
|
||||
void historyBackAvailable( bool avail );
|
||||
void historyForwardAvailable( bool avail );
|
||||
|
||||
void viewPageAdded( const QString& pageName, const QString& text, const QIcon& icon );
|
||||
void viewPageAdded( const QString& pageName, const QString& text, const QIcon& icon, int sortValue );
|
||||
|
||||
public slots:
|
||||
Tomahawk::ViewPage* showSuperCollection();
|
||||
@ -141,7 +141,7 @@ public slots:
|
||||
Tomahawk::ViewPage* showRecentPlaysPage();
|
||||
Tomahawk::ViewPage* showInboxPage();
|
||||
|
||||
void addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function< Tomahawk::ViewPage*() > instanceLoader );
|
||||
void addDynamicPage( const QString& pageName, const QString& text, const QIcon& icon, boost::function< Tomahawk::ViewPage*() > instanceLoader, int sortValue = 0 );
|
||||
Tomahawk::ViewPage* showDynamicPage( const QString& pageName );
|
||||
|
||||
void showCurrentTrack();
|
||||
|
@ -62,7 +62,7 @@ SourcesModel::SourcesModel( QObject* parent )
|
||||
{
|
||||
m_rootItem = new SourceTreeItem( this, 0, Invalid );
|
||||
|
||||
connect( ViewManager::instance(), SIGNAL( viewPageAdded( QString, QString, QIcon ) ), SLOT( appendPageItem( QString, QString, QIcon ) ) );
|
||||
connect( ViewManager::instance(), SIGNAL( viewPageAdded( QString, QString, QIcon, int ) ), SLOT( appendPageItem( QString, QString, QIcon, int ) ) );
|
||||
appendGroups();
|
||||
|
||||
onSourcesAdded( SourceList::instance()->sources() );
|
||||
@ -305,16 +305,15 @@ SourcesModel::appendGroups()
|
||||
m_myMusicGroup = new GroupItem( this, m_rootItem, tr( "My Music" ), 3 );
|
||||
|
||||
|
||||
InboxItem* inbox = new InboxItem( this, m_browse );
|
||||
inbox->setSortValue( 3 );
|
||||
|
||||
// super collection
|
||||
GenericPageItem* sc = new GenericPageItem( this, m_browse, tr( "SuperCollection" ), ImageRegistry::instance()->icon( RESPATH "images/supercollection.svg" ),
|
||||
boost::bind( &ViewManager::showSuperCollection, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::superCollectionView, ViewManager::instance() ) );
|
||||
sc->setSortValue( 1 );
|
||||
sc->setSortValue( 4 );
|
||||
|
||||
GenericPageItem* recent = new GenericPageItem( this, m_browse, tr( "Recently Played" ), ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ),
|
||||
boost::bind( &ViewManager::showRecentPlaysPage, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::recentPlaysWidget, ViewManager::instance() ) );
|
||||
recent->setSortValue( 4 );
|
||||
|
||||
GenericPageItem* hot = new GenericPageItem( this, m_browse, tr( "Charts" ), ImageRegistry::instance()->icon( RESPATH "images/charts.svg" ),
|
||||
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
|
||||
@ -327,8 +326,11 @@ SourcesModel::appendGroups()
|
||||
newReleases->setSortValue( 6 );
|
||||
|
||||
|
||||
InboxItem* inbox = new InboxItem( this, m_browse );
|
||||
inbox->setSortValue( 7 );
|
||||
GenericPageItem* recent = new GenericPageItem( this, m_browse, tr( "Recently Played" ), ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ),
|
||||
boost::bind( &ViewManager::showRecentPlaysPage, ViewManager::instance() ),
|
||||
boost::bind( &ViewManager::recentPlaysWidget, ViewManager::instance() ) );
|
||||
recent->setSortValue( 7 );
|
||||
|
||||
|
||||
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 4 );
|
||||
|
||||
@ -337,11 +339,13 @@ SourcesModel::appendGroups()
|
||||
endInsertRows();
|
||||
|
||||
// addDynamicPage takes care of begin/endInsertRows itself
|
||||
ViewManager::instance()->addDynamicPage("dashboard",
|
||||
ViewManager::instance()->addDynamicPage( "dashboard",
|
||||
tr( "Dashboard" ),
|
||||
ImageRegistry::instance()->icon( RESPATH "images/dashboard.svg" ),
|
||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::Dashboard >() )
|
||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::Dashboard >() ),
|
||||
1
|
||||
);
|
||||
|
||||
//HACK: this may not belong here, but adding the pages probably doesn't belong here either
|
||||
//TODO: find a good place for this
|
||||
ViewManager::instance()->showDynamicPage("dashboard");
|
||||
@ -349,19 +353,27 @@ SourcesModel::appendGroups()
|
||||
ViewManager::instance()->addDynamicPage("network_activity",
|
||||
tr( "Network Activity" ),
|
||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
|
||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::NetworkActivityWidget >() )
|
||||
boost::lambda::bind( boost::lambda::new_ptr< Tomahawk::Widgets::NetworkActivityWidget >() ),
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
SourcesModel::appendPageItem( const QString& name, const QString& text, const QIcon& icon )
|
||||
SourcesModel::appendPageItem( const QString& name, const QString& text, const QIcon& icon, int sortValue )
|
||||
{
|
||||
QModelIndex parentIndex = indexFromItem( m_browse );
|
||||
beginInsertRows( parentIndex, rowCount( parentIndex ), rowCount( parentIndex ) );
|
||||
GenericPageItem* pageItem = new GenericPageItem( this, m_browse, text, icon,
|
||||
boost::bind( &ViewManager::showDynamicPage, ViewManager::instance(), name ),
|
||||
boost::bind( &ViewManager::dynamicPageWidget, ViewManager::instance(), name ) );
|
||||
pageItem->setSortValue( rowCount( parentIndex ) );
|
||||
if( sortValue )
|
||||
{
|
||||
pageItem->setSortValue( sortValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
pageItem->setSortValue( rowCount( parentIndex ) );
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ private slots:
|
||||
/*
|
||||
* pageIcon and pageTitle are visible in the source tree, pageName is the internal name in the ViewManager
|
||||
*/
|
||||
void appendPageItem( const QString& name, const QString& text, const QIcon& icon );
|
||||
void appendPageItem( const QString& name, const QString& text, const QIcon& icon, int sortValue );
|
||||
|
||||
private:
|
||||
SourceTreeItem* itemFromIndex( const QModelIndex& idx ) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user