mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Fix position when moving
This commit is contained in:
@@ -574,6 +574,14 @@ SpotifyPlaylistUpdater::onTracksRemovedReturn( const QString& msgType, const QVa
|
|||||||
void
|
void
|
||||||
SpotifyPlaylistUpdater::tomahawkTracksMoved( const QList< plentry_ptr >& tracks, int position )
|
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;
|
qDebug() << Q_FUNC_INFO << "Got tracks moved at position:" << position;
|
||||||
foreach ( const plentry_ptr ple, tracks )
|
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
|
// Find the trackid of the nearest spotify track
|
||||||
QList< plentry_ptr > plTracks = playlist()->entries();
|
QList< plentry_ptr > plTracks = playlist()->entries();
|
||||||
Q_ASSERT( position-1 < plTracks.size() );
|
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[ "startPosition" ] = startPos;
|
||||||
msg[ "playlistid" ] = m_spotifyId;
|
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 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 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:
|
protected:
|
||||||
virtual void removeFromSettings(const QString& group) const;
|
virtual void removeFromSettings(const QString& group) const;
|
||||||
virtual void saveToSettings(const QString& group) const;
|
virtual void saveToSettings(const QString& group) const;
|
||||||
|
|
||||||
private slots:
|
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
|
// SpotifyResolver message handlers, all take msgtype, msg as argument
|
||||||
void onTracksInsertedReturn( const QString& msgType, const QVariantMap& msg );
|
void onTracksInsertedReturn( const QString& msgType, const QVariantMap& msg );
|
||||||
void onTracksRemovedReturn( 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( QSharedPointer< Tomahawk::Playlist > )
|
||||||
|
Q_DECLARE_METATYPE( QList< QSharedPointer< Tomahawk::PlaylistEntry > > )
|
||||||
|
|
||||||
#endif // PLAYLIST_H
|
#endif // PLAYLIST_H
|
||||||
|
@@ -444,6 +444,7 @@ PlaylistModel::endPlaylistChanges()
|
|||||||
if ( !item || item->entry().isNull() )
|
if ( !item || item->entry().isNull() )
|
||||||
continue;
|
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() )
|
if ( item->entry() == m_savedInsertTracks.first() )
|
||||||
{
|
{
|
||||||
// Found our index
|
// Found our index
|
||||||
|
Reference in New Issue
Block a user