mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 23:41:51 +02:00
Reactivate Hot Playlists
This commit is contained in:
parent
20b84ce507
commit
96b5a32a66
@ -254,7 +254,7 @@ NetworkActivityWidget::NetworkActivityWidget( QWidget* parent )
|
||||
QMetaObject::invokeMethod( d->worker, "run", Qt::QueuedConnection );
|
||||
|
||||
// FIXME: Activate hot playlists again
|
||||
d->ui->playlistsFrame->hide();
|
||||
// d->ui->playlistsFrame->hide();
|
||||
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
|
||||
static const uint numberOfHotPlaylists = 3;
|
||||
static const uint numberOfTrendingArtists = 3;
|
||||
static const uint numberOfTrendingTracks = 6;
|
||||
static const uint numberOfTrendingTracks = 3;
|
||||
static const uint numberOfNetworkChartEntries = 20;
|
||||
|
||||
protected:
|
||||
|
@ -73,11 +73,11 @@ NetworkActivityWorker::run()
|
||||
Database::instance()->enqueue( dbcmd_ptr( dbcmd ) );
|
||||
}
|
||||
{
|
||||
/* DatabaseCommand_LoadAllSources* dbcmd = new DatabaseCommand_LoadAllSources();
|
||||
DatabaseCommand_LoadAllSources* dbcmd = new DatabaseCommand_LoadAllSources();
|
||||
connect( dbcmd, SIGNAL( done( QList<Tomahawk::source_ptr> ) ),
|
||||
SLOT( allSourcesReceived( QList<Tomahawk::source_ptr> ) ),
|
||||
Qt::QueuedConnection);
|
||||
Database::instance()->enqueue( dbcmd_ptr( dbcmd ) ); */
|
||||
Database::instance()->enqueue( dbcmd_ptr( dbcmd ) );
|
||||
}
|
||||
tLog() << Q_FUNC_INFO << QDateTime::currentDateTime().toTime_t();
|
||||
}
|
||||
@ -125,6 +125,16 @@ NetworkActivityWorker::allSourcesReceived( const QList<source_ptr>& sources )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetworkActivityWorker::playlistLoaded(PlaylistRevision)
|
||||
{
|
||||
Q_D( NetworkActivityWorker );
|
||||
|
||||
d->playlistsToLoad--;
|
||||
checkHotPlaylistsDone();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetworkActivityWorker::playtime( const Tomahawk::playlist_ptr& playlist, uint playtime )
|
||||
{
|
||||
@ -142,11 +152,20 @@ NetworkActivityWorker::playtime( const Tomahawk::playlist_ptr& playlist, uint pl
|
||||
while (iter.hasPrevious() && (uint)playlists.size() < Widgets::NetworkActivityWidget::numberOfHotPlaylists )
|
||||
{
|
||||
iter.previous();
|
||||
playlists << iter.value();
|
||||
Tomahawk::playlist_ptr playlist = iter.value();
|
||||
playlists << playlist;
|
||||
if ( !playlist->loaded() )
|
||||
{
|
||||
d->playlistsToLoad++;
|
||||
connect( playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ),
|
||||
SLOT( playlistLoaded( Tomahawk::PlaylistRevision ) ),
|
||||
Qt::QueuedConnection );
|
||||
playlist->loadRevision();
|
||||
}
|
||||
}
|
||||
emit hotPlaylists( playlists );
|
||||
d->hotPlaylistsDone = true;
|
||||
checkDone();
|
||||
d->hotPlaylists = playlists;
|
||||
|
||||
checkHotPlaylistsDone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,12 +211,27 @@ void
|
||||
NetworkActivityWorker::checkDone()
|
||||
{
|
||||
Q_D( NetworkActivityWorker );
|
||||
if ( d->trendingTracksDone && d->trendingArtistsDone /* && d->hotPlaylistsDone */ )
|
||||
if ( d->trendingTracksDone && d->trendingArtistsDone && d->hotPlaylistsDone )
|
||||
{
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetworkActivityWorker::checkHotPlaylistsDone()
|
||||
{
|
||||
Q_D(NetworkActivityWorker);
|
||||
|
||||
if ( d->playlistsToLoad == 0 )
|
||||
{
|
||||
emit hotPlaylists( d->hotPlaylists );
|
||||
d->hotPlaylistsDone = true;
|
||||
checkDone();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Widgets
|
||||
|
||||
} // namespace Tomahawk
|
||||
|
@ -55,6 +55,7 @@ protected:
|
||||
private slots:
|
||||
void allPlaylistsReceived( const QHash< Tomahawk::playlist_ptr, QStringList >& playlists );
|
||||
void allSourcesReceived( const QList< Tomahawk::source_ptr >& sources );
|
||||
void playlistLoaded( Tomahawk::PlaylistRevision );
|
||||
void playtime( const Tomahawk::playlist_ptr& playlist , uint playtime );
|
||||
void trendingArtistsReceived( const QList< QPair< double,Tomahawk::artist_ptr > >& tracks );
|
||||
void trendingTracksReceived( const QList< QPair< double,Tomahawk::track_ptr > >& tracks );
|
||||
@ -63,6 +64,7 @@ private:
|
||||
Q_DECLARE_PRIVATE( NetworkActivityWorker )
|
||||
|
||||
void checkDone();
|
||||
void checkHotPlaylistsDone();
|
||||
};
|
||||
|
||||
} // namespace Widgets
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
, trendingArtistsDone( false )
|
||||
, trendingTracksDone( false )
|
||||
, hotPlaylistsDone( false )
|
||||
, playlistsToLoad( 0 )
|
||||
, playtimesToLoad( 0 )
|
||||
, trackStatsToLoad( 0 )
|
||||
{
|
||||
@ -50,7 +51,9 @@ private:
|
||||
bool trendingTracksDone;
|
||||
|
||||
bool hotPlaylistsDone;
|
||||
QList< Tomahawk::playlist_ptr > hotPlaylists;
|
||||
QHash< Tomahawk::playlist_ptr, QStringList > playlists;
|
||||
uint playlistsToLoad;
|
||||
uint playtimesToLoad;
|
||||
uint sourcesToLoad;
|
||||
uint trackStatsToLoad;
|
||||
|
@ -114,7 +114,7 @@ DatabaseCommand_CalculatePlaytime::exec( DatabaseImpl *dbi )
|
||||
" JOIN track t ON pi.trackname = t.name "
|
||||
" JOIN artist a ON a.name = pi.artistname AND t.artist = a.id "
|
||||
" JOIN playback_log pl ON pl.track = t.id "
|
||||
" WHERE pi.guid IN (%1); "
|
||||
" WHERE pi.guid IN (%1) "
|
||||
" AND pl.playtime >= %2 AND pl.playtime <= %3 "
|
||||
)
|
||||
.arg( d->plEntryIds.join(", ") )
|
||||
|
Loading…
x
Reference in New Issue
Block a user