* Do not add documents to the recent list in _UpdatePlaylistItemFile(), but do

so when the items are added to the playlist. This has the added advantage of
  being able to easily reselect sub-folders (an album for example).
* Enabled navigating folders in the recent item list.
* Added Playlist::IsEmpty() method.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38897 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-10-08 13:16:49 +00:00
parent 3f7a0ba1b0
commit 7bf8d24715
3 changed files with 29 additions and 18 deletions
+2 -11
View File
@@ -1423,19 +1423,13 @@ MainWin::_CreateMenu()
fFileMenu->AddItem(item); fFileMenu->AddItem(item);
item->SetTarget(be_app); item->SetTarget(be_app);
#if 0
// Plain "Open File" entry
fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS,
new BMessage(M_FILE_OPEN), 'O'));
#else
// Add recent files to "Open File" entry as sub-menu. // Add recent files to "Open File" entry as sub-menu.
BRecentFilesList recentFiles(10, false, NULL, kAppSig); BRecentFilesList recentFiles(10, false, NULL, kAppSig);
item = new BMenuItem(recentFiles.NewFileListMenu( item = new BMenuItem(recentFiles.NewFileListMenu(
"Open file"B_UTF8_ELLIPSIS, new BMessage(B_REFS_RECEIVED), "Open file"B_UTF8_ELLIPSIS, NULL, NULL, this, 10, true, NULL, kAppSig),
NULL, this, 10, false, NULL, 0, kAppSig), new BMessage(M_FILE_OPEN)); new BMessage(M_FILE_OPEN));
item->SetShortcut('O', 0); item->SetShortcut('O', 0);
fFileMenu->AddItem(item); fFileMenu->AddItem(item);
#endif
fFileMenu->AddSeparatorItem(); fFileMenu->AddSeparatorItem();
@@ -2397,9 +2391,6 @@ MainWin::_UpdatePlaylistItemFile()
if (node.InitCheck()) if (node.InitCheck())
return; return;
// Add to recent documents
be_roster->AddToRecentDocuments(&item->Ref(), kAppSig);
locker.Unlock(); locker.Unlock();
// Set some standard attributes of the currently played file. // Set some standard attributes of the currently played file.
@@ -44,6 +44,7 @@
#include "FilePlaylistItem.h" #include "FilePlaylistItem.h"
#include "FileReadWrite.h" #include "FileReadWrite.h"
#include "MainApp.h"
using std::nothrow; using std::nothrow;
@@ -247,6 +248,13 @@ Playlist::CountItems() const
} }
bool
Playlist::IsEmpty() const
{
return fItems.IsEmpty();
}
void void
Playlist::Sort() Playlist::Sort()
{ {
@@ -439,6 +447,7 @@ Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex)
i++) { i++) {
Playlist subPlaylist; Playlist subPlaylist;
BString type = _MIMEString(&ref); BString type = _MIMEString(&ref);
if (_IsPlaylist(type)) { if (_IsPlaylist(type)) {
AppendPlaylistToPlaylist(ref, &subPlaylist); AppendPlaylistToPlaylist(ref, &subPlaylist);
// Do not sort the whole playlist anymore, as that // Do not sort the whole playlist anymore, as that
@@ -455,6 +464,16 @@ Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex)
if (!sortPlaylist) if (!sortPlaylist)
subPlaylist.Sort(); subPlaylist.Sort();
} }
if (!subPlaylist.IsEmpty()) {
// Add to recent documents
BEntry entry(&ref, true);
if (entry.IsDirectory())
be_roster->AddToRecentFolders(&ref, kAppSig);
else
be_roster->AddToRecentDocuments(&ref, kAppSig);
}
int32 subPlaylistCount = subPlaylist.CountItems(); int32 subPlaylistCount = subPlaylist.CountItems();
AdoptPlaylist(subPlaylist, subAppendIndex); AdoptPlaylist(subPlaylist, subAppendIndex);
subAppendIndex += subPlaylistCount; subAppendIndex += subPlaylistCount;
+8 -7
View File
@@ -46,17 +46,17 @@ class Playlist : public BLocker {
public: public:
class Listener { class Listener {
public: public:
Listener(); Listener();
virtual ~Listener(); virtual ~Listener();
virtual void ItemAdded(PlaylistItem* item, int32 index); virtual void ItemAdded(PlaylistItem* item, int32 index);
virtual void ItemRemoved(int32 index); virtual void ItemRemoved(int32 index);
virtual void ItemsSorted(); virtual void ItemsSorted();
virtual void CurrentItemChanged(int32 newIndex); virtual void CurrentItemChanged(int32 newIndex);
virtual void ImportFailed(); virtual void ImportFailed();
}; };
public: public:
@@ -73,6 +73,7 @@ public:
// list functionality // list functionality
void MakeEmpty(bool deleteItems = true); void MakeEmpty(bool deleteItems = true);
int32 CountItems() const; int32 CountItems() const;
bool IsEmpty() const;
void Sort(); void Sort();