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;
43 // take a copy of actions that satisfy our conditions
44 vector<CStdString> actions;
45 for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
47 if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
49 if (!StringUtils::IsInteger(it->action))
50 actions.push_back(it->action);
55 for (vector<CStdString>::iterator i = actions.begin(); i != actions.end(); ++i)
57 CGUIMessage msg(GUI_MSG_EXECUTE, controlID, parentID);
58 msg.SetStringParam(*i);
59 if (m_sendThreadMessages)
60 g_windowManager.SendThreadMessage(msg);
62 g_windowManager.SendMessage(msg);
68 int CGUIAction::GetNavigation() const
70 for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
72 if (StringUtils::IsInteger(it->action))
74 if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))
75 return atoi(it->action.c_str());
81 void CGUIAction::SetNavigation(int id)
85 strId.Format("%i", id);
86 for (iActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
88 if (StringUtils::IsInteger(it->action) && it->condition.IsEmpty())
94 cond_action_pair pair;
96 m_actions.push_back(pair);
99 bool CGUIAction::HasActionsMeetingCondition() const
101 for (ciActions it = m_actions.begin() ; it != m_actions.end() ; ++it)
103 if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition))