xbmc
GUIAction.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 class CGUIControl;
16 class CGUIListItem; typedef std::shared_ptr<CGUIListItem> CGUIListItemPtr;
17 
22 {
23 public:
28  {
29  public:
34  explicit CExecutableAction(const std::string& action);
40  CExecutableAction(const std::string& condition, const std::string& action);
41 
46  std::string GetCondition() const;
47 
52  bool HasCondition() const;
53 
58  std::string GetAction() const;
59 
64  void SetAction(const std::string& action);
65 
66  private:
70  CExecutableAction() = delete;
71  /* The condition that dictates the action execution */
72  std::string m_condition;
73  /* The actual action */
74  std::string m_action;
75  };
76 
77  CGUIAction() = default;
78  explicit CGUIAction(int controlID);
82  bool ExecuteActions() const;
86  bool ExecuteActions(int controlID, int parentID, const CGUIListItemPtr& item = nullptr) const;
90  bool HasActionsMeetingCondition() const;
94  bool HasAnyActions() const;
98  int GetNavigation() const;
102  void SetNavigation(int id);
110  void Append(const CExecutableAction& action);
114  void Reset();
115 
116 private:
117  std::vector<CExecutableAction> m_actions;
118  bool m_sendThreadMessages = false;
119 };
bool HasActionsMeetingCondition() const
Check if there is any action that meet its condition.
Definition: GUIAction.cpp:124
Definition: GUIListItem.h:30
Class which defines an executable action.
Definition: GUIAction.h:27
bool HasAnyActions() const
Check if there is any action.
Definition: GUIAction.cpp:135
Base class for controls.
Definition: GUIControl.h:75
int GetNavigation() const
Get navigation route that meet its conditions first.
Definition: GUIAction.cpp:93
void SetNavigation(int id)
Set navigation route.
Definition: GUIAction.cpp:107
void Reset()
Prune any executable actions stored in the CGUIAction.
Definition: GUIAction.cpp:150
bool HasCondition() const
Checks if the executable action has any condition.
Definition: GUIAction.cpp:42
void EnableSendThreadMessageMode()
Configure CGUIAction to send threaded messages.
Definition: GUIAction.cpp:145
bool ExecuteActions() const
Execute actions without specifying any target control or parent control.
Definition: GUIAction.cpp:57
std::string GetCondition() const
Get the condition of this executable action (may be empty)
Definition: GUIAction.cpp:32
std::string GetAction() const
Get the action string of this executable action.
Definition: GUIAction.cpp:37
void SetAction(const std::string &action)
Sets/Replaces the action string of this executable action.
Definition: GUIAction.cpp:47
void Append(const CExecutableAction &action)
Add an executable action to the CGUIAction container.
Definition: GUIAction.cpp:140
Class containing vector of condition->(action/navigation route) and handling its execution.
Definition: GUIAction.h:21