[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / filesystem / VideoDatabaseDirectory / DirectoryNodeMoviesOverview.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 "DirectoryNodeMoviesOverview.h"
22 #include "FileItem.h"
23 #include "guilib/LocalizeStrings.h"
24 #include "video/VideoDatabase.h"
25 #include "video/VideoDbUrl.h"
26
27 using namespace XFILE::VIDEODATABASEDIRECTORY;
28 using namespace std;
29
30 Node MovieChildren[] = {
31                         { NODE_TYPE_GENRE,        1, 135 },
32                         { NODE_TYPE_TITLE_MOVIES, 2, 369 },
33                         { NODE_TYPE_YEAR,         3, 562 },
34                         { NODE_TYPE_ACTOR,        4, 344 },
35                         { NODE_TYPE_DIRECTOR,     5, 20348 },
36                         { NODE_TYPE_STUDIO,       6, 20388 },
37                         { NODE_TYPE_SETS,         7, 20434 },
38                         { NODE_TYPE_COUNTRY,      8, 20451 },
39                         { NODE_TYPE_TAGS,         9, 20459 }
40                        };
41
42 CDirectoryNodeMoviesOverview::CDirectoryNodeMoviesOverview(const CStdString& strName, CDirectoryNode* pParent)
43   : CDirectoryNode(NODE_TYPE_MOVIES_OVERVIEW, strName, pParent)
44 {
45
46 }
47
48 NODE_TYPE CDirectoryNodeMoviesOverview::GetChildType() const
49 {
50   for (unsigned int i = 0; i < sizeof(MovieChildren) / sizeof(Node); ++i)
51     if (GetID() == MovieChildren[i].id)
52       return MovieChildren[i].node;
53   
54   return NODE_TYPE_NONE;
55 }
56
57 CStdString CDirectoryNodeMoviesOverview::GetLocalizedName() const
58 {
59   for (unsigned int i = 0; i < sizeof(MovieChildren) / sizeof(Node); ++i)
60     if (GetID() == MovieChildren[i].id)
61       return g_localizeStrings.Get(MovieChildren[i].label);
62   return "";
63 }
64
65 bool CDirectoryNodeMoviesOverview::GetContent(CFileItemList& items) const
66 {
67   CVideoDbUrl videoUrl;
68   if (!videoUrl.FromString(BuildPath()))
69     return false;
70   
71   for (unsigned int i = 0; i < sizeof(MovieChildren) / sizeof(Node); ++i)
72   {
73     if (i == 6)
74     {
75       CVideoDatabase db;
76       if (db.Open() && !db.HasSets())
77         continue;
78     }
79
80     CVideoDbUrl itemUrl = videoUrl;
81     CStdString strDir; strDir.Format("%ld/", MovieChildren[i].id);
82     itemUrl.AppendPath(strDir);
83
84     CFileItemPtr pItem(new CFileItem(itemUrl.ToString(), true));
85     pItem->SetLabel(g_localizeStrings.Get(MovieChildren[i].label));
86     pItem->SetCanQueue(false);
87     items.Add(pItem);
88   }
89
90   return true;
91 }