| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "GUIViewStatePictures.h" |
| 10 |
|
| 11 |
#include "FileItem.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" |
| 22 |
|
| 23 |
using namespace XFILE; |
| 24 |
using namespace ADDON; |
| 25 |
|
| 26 |
CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& items) : CGUIViewState(items) |
| 27 |
{ |
| 28 |
if (items.IsVirtualDirectoryRoot()) |
| 29 |
{ |
| 30 |
AddSortMethod(SortByLabel, 551, LABEL_MASKS()); |
| 31 |
AddSortMethod(SortByDriveType, 564, LABEL_MASKS()); |
| 32 |
SetSortMethod(SortByLabel); |
| 33 |
|
| 34 |
SetViewAsControl(DEFAULT_VIEW_LIST); |
| 35 |
|
| 36 |
SetSortOrder(SortOrderAscending); |
| 37 |
} |
| 38 |
else |
| 39 |
{ |
| 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 |
| 45 |
|
| 46 |
const CViewState *viewState = CViewStateSettings::GetInstance().Get("pictures"); |
| 47 |
SetSortMethod(viewState->m_sortDescription); |
| 48 |
SetViewAsControl(viewState->m_viewMode); |
| 49 |
SetSortOrder(viewState->m_sortDescription.sortOrder); |
| 50 |
} |
| 51 |
LoadViewState(items.GetPath(), WINDOW_PICTURES); |
| 52 |
} |
| 53 |
|
| 54 |
void CGUIViewStateWindowPictures::SaveViewState() |
| 55 |
{ |
| 56 |
SaveViewToDb(m_items.GetPath(), WINDOW_PICTURES, CViewStateSettings::GetInstance().Get("pictures")); |
| 57 |
} |
| 58 |
|
| 59 |
std::string CGUIViewStateWindowPictures::GetLockType() |
| 60 |
{ |
| 61 |
return "pictures"; |
| 62 |
} |
| 63 |
|
| 64 |
std::string CGUIViewStateWindowPictures::GetExtensions() |
| 65 |
{ |
| 66 |
std::string extensions = CServiceBroker::GetFileExtensionProvider().GetPictureExtensions(); |
| 67 |
if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_PICTURES_SHOWVIDEOS)) |
| 68 |
extensions += "|" + CServiceBroker::GetFileExtensionProvider().GetVideoExtensions(); |
| 69 |
|
| 70 |
return extensions; |
| 71 |
} |
| 72 |
|
| 73 |
VECSOURCES& CGUIViewStateWindowPictures::GetSources() |
| 74 |
{ |
| 75 |
VECSOURCES *pictureSources = CMediaSourceSettings::GetInstance().GetSources("pictures"); |
| 76 |
|
| 77 |
// Guard against source type not existing |
| 78 |
if (pictureSources == nullptr) |
| 79 |
{ |
| 80 |
static VECSOURCES empty; |
| 81 |
return empty; |
| 82 |
} |
| 83 |
|
| 84 |
return *pictureSources; |
| 85 |
} |
| 86 |
|