VTB: release CVBuffer after it actually has been rendered
[xbmc.git] / xbmc / ContextMenuItem.h
blob05cb9dc9b7625579988a715012c7162979a51ad9
1 #pragma once
2 /*
3 * Copyright (C) 2015 Team XBMC
4 * http://xbmc.org
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include <map>
24 #include "addons/IAddon.h"
25 #include "addons/AddonManager.h"
26 #include "addons/Repository.h"
27 #include "addons/RepositoryUpdater.h"
28 #include "addons/GUIDialogAddonInfo.h"
29 #include "addons/GUIDialogAddonSettings.h"
32 namespace ADDON
34 class CContextMenuAddon;
37 class IContextMenuItem
39 public:
40 virtual bool IsVisible(const CFileItem& item) const = 0;
41 virtual bool Execute(const CFileItemPtr& item) const = 0;
42 virtual std::string GetLabel(const CFileItem& item) const = 0;
43 virtual bool IsGroup() const { return false; }
47 class CStaticContextMenuAction : public IContextMenuItem
49 public:
50 explicit CStaticContextMenuAction(uint32_t label) : m_label(label) {}
51 std::string GetLabel(const CFileItem& item) const override final
53 return g_localizeStrings.Get(m_label);
55 bool IsGroup() const override final { return false; }
56 private:
57 const uint32_t m_label;
61 class CContextMenuItem : public IContextMenuItem
63 public:
64 std::string GetLabel(const CFileItem& item) const override { return m_label; }
65 bool IsVisible(const CFileItem& item) const override ;
66 bool IsParentOf(const CContextMenuItem& menuItem) const;
67 bool IsGroup() const override ;
68 bool Execute(const CFileItemPtr& item) const override;
69 bool operator==(const CContextMenuItem& other) const;
70 std::string ToString() const;
72 static CContextMenuItem CreateGroup(
73 const std::string& label,
74 const std::string& parent,
75 const std::string& groupId,
76 const std::string& addonId);
78 static CContextMenuItem CreateItem(
79 const std::string& label,
80 const std::string& parent,
81 const std::string& library,
82 const std::string& condition,
83 const std::string& addonId);
85 friend class ADDON::CContextMenuAddon;
87 private:
88 std::string m_label;
89 std::string m_parent;
90 std::string m_groupId;
91 std::string m_library;
92 std::string m_addonId; // The owner of this menu item
94 std::string m_visibilityCondition;
95 mutable INFO::InfoPtr m_infoBool;
96 mutable bool m_infoBoolRegistered{false};