mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
notifications for track moved
This commit is contained in:
@@ -85,6 +85,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( 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( tracksRemoved( QList<Tomahawk::query_ptr> ) ), this, SLOT( tomahawkTracksRemoved( QList<Tomahawk::query_ptr> ) ) );
|
||||||
|
connect( playlist().data(), SIGNAL( tracksMoved( QList<Tomahawk::plentry_ptr>, int ) ), this, SLOT( tomahawkTracksMoved( QList<Tomahawk::plentry_ptr>, int ) ) );
|
||||||
connect( playlist().data(), SIGNAL( renamed( QString, QString ) ), this, SLOT( tomahawkPlaylistRenamed( QString, QString ) ) );
|
connect( playlist().data(), SIGNAL( renamed( QString, QString ) ), this, SLOT( tomahawkPlaylistRenamed( QString, QString ) ) );
|
||||||
connect( playlist().data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistRevisionLoaded() ), Qt::QueuedConnection ); // Queued so that in playlist.cpp:443 we let the playlist clear its own queue first
|
connect( playlist().data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistRevisionLoaded() ), Qt::QueuedConnection ); // Queued so that in playlist.cpp:443 we let the playlist clear its own queue first
|
||||||
// TODO reorders in a playlist
|
// TODO reorders in a playlist
|
||||||
@@ -554,6 +555,17 @@ SpotifyPlaylistUpdater::onTracksRemovedReturn( const QString& msgType, const QVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyPlaylistUpdater::tomahawkTracksMoved( const QList< plentry_ptr >& tracks, int position )
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "Got tracks moved at position:" << position;
|
||||||
|
foreach ( const plentry_ptr ple, tracks )
|
||||||
|
{
|
||||||
|
qDebug() << ple->query()->track() << ple->query()->artist();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantList
|
QVariantList
|
||||||
SpotifyPlaylistUpdater::queriesToVariant( const QList< query_ptr >& queries )
|
SpotifyPlaylistUpdater::queriesToVariant( const QList< query_ptr >& queries )
|
||||||
{
|
{
|
||||||
|
@@ -69,6 +69,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void tomahawkTracksInserted( const QList<Tomahawk::plentry_ptr>& ,int );
|
void tomahawkTracksInserted( const QList<Tomahawk::plentry_ptr>& ,int );
|
||||||
void tomahawkTracksRemoved( const QList<Tomahawk::query_ptr>& );
|
void tomahawkTracksRemoved( const QList<Tomahawk::query_ptr>& );
|
||||||
|
void tomahawkTracksMoved( const QList<Tomahawk::plentry_ptr>& ,int );
|
||||||
void tomahawkPlaylistRenamed( const QString&, const QString& );
|
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 );
|
||||||
|
@@ -220,6 +220,10 @@ signals:
|
|||||||
/// Notification for tracks being removed from playlist
|
/// Notification for tracks being removed from playlist
|
||||||
void tracksRemoved( const QList< Tomahawk::query_ptr >& tracks );
|
void tracksRemoved( const QList< Tomahawk::query_ptr >& tracks );
|
||||||
|
|
||||||
|
/// Notification for tracks being moved in a playlist. List is of new tracks, and new position of first track
|
||||||
|
/// Contiguous range from startPosition
|
||||||
|
void tracksMoved( const QList< Tomahawk::plentry_ptr >& tracks, int startPosition );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// want to update the playlist from the model?
|
// want to update the playlist from the model?
|
||||||
// generate a newrev using uuid() and call this:
|
// generate a newrev using uuid() and call this:
|
||||||
|
@@ -428,7 +428,34 @@ PlaylistModel::endPlaylistChanges()
|
|||||||
m_playlist->createNewRevision( newrev, m_playlist->currentrevision(), l );
|
m_playlist->createNewRevision( newrev, m_playlist->currentrevision(), l );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_savedInsertPos >= 0 )
|
if ( m_savedInsertPos >= 0 && !m_savedInsertTracks.isEmpty() &&
|
||||||
|
!m_savedRemoveTracks.isEmpty() )
|
||||||
|
{
|
||||||
|
// If we have *both* an insert and remove, then it's a move action
|
||||||
|
// However, since we got the insert before the remove (Qt...), the index we have as the saved
|
||||||
|
// insert position is no longer valid. Find the proper one by finding the location of the first inserted
|
||||||
|
// track
|
||||||
|
for ( int i = 0; i < rowCount( QModelIndex() ); i++ )
|
||||||
|
{
|
||||||
|
const QModelIndex idx = index( i, 0, QModelIndex() );
|
||||||
|
if ( !idx.isValid() )
|
||||||
|
continue;
|
||||||
|
const TrackModelItem* item = itemFromIndex( idx );
|
||||||
|
if ( !item || item->entry().isNull() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( item->entry() == m_savedInsertTracks.first() )
|
||||||
|
{
|
||||||
|
// Found our index
|
||||||
|
emit m_playlist->tracksMoved( m_savedInsertTracks, i );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_savedInsertPos = -1;
|
||||||
|
m_savedInsertTracks.clear();
|
||||||
|
m_savedRemoveTracks.clear();
|
||||||
|
}
|
||||||
|
else if ( m_savedInsertPos >= 0 )
|
||||||
{
|
{
|
||||||
emit m_playlist->tracksInserted( m_savedInsertTracks, m_savedInsertPos );
|
emit m_playlist->tracksInserted( m_savedInsertTracks, m_savedInsertPos );
|
||||||
m_savedInsertPos = -1;
|
m_savedInsertPos = -1;
|
||||||
|
Reference in New Issue
Block a user