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"
25 #include "utils/StringUtils.h"
29 namespace MUSICDATABASEDIRECTORY
31 Node OverviewChildren[] = {
32 { NODE_TYPE_GENRE, "genres", 135 },
33 { NODE_TYPE_ARTIST, "artists", 133 },
34 { NODE_TYPE_ALBUM, "albums", 132 },
35 { NODE_TYPE_SINGLES, "singles", 1050 },
36 { NODE_TYPE_SONG, "songs", 134 },
37 { NODE_TYPE_YEAR, "years", 652 },
38 { NODE_TYPE_TOP100, "top100", 271 },
39 { NODE_TYPE_ALBUM_RECENTLY_ADDED, "recentlyaddedalbums", 359 },
40 { NODE_TYPE_ALBUM_RECENTLY_PLAYED, "recentlyplayedalbums", 517 },
41 { NODE_TYPE_ALBUM_COMPILATIONS, "compilations", 521 },
47 using namespace XFILE::MUSICDATABASEDIRECTORY;
49 CDirectoryNodeOverview::CDirectoryNodeOverview(const CStdString& strName, CDirectoryNode* pParent)
50 : CDirectoryNode(NODE_TYPE_OVERVIEW, strName, pParent)
55 NODE_TYPE CDirectoryNodeOverview::GetChildType() const
57 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
58 if (GetName().Equals(OverviewChildren[i].id.c_str()))
59 return OverviewChildren[i].node;
60 return NODE_TYPE_NONE;
63 CStdString CDirectoryNodeOverview::GetLocalizedName() const
65 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
66 if (GetName().Equals(OverviewChildren[i].id.c_str()))
67 return g_localizeStrings.Get(OverviewChildren[i].label);
71 bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const
73 CMusicDatabase musicDatabase;
74 bool showSingles = false;
75 if (musicDatabase.Open())
77 CDatabase::Filter filter("songview.idAlbum IN (SELECT idAlbum FROM album WHERE strAlbum = '')");
78 if (musicDatabase.GetSongsCount(filter) > 0)
82 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
84 if (i == 3 && !showSingles) // singles
86 if (i == 9 && musicDatabase.GetCompilationAlbumsCount() == 0) // compilations
89 CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(OverviewChildren[i].label)));
90 CStdString strDir = StringUtils::Format("%s/", OverviewChildren[i].id.c_str());
91 pItem->SetPath(BuildPath() + strDir);
92 pItem->m_bIsFolder = true;
93 pItem->SetCanQueue(false);