1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-23 06:02:53 +02:00

emit rename signal and update spotify playlistname

This commit is contained in:
Hugo Lindström
2012-04-07 10:23:40 +02:00
parent 1f1f0d5bda
commit 570171bddd
5 changed files with 30 additions and 3 deletions

View File

@@ -220,7 +220,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
{
const QString plid = msg.value( "id" ).toString();
// We should already be syncing this playlist if we get updates for it
Q_ASSERT( m_updaters.contains( plid ) );
//Q_ASSERT( m_updaters.contains( plid ) );
qDebug() << Q_FUNC_INFO;
if ( !m_updaters.contains( plid ) )

View File

@@ -84,6 +84,7 @@ SpotifyPlaylistUpdater::init()
connect( playlist().data(), SIGNAL( tracksInserted( QList<Tomahawk::plentry_ptr>, int ) ), this, SLOT( tomahawkTracksInserted( QList<Tomahawk::plentry_ptr>, int ) ) );
connect( playlist().data(), SIGNAL( tracksRemoved( QList<Tomahawk::query_ptr> ) ), this, SLOT( tomahawkTracksRemoved( QList<Tomahawk::query_ptr> ) ) );
connect( playlist().data(), SIGNAL( renamed(const QString&, const QString& ) ), this, SLOT( tomahawkPlaylistRenamed( const QString&, const QString& ) ) );
// TODO reorders in a playlist
}
@@ -231,6 +232,19 @@ SpotifyPlaylistUpdater::spotifyPlaylistRenamed( const QString title, const QStri
}
void
SpotifyPlaylistUpdater::tomahawkPlaylistRenamed(const QString &newT, const QString &oldT)
{
qDebug() << Q_FUNC_INFO;
QVariantMap msg;
msg[ "_msgtype" ] = "playlistRenamed";
msg[ "oldrev" ] = m_latestRev;
msg[ "newTitle" ] = newT;
msg[ "oldTitle" ] = oldT;
msg[ "playlistid" ] = m_spotifyId;
m_spotify.data()->sendMessage( msg, this, "onPlaylistRename" );
}
void
SpotifyPlaylistUpdater::spotifyTracksMoved( const QVariantList& tracks, const QString& newRev, const QString& oldRev )
{

View File

@@ -61,7 +61,7 @@ protected:
private slots:
void tomahawkTracksInserted( const QList<Tomahawk::plentry_ptr>& ,int );
void tomahawkTracksRemoved( const QList<Tomahawk::query_ptr>& );
void tomahawkPlaylistRenamed( const QString&, const QString&);
// SpotifyResolver message handlers, all take msgtype, msg as argument
void onTracksInsertedReturn( const QString& msgType, const QVariantMap& msg );
void onTracksRemovedReturn( const QString& msgType, const QVariantMap& msg );

View File

@@ -248,6 +248,18 @@ Playlist::rename( const QString& title )
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
}
void
Playlist::setTitle( const QString& title )
{
if( title == m_title )
return;
const QString oldTitle = m_title;
const QString newTitle = title;
m_title = title;
emit changed();
emit renamed( newTitle, oldTitle );
}
void
Playlist::reportCreated( const playlist_ptr& self )

View File

@@ -178,12 +178,12 @@ public:
// maybe friend QObjectHelper and make them private?
explicit Playlist( const source_ptr& author );
void setCurrentrevision( const QString& s ) { m_currentrevision = s; }
void setTitle( const QString& s ) { m_title = s; emit changed(); }
void setInfo( const QString& s ) { m_info = s; }
void setCreator( const QString& s ) { m_creator = s; }
void setGuid( const QString& s ) { m_guid = s; }
void setShared( bool b ) { m_shared = b; }
void setCreatedOn( uint createdOn ) { m_createdOn = createdOn; }
void setTitle( const QString& s );
// </IGNORE>
@@ -202,6 +202,7 @@ signals:
/// renamed etc.
void changed();
void renamed( const QString&, const QString& );
/**
* delete command is scheduled but not completed. Do not call remove() again once this