2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIAction.h"
22 #include "utils/StringUtils.h"
23 #include "GUIWindowManager.h"
24 #include "GUIControl.h"
25 #include "GUIInfoManager.h"
29 CGUIAction::CGUIAction()
31 m_sendThreadMessages = false;
34 CGUIAction::CGUIAction(int controlID)
36 m_sendThreadMessages = false;
37 SetNavigation(controlID);
40 bool CGUIAction::ExecuteActions(int controlID, int parentID) const
42 if (m_actions.size() == 0) return false;
44 CGUIAction copy(*this);
45 for (ciActions it = copy.m_actions.begin() ; it != copy.m_actions.end() ; it++)
47 if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
49 if (!StringUtils::IsInteger(it->action))
51 CGUIMessage msg(GUI_MSG_EXECUTE, controlID, parentID);
52 msg.SetStringParam(it->action);
53 if (m_sendThreadMessages)
54 g_windowManager.SendThreadMessage(msg);
56 g_windowManager.SendMessage(msg);
64 int CGUIAction::GetNavigation() const
66 for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
68 if (StringUtils::IsInteger(it->action))
70 if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
71 return atoi(it->action.c_str());
77 void CGUIAction::SetNavigation(int id)
81 strId.Format("%i", id);
82 for (iActions it = m_actions.begin() ; it != m_actions.end() ; it++)
84 if (StringUtils::IsInteger(it->action) && it->condition.IsEmpty())
90 cond_action_pair pair;
92 m_actions.push_back(pair);
95 bool CGUIAction::HasActionsMeetingCondition() const
97 for (ciActions it = m_actions.begin() ; it != m_actions.end() ; it++)
99 if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))