| 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 "GUIViewStatePrograms.h" |
| 10 |
|
| 11 |
#include "FileItem.h" |
| 12 |
#include "ServiceBroker.h" |
| 13 |
#include "filesystem/Directory.h" |
| 14 |
#include "guilib/LocalizeStrings.h" |
| 15 |
#include "guilib/TextureManager.h" |
| 16 |
#include "guilib/WindowIDs.h" |
| 17 |
#include "settings/MediaSourceSettings.h" |
| 18 |
#include "settings/Settings.h" |
| 19 |
#include "settings/SettingsComponent.h" |
| 20 |
#include "view/ViewState.h" |
| 21 |
#include "view/ViewStateSettings.h" |
| 22 |
|
| 23 |
using namespace XFILE; |
| 24 |
|
| 25 |
CGUIViewStateWindowPrograms::CGUIViewStateWindowPrograms(const CFileItemList& items) : CGUIViewState(items) |
| 26 |
{ |
| 27 |
AddSortMethod(SortByLabel, 551, LABEL_MASKS("%K", "%I", "%L", ""), // Title, Size | Foldername, empty |
| 28 |
CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); |
| 29 |
|
| 30 |
const CViewState *viewState = CViewStateSettings::GetInstance().Get("programs"); |
| 31 |
SetSortMethod(viewState->m_sortDescription); |
| 32 |
SetViewAsControl(viewState->m_viewMode); |
| 33 |
SetSortOrder(viewState->m_sortDescription.sortOrder); |
| 34 |
|
| 35 |
LoadViewState(items.GetPath(), WINDOW_PROGRAMS); |
| 36 |
} |
| 37 |
|
| 38 |
void CGUIViewStateWindowPrograms::SaveViewState() |
| 39 |
{ |
| 40 |
SaveViewToDb(m_items.GetPath(), WINDOW_PROGRAMS, CViewStateSettings::GetInstance().Get("programs")); |
| 41 |
} |
| 42 |
|
| 43 |
std::string CGUIViewStateWindowPrograms::GetLockType() |
| 44 |
{ |
| 45 |
return "programs"; |
| 46 |
} |
| 47 |
|
| 48 |
std::string CGUIViewStateWindowPrograms::GetExtensions() |
| 49 |
{ |
| 50 |
return ".cut"; |
| 51 |
} |
| 52 |
|
| 53 |
VECSOURCES& CGUIViewStateWindowPrograms::GetSources() |
| 54 |
{ |
| 55 |
#if defined(TARGET_ANDROID) |
| 56 |
{ |
| 57 |
CMediaSource source; |
| 58 |
source.strPath = "androidapp://sources/apps/"; |
| 59 |
source.strName = g_localizeStrings.Get(20244); |
| 60 |
if (CServiceBroker::GetGUI()->GetTextureManager().HasTexture("DefaultProgram.png")) |
| 61 |
source.m_strThumbnailImage = "DefaultProgram.png"; |
| 62 |
source.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL; |
| 63 |
source.m_ignore = true; |
| 64 |
m_sources.emplace_back(std::move(source)); |
| 65 |
} |
| 66 |
#endif |
| 67 |
|
| 68 |
VECSOURCES *programSources = CMediaSourceSettings::GetInstance().GetSources("programs"); |
| 69 |
AddOrReplace(*programSources, CGUIViewState::GetSources()); |
| 70 |
return *programSources; |
| 71 |
} |
| 72 |
|