Skip to content
Browse files

[gui] convert a bunch of GUI_MSG_RESET|ADD|SELECT_LABEL to use SET_CO…

…NTROL_LABELS
  • Loading branch information...
1 parent 6322457 commit 7c52d33444452d5706beb77dabf4c8d1805331c2 Jonathan Marshall committed Jun 15, 2014
View
79 xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
@@ -315,39 +315,19 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
}
// sort out the order fields
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ORDER_FIELD);
- OnMessage(msg);
- }
+ std::vector< std::pair<std::string, int> > labels;
vector<SortBy> orders = CSmartPlaylistRule::GetOrders(m_playlist.GetType());
for (unsigned int i = 0; i < orders.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ORDER_FIELD, orders[i]);
- msg.SetLabel(SortUtils::GetSortLabel(orders[i]));
- OnMessage(msg);
- }
- {
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_ORDER_FIELD, m_playlist.m_orderField);
- OnMessage(msg);
- }
+ labels.push_back(make_pair(g_localizeStrings.Get(SortUtils::GetSortLabel(orders[i])), orders[i]));
+ SET_CONTROL_LABELS(CONTROL_ORDER_FIELD, m_playlist.m_orderField, &labels);
// setup groups
- {
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_GROUP_BY);
- OnMessage(msg);
- }
+ labels.clear();
vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType());
Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup());
for (unsigned int i = 0; i < groups.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_GROUP_BY, groups[i]);
- msg.SetLabel(CSmartPlaylistRule::GetLocalizedGroup(groups[i]));
- OnMessage(msg);
- }
- {
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_GROUP_BY, currentGroup);
- OnMessage(msg);
- }
+ labels.push_back(make_pair(CSmartPlaylistRule::GetLocalizedGroup(groups[i]), groups[i]));
+ SET_CONTROL_LABELS(CONTROL_GROUP_BY, currentGroup, &labels);
if (m_playlist.IsGroupMixed())
CONTROL_SELECT(CONTROL_GROUP_MIXED);
@@ -383,33 +363,21 @@ void CGUIDialogSmartPlaylistEditor::UpdateRuleControlButtons()
void CGUIDialogSmartPlaylistEditor::OnWindowLoaded()
{
CGUIDialog::OnWindowLoaded();
+
SendMessage(GUI_MSG_SET_TYPE, CONTROL_NAME, 0, 16012);
// setup the match spinner
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_MATCH, 0);
- msg.SetLabel(21425);
- OnMessage(msg);
- }
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_MATCH, 1);
- msg.SetLabel(21426);
- OnMessage(msg);
- }
- SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_MATCH, m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd ? 0 : 1);
+ std::vector< std::pair<std::string, int> > labels;
+ labels.push_back(make_pair(g_localizeStrings.Get(21425), 0));
+ labels.push_back(make_pair(g_localizeStrings.Get(21426), 1));
+ SET_CONTROL_LABELS(CONTROL_MATCH, m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd ? 0 : 1, &labels);
+
// and now the limit spinner
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_LIMIT, 0);
- msg.SetLabel(21428);
- OnMessage(msg);
- }
+ labels.clear();
+ labels.push_back(make_pair(g_localizeStrings.Get(21428), 0));
const int limits[] = { 10, 25, 50, 100, 250, 500, 1000 };
for (unsigned int i = 0; i < sizeof(limits) / sizeof(int); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_LIMIT, limits[i]);
- CStdString label = StringUtils::Format(g_localizeStrings.Get(21436).c_str(), limits[i]);
- msg.SetLabel(label);
- OnMessage(msg);
- }
+ labels.push_back(make_pair(StringUtils::Format(g_localizeStrings.Get(21436).c_str(), limits[i]), limits[i]));
+ SET_CONTROL_LABELS(CONTROL_LIMIT, 0, &labels);
}
void CGUIDialogSmartPlaylistEditor::OnInitWindow()
@@ -445,12 +413,9 @@ void CGUIDialogSmartPlaylistEditor::OnInitWindow()
allowedTypes.push_back(TYPE_MIXED);
}
// add to the spinner
+ std::vector< std::pair<std::string, int> > labels;
for (unsigned int i = 0; i < allowedTypes.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_TYPE, allowedTypes[i]);
- msg.SetLabel(GetLocalizedType(allowedTypes[i]));
- OnMessage(msg);
- }
+ labels.push_back(make_pair(GetLocalizedType(allowedTypes[i]), allowedTypes[i]));
// check our playlist type is allowed
PLAYLIST_TYPE type = ConvertType(m_playlist.GetType());
bool allowed = false;
@@ -460,7 +425,7 @@ void CGUIDialogSmartPlaylistEditor::OnInitWindow()
if (!allowed && allowedTypes.size())
type = allowedTypes[0];
- SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_TYPE, type);
+ SET_CONTROL_LABELS(CONTROL_TYPE, type, &labels);
m_playlist.SetType(ConvertType(type));
UpdateButtons();
@@ -484,13 +449,13 @@ CGUIDialogSmartPlaylistEditor::PLAYLIST_TYPE CGUIDialogSmartPlaylistEditor::Conv
return TYPE_SONGS;
}
-int CGUIDialogSmartPlaylistEditor::GetLocalizedType(PLAYLIST_TYPE type)
+std::string CGUIDialogSmartPlaylistEditor::GetLocalizedType(PLAYLIST_TYPE type)
{
for (unsigned int i = 0; i < NUM_TYPES; i++)
if (types[i].type == type)
- return types[i].localizedString;
+ return g_localizeStrings.Get(types[i].localizedString);
assert(false);
- return 0;
+ return "";
}
CStdString CGUIDialogSmartPlaylistEditor::ConvertType(PLAYLIST_TYPE type)
View
2 xbmc/dialogs/GUIDialogSmartPlaylistEditor.h
@@ -61,7 +61,7 @@ class CGUIDialogSmartPlaylistEditor :
void HighlightItem(int item);
PLAYLIST_TYPE ConvertType(const CStdString &type);
CStdString ConvertType(PLAYLIST_TYPE type);
- int GetLocalizedType(PLAYLIST_TYPE type);
+ std::string GetLocalizedType(PLAYLIST_TYPE type);
CSmartPlaylist m_playlist;
View
67 xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
@@ -374,6 +374,11 @@ void CGUIDialogSmartPlaylistRule::OnOperator()
UpdateButtons();
}
+std::pair<std::string, int> OperatorLabel(CDatabaseQueryRule::SEARCH_OPERATOR op)
+{
+ return make_pair(CSmartPlaylistRule::GetLocalizedOperator(op), op);
+}
+
void CGUIDialogSmartPlaylistRule::UpdateButtons()
{
// update the field control
@@ -391,55 +396,57 @@ void CGUIDialogSmartPlaylistRule::UpdateButtons()
else
CONTROL_DISABLE(CONTROL_BROWSE);
+ std::vector< std::pair<std::string, int> > labels;
switch (m_rule.GetFieldType(m_rule.m_field))
{
case CDatabaseQueryRule::TEXT_FIELD:
// text fields - add the usual comparisons
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_CONTAINS);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_CONTAIN);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_STARTS_WITH);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_ENDS_WITH);
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_CONTAINS));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_CONTAIN));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_STARTS_WITH));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_ENDS_WITH));
break;
case CDatabaseQueryRule::NUMERIC_FIELD:
case CDatabaseQueryRule::SECONDS_FIELD:
// numerical fields - less than greater than
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_GREATER_THAN);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_LESS_THAN);
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_GREATER_THAN));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_LESS_THAN));
break;
case CDatabaseQueryRule::DATE_FIELD:
// date field
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_AFTER);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_BEFORE);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_IN_THE_LAST);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_NOT_IN_THE_LAST);
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_AFTER));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_BEFORE));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_IN_THE_LAST));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_NOT_IN_THE_LAST));
break;
case CDatabaseQueryRule::PLAYLIST_FIELD:
CONTROL_ENABLE(CONTROL_BROWSE);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL);
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL));
break;
case CDatabaseQueryRule::BOOLEAN_FIELD:
CONTROL_DISABLE(CONTROL_VALUE);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_TRUE);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_FALSE);
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_TRUE));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_FALSE));
break;
case CDatabaseQueryRule::TEXTIN_FIELD:
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS);
- AddOperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL);
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_EQUALS));
+ labels.push_back(OperatorLabel(CDatabaseQueryRule::OPERATOR_DOES_NOT_EQUAL));
break;
}
+ SET_CONTROL_LABELS(CONTROL_OPERATOR, m_rule.m_operator, &labels);
+
// check our operator is valid, and update if not
- SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_OPERATOR, m_rule.m_operator);
CGUIMessage selected(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_OPERATOR);
OnMessage(selected);
m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)selected.GetParam1();
@@ -473,26 +480,18 @@ void CGUIDialogSmartPlaylistRule::UpdateButtons()
SendMessage(GUI_MSG_SET_TYPE, CONTROL_VALUE, type, 21420);
}
-void CGUIDialogSmartPlaylistRule::AddOperatorLabel(CDatabaseQueryRule::SEARCH_OPERATOR op)
-{
- CGUIMessage select(GUI_MSG_LABEL_ADD, GetID(), CONTROL_OPERATOR, op);
- select.SetLabel(CSmartPlaylistRule::GetLocalizedOperator(op));
- OnMessage(select);
-}
-
void CGUIDialogSmartPlaylistRule::OnInitWindow()
{
CGUIDialog::OnInitWindow();
- SendMessage(GUI_MSG_LABEL_RESET, CONTROL_FIELD);
// add the fields to the field spincontrol
+ std::vector< std::pair<std::string, int> > labels;
vector<Field> fields = CSmartPlaylistRule::GetFields(m_type);
for (unsigned int i = 0; i < fields.size(); i++)
- {
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_FIELD, fields[i]);
- msg.SetLabel(CSmartPlaylistRule::GetLocalizedField(fields[i]));
- OnMessage(msg);
- }
+ labels.push_back(make_pair(CSmartPlaylistRule::GetLocalizedField(fields[i]), fields[i]));
+
+ SET_CONTROL_LABELS(CONTROL_FIELD, 0, &labels);
+
UpdateButtons();
CGUIEditControl *editControl = dynamic_cast<CGUIEditControl*>(GetControl(CONTROL_VALUE));
View
1 xbmc/dialogs/GUIDialogSmartPlaylistRule.h
@@ -42,7 +42,6 @@ class CGUIDialogSmartPlaylistRule :
void OnOK();
void OnCancel();
void UpdateButtons();
- void AddOperatorLabel(CDatabaseQueryRule::SEARCH_OPERATOR op);
void OnBrowse();
CSmartPlaylistRule m_rule;
View
13 xbmc/pvr/channels/PVRChannelGroups.cpp
@@ -507,7 +507,7 @@ void CPVRChannelGroups::FillGroupsGUI(int iWindowId, int iControlId) const
int iListGroupPtr(0);
int iSelectedGroupPtr(0);
CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(false);
- std::vector<CGUIMessage> messages;
+ std::vector< std::pair<std::string, int> > labels;
// fetch all groups
{
@@ -521,18 +521,13 @@ void CPVRChannelGroups::FillGroupsGUI(int iWindowId, int iControlId) const
if ((*it)->GroupID() == selectedGroup->GroupID())
iSelectedGroupPtr = iListGroupPtr;
- CGUIMessage msg(GUI_MSG_LABEL_ADD, iWindowId, iControlId, iListGroupPtr++);
- msg.SetLabel((*it)->GroupName());
- messages.push_back(msg);
+ labels.push_back(make_pair((*it)->GroupName(), iListGroupPtr++));
}
}
- // send updates
- for (std::vector<CGUIMessage>::iterator it = messages.begin(); it != messages.end(); it++)
- g_windowManager.SendMessage(*it);
-
// selected group
- CGUIMessage msgSel(GUI_MSG_ITEM_SELECT, iWindowId, iControlId, iSelectedGroupPtr);
+ CGUIMessage msgSel(GUI_MSG_SET_LABELS, iWindowId, iControlId, iSelectedGroupPtr);
+ msgSel.SetPointer(&labels);
g_windowManager.SendMessage(msgSel);
}
View
23 xbmc/settings/dialogs/GUIDialogContentSettings.cpp
@@ -421,25 +421,26 @@ void CGUIDialogContentSettings::InitializeSettings()
void CGUIDialogContentSettings::FillContentTypes()
{
- CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_CONTENT_TYPE);
- g_windowManager.SendMessage(msg);
+ std::vector< std::pair<std::string, int> > labels;
if (m_content == CONTENT_ALBUMS || m_content == CONTENT_ARTISTS)
+ {
FillContentTypes(m_content);
+ labels.push_back(make_pair(ADDON::TranslateContent(m_content, true), m_content));
+ }
else
{
FillContentTypes(CONTENT_MOVIES);
FillContentTypes(CONTENT_TVSHOWS);
FillContentTypes(CONTENT_MUSICVIDEOS);
- // add 'None' to spinner
- CGUIMessage msg2(GUI_MSG_LABEL_ADD, GetID(), CONTROL_CONTENT_TYPE);
- msg2.SetLabel(ADDON::TranslateContent(CONTENT_NONE, true));
- msg2.SetParam1(static_cast<int>(CONTENT_NONE));
- g_windowManager.SendMessage(msg2);
+ labels.push_back(make_pair(ADDON::TranslateContent(CONTENT_MOVIES, true), CONTENT_MOVIES));
+ labels.push_back(make_pair(ADDON::TranslateContent(CONTENT_TVSHOWS, true), CONTENT_TVSHOWS));
+ labels.push_back(make_pair(ADDON::TranslateContent(CONTENT_MUSICVIDEOS, true), CONTENT_MUSICVIDEOS));
+ labels.push_back(make_pair(ADDON::TranslateContent(CONTENT_NONE, true), CONTENT_NONE));
}
- CONTROL_SELECT_ITEM(CONTROL_CONTENT_TYPE, static_cast<int>(m_content));
+ SET_CONTROL_LABELS(CONTROL_CONTENT_TYPE, m_content, &labels);
}
void CGUIDialogContentSettings::FillContentTypes(CONTENT_TYPE content)
@@ -481,12 +482,6 @@ void CGUIDialogContentSettings::FillContentTypes(CONTENT_TYPE content)
m_scrapers.insert(make_pair(content,vec));
}
}
-
- // add CONTENT type to spinner
- CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_CONTENT_TYPE);
- msg.SetLabel(ADDON::TranslateContent(content, true));
- msg.SetParam1(static_cast<int>(content));
- g_windowManager.SendMessage(msg);
}
void CGUIDialogContentSettings::FillScraperList()
View
14 xbmc/view/GUIViewControl.cpp
@@ -298,18 +298,16 @@ int CGUIViewControl::GetView(VIEW_TYPE type, int id) const
void CGUIViewControl::UpdateViewAsControl(const CStdString &viewLabel)
{
// the view as control could be a select/spin/dropdown button
- CGUIMessage msg(GUI_MSG_LABEL_RESET, m_parentWindow, m_viewAsControl);
- g_windowManager.SendMessage(msg, m_parentWindow);
+ std::vector< std::pair<std::string, int> > labels;
for (unsigned int i = 0; i < m_visibleViews.size(); i++)
{
IGUIContainer *view = (IGUIContainer *)m_visibleViews[i];
- CGUIMessage msg(GUI_MSG_LABEL_ADD, m_parentWindow, m_viewAsControl, i);
- CStdString label = StringUtils::Format(g_localizeStrings.Get(534).c_str(), view->GetLabel().c_str()); // View: %s
- msg.SetLabel(label);
- g_windowManager.SendMessage(msg, m_parentWindow);
+ std::string label = StringUtils::Format(g_localizeStrings.Get(534).c_str(), view->GetLabel().c_str()); // View: %s
+ labels.push_back(make_pair(label, i));
}
- CGUIMessage msgSelect(GUI_MSG_ITEM_SELECT, m_parentWindow, m_viewAsControl, m_currentView);
- g_windowManager.SendMessage(msgSelect, m_parentWindow);
+ CGUIMessage msg(GUI_MSG_SET_LABELS, m_parentWindow, m_viewAsControl, m_currentView);
+ msg.SetPointer(&labels);
+ g_windowManager.SendMessage(msg, m_parentWindow);
// otherwise it's just a normal button
CStdString label = StringUtils::Format(g_localizeStrings.Get(534).c_str(), viewLabel.c_str()); // View: %s
View
23 xbmc/windows/GUIWindowWeather.cpp
@@ -144,9 +144,8 @@ void CGUIWindowWeather::UpdateLocations()
if (!IsActive()) return;
m_maxLocation = strtol(GetProperty("Locations").asString().c_str(),0,10);
if (m_maxLocation < 1) return;
- CGUIMessage msg(GUI_MSG_LABEL_RESET,GetID(),CONTROL_SELECTLOCATION);
- g_windowManager.SendMessage(msg);
- CGUIMessage msg2(GUI_MSG_LABEL_ADD,GetID(),CONTROL_SELECTLOCATION);
+
+ std::vector< std::pair<std::string, int> > labels;
unsigned int iCurWeather = g_weatherManager.GetArea();
@@ -157,35 +156,31 @@ void CGUIWindowWeather::UpdateLocations()
ClearProperties();
g_weatherManager.Refresh();
}
-
+
for (unsigned int i = 1; i <= m_maxLocation; i++)
{
- CStdString strLabel = g_weatherManager.GetLocation(i);
+ std::string strLabel = g_weatherManager.GetLocation(i);
if (strLabel.size() > 1) //got the location string yet?
{
size_t iPos = strLabel.rfind(", ");
if (iPos != std::string::npos)
{
- CStdString strLabel2(strLabel);
+ std::string strLabel2(strLabel);
strLabel = strLabel2.substr(0,iPos);
}
- msg2.SetParam1(i);
- msg2.SetLabel(strLabel);
- g_windowManager.SendMessage(msg2);
+ labels.push_back(make_pair(strLabel, i));
}
else
{
strLabel = StringUtils::Format("AreaCode %i", i);
-
- msg2.SetLabel(strLabel);
- msg2.SetParam1(i);
- g_windowManager.SendMessage(msg2);
+ labels.push_back(make_pair(strLabel, i));
}
+ // in case it's a button, set the label
if (i == iCurWeather)
SET_CONTROL_LABEL(CONTROL_SELECTLOCATION,strLabel);
}
- CONTROL_SELECT_ITEM(CONTROL_SELECTLOCATION, iCurWeather);
+ SET_CONTROL_LABELS(CONTROL_SELECTLOCATION, iCurWeather, &labels);
}
void CGUIWindowWeather::UpdateButtons()

0 comments on commit 7c52d33

Please sign in to comment.
Something went wrong with that request. Please try again.