mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Fix sort order of viewpages in the sidebar
This commit is contained in:
@@ -878,7 +878,7 @@ ViewManager::dynamicPageWidget( const QString& pageName ) const
|
|||||||
|
|
||||||
|
|
||||||
void
|
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;
|
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 );
|
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 historyBackAvailable( bool avail );
|
||||||
void historyForwardAvailable( 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:
|
public slots:
|
||||||
Tomahawk::ViewPage* showSuperCollection();
|
Tomahawk::ViewPage* showSuperCollection();
|
||||||
@@ -141,7 +141,7 @@ public slots:
|
|||||||
Tomahawk::ViewPage* showRecentPlaysPage();
|
Tomahawk::ViewPage* showRecentPlaysPage();
|
||||||
Tomahawk::ViewPage* showInboxPage();
|
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 );
|
Tomahawk::ViewPage* showDynamicPage( const QString& pageName );
|
||||||
|
|
||||||
void showCurrentTrack();
|
void showCurrentTrack();
|
||||||
|
@@ -62,7 +62,7 @@ SourcesModel::SourcesModel( QObject* parent )
|
|||||||
{
|
{
|
||||||
m_rootItem = new SourceTreeItem( this, 0, Invalid );
|
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();
|
appendGroups();
|
||||||
|
|
||||||
onSourcesAdded( SourceList::instance()->sources() );
|
onSourcesAdded( SourceList::instance()->sources() );
|
||||||
@@ -305,16 +305,15 @@ SourcesModel::appendGroups()
|
|||||||
m_myMusicGroup = new GroupItem( this, m_rootItem, tr( "My Music" ), 3 );
|
m_myMusicGroup = new GroupItem( this, m_rootItem, tr( "My Music" ), 3 );
|
||||||
|
|
||||||
|
|
||||||
|
InboxItem* inbox = new InboxItem( this, m_browse );
|
||||||
|
inbox->setSortValue( 3 );
|
||||||
|
|
||||||
// super collection
|
// super collection
|
||||||
GenericPageItem* sc = new GenericPageItem( this, m_browse, tr( "SuperCollection" ), ImageRegistry::instance()->icon( RESPATH "images/supercollection.svg" ),
|
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::showSuperCollection, ViewManager::instance() ),
|
||||||
boost::bind( &ViewManager::superCollectionView, 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" ),
|
GenericPageItem* hot = new GenericPageItem( this, m_browse, tr( "Charts" ), ImageRegistry::instance()->icon( RESPATH "images/charts.svg" ),
|
||||||
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
|
boost::bind( &ViewManager::showWhatsHotPage, ViewManager::instance() ),
|
||||||
@@ -327,8 +326,11 @@ SourcesModel::appendGroups()
|
|||||||
newReleases->setSortValue( 6 );
|
newReleases->setSortValue( 6 );
|
||||||
|
|
||||||
|
|
||||||
InboxItem* inbox = new InboxItem( this, m_browse );
|
GenericPageItem* recent = new GenericPageItem( this, m_browse, tr( "Recently Played" ), ImageRegistry::instance()->icon( RESPATH "images/recently-played.svg" ),
|
||||||
inbox->setSortValue( 7 );
|
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 );
|
m_collectionsGroup = new GroupItem( this, m_rootItem, tr( "Friends" ), 4 );
|
||||||
|
|
||||||
@@ -337,11 +339,13 @@ SourcesModel::appendGroups()
|
|||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
// addDynamicPage takes care of begin/endInsertRows itself
|
// addDynamicPage takes care of begin/endInsertRows itself
|
||||||
ViewManager::instance()->addDynamicPage("dashboard",
|
ViewManager::instance()->addDynamicPage( "dashboard",
|
||||||
tr( "Dashboard" ),
|
tr( "Dashboard" ),
|
||||||
ImageRegistry::instance()->icon( RESPATH "images/dashboard.svg" ),
|
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
|
//HACK: this may not belong here, but adding the pages probably doesn't belong here either
|
||||||
//TODO: find a good place for this
|
//TODO: find a good place for this
|
||||||
ViewManager::instance()->showDynamicPage("dashboard");
|
ViewManager::instance()->showDynamicPage("dashboard");
|
||||||
@@ -349,19 +353,27 @@ SourcesModel::appendGroups()
|
|||||||
ViewManager::instance()->addDynamicPage("network_activity",
|
ViewManager::instance()->addDynamicPage("network_activity",
|
||||||
tr( "Network Activity" ),
|
tr( "Network Activity" ),
|
||||||
TomahawkUtils::defaultPixmap( TomahawkUtils::NetworkActivity, TomahawkUtils::Original ),
|
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
|
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 );
|
QModelIndex parentIndex = indexFromItem( m_browse );
|
||||||
beginInsertRows( parentIndex, rowCount( parentIndex ), rowCount( parentIndex ) );
|
beginInsertRows( parentIndex, rowCount( parentIndex ), rowCount( parentIndex ) );
|
||||||
GenericPageItem* pageItem = new GenericPageItem( this, m_browse, text, icon,
|
GenericPageItem* pageItem = new GenericPageItem( this, m_browse, text, icon,
|
||||||
boost::bind( &ViewManager::showDynamicPage, ViewManager::instance(), name ),
|
boost::bind( &ViewManager::showDynamicPage, ViewManager::instance(), name ),
|
||||||
boost::bind( &ViewManager::dynamicPageWidget, 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();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
@@ -149,7 +149,7 @@ private slots:
|
|||||||
/*
|
/*
|
||||||
* pageIcon and pageTitle are visible in the source tree, pageName is the internal name in the ViewManager
|
* 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:
|
private:
|
||||||
SourceTreeItem* itemFromIndex( const QModelIndex& idx ) const;
|
SourceTreeItem* itemFromIndex( const QModelIndex& idx ) const;
|
||||||
|
Reference in New Issue
Block a user