MythGenericTree* MythGenericTree::getVisibleChildAt(uint reference) const { if (reference >= (uint)m_ordered_subnodes->count()) return NULL; QList<MythGenericTree*> *list; if (m_currentOrderingIndex == -1) list = m_subnodes; else list = m_ordered_subnodes; uint n = 0; for (int i = 0; i < list->size(); ++i) { MythGenericTree *child = list->at(i); if (child->IsVisible()) { if (n == reference) return child; n++; } } return NULL; }
/*! * \brief Update a list with children of the tree node * * \param list List to refill * \param node Parent node whose children will appear in the list * * \return True if successful, False if the node had no children or was invalid */ bool MythUIButtonTree::UpdateList(MythUIButtonList *list, MythGenericTree *node) { disconnect(list, 0, 0, 0); list->Reset(); QList<MythGenericTree *> *nodelist = NULL; if (node) nodelist = node->getAllChildren(); if (!nodelist || nodelist->isEmpty()) return false; MythGenericTree *selectedNode = node->getSelectedChild(true); MythUIButtonListItem *selectedItem = NULL; QList<MythGenericTree *>::iterator it; for (it = nodelist->begin(); it != nodelist->end(); ++it) { MythGenericTree *childnode = *it; if (!childnode->IsVisible()) continue; MythUIButtonListItem *item = childnode->CreateListButton(list); if (childnode == selectedNode) selectedItem = item; } if (list->IsEmpty()) return false; if (selectedItem) list->SetItemCurrent(selectedItem); connect(list, SIGNAL(itemSelected(MythUIButtonListItem *)), SLOT(handleSelect(MythUIButtonListItem *))); connect(list, SIGNAL(itemClicked(MythUIButtonListItem *)), SLOT(handleClick(MythUIButtonListItem *))); connect(list, SIGNAL(itemVisible(MythUIButtonListItem *)), SLOT(handleVisible(MythUIButtonListItem *))); return true; }
MythGenericTree* MythGenericTree::getVisibleChildAt(uint reference) const { if (reference >= (uint)m_subnodes->count()) return nullptr; QList<MythGenericTree*> *list = m_subnodes; uint n = 0; for (int i = 0; i < list->size(); ++i) { MythGenericTree *child = list->at(i); if (child->IsVisible()) { if (n == reference) return child; n++; } } return nullptr; }