2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "DirectoryNodeAlbumRecentlyPlayed.h"
22 #include "music/MusicDatabase.h"
24 #include "utils/StringUtils.h"
26 using namespace XFILE::MUSICDATABASEDIRECTORY;
28 CDirectoryNodeAlbumRecentlyPlayed::CDirectoryNodeAlbumRecentlyPlayed(const CStdString& strName, CDirectoryNode* pParent)
29 : CDirectoryNode(NODE_TYPE_ALBUM_RECENTLY_PLAYED, strName, pParent)
34 NODE_TYPE CDirectoryNodeAlbumRecentlyPlayed::GetChildType() const
37 return NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS;
39 return NODE_TYPE_SONG;
42 CStdString CDirectoryNodeAlbumRecentlyPlayed::GetLocalizedName() const
45 return g_localizeStrings.Get(15102); // All Albums
48 return db.GetAlbumById(GetID());
52 bool CDirectoryNodeAlbumRecentlyPlayed::GetContent(CFileItemList& items) const
54 CMusicDatabase musicdatabase;
55 if (!musicdatabase.Open())
59 if (!musicdatabase.GetRecentlyPlayedAlbums(albums))
61 musicdatabase.Close();
65 for (int i=0; i<(int)albums.size(); ++i)
67 CAlbum& album=albums[i];
68 CStdString strDir = StringUtils::Format("%s%ld/", BuildPath().c_str(), album.idAlbum);
69 CFileItemPtr pItem(new CFileItem(strDir, album));
74 musicdatabase.Close();