From e9246c710e3b62ee4cb64eafcb896f46c98e62f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 26 Jun 2008 22:42:20 +0000 Subject: [PATCH] Implemented Playlist->Edit->Make Empty (undoable). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26144 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/playlist/ListViews.cpp | 15 +++++++++++++++ src/apps/mediaplayer/playlist/ListViews.h | 1 + src/apps/mediaplayer/playlist/PlaylistWindow.cpp | 1 + 3 files changed, 17 insertions(+) diff --git a/src/apps/mediaplayer/playlist/ListViews.cpp b/src/apps/mediaplayer/playlist/ListViews.cpp index 5c86c699ca..ab898026a1 100644 --- a/src/apps/mediaplayer/playlist/ListViews.cpp +++ b/src/apps/mediaplayer/playlist/ListViews.cpp @@ -717,6 +717,21 @@ DragSortableListView::RemoveSelected() RemoveItemList(indices); } +// RemoveAll +void +DragSortableListView::RemoveAll() +{ + BList indices; + int32 count = CountItems(); + for (int32 i = 0; i < count; i++) { + if (!indices.AddItem((void*)i)) + break; + } + + if (indices.CountItems() > 0) + RemoveItemList(indices); +} + // CountSelectedItems int32 DragSortableListView::CountSelectedItems() const diff --git a/src/apps/mediaplayer/playlist/ListViews.h b/src/apps/mediaplayer/playlist/ListViews.h index 5a9994852f..2f7f077ec8 100644 --- a/src/apps/mediaplayer/playlist/ListViews.h +++ b/src/apps/mediaplayer/playlist/ListViews.h @@ -93,6 +93,7 @@ class DragSortableListView : public BListView { virtual void CopyItems(BList& indices, int32 toIndex); virtual void RemoveItemList(BList& indices); void RemoveSelected(); // uses RemoveItemList() + void RemoveAll(); // uses RemoveItemList() int32 CountSelectedItems() const; void SelectAll(); virtual bool DeleteItem(int32 index); diff --git a/src/apps/mediaplayer/playlist/PlaylistWindow.cpp b/src/apps/mediaplayer/playlist/PlaylistWindow.cpp index a949ce4ee7..944392e5ac 100644 --- a/src/apps/mediaplayer/playlist/PlaylistWindow.cpp +++ b/src/apps/mediaplayer/playlist/PlaylistWindow.cpp @@ -145,6 +145,7 @@ PlaylistWindow::MessageReceived(BMessage* message) fOpenPanel->Show(); break; case M_PLAYLIST_EMPTY: + fListView->RemoveAll(); break; default: BWindow::MessageReceived(message);