2 * Copyright (C) 2005-2008 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, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #include "DirectoryNodeOverview.h"
24 #include "music/MusicDatabase.h"
25 #include "guilib/LocalizeStrings.h"
28 using namespace XFILE::MUSICDATABASEDIRECTORY;
30 CDirectoryNodeOverview::CDirectoryNodeOverview(const CStdString& strName, CDirectoryNode* pParent)
31 : CDirectoryNode(NODE_TYPE_OVERVIEW, strName, pParent)
36 NODE_TYPE CDirectoryNodeOverview::GetChildType()
39 return NODE_TYPE_GENRE;
40 else if (GetName()=="2")
41 return NODE_TYPE_ARTIST;
42 else if (GetName()=="3")
43 return NODE_TYPE_ALBUM;
44 else if (GetName()=="4")
45 return NODE_TYPE_SONG;
46 else if (GetName()=="5")
47 return NODE_TYPE_TOP100;
48 else if (GetName()=="6")
49 return NODE_TYPE_ALBUM_RECENTLY_ADDED;
50 else if (GetName()=="7")
51 return NODE_TYPE_ALBUM_RECENTLY_PLAYED;
52 else if (GetName()=="8")
53 return NODE_TYPE_ALBUM_COMPILATIONS;
54 else if (GetName()=="9")
55 return NODE_TYPE_YEAR;
56 else if (GetName()=="10")
57 return NODE_TYPE_SINGLES;
58 return NODE_TYPE_NONE;
61 bool CDirectoryNodeOverview::GetContent(CFileItemList& items)
63 vector< pair<int, int> > rootItems;
64 CMusicDatabase musicDatabase;
65 bool showSingles = false;
66 if (musicDatabase.Open())
68 if (musicDatabase.GetSongsCount("where idAlbum in (select idAlbum from album where strAlbum='')") > 0)
72 rootItems.push_back(make_pair(1, 135));
73 rootItems.push_back(make_pair(2, 133));
74 rootItems.push_back(make_pair(3, 132));
76 rootItems.push_back(make_pair(10, 1050));
77 rootItems.push_back(make_pair(4, 134));
78 rootItems.push_back(make_pair(9, 652));
79 rootItems.push_back(make_pair(5, 271));
80 rootItems.push_back(make_pair(6, 359));
81 rootItems.push_back(make_pair(7, 517));
82 if (musicDatabase.GetVariousArtistsAlbumsCount() > 0)
83 rootItems.push_back(make_pair(8, 521));
85 for (unsigned int i = 0; i < rootItems.size(); ++i)
87 CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(rootItems[i].second)));
89 strDir.Format("%i/", rootItems[i].first);
90 pItem->m_strPath = BuildPath() + strDir;
91 pItem->m_bIsFolder = true;
92 pItem->SetCanQueue(false);