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 "DirectoryNodeOverview.h"
23 #include "music/MusicDatabase.h"
24 #include "guilib/LocalizeStrings.h"
28 namespace MUSICDATABASEDIRECTORY
30 Node OverviewChildren[] = {
31 { NODE_TYPE_GENRE, 1, 135 },
32 { NODE_TYPE_ARTIST, 2, 133 },
33 { NODE_TYPE_ALBUM, 3, 132 },
34 { NODE_TYPE_SINGLES, 10, 1050 },
35 { NODE_TYPE_SONG, 4, 134 },
36 { NODE_TYPE_YEAR, 9, 652 },
37 { NODE_TYPE_TOP100, 5, 271 },
38 { NODE_TYPE_ALBUM_RECENTLY_ADDED, 6, 359 },
39 { NODE_TYPE_ALBUM_RECENTLY_PLAYED, 7, 517 },
40 { NODE_TYPE_ALBUM_COMPILATIONS, 8, 521 },
46 using namespace XFILE::MUSICDATABASEDIRECTORY;
48 CDirectoryNodeOverview::CDirectoryNodeOverview(const CStdString& strName, CDirectoryNode* pParent)
49 : CDirectoryNode(NODE_TYPE_OVERVIEW, strName, pParent)
54 NODE_TYPE CDirectoryNodeOverview::GetChildType() const
56 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
57 if (GetID() == OverviewChildren[i].id)
58 return OverviewChildren[i].node;
59 return NODE_TYPE_NONE;
62 CStdString CDirectoryNodeOverview::GetLocalizedName() const
64 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
65 if (GetID() == OverviewChildren[i].id)
66 return g_localizeStrings.Get(OverviewChildren[i].label);
70 bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const
72 CMusicDatabase musicDatabase;
73 bool showSingles = false;
74 if (musicDatabase.Open())
76 CDatabase::Filter filter("songview.idAlbum IN (SELECT idAlbum FROM album WHERE strAlbum = '')");
77 if (musicDatabase.GetSongsCount(filter) > 0)
81 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
83 if (i == 3 && !showSingles) // singles
85 if (i == 9 && musicDatabase.GetCompilationAlbumsCount() == 0) // compilations
88 CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(OverviewChildren[i].label)));
90 strDir.Format("%ld/", OverviewChildren[i].id);
91 pItem->SetPath(BuildPath() + strDir);
92 pItem->m_bIsFolder = true;
93 pItem->SetCanQueue(false);