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