This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
/
GUIViewStateAddonBrowser.cpp
84 lines (73 loc) · 2.51 KB
/
GUIViewStateAddonBrowser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "GUIViewStateAddonBrowser.h"
#include "GUIBaseContainer.h"
#include "FileItem.h"
#include "Key.h"
#include "ViewState.h"
#include "Settings.h"
#include "FileSystem/Directory.h"
#include "addons/Addon.h"
#include "addons/AddonManager.h"
using namespace XFILE;
using namespace ADDON;
CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items) : CGUIViewState(items)
{
AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%I", "%L", "")); // Filename, Size | Foldername, empty
AddSortMethod(SORT_METHOD_DATE, 552, LABEL_MASKS("%L", "%J", "%L", "%J")); // Filename, Date | Foldername, Date
SetSortMethod(SORT_METHOD_LABEL);
SetViewAsControl(DEFAULT_VIEW_LIST);
SetSortOrder(SORT_ORDER_ASC);
LoadViewState(items.m_strPath, WINDOW_ADDON_BROWSER);
}
void CGUIViewStateAddonBrowser::SaveViewState()
{
SaveViewToDb(m_items.m_strPath, WINDOW_ADDON_BROWSER);
}
CStdString CGUIViewStateAddonBrowser::GetExtensions()
{
return "";
}
VECSOURCES& CGUIViewStateAddonBrowser::GetSources()
{
m_sources.clear();
VECADDONS addons;
CAddonMgr::Get()->GetAllAddons(addons);
if (addons.size())
{
CMediaSource share;
share.strPath = "addons://enabled/";
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = g_localizeStrings.Get(24062);
m_sources.push_back(share);
}
addons.clear();
CAddonMgr::Get()->GetAddons(ADDON_REPOSITORY,addons,CONTENT_NONE,true);
for (unsigned int i=0;i<addons.size();++i)
{
CMediaSource share;
share.strPath = "addons://"+addons[i]->ID();
share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
share.strName = addons[i]->Name();
m_sources.push_back(share);
}
return CGUIViewState::GetSources();
}