Merge pull request #5039 from CEikermann/patch-1
[vuplus_xbmc] / xbmc / pictures / GUIViewStatePictures.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://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 "GUIViewStatePictures.h"
22 #include "FileItem.h"
23 #include "view/ViewState.h"
24 #include "settings/AdvancedSettings.h"
25 #include "settings/MediaSourceSettings.h"
26 #include "settings/Settings.h"
27 #include "filesystem/Directory.h"
28 #include "filesystem/PluginDirectory.h"
29 #include "guilib/LocalizeStrings.h"
30 #include "guilib/WindowIDs.h"
31 #include "view/ViewStateSettings.h"
32
33 using namespace XFILE;
34 using namespace ADDON;
35
36 CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& items) : CGUIViewState(items)
37 {
38   if (items.IsVirtualDirectoryRoot())
39   {
40     AddSortMethod(SortByLabel, 551, LABEL_MASKS());
41     AddSortMethod(SortByDriveType, 564, LABEL_MASKS());
42     SetSortMethod(SortByLabel);
43
44     SetViewAsControl(DEFAULT_VIEW_LIST);
45
46     SetSortOrder(SortOrderAscending);
47   }
48   else
49   {
50     AddSortMethod(SortByLabel, 551, LABEL_MASKS("%L", "%I", "%L", ""));  // Filename, Size | Foldername, empty
51     AddSortMethod(SortBySize, 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // Filename, Size | Foldername, Size
52     AddSortMethod(SortByDate, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // Filename, Date | Foldername, Date
53     AddSortMethod(SortByDateTaken, 577, LABEL_MASKS("%L", "%t", "%L", "%J"));  // Filename, DateTaken | Foldername, Date
54     AddSortMethod(SortByFile, 561, LABEL_MASKS("%L", "%I", "%L", ""));  // Filename, Size | FolderName, empty
55
56     const CViewState *viewState = CViewStateSettings::Get().Get("pictures");
57     SetSortMethod(viewState->m_sortDescription);
58     SetViewAsControl(viewState->m_viewMode);
59     SetSortOrder(viewState->m_sortDescription.sortOrder);
60   }
61   LoadViewState(items.GetPath(), WINDOW_PICTURES);
62 }
63
64 void CGUIViewStateWindowPictures::SaveViewState()
65 {
66   SaveViewToDb(m_items.GetPath(), WINDOW_PICTURES, CViewStateSettings::Get().Get("pictures"));
67 }
68
69 CStdString CGUIViewStateWindowPictures::GetLockType()
70 {
71   return "pictures";
72 }
73
74 CStdString CGUIViewStateWindowPictures::GetExtensions()
75 {
76   if (CSettings::Get().GetBool("pictures.showvideos"))
77     return g_advancedSettings.m_pictureExtensions+"|"+g_advancedSettings.m_videoExtensions;
78
79   return g_advancedSettings.m_pictureExtensions;
80 }
81
82 VECSOURCES& CGUIViewStateWindowPictures::GetSources()
83 {
84   VECSOURCES *pictureSources = CMediaSourceSettings::Get().GetSources("pictures");
85   AddAddonsSource("image", g_localizeStrings.Get(1039), "DefaultAddonPicture.png");
86   AddOrReplace(*pictureSources, CGUIViewState::GetSources());
87   return *pictureSources;
88 }
89