* 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
This commit is contained in:
Axel Dörfler 2010-09-21 20:44:16 +00:00
parent 24b218c5a7
commit 4243bc41f2
4 changed files with 37 additions and 3 deletions

View File

@ -111,6 +111,7 @@ Application MediaPlayer :
VideoView.cpp
: be game locale media tracker translation textencoding $(TARGET_LIBSTDC++)
libshared.a
: MediaPlayer.rdef
;

View File

@ -40,6 +40,8 @@
#include <Roster.h>
#include <String.h>
#include <QueryFile.h>
#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)
{

View File

@ -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*,

View File

@ -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();
}
}