aboutsummaryrefslogtreecommitdiff
path: root/xbmc/addons/gui/GUIViewStateAddonBrowser.cpp
blob: 5504f33ecd0846a22863e9a2ff3f6c6d832df654 (plain)
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
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "GUIViewStateAddonBrowser.h"

#include "FileItem.h"
#include "filesystem/File.h"
#include "guilib/WindowIDs.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "view/ViewState.h"
#include "windowing/GraphicContext.h"

using namespace XFILE;
using namespace ADDON;

CGUIViewStateAddonBrowser::CGUIViewStateAddonBrowser(const CFileItemList& items)
  : CGUIViewState(items)
{
  if (URIUtils::PathEquals(items.GetPath(), "addons://"))
  {
    AddSortMethod(SortByNone, 551, LABEL_MASKS("%F", "", "%L", ""));
    SetSortMethod(SortByNone);
  }
  else if (URIUtils::PathEquals(items.GetPath(), "addons://recently_updated/", true))
  {
    AddSortMethod(SortByLastUpdated, 12014, LABEL_MASKS("%L", "%v", "%L", "%v"),
                  SortAttributeIgnoreFolders, SortOrderDescending);
  }
  else
  {
    AddSortMethod(SortByLabel, SortAttributeIgnoreFolders, 551,
                  LABEL_MASKS("%L", "%s", "%L", "%s"));

    if (StringUtils::StartsWith(items.GetPath(), "addons://sources/"))
      AddSortMethod(SortByLastUsed, 12012, LABEL_MASKS("%L", "%u", "%L", "%u"),
                    SortAttributeIgnoreFolders, SortOrderDescending); //Label, Last used

    if (StringUtils::StartsWith(items.GetPath(), "addons://user/") &&
        items.GetContent() == "addons")
      AddSortMethod(SortByInstallDate, 12013, LABEL_MASKS("%L", "%i", "%L", "%i"),
                    SortAttributeIgnoreFolders, SortOrderDescending);

    SetSortMethod(SortByLabel);
  }
  SetViewAsControl(DEFAULT_VIEW_AUTO);

  LoadViewState(items.GetPath(), WINDOW_ADDON_BROWSER);
}

void CGUIViewStateAddonBrowser::SaveViewState()
{
  SaveViewToDb(m_items.GetPath(), WINDOW_ADDON_BROWSER);
}

std::string CGUIViewStateAddonBrowser::GetExtensions()
{
  return "";
}