[haiku-commits] r38897 - in haiku/trunk/src/apps/mediaplayer: . playlist

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 8 Oct 2010 15:16:49 +0200 (CEST)

Author: axeld
Date: 2010-10-08 15:16:49 +0200 (Fri, 08 Oct 2010)
New Revision: 38897
Changeset: http://dev.haiku-os.org/changeset/38897

Modified:
   haiku/trunk/src/apps/mediaplayer/MainWin.cpp
   haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp
   haiku/trunk/src/apps/mediaplayer/playlist/Playlist.h
Log:
* 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.


Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2010-10-08 13:13:31 UTC 
(rev 38896)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2010-10-08 13:16:49 UTC 
(rev 38897)
@@ -1423,19 +1423,13 @@
        fFileMenu->AddItem(item);
        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.
        BRecentFilesList recentFiles(10, false, NULL, kAppSig);
        item = new BMenuItem(recentFiles.NewFileListMenu(
-               "Open file"B_UTF8_ELLIPSIS, new BMessage(B_REFS_RECEIVED),
-               NULL, this, 10, false, NULL, 0, kAppSig), new 
BMessage(M_FILE_OPEN));
+               "Open file"B_UTF8_ELLIPSIS, NULL, NULL, this, 10, true, NULL, 
kAppSig),
+               new BMessage(M_FILE_OPEN));
        item->SetShortcut('O', 0);
        fFileMenu->AddItem(item);
-#endif
 
        fFileMenu->AddSeparatorItem();
 
@@ -2397,9 +2391,6 @@
        if (node.InitCheck())
                return;
 
-       // Add to recent documents
-       be_roster->AddToRecentDocuments(&item->Ref(), kAppSig);
-
        locker.Unlock();
 
        // Set some standard attributes of the currently played file.

Modified: haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp      2010-10-08 
13:13:31 UTC (rev 38896)
+++ haiku/trunk/src/apps/mediaplayer/playlist/Playlist.cpp      2010-10-08 
13:16:49 UTC (rev 38897)
@@ -44,6 +44,7 @@
 
 #include "FilePlaylistItem.h"
 #include "FileReadWrite.h"
+#include "MainApp.h"
 
 using std::nothrow;
 
@@ -247,6 +248,13 @@
 }
 
 
+bool
+Playlist::IsEmpty() const
+{
+       return fItems.IsEmpty();
+}
+
+
 void
 Playlist::Sort()
 {
@@ -439,6 +447,7 @@
                        i++) {
                Playlist subPlaylist;
                BString type = _MIMEString(&ref);
+
                if (_IsPlaylist(type)) {
                        AppendPlaylistToPlaylist(ref, &subPlaylist);
                        // Do not sort the whole playlist anymore, as that
@@ -455,6 +464,16 @@
                        if (!sortPlaylist)
                                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();
                AdoptPlaylist(subPlaylist, subAppendIndex);
                subAppendIndex += subPlaylistCount;

Modified: haiku/trunk/src/apps/mediaplayer/playlist/Playlist.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/playlist/Playlist.h        2010-10-08 
13:13:31 UTC (rev 38896)
+++ haiku/trunk/src/apps/mediaplayer/playlist/Playlist.h        2010-10-08 
13:16:49 UTC (rev 38897)
@@ -46,17 +46,17 @@
 public:
        class Listener {
        public:
-                                               Listener();
-               virtual                 ~Listener();
+                                                               Listener();
+               virtual                                 ~Listener();
 
-               virtual void    ItemAdded(PlaylistItem* item, int32 index);
-               virtual void    ItemRemoved(int32 index);
+               virtual void                    ItemAdded(PlaylistItem* item, 
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:
@@ -73,6 +73,7 @@
                        // list functionality
                        void                            MakeEmpty(bool 
deleteItems = true);
                        int32                           CountItems() const;
+                       bool                            IsEmpty() const;
 
                        void                            Sort();
 


Other related posts:

  • » [haiku-commits] r38897 - in haiku/trunk/src/apps/mediaplayer: . playlist - axeld