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 "video/VideoDatabase.h"
22 #include "DirectoryNodeOverview.h"
23 #include "settings/Settings.h"
25 #include "guilib/LocalizeStrings.h"
26 #include "video/VideoDbUrl.h"
28 using namespace XFILE::VIDEODATABASEDIRECTORY;
32 Node OverviewChildren[] = {
33 { NODE_TYPE_MOVIES_OVERVIEW, 1, 342 },
34 { NODE_TYPE_TVSHOWS_OVERVIEW, 2, 20343 },
35 { NODE_TYPE_MUSICVIDEOS_OVERVIEW, 3, 20389 },
36 { NODE_TYPE_RECENTLY_ADDED_MOVIES, 4, 20386 },
37 { NODE_TYPE_RECENTLY_ADDED_EPISODES, 5, 20387 },
38 { NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS, 6, 20390 },
41 CDirectoryNodeOverview::CDirectoryNodeOverview(const CStdString& strName, CDirectoryNode* pParent)
42 : CDirectoryNode(NODE_TYPE_OVERVIEW, strName, pParent)
47 NODE_TYPE CDirectoryNodeOverview::GetChildType() const
49 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
50 if (GetID() == OverviewChildren[i].id)
51 return OverviewChildren[i].node;
53 return NODE_TYPE_NONE;
56 CStdString CDirectoryNodeOverview::GetLocalizedName() const
58 for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
59 if (GetID() == OverviewChildren[i].id)
60 return g_localizeStrings.Get(OverviewChildren[i].label);
64 bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const
66 CVideoDatabase database;
68 bool hasMovies = database.HasContent(VIDEODB_CONTENT_MOVIES);
69 bool hasTvShows = database.HasContent(VIDEODB_CONTENT_TVSHOWS);
70 bool hasMusicVideos = database.HasContent(VIDEODB_CONTENT_MUSICVIDEOS);
71 vector<pair<const char*, int> > vec;
74 if (g_settings.m_bMyVideoNavFlatten)
75 vec.push_back(make_pair("1/2", 342));
77 vec.push_back(make_pair("1", 342)); // Movies
81 if (g_settings.m_bMyVideoNavFlatten)
82 vec.push_back(make_pair("2/2", 20343));
84 vec.push_back(make_pair("2", 20343)); // TV Shows
88 if (g_settings.m_bMyVideoNavFlatten)
89 vec.push_back(make_pair("3/2", 20389));
91 vec.push_back(make_pair("3", 20389)); // Music Videos
95 vec.push_back(make_pair("4", 20386)); // Recently Added Movies
97 vec.push_back(make_pair("5", 20387)); // Recently Added Episodes
99 vec.push_back(make_pair("6", 20390)); // Recently Added Music Videos
101 CStdString path = BuildPath();
102 for (unsigned int i = 0; i < vec.size(); ++i)
104 CFileItemPtr pItem(new CFileItem(path + vec[i].first + "/", true));
105 pItem->SetLabel(g_localizeStrings.Get(vec[i].second));
106 pItem->SetLabelPreformated(true);
107 pItem->SetCanQueue(false);