1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 09:49:42 +01:00

Fix position when moving

This commit is contained in:
Leo Franchi 2012-04-14 13:07:33 -04:00
parent 4ec0117c43
commit c4a9dd6b32
4 changed files with 18 additions and 5 deletions

@ -574,6 +574,14 @@ SpotifyPlaylistUpdater::onTracksRemovedReturn( const QString& msgType, const QVa
void
SpotifyPlaylistUpdater::tomahawkTracksMoved( const QList< plentry_ptr >& tracks, int position )
{
if( playlist()->busy() )
{
// the playlist has had the new revision set, but it might not be finished, if it's not finished, playlist()->entries() still
// contains the *old* order, so we get the wrong data
m_queuedOps << NewClosure( 0, "", this, SLOT(tomahawkTracksMoved(QList<Tomahawk::plentry_ptr>,int)), tracks, position );
return;
}
qDebug() << Q_FUNC_INFO << "Got tracks moved at position:" << position;
foreach ( const plentry_ptr ple, tracks )
{
@ -588,7 +596,10 @@ SpotifyPlaylistUpdater::tomahawkTracksMoved( const QList< plentry_ptr >& tracks,
// Find the trackid of the nearest spotify track
QList< plentry_ptr > plTracks = playlist()->entries();
Q_ASSERT( position-1 < plTracks.size() );
const QString startPos = nearestSpotifyTrack( plTracks, position );
QString startPos;
if ( position > 0 )
startPos = nearestSpotifyTrack( plTracks, position );
msg[ "startPosition" ] = startPos;
msg[ "playlistid" ] = m_spotifyId;

@ -62,15 +62,15 @@ public slots:
void spotifyTracksMoved( const QVariantList& tracks, const QString& newStartPos, const QString& newRev, const QString& oldRev );
void spotifyPlaylistRenamed( const QString& title, const QString& newRev, const QString& oldRev );
void tomahawkTracksInserted( const QList<Tomahawk::plentry_ptr>& ,int );
void tomahawkTracksRemoved( const QList<Tomahawk::query_ptr>& );
void tomahawkTracksMoved( const QList<Tomahawk::plentry_ptr>& ,int );
void tomahawkPlaylistRenamed( const QString&, const QString& );
protected:
virtual void removeFromSettings(const QString& group) const;
virtual void saveToSettings(const QString& group) const;
private slots:
void tomahawkTracksInserted( const QList<Tomahawk::plentry_ptr>& ,int );
void tomahawkTracksRemoved( const QList<Tomahawk::query_ptr>& );
void tomahawkTracksMoved( const QList<Tomahawk::plentry_ptr>& ,int );
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 );

@ -311,5 +311,6 @@ private:
}
Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::Playlist > )
Q_DECLARE_METATYPE( QList< QSharedPointer< Tomahawk::PlaylistEntry > > )
#endif // PLAYLIST_H

@ -444,6 +444,7 @@ PlaylistModel::endPlaylistChanges()
if ( !item || item->entry().isNull() )
continue;
// qDebug() << "Checking for equality:" << (item->entry() == m_savedInsertTracks.first()) << m_savedInsertTracks.first()->query()->track() << m_savedInsertTracks.first()->query()->artist();
if ( item->entry() == m_savedInsertTracks.first() )
{
// Found our index