2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "GUIViewStatePictures.h"
12 #include "ServiceBroker.h"
13 #include "filesystem/Directory.h"
14 #include "guilib/LocalizeStrings.h"
15 #include "guilib/WindowIDs.h"
16 #include "settings/MediaSourceSettings.h"
17 #include "settings/Settings.h"
18 #include "settings/SettingsComponent.h"
19 #include "utils/FileExtensionProvider.h"
20 #include "view/ViewState.h"
21 #include "view/ViewStateSettings.h"
23 using namespace XFILE
;
24 using namespace ADDON
;
26 CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList
& items
) : CGUIViewState(items
)
28 if (items
.IsVirtualDirectoryRoot())
30 AddSortMethod(SortByLabel
, 551, LABEL_MASKS());
31 AddSortMethod(SortByDriveType
, 564, LABEL_MASKS());
32 SetSortMethod(SortByLabel
);
34 SetViewAsControl(DEFAULT_VIEW_LIST
);
36 SetSortOrder(SortOrderAscending
);
40 AddSortMethod(SortByLabel
, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty
41 AddSortMethod(SortBySize
, 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // Filename, Size | Foldername, Size
42 AddSortMethod(SortByDate
, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date
43 AddSortMethod(SortByDateTaken
, 577, LABEL_MASKS("%L", "%t", "%L", "%J")); // Filename, DateTaken | Foldername, Date
44 AddSortMethod(SortByFile
, 561, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | FolderName, empty
46 const CViewState
*viewState
= CViewStateSettings::GetInstance().Get("pictures");
47 SetSortMethod(viewState
->m_sortDescription
);
48 SetViewAsControl(viewState
->m_viewMode
);
49 SetSortOrder(viewState
->m_sortDescription
.sortOrder
);
51 LoadViewState(items
.GetPath(), WINDOW_PICTURES
);
54 void CGUIViewStateWindowPictures::SaveViewState()
56 SaveViewToDb(m_items
.GetPath(), WINDOW_PICTURES
, CViewStateSettings::GetInstance().Get("pictures"));
59 std::string
CGUIViewStateWindowPictures::GetLockType()
64 std::string
CGUIViewStateWindowPictures::GetExtensions()
66 std::string extensions
= CServiceBroker::GetFileExtensionProvider().GetPictureExtensions();
67 if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_SHOWVIDEOS
))
68 extensions
+= "|" + CServiceBroker::GetFileExtensionProvider().GetVideoExtensions();
73 VECSOURCES
& CGUIViewStateWindowPictures::GetSources()
75 VECSOURCES
*pictureSources
= CMediaSourceSettings::GetInstance().GetSources("pictures");
77 // Guard against source type not existing
78 if (pictureSources
== nullptr)
80 static VECSOURCES empty
;
84 return *pictureSources
;