1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 16:29:43 +01:00

UI tweaks for synchronizing last.fm loved tracks

This commit is contained in:
Leo Franchi 2012-07-31 17:48:41 -04:00
parent 26509493a2
commit 0c4db907b3
3 changed files with 13 additions and 3 deletions

View File

@ -43,6 +43,7 @@ LastFmConfig::LastFmConfig( LastFmAccount* account )
, m_lastTimeStamp( 0 )
, m_totalLovedPages( -1 )
, m_doneFetchingLoved( false )
, m_doneFetchingLocal( false )
{
m_ui = new Ui_LastFmConfig;
m_ui->setupUi( this );
@ -252,6 +253,8 @@ LastFmConfig::syncLovedTracks( uint page )
{
QNetworkReply* reply = lastfm::User( username() ).getLovedTracks( 200, page );
m_ui->syncLovedTracks->setEnabled( false );
m_ui->syncLovedTracks->setText( tr( "Synchronizing..." ) );
m_ui->progressBar->show();
NewClosure( reply, SIGNAL( finished() ), this, SLOT( onLovedFinished( QNetworkReply* ) ), reply );
@ -283,7 +286,7 @@ LastFmConfig::onLovedFinished( QNetworkReply* reply )
if ( m_totalLovedPages < 0 )
{
m_totalLovedPages = loved.attribute( "totalPages" ).toInt();
m_ui->progressBar->setMaximum( m_totalLovedPages );
m_ui->progressBar->setMaximum( m_totalLovedPages + 2 );
}
m_ui->progressBar->setValue( thisPage );
@ -302,7 +305,7 @@ LastFmConfig::onLovedFinished( QNetworkReply* reply )
{
m_doneFetchingLoved = true;
if ( !m_localLoved.isEmpty() )
if ( m_doneFetchingLocal )
syncLoved();
return;
@ -330,6 +333,7 @@ void
LastFmConfig::localLovedLoaded( DatabaseCommand_LoadSocialActions::TrackActions tracks )
{
m_localLoved = tracks;
m_doneFetchingLocal = true;
if ( m_doneFetchingLoved )
syncLoved();
@ -343,6 +347,8 @@ LastFmConfig::syncLoved()
const QSet< Tomahawk::query_ptr > myLoved = m_localLoved.keys().toSet();
m_ui->progressBar->setValue( m_ui->progressBar->value() + 1 );
foreach ( const Tomahawk::query_ptr& lastfmLoved, m_lastfmLoved )
{
QSet< Tomahawk::query_ptr >::const_iterator iter = std::find_if( myLoved.begin(), myLoved.end(), boost::bind( &trackEquality, _1, boost::ref( lastfmLoved ) ) );
@ -389,5 +395,8 @@ LastFmConfig::syncLoved()
else
lfmTrack.love();
}
m_ui->progressBar->setValue( m_ui->progressBar->value() + 1 );
m_ui->syncLovedTracks->setText( tr( "Synchronization Finished" ) );
}

View File

@ -72,7 +72,7 @@ private:
unsigned int m_lastTimeStamp;
int m_totalLovedPages;
bool m_doneFetchingLoved;
bool m_doneFetchingLoved, m_doneFetchingLocal;
QSet< Tomahawk::query_ptr > m_lastfmLoved;
DatabaseCommand_LoadSocialActions::TrackActions m_localLoved;
};

View File

@ -126,6 +126,7 @@ public:
*/
void setTrack( const QString& s ) { m_track = s; }
virtual bool doesMutates() const { return false; }
signals:
/**
* All loaded social actions for each track found, for queries that generate all tracks