Skip to content

Commit

Permalink
* Update recent additions on welcome page whenever a collection changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Nov 23, 2011
1 parent 01c6c3f commit 5cabc62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/libtomahawk/widgets/welcomewidget.cpp
Expand Up @@ -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
Expand All @@ -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 );

Expand All @@ -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 );
Expand All @@ -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() ) );
}


Expand All @@ -99,6 +97,7 @@ WelcomeWidget::~WelcomeWidget()
delete ui;
}


PlaylistInterface*
WelcomeWidget::playlistInterface() const
{
Expand All @@ -112,6 +111,7 @@ WelcomeWidget::jumpToCurrentTrack()
return ui->tracksView->jumpToCurrentTrack();
}


bool
WelcomeWidget::isBeingPlayed() const
{
Expand All @@ -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 );
}


Expand Down Expand Up @@ -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 ) ) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/libtomahawk/widgets/welcomewidget.h
Expand Up @@ -102,11 +102,11 @@ Q_OBJECT
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 );
Expand Down

0 comments on commit 5cabc62

Please sign in to comment.