Merge branch 'container_foldername'
[vuplus_xbmc] / xbmc / filesystem / MusicDatabaseDirectory / DirectoryNodeTop100.cpp
1 /*
2  *      Copyright (C) 2005-2008 Team XBMC
3  *      http://www.xbmc.org
4  *
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)
8  *  any later version.
9  *
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.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #include "DirectoryNodeTop100.h"
23 #include "FileItem.h"
24 #include "guilib/LocalizeStrings.h"
25
26 using namespace std;
27 using namespace XFILE::MUSICDATABASEDIRECTORY;
28
29 Node Top100Children[] = {
30                           { NODE_TYPE_SONG_TOP100,  1, 10504 },
31                           { NODE_TYPE_ALBUM_TOP100, 2, 10505 },
32                         };
33
34 CDirectoryNodeTop100::CDirectoryNodeTop100(const CStdString& strName, CDirectoryNode* pParent)
35   : CDirectoryNode(NODE_TYPE_TOP100, strName, pParent)
36 {
37
38 }
39
40 NODE_TYPE CDirectoryNodeTop100::GetChildType() const
41 {
42   for (unsigned int i = 0; i < sizeof(Top100Children) / sizeof(Node); ++i)
43     if (GetID() == Top100Children[i].id)
44       return Top100Children[i].node;
45
46   return NODE_TYPE_NONE;
47 }
48
49 CStdString CDirectoryNodeTop100::GetLocalizedName() const
50 {
51   for (unsigned int i = 0; i < sizeof(Top100Children) / sizeof(Node); ++i)
52     if (GetID() == Top100Children[i].id)
53       return g_localizeStrings.Get(Top100Children[i].label);
54   return "";
55 }
56
57 bool CDirectoryNodeTop100::GetContent(CFileItemList& items) const
58 {
59   for (unsigned int i = 0; i < sizeof(Top100Children) / sizeof(Node); ++i)
60   {
61     CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(Top100Children[i].label)));
62     CStdString strDir;
63     strDir.Format("%ld/", Top100Children[i].id);
64     pItem->m_strPath += BuildPath() + strDir;
65     pItem->m_bIsFolder = true;
66     items.Add(pItem);
67   }
68
69   return true;
70 }