[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / filesystem / VideoDatabaseDirectory / DirectoryNodeOverview.cpp
1 /*
2  *      Copyright (C) 2005-2013 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, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "video/VideoDatabase.h"
22 #include "DirectoryNodeOverview.h"
23 #include "settings/Settings.h"
24 #include "FileItem.h"
25 #include "guilib/LocalizeStrings.h"
26 #include "video/VideoDbUrl.h"
27
28 using namespace XFILE::VIDEODATABASEDIRECTORY;
29 using namespace std;
30
31
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 },
39                           };
40
41 CDirectoryNodeOverview::CDirectoryNodeOverview(const CStdString& strName, CDirectoryNode* pParent)
42   : CDirectoryNode(NODE_TYPE_OVERVIEW, strName, pParent)
43 {
44
45 }
46
47 NODE_TYPE CDirectoryNodeOverview::GetChildType() const
48 {
49   for (unsigned int i = 0; i < sizeof(OverviewChildren) / sizeof(Node); ++i)
50     if (GetID() == OverviewChildren[i].id)
51       return OverviewChildren[i].node;
52
53   return NODE_TYPE_NONE;
54 }
55
56 CStdString CDirectoryNodeOverview::GetLocalizedName() const
57 {
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);
61   return "";
62 }
63
64 bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const
65 {
66   CVideoDatabase database;
67   database.Open();
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;
72   if (hasMovies)
73   {
74     if (g_settings.m_bMyVideoNavFlatten)
75       vec.push_back(make_pair("1/2", 342));
76     else
77       vec.push_back(make_pair("1", 342));   // Movies
78   }
79   if (hasTvShows)
80   {
81     if (g_settings.m_bMyVideoNavFlatten)
82       vec.push_back(make_pair("2/2", 20343));
83     else
84       vec.push_back(make_pair("2", 20343)); // TV Shows
85   }
86   if (hasMusicVideos)
87   {
88     if (g_settings.m_bMyVideoNavFlatten)
89       vec.push_back(make_pair("3/2", 20389));
90     else
91       vec.push_back(make_pair("3", 20389)); // Music Videos
92   }
93   {
94     if (hasMovies)
95       vec.push_back(make_pair("4", 20386));  // Recently Added Movies
96     if (hasTvShows)
97       vec.push_back(make_pair("5", 20387)); // Recently Added Episodes
98     if (hasMusicVideos)
99       vec.push_back(make_pair("6", 20390)); // Recently Added Music Videos
100   }
101   CStdString path = BuildPath();
102   for (unsigned int i = 0; i < vec.size(); ++i)
103   {
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);
108     items.Add(pItem);
109   }
110
111   return true;
112 }