The insert and remove signal for a playlist was not correct.

This commit is contained in:
Andreas 2013-07-31 19:06:29 +02:00
parent e8f9d856b6
commit 4fe293b6d0
4 changed files with 28 additions and 20 deletions

View File

@ -66,12 +66,12 @@ IncomingDataParser::IncomingDataParser(Application* app)
connect(this, SIGNAL(SetShuffleMode(PlaylistSequence::ShuffleMode)),
app_->playlist_manager()->sequence(),
SLOT(SetShuffleMode(PlaylistSequence::ShuffleMode)));
connect(this, SIGNAL(InsertUrls(const QList<QUrl>&, int, bool, bool)),
app_->playlist_manager()->active(),
SLOT(InsertUrls(const QList<QUrl>&, int, bool, bool)));
connect(this, SIGNAL(RemoveSongs(const QList<int>&)),
app_->playlist_manager()->active(),
SLOT(RemoveItemsWithoutUndo(const QList<int>&)));
connect(this, SIGNAL(InsertUrls(int, const QList<QUrl>&, int, bool, bool)),
app_->playlist_manager(),
SLOT(InsertUrls(int, const QList<QUrl>&, int, bool, bool)));
connect(this, SIGNAL(RemoveSongs(int, const QList<int>&)),
app_->playlist_manager(),
SLOT(RemoveItemsWithoutUndo(int, const QList<int>&)));
connect(this, SIGNAL(Open(int)),
app_->playlist_manager(), SLOT(Open(int)));
connect(this, SIGNAL(Close(int)),
@ -217,11 +217,6 @@ void IncomingDataParser::SetShuffleMode(const pb::remote::Shuffle& shuffle) {
void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) {
const pb::remote::RequestInsertUrls& request = msg.request_insert_urls();
// Check if we need to change the playlist
if (request.playlist_id() != app_->playlist_manager()->active_id()) {
emit SetActivePlaylist(request.playlist_id());
}
// Extract urls
QList<QUrl> urls;
for (auto it = request.urls().begin(); it != request.urls().end(); ++it) {
@ -229,23 +224,19 @@ void IncomingDataParser::InsertUrls(const pb::remote::Message& msg) {
}
// Insert the urls
emit InsertUrls(urls, request.position(), request.play_now(), request.enqueue());
emit InsertUrls(request.playlist_id(), urls, request.position(),
request.play_now(), request.enqueue());
}
void IncomingDataParser::RemoveSongs(const pb::remote::Message& msg) {
const pb::remote::RequestRemoveSongs& request = msg.request_remove_songs();
// Check if we need to change the playlist
if (request.playlist_id() != app_->playlist_manager()->active_id()) {
emit SetActivePlaylist(request.playlist_id());
}
// Extract urls
QList<int> songs;
std::copy(request.songs().begin(), request.songs().end(), songs.begin());
// Insert the urls
emit RemoveSongs(songs);
emit RemoveSongs(request.playlist_id(), songs);
}
void IncomingDataParser::ClientConnect(const pb::remote::Message& msg) {

View File

@ -42,8 +42,8 @@ signals:
void ShuffleCurrent();
void SetRepeatMode(PlaylistSequence::RepeatMode mode);
void SetShuffleMode(PlaylistSequence::ShuffleMode mode);
void InsertUrls(const QList<QUrl>& urls, int pos, bool play_now, bool enqueue);
void RemoveSongs(const QList<int>& indices);
void InsertUrls(int id, const QList<QUrl>& urls, int pos, bool play_now, bool enqueue);
void RemoveSongs(int id, const QList<int>& indices);
void SeekTo(int seconds);
void SendSongs(const pb::remote::RequestDownloadSongs& request, RemoteClient* client);
void ResponseSongOffer(RemoteClient* client, bool accepted);

View File

@ -462,6 +462,19 @@ void PlaylistManager::SongChangeRequestProcessed(const QUrl& url, bool valid) {
}
}
void PlaylistManager::InsertUrls(int id, const QList<QUrl> &urls, int pos,
bool play_now, bool enqueue) {
Q_ASSERT(playlists_.contains(id));
playlists_[id].p->InsertUrls(urls, pos, play_now, enqueue);
}
void PlaylistManager::RemoveItemsWithoutUndo(int id, const QList<int> &indices) {
Q_ASSERT(playlists_.contains(id));
playlists_[id].p->RemoveItemsWithoutUndo(indices);
}
void PlaylistManager::InvalidateDeletedSongs() {
foreach(Playlist* playlist, GetAllPlaylists()) {
playlist->InvalidateDeletedSongs();

View File

@ -211,6 +211,10 @@ public slots:
void SongChangeRequestProcessed(const QUrl& url, bool valid);
void InsertUrls(int id, const QList<QUrl>& urls, int pos = -1, bool play_now = false, bool enqueue = false);
// Removes items with given indices from the playlist. This operation is not undoable.
void RemoveItemsWithoutUndo(int id, const QList<int>& indices);
private slots:
void SetActivePlaying();
void SetActivePaused();