From 4243bc41f280fc911c8b648dbbb895b539ff4fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 21 Sep 2010 20:44:16 +0000 Subject: [PATCH] * Added support for dropped queries - the queries will be evaluated once, only (ie. no live mode). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38768 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/Jamfile | 1 + src/apps/mediaplayer/playlist/Playlist.cpp | 34 +++++++++++++++++-- src/apps/mediaplayer/playlist/Playlist.h | 3 ++ .../mediaplayer/playlist/PlaylistListView.cpp | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/apps/mediaplayer/Jamfile b/src/apps/mediaplayer/Jamfile index e445b77c66..b01883b271 100644 --- a/src/apps/mediaplayer/Jamfile +++ b/src/apps/mediaplayer/Jamfile @@ -111,6 +111,7 @@ Application MediaPlayer : VideoView.cpp : be game locale media tracker translation textencoding $(TARGET_LIBSTDC++) + libshared.a : MediaPlayer.rdef ; diff --git a/src/apps/mediaplayer/playlist/Playlist.cpp b/src/apps/mediaplayer/playlist/Playlist.cpp index f99ed580e4..8180eefdaa 100644 --- a/src/apps/mediaplayer/playlist/Playlist.cpp +++ b/src/apps/mediaplayer/playlist/Playlist.cpp @@ -40,6 +40,8 @@ #include #include +#include + #include "FilePlaylistItem.h" #include "FileReadWrite.h" @@ -436,13 +438,18 @@ Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex) for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK; i++) { Playlist subPlaylist; - if (_IsPlaylist(_MIMEString(&ref))) { + BString type = _MIMEString(&ref); + if (_IsPlaylist(type)) { AppendPlaylistToPlaylist(ref, &subPlaylist); // Do not sort the whole playlist anymore, as that // will screw up the ordering in the saved playlist. sortPlaylist = false; } else { - AppendToPlaylistRecursive(ref, &subPlaylist); + if (_IsQuery(type)) + AppendQueryToPlaylist(ref, &subPlaylist); + else + AppendToPlaylistRecursive(ref, &subPlaylist); + // At least sort this subsection of the playlist // if the whole playlist is not sorted anymore. if (!sortPlaylist) @@ -538,6 +545,22 @@ Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist) } +/*static*/ void +Playlist::AppendQueryToPlaylist(const entry_ref& ref, Playlist* playlist) +{ + BQueryFile query(&ref); + if (query.InitCheck() != B_OK) + return; + + entry_ref foundRef; + while (query.GetNextRef(&foundRef) == B_OK) { + PlaylistItem* item = new (std::nothrow) FilePlaylistItem(foundRef); + if (item == NULL || !playlist->AddItem(item)) + delete item; + } +} + + void Playlist::NotifyImportFailed() { @@ -605,6 +628,13 @@ Playlist::_IsPlaylist(const BString& mimeString) } +/*static*/ bool +Playlist::_IsQuery(const BString& mimeString) +{ + return mimeString.Compare(BQueryFile::MimeType()) == 0; +} + + /*static*/ BString Playlist::_MIMEString(const entry_ref* ref) { diff --git a/src/apps/mediaplayer/playlist/Playlist.h b/src/apps/mediaplayer/playlist/Playlist.h index 0f7ad7cf78..4f8e12c21c 100644 --- a/src/apps/mediaplayer/playlist/Playlist.h +++ b/src/apps/mediaplayer/playlist/Playlist.h @@ -107,6 +107,8 @@ public: Playlist* playlist); static void AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist); + static void AppendQueryToPlaylist(const entry_ref& ref, + Playlist* playlist); void NotifyImportFailed(); @@ -119,6 +121,7 @@ private: static bool _IsTextPlaylist(const BString& mimeString); static bool _IsBinaryPlaylist(const BString& mimeString); static bool _IsPlaylist(const BString& mimeString); + static bool _IsQuery(const BString& mimeString); static BString _MIMEString(const entry_ref* ref); void _NotifyItemAdded(PlaylistItem*, diff --git a/src/apps/mediaplayer/playlist/PlaylistListView.cpp b/src/apps/mediaplayer/playlist/PlaylistListView.cpp index 5a289f959b..bd92955b65 100644 --- a/src/apps/mediaplayer/playlist/PlaylistListView.cpp +++ b/src/apps/mediaplayer/playlist/PlaylistListView.cpp @@ -445,7 +445,7 @@ void PlaylistListView::RefsReceived(BMessage* message, int32 appendIndex) { if (fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist, - message, appendIndex)) != B_OK) { + message, appendIndex)) != B_OK) { fPlaylist->NotifyImportFailed(); } }