command: range support for "delete"
This commit is contained in:
parent
0478a8e288
commit
31cabc751d
1
NEWS
1
NEWS
@ -4,6 +4,7 @@ ver 0.16 (20??/??/??)
|
|||||||
- added "update" idle event
|
- added "update" idle event
|
||||||
- removed the deprecated "volume" command
|
- removed the deprecated "volume" command
|
||||||
- added the "findadd" command
|
- added the "findadd" command
|
||||||
|
- range support for "delete"
|
||||||
* input:
|
* input:
|
||||||
- lastfm: use metadata
|
- lastfm: use metadata
|
||||||
* tags:
|
* tags:
|
||||||
|
@ -632,13 +632,13 @@ handle_addid(struct client *client, int argc, char *argv[])
|
|||||||
static enum command_return
|
static enum command_return
|
||||||
handle_delete(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
handle_delete(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int song;
|
unsigned start, end;
|
||||||
enum playlist_result result;
|
enum playlist_result result;
|
||||||
|
|
||||||
if (!check_int(client, &song, argv[1], need_positive))
|
if (!check_range(client, &start, &end, argv[1], need_range))
|
||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
|
|
||||||
result = playlist_delete(&g_playlist, song);
|
result = playlist_delete_range(&g_playlist, start, end);
|
||||||
return print_playlist_result(client, result);
|
return print_playlist_result(client, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,15 @@ playlist_append_song(struct playlist *playlist,
|
|||||||
enum playlist_result
|
enum playlist_result
|
||||||
playlist_delete(struct playlist *playlist, unsigned song);
|
playlist_delete(struct playlist *playlist, unsigned song);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a range of songs from the playlist.
|
||||||
|
*
|
||||||
|
* @param start the position of the first song to delete
|
||||||
|
* @param end the position after the last song to delete
|
||||||
|
*/
|
||||||
|
enum playlist_result
|
||||||
|
playlist_delete_range(struct playlist *playlist, unsigned start, unsigned end);
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
playlist_delete_id(struct playlist *playlist, unsigned song);
|
playlist_delete_id(struct playlist *playlist, unsigned song);
|
||||||
|
|
||||||
|
@ -279,6 +279,32 @@ playlist_delete(struct playlist *playlist, unsigned song)
|
|||||||
return PLAYLIST_RESULT_SUCCESS;
|
return PLAYLIST_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum playlist_result
|
||||||
|
playlist_delete_range(struct playlist *playlist, unsigned start, unsigned end)
|
||||||
|
{
|
||||||
|
const struct song *queued;
|
||||||
|
|
||||||
|
if (start >= queue_length(&playlist->queue))
|
||||||
|
return PLAYLIST_RESULT_BAD_RANGE;
|
||||||
|
|
||||||
|
if (end > queue_length(&playlist->queue))
|
||||||
|
end = queue_length(&playlist->queue);
|
||||||
|
|
||||||
|
if (start >= end)
|
||||||
|
return PLAYLIST_RESULT_SUCCESS;
|
||||||
|
|
||||||
|
queued = playlist_get_queued_song(playlist);
|
||||||
|
|
||||||
|
do {
|
||||||
|
playlist_delete_internal(playlist, --end, &queued);
|
||||||
|
} while (end != start);
|
||||||
|
|
||||||
|
playlist_increment_version(playlist);
|
||||||
|
playlist_update_queued_song(playlist, queued);
|
||||||
|
|
||||||
|
return PLAYLIST_RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
enum playlist_result
|
enum playlist_result
|
||||||
playlist_delete_id(struct playlist *playlist, unsigned id)
|
playlist_delete_id(struct playlist *playlist, unsigned id)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user