mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
Some tomahawk-side fixes to playlist syncing. Removing works, adding not yet.
This commit is contained in:
@@ -95,9 +95,6 @@ SpotifyAccount::init()
|
|||||||
msg[ "_msgtype" ] = "getCredentials";
|
msg[ "_msgtype" ] = "getCredentials";
|
||||||
m_spotifyResolver.data()->sendMessage( msg );
|
m_spotifyResolver.data()->sendMessage( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add caching
|
|
||||||
loadPlaylists();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,7 +141,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
|||||||
const QString name = plMap.value( "name" ).toString();
|
const QString name = plMap.value( "name" ).toString();
|
||||||
const QString plid = plMap.value( "id" ).toString();
|
const QString plid = plMap.value( "id" ).toString();
|
||||||
const QString revid = plMap.value( "revid" ).toString();
|
const QString revid = plMap.value( "revid" ).toString();
|
||||||
const bool sync = plMap.value( "map" ).toBool();
|
const bool sync = plMap.value( "sync" ).toBool();
|
||||||
|
|
||||||
if ( name.isNull() || plid.isNull() || revid.isNull() )
|
if ( name.isNull() || plid.isNull() || revid.isNull() )
|
||||||
{
|
{
|
||||||
@@ -216,24 +213,6 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
|||||||
|
|
||||||
updater->spotifyTracksMoved( tracksList, newRev, oldRev );
|
updater->spotifyTracksMoved( tracksList, newRev, oldRev );
|
||||||
}
|
}
|
||||||
else if ( msgType == "playlists" )
|
|
||||||
{
|
|
||||||
// QList< Tomahawk::query_ptr > tracks;
|
|
||||||
// const QString qid = m.value( "qid" ).toString();
|
|
||||||
// const QString title = m.value( "identifier" ).toString();
|
|
||||||
// const QVariantList reslist = m.value( "playlist" ).toList();
|
|
||||||
|
|
||||||
// if( !reslist.isEmpty() )
|
|
||||||
// {
|
|
||||||
// foreach( const QVariant& rv, reslist )
|
|
||||||
// {
|
|
||||||
// QVariantMap m = rv.toMap();
|
|
||||||
// qDebug() << "Found playlist result:" << m;
|
|
||||||
// Tomahawk::query_ptr q = Tomahawk::Query::get( m.value( "artist" ).toString() , m.value( "track" ).toString() , QString(), uuid(), false );
|
|
||||||
// tracks << q;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,6 +272,7 @@ SpotifyAccount::saveConfig()
|
|||||||
m_configWidget.data()->saveSettings();
|
m_configWidget.data()->saveSettings();
|
||||||
foreach ( SpotifyPlaylistInfo* pl, m_allSpotifyPlaylists )
|
foreach ( SpotifyPlaylistInfo* pl, m_allSpotifyPlaylists )
|
||||||
{
|
{
|
||||||
|
qDebug() << "Checking changed state:" << pl->changed << pl->name << pl->sync;
|
||||||
if ( pl->changed )
|
if ( pl->changed )
|
||||||
{
|
{
|
||||||
pl->changed = false;
|
pl->changed = false;
|
||||||
@@ -359,59 +339,6 @@ SpotifyAccount::startPlaylistSyncWithPlaylist( const QString& msgType, const QVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SpotifyAccount::addPlaylist( const QString &qid, const QString& title, QList< Tomahawk::query_ptr > tracks )
|
|
||||||
{
|
|
||||||
/* Sync sync;
|
|
||||||
sync.id_ = qid;
|
|
||||||
int index = m_syncPlaylists.indexOf( sync );
|
|
||||||
|
|
||||||
if( !m_syncPlaylists.contains( sync ) )
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << "Adding playlist to sync" << qid;
|
|
||||||
playlist_ptr pl;
|
|
||||||
pl = Tomahawk::Playlist::create( SourceList::instance()->getLocal(),
|
|
||||||
uuid(),
|
|
||||||
title,
|
|
||||||
QString(),
|
|
||||||
QString(),
|
|
||||||
false,
|
|
||||||
tracks );
|
|
||||||
sync.playlist = pl;
|
|
||||||
sync.uuid = pl->guid();
|
|
||||||
m_syncPlaylists.append( sync );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "Found playlist";
|
|
||||||
|
|
||||||
if ( index != -1 && !tracks.isEmpty())
|
|
||||||
{
|
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "Got pl" << m_syncPlaylists[ index ].playlist->guid();
|
|
||||||
|
|
||||||
QList< query_ptr > currTracks;
|
|
||||||
foreach ( const plentry_ptr ple, m_syncPlaylists[ index ].playlist->entries() )
|
|
||||||
currTracks << ple->query();
|
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "tracks" << currTracks;
|
|
||||||
|
|
||||||
bool changed = false;
|
|
||||||
QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( currTracks, tracks, changed );
|
|
||||||
|
|
||||||
if ( changed )
|
|
||||||
{
|
|
||||||
QList<Tomahawk::plentry_ptr> el = m_syncPlaylists[ index ].playlist->entriesFromQueries( mergedTracks, true );
|
|
||||||
m_syncPlaylists[ index ].playlist->createNewRevision( uuid(), m_syncPlaylists[ index ].playlist->currentrevision(), el );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::sendMessage( const QVariantMap &m, QObject* obj, const QString& slot )
|
SpotifyAccount::sendMessage( const QVariantMap &m, QObject* obj, const QString& slot )
|
||||||
{
|
{
|
||||||
@@ -442,7 +369,11 @@ SpotifyAccount::fetchFullPlaylist( SpotifyPlaylistInfo* playlist )
|
|||||||
void
|
void
|
||||||
SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist )
|
SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist )
|
||||||
{
|
{
|
||||||
|
QVariantMap msg;
|
||||||
|
msg[ "_msgtype" ] = "removeFromSyncList";
|
||||||
|
msg[ "playlistid" ] = playlist->plid;
|
||||||
|
|
||||||
|
m_spotifyResolver.data()->sendMessage( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,8 +84,6 @@ public:
|
|||||||
virtual QWidget* aclWidget() { return 0; }
|
virtual QWidget* aclWidget() { return 0; }
|
||||||
virtual InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
virtual InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin() { return 0; }
|
||||||
|
|
||||||
void addPlaylist( const QString &qid, const QString& title, QList< Tomahawk::query_ptr > tracks );
|
|
||||||
/*
|
/*
|
||||||
struct Sync {
|
struct Sync {
|
||||||
QString id_;
|
QString id_;
|
||||||
|
@@ -60,7 +60,8 @@ SpotifyAccountConfig::saveSettings()
|
|||||||
{
|
{
|
||||||
for( int i = 0; i < m_ui->playlistList->count(); i++ )
|
for( int i = 0; i < m_ui->playlistList->count(); i++ )
|
||||||
{
|
{
|
||||||
const QListWidgetItem* item = m_ui->playlistList->itemAt( i, 0 );
|
const QListWidgetItem* item = m_ui->playlistList->item( i );
|
||||||
|
|
||||||
SpotifyPlaylistInfo* pl = item->data( Qt::UserRole ).value< SpotifyPlaylistInfo* >();
|
SpotifyPlaylistInfo* pl = item->data( Qt::UserRole ).value< SpotifyPlaylistInfo* >();
|
||||||
const bool toSync = ( item->checkState() == Qt::Checked );
|
const bool toSync = ( item->checkState() == Qt::Checked );
|
||||||
if ( pl->sync != toSync )
|
if ( pl->sync != toSync )
|
||||||
|
@@ -171,6 +171,13 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="playlistList"/>
|
<widget class="QListWidget" name="playlistList"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="deleteOnUnsync">
|
||||||
|
<property name="text">
|
||||||
|
<string>Delete Tomahawk playlist when removing Spotify sync</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@@ -238,6 +238,7 @@ SpotifyPlaylistUpdater::tomahawkTracksRemoved( const QList< query_ptr >& tracks
|
|||||||
qDebug() << Q_FUNC_INFO << "updating spotify resolver with removed tracks:" << tracks;
|
qDebug() << Q_FUNC_INFO << "updating spotify resolver with removed tracks:" << tracks;
|
||||||
QVariantMap msg;
|
QVariantMap msg;
|
||||||
msg[ "_msgtype" ] = "removeTracksFromPlaylist";
|
msg[ "_msgtype" ] = "removeTracksFromPlaylist";
|
||||||
|
msg[ "playlistid" ] = m_spotifyId;
|
||||||
msg[ "oldrev" ] = m_latestRev;
|
msg[ "oldrev" ] = m_latestRev;
|
||||||
msg[ "tracks" ] = queriesToVariant( tracks );
|
msg[ "tracks" ] = queriesToVariant( tracks );
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ PlaylistModel::PlaylistModel( QObject* parent )
|
|||||||
: TrackModel( parent )
|
: TrackModel( parent )
|
||||||
, m_isTemporary( false )
|
, m_isTemporary( false )
|
||||||
, m_changesOngoing( false )
|
, m_changesOngoing( false )
|
||||||
|
, m_isLoading( false )
|
||||||
, m_savedInsertPos( -1 )
|
, m_savedInsertPos( -1 )
|
||||||
{
|
{
|
||||||
m_dropStorage.parent = QPersistentModelIndex();
|
m_dropStorage.parent = QPersistentModelIndex();
|
||||||
@@ -65,6 +66,8 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
disconnect( m_playlist.data(), SIGNAL( changed() ), this, SIGNAL( playlistChanged() ) );
|
disconnect( m_playlist.data(), SIGNAL( changed() ), this, SIGNAL( playlistChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isLoading = true;
|
||||||
|
|
||||||
if ( loadEntries )
|
if ( loadEntries )
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
@@ -80,11 +83,17 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEn
|
|||||||
.arg( TomahawkUtils::ageToString( QDateTime::fromTime_t( playlist->createdOn() ), true ) ) );
|
.arg( TomahawkUtils::ageToString( QDateTime::fromTime_t( playlist->createdOn() ), true ) ) );
|
||||||
|
|
||||||
m_isTemporary = false;
|
m_isTemporary = false;
|
||||||
|
|
||||||
if ( !loadEntries )
|
if ( !loadEntries )
|
||||||
|
{
|
||||||
|
m_isLoading = false;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QList<plentry_ptr> entries = playlist->entries();
|
QList<plentry_ptr> entries = playlist->entries();
|
||||||
append( entries );
|
append( entries );
|
||||||
|
|
||||||
|
m_isLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -204,8 +213,11 @@ PlaylistModel::insert( const QList< Tomahawk::plentry_ptr >& entries, int row )
|
|||||||
crows.first = c;
|
crows.first = c;
|
||||||
crows.second = c + entries.count() - 1;
|
crows.second = c + entries.count() - 1;
|
||||||
|
|
||||||
m_savedInsertPos = row;
|
if ( !m_isLoading )
|
||||||
m_savedInsertTracks = entries;
|
{
|
||||||
|
m_savedInsertPos = row;
|
||||||
|
m_savedInsertTracks = entries;
|
||||||
|
}
|
||||||
|
|
||||||
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
emit beginInsertRows( QModelIndex(), crows.first, crows.second );
|
||||||
|
|
||||||
@@ -463,7 +475,7 @@ PlaylistModel::remove( const QModelIndex& index, bool moreToCome )
|
|||||||
if ( !m_changesOngoing )
|
if ( !m_changesOngoing )
|
||||||
beginPlaylistChanges();
|
beginPlaylistChanges();
|
||||||
|
|
||||||
if ( item )
|
if ( item && !m_isLoading )
|
||||||
m_savedRemoveTracks << item->query();
|
m_savedRemoveTracks << item->query();
|
||||||
|
|
||||||
TrackModel::remove( index, moreToCome );
|
TrackModel::remove( index, moreToCome );
|
||||||
|
@@ -97,6 +97,7 @@ private:
|
|||||||
Tomahawk::playlist_ptr m_playlist;
|
Tomahawk::playlist_ptr m_playlist;
|
||||||
bool m_isTemporary;
|
bool m_isTemporary;
|
||||||
bool m_changesOngoing;
|
bool m_changesOngoing;
|
||||||
|
bool m_isLoading;
|
||||||
QList< Tomahawk::Query* > m_waitingForResolved;
|
QList< Tomahawk::Query* > m_waitingForResolved;
|
||||||
QStringList m_waitForRevision;
|
QStringList m_waitForRevision;
|
||||||
|
|
||||||
|
@@ -262,7 +262,6 @@ XSPFLoader::gotBody()
|
|||||||
m_entries );
|
m_entries );
|
||||||
|
|
||||||
// 10 minute default---for now, no way to change it
|
// 10 minute default---for now, no way to change it
|
||||||
connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) );
|
|
||||||
new Tomahawk::XspfUpdater( m_playlist, 6000000, m_autoUpdate, m_url.toString() );
|
new Tomahawk::XspfUpdater( m_playlist, 6000000, m_autoUpdate, m_url.toString() );
|
||||||
emit ok( m_playlist );
|
emit ok( m_playlist );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user