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

Report social action changes and refresh loved playlists

This commit is contained in:
Leo Franchi 2011-08-06 18:06:21 -04:00
parent b9733249ee
commit 23ea7537e6
5 changed files with 43 additions and 0 deletions

View File

@ -36,6 +36,8 @@ DatabaseCommand_SocialAction::postCommitHook()
{ {
Servent::instance()->triggerDBSync(); Servent::instance()->triggerDBSync();
} }
source()->reportSocialAttributesChanged();
} }

View File

@ -22,6 +22,7 @@
#include "database/databasecommand_genericselect.h" #include "database/databasecommand_genericselect.h"
#include "database/database.h" #include "database/database.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include <sourcelist.h>
using namespace Tomahawk; using namespace Tomahawk;
@ -37,6 +38,16 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c
setPlaylistModel( m_model ); setPlaylistModel( m_model );
generateTracks(); generateTracks();
if ( m_type == SourceLovedTracks )
connect( m_source.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
else if ( m_type == AllLovedTracks )
{
foreach ( const source_ptr& s, SourceList::instance()->sources( true ) )
connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( sourceAdded( Tomahawk::source_ptr ) ) );
}
} }
@ -105,3 +116,17 @@ CustomPlaylistView::pixmap() const
{ {
return QPixmap( RESPATH "images/loved_playlist.png" ); return QPixmap( RESPATH "images/loved_playlist.png" );
} }
void
CustomPlaylistView::reload()
{
m_model->clear();
generateTracks();
}
void
CustomPlaylistView::sourceAdded( const source_ptr& s)
{
connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
}

View File

@ -51,6 +51,9 @@ public:
private slots: private slots:
void tracksGenerated( QList<Tomahawk::query_ptr> tracks ); void tracksGenerated( QList<Tomahawk::query_ptr> tracks );
void reload();
void sourceAdded( const Tomahawk::source_ptr& );
private: private:
void generateTracks(); void generateTracks();

View File

@ -312,3 +312,10 @@ Source::trackTimerFired()
emit stateChanged(); emit stateChanged();
} }
void
Source::reportSocialAttributesChanged()
{
emit socialAttributesChanged();
}

View File

@ -31,6 +31,7 @@
class DatabaseCommand_LogPlayback; class DatabaseCommand_LogPlayback;
class ControlConnection; class ControlConnection;
class DatabaseCommand_SocialAction;
namespace Tomahawk namespace Tomahawk
{ {
@ -41,6 +42,7 @@ Q_OBJECT
friend class ::DatabaseCommand_LogPlayback; friend class ::DatabaseCommand_LogPlayback;
friend class ::DBSyncConnection; friend class ::DBSyncConnection;
friend class ::DatabaseCommand_SocialAction;
public: public:
explicit Source( int id, const QString& username = QString() ); explicit Source( int id, const QString& username = QString() );
@ -95,6 +97,8 @@ signals:
void stateChanged(); void stateChanged();
void socialAttributesChanged();
public slots: public slots:
void setStats( const QVariantMap& m ); void setStats( const QVariantMap& m );
@ -110,6 +114,8 @@ private slots:
void trackTimerFired(); void trackTimerFired();
private: private:
void reportSocialAttributesChanged();
bool m_isLocal; bool m_isLocal;
bool m_online; bool m_online;
QString m_username, m_friendlyname; QString m_username, m_friendlyname;