merged: Linuxport revisions through to r15292.
[xbmc:xbmc-antiquated.git] / xbmc / GUIViewStatePictures.cpp
1 /*
2  *      Copyright (C) 2005-2008 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, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #include "stdafx.h"
23 #include "GUIViewStatePictures.h"
24 #include "GUIBaseContainer.h"
25 #include "FileItem.h"
26 #include "ViewState.h"
27 #include "Settings.h"
28 #include "FileSystem/Directory.h"
29 #include "FileSystem/PluginDirectory.h"
30 #include "Util.h"
31
32 using namespace DIRECTORY;
33
34 CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& items) : CGUIViewState(items)
35 {
36   if (items.IsVirtualDirectoryRoot())
37   {
38     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS());
39     AddSortMethod(SORT_METHOD_DRIVE_TYPE, 564, LABEL_MASKS());
40     SetSortMethod(SORT_METHOD_LABEL);
41
42     SetViewAsControl(DEFAULT_VIEW_LIST);
43
44     SetSortOrder(SORT_ORDER_ASC);
45   }
46   else
47   {
48     AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", ""));  // Filename, Size | Foldername, empty
49     AddSortMethod(SORT_METHOD_SIZE, 553, LABEL_MASKS("%L", "%I", "%L", "%I"));  // Filename, Size | Foldername, Size
50     AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J"));  // Filename, Date | Foldername, Date
51     AddSortMethod(SORT_METHOD_FILE, 561, LABEL_MASKS("%L", "%I", "%L", ""));  // Filename, Size | FolderName, empty
52
53     SetSortMethod((SORT_METHOD)g_guiSettings.GetInt("pictures.sortmethod"));
54     SetViewAsControl(g_guiSettings.GetInt("pictures.viewmode"));
55     SetSortOrder((SORT_ORDER)g_guiSettings.GetInt("pictures.sortorder"));
56   }
57   LoadViewState(items.m_strPath, WINDOW_PICTURES);
58 }
59
60 void CGUIViewStateWindowPictures::SaveViewState()
61 {
62   if (g_guiSettings.GetBool("pictures.savefolderviews"))
63     SaveViewToDb(m_items.m_strPath, WINDOW_PICTURES);
64 }
65
66 CStdString CGUIViewStateWindowPictures::GetLockType()
67 {
68   return "pictures";
69 }
70
71 bool CGUIViewStateWindowPictures::UnrollArchives()
72 {
73   return g_guiSettings.GetBool("filelists.unrollarchives");
74 }
75
76 CStdString CGUIViewStateWindowPictures::GetExtensions()
77 {
78   return g_stSettings.m_pictureExtensions;
79 }
80
81 VECSOURCES& CGUIViewStateWindowPictures::GetSources()
82 {
83   bool bIsSourceName = true;
84   // plugins share
85   if (CPluginDirectory::HasPlugins("pictures"))
86   {
87     CMediaSource share;
88     share.strName = g_localizeStrings.Get(1039); // Picture Plugins
89     share.strPath = "plugin://pictures/";
90     if (CUtil::GetMatchingSource(share.strName, g_settings.m_pictureSources, bIsSourceName) < 0)
91       g_settings.m_pictureSources.push_back(share);
92   }
93   return g_settings.m_pictureSources; 
94 }
95