1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-18 20:04:00 +02:00

Add a "New Additions" entry to each source to show the SourceInfoWidget

This commit is contained in:
Leo Franchi
2011-06-08 21:33:50 -04:00
parent 5a38219754
commit 92805d37c1
5 changed files with 37 additions and 3 deletions

View File

@@ -41,11 +41,11 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
ui->historyView->overlay()->setEnabled( false ); ui->historyView->overlay()->setEnabled( false );
m_recentCollectionModel = new CollectionFlatModel( ui->recentCollectionView ); m_recentCollectionModel = new CollectionFlatModel( ui->recentCollectionView );
ui->recentCollectionView->setModel( m_recentCollectionModel ); ui->recentCollectionView->setTrackModel( m_recentCollectionModel );
m_recentCollectionModel->addFilteredCollection( source->collection(), 250, DatabaseCommand_AllTracks::ModificationTime ); m_recentCollectionModel->addFilteredCollection( source->collection(), 250, DatabaseCommand_AllTracks::ModificationTime );
m_historyModel = new PlaylistModel( ui->historyView ); m_historyModel = new PlaylistModel( ui->historyView );
ui->historyView->setModel( m_historyModel ); ui->historyView->setPlaylistModel( m_historyModel );
m_historyModel->loadHistory( source ); m_historyModel->loadHistory( source );
connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) ); connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) );
@@ -59,7 +59,7 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
ui->historyView->setColumnHidden( TrackModel::Filesize, true ); ui->historyView->setColumnHidden( TrackModel::Filesize, true );
m_recentAlbumModel = new AlbumModel( ui->recentAlbumView ); m_recentAlbumModel = new AlbumModel( ui->recentAlbumView );
ui->recentAlbumView->setModel( m_recentAlbumModel ); ui->recentAlbumView->setAlbumModel( m_recentAlbumModel );
m_recentAlbumModel->addFilteredCollection( source->collection(), 20, DatabaseCommand_AllAlbums::ModificationTime ); m_recentAlbumModel->addFilteredCollection( source->collection(), 20, DatabaseCommand_AllAlbums::ModificationTime );
m_title = tr( "Info about %1" ).arg( source->isLocal() ? tr( "Your Collection" ) : source->friendlyName() ); m_title = tr( "Info about %1" ).arg( source->isLocal() ? tr( "Your Collection" ) : source->friendlyName() );

View File

@@ -33,13 +33,22 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
, m_playlists( 0 ) , m_playlists( 0 )
, m_stations( 0 ) , m_stations( 0 )
, m_tempItem( 0 ) , m_tempItem( 0 )
, m_sourceInfoItem( 0 )
, m_curTempPage( 0 ) , m_curTempPage( 0 )
, m_sourceInfoPage( 0 )
{ {
if( m_source.isNull() ) { // super collection if( m_source.isNull() ) { // super collection
connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage*) ), this, SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) ); connect( ViewManager::instance(), SIGNAL( tempPageActivated( Tomahawk::ViewPage*) ), this, SLOT( tempPageActivated( Tomahawk::ViewPage* ) ) );
return; return;
} }
m_sourceInfoItem = new GenericPageItem( model(), this, tr( "New Additions" ), QIcon(),
boost::bind( &CollectionItem::sourceInfoClicked, this ),
boost::bind( &CollectionItem::getSourceInfoPage, this )
);
m_sourceInfoItem->setSortValue( -300 );
// create category items if there are playlists to show, or stations to show // create category items if there are playlists to show, or stations to show
QList< playlist_ptr > playlists = source->collection()->playlists(); QList< playlist_ptr > playlists = source->collection()->playlists();
QList< dynplaylist_ptr > autoplaylists = source->collection()->autoPlaylists(); QList< dynplaylist_ptr > autoplaylists = source->collection()->autoPlaylists();
@@ -306,3 +315,19 @@ CollectionItem::getTempPage() const
{ {
return m_curTempPage; return m_curTempPage;
} }
ViewPage*
CollectionItem::sourceInfoClicked()
{
if( m_source.isNull() )
return 0;
m_sourceInfoPage = ViewManager::instance()->show( m_source );
return m_sourceInfoPage;
}
ViewPage*
CollectionItem::getSourceInfoPage() const
{
return m_sourceInfoPage;
}

View File

@@ -55,6 +55,9 @@ private slots:
Tomahawk::ViewPage* tempItemClicked(); Tomahawk::ViewPage* tempItemClicked();
Tomahawk::ViewPage* getTempPage() const; Tomahawk::ViewPage* getTempPage() const;
Tomahawk::ViewPage* sourceInfoClicked();
Tomahawk::ViewPage* getSourceInfoPage() const;
private: private:
void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists ); void playlistsAddedInternal( SourceTreeItem* parent, const QList< Tomahawk::dynplaylist_ptr >& playlists );
template< typename T > template< typename T >
@@ -65,7 +68,9 @@ private:
CategoryItem* m_stations; CategoryItem* m_stations;
GenericPageItem* m_tempItem; GenericPageItem* m_tempItem;
GenericPageItem* m_sourceInfoItem;
Tomahawk::ViewPage* m_curTempPage; Tomahawk::ViewPage* m_curTempPage;
Tomahawk::ViewPage* m_sourceInfoPage;
}; };

View File

@@ -26,6 +26,7 @@ GenericPageItem::GenericPageItem( SourcesModel* model, SourceTreeItem* parent, c
: SourceTreeItem( model, parent, SourcesModel::GenericPage ) : SourceTreeItem( model, parent, SourcesModel::GenericPage )
, m_icon( icon ) , m_icon( icon )
, m_text( text ) , m_text( text )
, m_sortValue( 0 )
, m_show( show ) , m_show( show )
, m_get( get ) , m_get( get )
{ {

View File

@@ -35,14 +35,17 @@ public:
virtual void activate(); virtual void activate();
virtual bool willAcceptDrag( const QMimeData* data ) const; virtual bool willAcceptDrag( const QMimeData* data ) const;
virtual QIcon icon() const; virtual QIcon icon() const;
virtual int peerSortValue() const { return m_sortValue; } // How to sort relative to peers in the tree.
void setText( const QString& text ); void setText( const QString& text );
void setSortValue( int value ) { m_sortValue = value; }
signals: signals:
void activated(); void activated();
private: private:
QIcon m_icon; QIcon m_icon;
QString m_text; QString m_text;
int m_sortValue;
boost::function< Tomahawk::ViewPage*() > m_show; boost::function< Tomahawk::ViewPage*() > m_show;
boost::function< Tomahawk::ViewPage*() > m_get; boost::function< Tomahawk::ViewPage*() > m_get;
}; };