void MythUIStateType::CopyFrom(MythUIType *base) { MythUIStateType *st = dynamic_cast<MythUIStateType *>(base); if (!st) { VERBOSE(VB_IMPORTANT, "ERROR, bad parsing"); return; } ClearMaps(); m_ShowEmpty = st->m_ShowEmpty; MythUIType::CopyFrom(base); QMap<QString, MythUIType *>::iterator i; for (i = st->m_ObjectsByName.begin(); i != st->m_ObjectsByName.end(); ++i) { MythUIType *other = i.data(); QString key = i.key(); MythUIType *newtype = GetChild(other->name()); AddObject(key, newtype); newtype->SetVisible(other->IsVisible()); } QMap<int, MythUIType *>::iterator j; for (j = st->m_ObjectsByState.begin(); j != st->m_ObjectsByState.end(); ++j) { MythUIType *other = j.data(); int key = j.key(); MythUIType *newtype = GetChild(other->name()); AddObject((StateType)key, newtype); newtype->SetVisible(other->IsVisible()); } }
bool MythScreenType::SetFocusWidget(MythUIType *widget) { if (!widget || !widget->IsVisible()) { QMap<int, MythUIType *>::iterator it = m_FocusWidgetList.begin(); MythUIType *current; while (it != m_FocusWidgetList.end()) { current = *it; if (current->CanTakeFocus() && current->IsVisible()) { widget = current; break; } ++it; } } if (!widget) return false; if (m_CurrentFocusWidget == widget) return true; MythUIText *helpText = dynamic_cast<MythUIText *>(GetChild("helptext")); if (helpText) helpText->Reset(); if (m_CurrentFocusWidget) m_CurrentFocusWidget->LoseFocus(); m_CurrentFocusWidget = widget; m_CurrentFocusWidget->TakeFocus(); if (helpText && !widget->GetHelpText().isEmpty()) helpText->SetText(widget->GetHelpText()); return true; }
static void DoSetTextFromMap(MythUIType *UItype, QHash<QString, QString> &infoMap) { QList<MythUIType *> *children = UItype->GetAllChildren(); MythUIText *textType; QMutableListIterator<MythUIType *> i(*children); while (i.hasNext()) { MythUIType *type = i.next(); if (!type->IsVisible()) continue; textType = dynamic_cast<MythUIText *> (type); if (textType && infoMap.contains(textType->objectName())) textType->SetTextFromMap(infoMap); MythUIGroup *group = dynamic_cast<MythUIGroup *> (type); if (group) DoSetTextFromMap(type, infoMap); } }
bool MythScreenType::NextPrevWidgetFocus(bool up) { if (!m_CurrentFocusWidget || m_FocusWidgetList.isEmpty()) return SetFocusWidget(NULL); bool reachedCurrent = false; bool looped = false; QMap<int, MythUIType *>::iterator it = m_FocusWidgetList.begin(); MythUIType *current; // There is probably a more efficient way to do this, but the list // is never going to be that big so it will do for now if (up) { while (it != m_FocusWidgetList.end()) { current = *it; if ((looped || reachedCurrent) && current->IsVisible() && current->IsEnabled()) return SetFocusWidget(current); if (current == m_CurrentFocusWidget) reachedCurrent = true; ++it; if (it == m_FocusWidgetList.end()) { if (looped) return false; else { looped = true; it = m_FocusWidgetList.begin(); } } } } else { it = m_FocusWidgetList.end() - 1; while (it != m_FocusWidgetList.begin() - 1) { current = *it; if ((looped || reachedCurrent) && current->IsVisible() && current->IsEnabled()) return SetFocusWidget(current); if (current == m_CurrentFocusWidget) reachedCurrent = true; --it; if (it == m_FocusWidgetList.begin() - 1) { if (looped) return false; else { looped = true; it = m_FocusWidgetList.end() - 1; } } } } return false; }