Merge pull request #26148 from ksooo/fix-secondstotimestring-warning
[xbmc.git] / xbmc / ContextMenuItem.h
blob6577de3224597b290d9708676e71a054c4d372d3
1 /*
2 * Copyright (C) 2015-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.
7 */
9 #pragma once
11 #include <cstdint>
12 #include <map>
13 #include <memory>
14 #include <string>
15 #include <vector>
17 class CFileItem;
19 namespace ADDON
21 class CContextMenuAddon;
24 namespace INFO
26 class InfoBool;
29 class IContextMenuItem
31 public:
32 virtual ~IContextMenuItem() = default;
33 virtual bool IsVisible(const CFileItem& item) const = 0;
34 virtual bool Execute(const std::shared_ptr<CFileItem>& item) const = 0;
35 virtual std::string GetLabel(const CFileItem& item) const = 0;
36 virtual bool IsGroup() const { return false; }
37 virtual bool HasParent() const { return false; }
41 class CStaticContextMenuAction : public IContextMenuItem
43 public:
44 explicit CStaticContextMenuAction(uint32_t label) : m_label(label) {}
45 std::string GetLabel(const CFileItem& item) const final;
46 bool IsGroup() const final { return false; }
47 private:
48 const uint32_t m_label;
52 class CContextMenuItem : public IContextMenuItem
54 public:
55 CContextMenuItem() = default;
57 std::string GetLabel(const CFileItem& item) const override { return m_label; }
58 bool IsVisible(const CFileItem& item) const override ;
59 bool IsParentOf(const CContextMenuItem& menuItem) const;
60 bool IsGroup() const override ;
61 bool HasParent() const override;
62 bool Execute(const std::shared_ptr<CFileItem>& item) const override;
63 bool operator==(const CContextMenuItem& other) const;
64 std::string ToString() const;
66 static CContextMenuItem CreateGroup(
67 const std::string& label,
68 const std::string& parent,
69 const std::string& groupId,
70 const std::string& addonId);
72 static CContextMenuItem CreateItem(
73 const std::string& label,
74 const std::string& parent,
75 const std::string& library,
76 const std::string& condition,
77 const std::string& addonId,
78 const std::vector<std::string>& args = std::vector<std::string>());
80 friend class ADDON::CContextMenuAddon;
82 private:
83 std::string m_label;
84 std::string m_parent;
85 std::string m_groupId;
86 std::string m_library;
87 std::string m_addonId; // The owner of this menu item
88 std::vector<std::string> m_args;
90 std::string m_visibilityCondition;
91 mutable std::shared_ptr<INFO::InfoBool> m_infoBool;
92 mutable bool m_infoBoolRegistered{false};