1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

* Update recent additions on welcome page whenever a collection changes.

This commit is contained in:
Christian Muehlhaeuser 2011-11-23 04:18:14 +01:00
parent ddfe32eec3
commit 34fab0f210
2 changed files with 12 additions and 10 deletions
src/libtomahawk/widgets

@ -33,7 +33,7 @@
#include "widgets/overlaywidget.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#include <dynamic/GeneratorInterface.h>
#include "dynamic/GeneratorInterface.h"
#include "RecentlyPlayedPlaylistsModel.h"
#define HISTORY_TRACK_ITEMS 25
@ -48,9 +48,8 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
, ui( new Ui::WelcomeWidget )
{
ui->setupUi( this );
ui->splitter_2->setStretchFactor( 0, 2 );
ui->splitter_2->setStretchFactor( 0, 1 );
ui->splitter_2->setStretchFactor( 0, 3 );
ui->splitter_2->setStretchFactor( 1, 1 );
RecentPlaylistsModel* model = new RecentPlaylistsModel( HISTORY_PLAYLIST_ITEMS, this );
@ -73,8 +72,6 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
ui->playlistWidget->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
updatePlaylists();
connect( model, SIGNAL( emptinessChanged( bool ) ), this, SLOT( updatePlaylists() ) );
m_tracksModel = new PlaylistModel( ui->tracksView );
m_tracksModel->setStyle( TrackModel::ShortWithAvatars );
ui->tracksView->overlay()->setEnabled( false );
@ -88,9 +85,10 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( updateRecentTracks() ) );
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( onSourcesReady() ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) );
connect( model, SIGNAL( emptinessChanged( bool ) ), this, SLOT( updatePlaylists() ) );
}
@ -99,6 +97,7 @@ WelcomeWidget::~WelcomeWidget()
delete ui;
}
PlaylistInterface*
WelcomeWidget::playlistInterface() const
{
@ -112,6 +111,7 @@ WelcomeWidget::jumpToCurrentTrack()
return ui->tracksView->jumpToCurrentTrack();
}
bool
WelcomeWidget::isBeingPlayed() const
{
@ -120,11 +120,12 @@ WelcomeWidget::isBeingPlayed() const
void
WelcomeWidget::updateRecentTracks()
WelcomeWidget::onSourcesReady()
{
m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS );
connect( SourceList::instance()->getLocal().data(), SIGNAL( stats( QVariantMap ) ), this, SLOT( updateRecentAdditions() ) );
foreach ( const source_ptr& source, SourceList::instance()->sources() )
onSourceAdded( source );
}
@ -152,6 +153,7 @@ WelcomeWidget::updatePlaylists()
void
WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source )
{
connect( source->collection().data(), SIGNAL( changed() ), SLOT( updateRecentAdditions() ) );
connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) );
}

@ -102,11 +102,11 @@ signals:
void destroyed( QWidget* widget );
public slots:
void updateRecentTracks();
void updatePlaylists();
void updateRecentAdditions();
private slots:
void onSourcesReady();
void onSourceAdded( const Tomahawk::source_ptr& source );
void onPlaylistActivated( const QModelIndex& );
void onPlaybackFinished( const Tomahawk::query_ptr& query );