From 1805637b488d7ecab6e110017b9b1a93883b6ac9 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 29 Mar 2013 19:31:02 +0000 Subject: [PATCH] Cleanup some old/unused code from MythGenericTree and fix sorting. Strip it back to basics, a less bloated and more managable class that offers just the features it needs to. In this first pass I've mostly slashed and burned the fat, there's scope for further improvements through refactoring what remains. Member variables have been renamed to meet coding standards, methods need similar treatment but I'll do that as a separate commit because of the potential to break plugins. --- mythplugins/mythgame/mythgame/gameui.cpp | 12 +- .../mythmusic/playlisteditorview.cpp | 34 +- .../mythnetvision/mythnetvision/nettree.cpp | 16 +- mythtv/libs/libmythbase/mythversion.h | 2 +- mythtv/libs/libmythui/mythgenerictree.cpp | 291 ++---------------- mythtv/libs/libmythui/mythgenerictree.h | 30 +- mythtv/libs/libmythui/mythuibuttontree.cpp | 2 +- mythtv/programs/mythfrontend/videodlg.cpp | 32 +- mythtv/programs/mythfrontend/videolist.cpp | 16 +- 9 files changed, 74 insertions(+), 361 deletions(-) diff --git a/mythplugins/mythgame/mythgame/gameui.cpp b/mythplugins/mythgame/mythgame/gameui.cpp index fd12f048d88..3a042c01647 100644 --- a/mythplugins/mythgame/mythgame/gameui.cpp +++ b/mythplugins/mythgame/mythgame/gameui.cpp @@ -269,7 +269,7 @@ void GameUI::itemClicked(MythUIButtonListItem*) else { //: %1 is the game name - QString msg = tr("Choose System for:\n%1").arg(node->getString()); + QString msg = tr("Choose System for:\n%1").arg(node->GetText()); MythScreenStack *popupStack = GetMythMainWindow()-> GetStack("popup stack"); MythDialogBox *chooseSystemPopup = new MythDialogBox( @@ -431,7 +431,7 @@ void GameUI::showMenu() MythScreenStack *popupStack = GetMythMainWindow()-> GetStack("popup stack"); MythDialogBox *showMenuPopup = - new MythDialogBox(node->getString(), popupStack, "showMenuPopup"); + new MythDialogBox(node->GetText(), popupStack, "showMenuPopup"); if (showMenuPopup->Create()) { @@ -471,7 +471,7 @@ void GameUI::searchStart(void) for (it = children->begin(); it != children->end(); ++it) { MythGenericTree *child = *it; - childList << child->getString(); + childList << child->GetText(); } MythScreenStack *popupStack = @@ -552,7 +552,7 @@ void GameUI::customEvent(QEvent *event) RomInfo *romInfo = qVariantValue(dce->GetData()); node->SetData(qVariantFromValue(romInfo)); - node->setString(romInfo->Gamename()); + node->SetText(romInfo->Gamename()); romInfo->SaveToDatabase(); updateChangedNode(node, romInfo); @@ -637,7 +637,7 @@ void GameUI::customEvent(QEvent *event) QString GameUI::getFillSql(MythGenericTree *node) const { - QString layer = node->getString(); + QString layer = node->GetText(); int childDepth = node->getInt() + 1; QString childLevel = getChildLevelString(node); QString filter = getFilter(node); @@ -790,7 +790,7 @@ bool GameUI::isLeaf(MythGenericTree *node) const void GameUI::fillNode(MythGenericTree *node) { - QString layername = node->getString(); + QString layername = node->GetText(); RomInfo *romInfo = qVariantValue(node->GetData()); MSqlQuery query(MSqlQuery::InitCon()); diff --git a/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp b/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp index 8857febb037..133106b4b43 100644 --- a/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp +++ b/mythplugins/mythmusic/mythmusic/playlisteditorview.cpp @@ -64,7 +64,7 @@ void MusicGenericTree::setCheck(MythUIButtonListItem::CheckState state) MythUIButtonListItem *MusicGenericTree::CreateListButton(MythUIButtonList *list) { - MusicButtonItem *item = new MusicButtonItem(list, getString()); + MusicButtonItem *item = new MusicButtonItem(list, GetText()); item->SetData(qVariantFromValue((MythGenericTree*) this)); if (visibleChildCount() > 0) @@ -230,7 +230,7 @@ void PlaylistEditorView::customEvent(QEvent *event) { QString category; if (mnode->getAction() == "smartplaylistcategory") - category = mnode->getString(); + category = mnode->GetText(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); SmartPlaylistEditor* editor = new SmartPlaylistEditor(mainStack); @@ -250,8 +250,8 @@ void PlaylistEditorView::customEvent(QEvent *event) } else if (resulttext == tr("Remove Smart Playlist")) { - QString category = mnode->getParent()->getString(); - QString name = mnode->getString(); + QString category = mnode->getParent()->GetText(); + QString name = mnode->GetText(); ShowOkPopup(tr("Are you sure you want to delete this Smart Playlist?\n" "Category: %1 - Name: %2").arg(category).arg(name), @@ -259,8 +259,8 @@ void PlaylistEditorView::customEvent(QEvent *event) } else if (resulttext == tr("Edit Smart Playlist")) { - QString category = mnode->getParent()->getString(); - QString name = mnode->getString(); + QString category = mnode->getParent()->GetText(); + QString name = mnode->GetText(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); SmartPlaylistEditor* editor = new SmartPlaylistEditor(mainStack); @@ -304,7 +304,7 @@ void PlaylistEditorView::customEvent(QEvent *event) if (resulttext == tr("Remove Playlist")) { - QString name = mnode->getString(); + QString name = mnode->GetText(); ShowOkPopup(tr("Are you sure you want to delete this Playlist?\n" "Name: %1").arg(name), @@ -353,8 +353,8 @@ bool PlaylistEditorView::keyPressEvent(QKeyEvent *event) { if (mnode->getAction() == "smartplaylist" && action == "EDIT") { - QString category = mnode->getParent()->getString(); - QString name = mnode->getString(); + QString category = mnode->getParent()->GetText(); + QString name = mnode->GetText(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); SmartPlaylistEditor* editor = new SmartPlaylistEditor(mainStack); @@ -375,7 +375,7 @@ bool PlaylistEditorView::keyPressEvent(QKeyEvent *event) } else if (mnode->getAction() == "smartplaylistcategory" && action == "EDIT") { - QString category = mnode->getString(); + QString category = mnode->GetText(); MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); SmartPlaylistEditor* editor = new SmartPlaylistEditor(mainStack); @@ -423,8 +423,8 @@ bool PlaylistEditorView::keyPressEvent(QKeyEvent *event) { if (mnode->getAction() == "smartplaylist") { - QString category = mnode->getParent()->getString(); - QString name = mnode->getString(); + QString category = mnode->getParent()->GetText(); + QString name = mnode->GetText(); ShowOkPopup(tr("Are you sure you want to delete this Smart Playlist?\n" "Category: %1 - Name: %2").arg(category).arg(name), @@ -433,7 +433,7 @@ bool PlaylistEditorView::keyPressEvent(QKeyEvent *event) } else if (mnode->getAction() == "playlist") { - QString name = mnode->getString(); + QString name = mnode->GetText(); ShowOkPopup(tr("Are you sure you want to delete this Playlist?\n" "Name: %1").arg(name), @@ -733,11 +733,11 @@ void PlaylistEditorView::treeItemVisible(MythUIButtonListItem *item) } else if (mnode->getAction() == "compartist") { - artFile = findIcon("artist", mnode->getString().toLower()); + artFile = findIcon("artist", mnode->GetText().toLower()); } else { - artFile = findIcon(mnode->getAction(), mnode->getString().toLower()); + artFile = findIcon(mnode->getAction(), mnode->GetText().toLower()); } QString state = "default"; @@ -1564,8 +1564,8 @@ void PlaylistEditorView::deleteSmartPlaylist(bool ok) { if (mnode->getAction() == "smartplaylist") { - QString category = mnode->getParent()->getString(); - QString name = mnode->getString(); + QString category = mnode->getParent()->GetText(); + QString name = mnode->GetText(); SmartPlaylistEditor::deleteSmartPlaylist(category, name); reloadTree(); diff --git a/mythplugins/mythnetvision/mythnetvision/nettree.cpp b/mythplugins/mythnetvision/mythnetvision/nettree.cpp index 2a0164937b2..7e7843f0e98 100644 --- a/mythplugins/mythnetvision/mythnetvision/nettree.cpp +++ b/mythplugins/mythnetvision/mythnetvision/nettree.cpp @@ -279,15 +279,15 @@ void NetTree::UpdateItem(MythUIButtonListItem *item) { item->SetText(QString("%1").arg(node->visibleChildCount()), "childcount"); item->DisplayState("subfolder", "nodetype"); - item->SetText(node->getString(), "title"); - item->SetText(node->getString()); + item->SetText(node->GetText(), "title"); + item->SetText(node->GetText()); item->SetImage(node->GetData().toString()); } else if (nodeInt == kUpFolder) { item->DisplayState("upfolder", "nodetype"); - item->SetText(node->getString(), "title"); - item->SetText(node->getString()); + item->SetText(node->GetText(), "title"); + item->SetText(node->GetText()); } if (site) @@ -326,7 +326,7 @@ void NetTree::UpdateItem(MythUIButtonListItem *item) } else { - item->SetText(node->getString()); + item->SetText(node->GetText()); if (!node->GetData().toString().isEmpty()) { QString tpath = node->GetData().toString(); @@ -339,11 +339,11 @@ void NetTree::UpdateItem(MythUIButtonListItem *item) pos = m_siteButtonList->GetItemPos(item); QString dlfile = GetThumbnailFilename(tpath, - node->getString()); + node->GetText()); if (QFile::exists(dlfile)) item->SetImage(dlfile); else - m_imageDownload->addThumb(node->getString(), tpath, + m_imageDownload->addThumb(node->GetText(), tpath, qVariantFromValue(pos)); } else if (tpath != "0") @@ -1259,7 +1259,7 @@ void NetTree::customEvent(QEvent *event) if (m_type == DLG_TREE) { - if (title == m_siteMap->GetCurrentNode()->getString() && + if (title == m_siteMap->GetCurrentNode()->GetText() && m_thumbImage) { m_thumbImage->SetFilename(file); diff --git a/mythtv/libs/libmythbase/mythversion.h b/mythtv/libs/libmythbase/mythversion.h index ef548c6ab66..c239ea5d180 100644 --- a/mythtv/libs/libmythbase/mythversion.h +++ b/mythtv/libs/libmythbase/mythversion.h @@ -12,7 +12,7 @@ /// Update this whenever the plug-in ABI changes. /// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and /// libmythui class methods in exported headers. -#define MYTH_BINARY_VERSION "0.27.20130301-1" +#define MYTH_BINARY_VERSION "0.27.20130329-1" /** \brief Increment this whenever the MythTV network protocol changes. * diff --git a/mythtv/libs/libmythui/mythgenerictree.cpp b/mythtv/libs/libmythui/mythgenerictree.cpp index 4138982e164..b81d4276220 100644 --- a/mythtv/libs/libmythui/mythgenerictree.cpp +++ b/mythtv/libs/libmythui/mythgenerictree.cpp @@ -9,33 +9,17 @@ class SortableMythGenericTreeList : public QList { public: - SortableMythGenericTreeList() : m_sortType(SORT_ATTRIBUTE), + SortableMythGenericTreeList() : m_sortType(SORT_STRING), m_attributeIndex(0) { } - enum SortType {SORT_ATTRIBUTE=0, SORT_STRING=1, SORT_SELECTABLE=3, - SORT_ATT_THEN_STRING}; + enum SortType {SORT_STRING=0, SORT_SELECTABLE=1}; void SetSortType(SortType stype) { m_sortType = stype; } void SetAttributeIndex(int index) { m_attributeIndex = (index >= 0) ? index : 0; } -// static int sortByAttribute(MythGenericTree *one, MythGenericTree *two) -// { -// int onea = one->getAttribute(m_attributeIndex); -// int twoa = two->getAttribute(m_attributeIndex); -// -// if (onea == twoa) -// return 0; -// else if (onea < twoa) -// return -1; -// else -// return 1; -// } - - static int sortByString(MythGenericTree *one, MythGenericTree *two) + static bool sortByString(MythGenericTree *one, MythGenericTree *two) { - QString ones = one->getString().toLower(); - QString twos = two->getString().toLower(); - return QString::localeAwareCompare(ones, twos); + return one->GetText().toLower() < two->GetText().toLower(); } static int sortBySelectable(MythGenericTree *one, MythGenericTree *two) @@ -51,48 +35,18 @@ class SortableMythGenericTreeList : public QList return -1; } -// static int sortByAttributeThenString(MythGenericTree *one, MythGenericTree *two) -// { -// // -// // Sort by attribute (ordering index), but, it if those are -// // equal, then sort by string -// // -// -// int onea = one->getAttribute(m_attributeIndex); -// int twoa = two->getAttribute(m_attributeIndex); -// -// if (onea == twoa) -// { -// QString ones = one->getString().toLower(); -// QString twos = two->getString().toLower(); -// return QString::localeAwareCompare(ones, twos); -// } -// else if (onea < twoa) -// return -1; -// else -// return 1; -// } - void Sort(SortType stype, int attributeIndex = 0) { m_sortType = stype; m_attributeIndex = attributeIndex; switch (m_sortType) { -// case SORT_ATTRIBUTE: -// std::sort(begin(), end(), sortByAttribute); -// break; case SORT_STRING: qSort(begin(), end(), sortByString); break; case SORT_SELECTABLE: qSort(begin(), end(), sortBySelectable); break; -// case SORT_ATT_THEN_STRING: -// std::sort(begin(), end(), sortByAttributeThenString); -// break; - case SORT_ATTRIBUTE: - case SORT_ATT_THEN_STRING: break; } } @@ -108,15 +62,9 @@ MythGenericTree::MythGenericTree(const QString &a_string, int an_int, bool selectable_flag) { m_subnodes = new SortableMythGenericTreeList; - m_ordered_subnodes = new SortableMythGenericTreeList; - m_flatenedSubnodes = new SortableMythGenericTreeList; m_parent = NULL; - m_selected_subnode = NULL; - m_currentOrderingIndex = -1; - - // TODO Switch to a QT List, or drop the attribute concept entirely - m_attributes = new IntVector(6); + m_selectedSubnode = NULL; m_text = a_string; m_int = an_int; @@ -131,9 +79,6 @@ MythGenericTree::~MythGenericTree() { deleteAllChildren(); delete m_subnodes; - delete m_ordered_subnodes; - delete m_flatenedSubnodes; - delete m_attributes; } MythGenericTree* MythGenericTree::addNode(const QString &a_string, int an_int, @@ -150,7 +95,6 @@ MythGenericTree *MythGenericTree::addNode(MythGenericTree *child) { child->setParent(this); m_subnodes->append(child); - m_ordered_subnodes->append(child); if (child->IsVisible()) IncVisibleCount(); @@ -170,11 +114,9 @@ void MythGenericTree::removeNode(MythGenericTree *child) if (!child) return; - if (m_selected_subnode == child) - m_selected_subnode = NULL; + if (m_selectedSubnode == child) + m_selectedSubnode = NULL; - m_ordered_subnodes->removeAll(child); - m_flatenedSubnodes->removeAll(child); m_subnodes->removeAll(child); child->setParent(NULL); @@ -195,14 +137,7 @@ void MythGenericTree::deleteNode(MythGenericTree *child) MythGenericTree* MythGenericTree::findLeaf() { if (m_subnodes->count() > 0) - { - if (m_currentOrderingIndex == -1) - return m_subnodes->first()->findLeaf(); - - MythGenericTree *first_child = getChildAt(0); - - return first_child->findLeaf(); - } + return m_subnodes->first()->findLeaf(); return this; } @@ -254,10 +189,7 @@ MythGenericTree* MythGenericTree::findNode(QList route_of_branches, int MythGenericTree::getChildPosition(MythGenericTree *child) const { - if (m_currentOrderingIndex == -1) - return m_subnodes->indexOf(child); - - return m_ordered_subnodes->indexOf(child); + return m_subnodes->indexOf(child); } int MythGenericTree::getPosition() @@ -285,12 +217,12 @@ QStringList MythGenericTree::getRouteByString() { QStringList routeByString; - routeByString.push_front(getString()); + routeByString.push_front(GetText()); MythGenericTree *parent = this; while( (parent = parent->getParent()) ) { - routeByString.push_front(parent->getString()); + routeByString.push_front(parent->GetText()); } return routeByString; } @@ -333,34 +265,23 @@ int MythGenericTree::currentDepth(void) QList *MythGenericTree::getAllChildren() const { - if (m_currentOrderingIndex == -1) - return m_subnodes; - - return m_ordered_subnodes; + return m_subnodes; } MythGenericTree* MythGenericTree::getChildAt(uint reference) const { - if (reference >= (uint)m_ordered_subnodes->count()) + if (reference >= (uint)m_subnodes->count()) return NULL; - if (m_currentOrderingIndex == -1) - return m_subnodes->at(reference); - - return m_ordered_subnodes->at(reference); + return m_subnodes->at(reference); } MythGenericTree* MythGenericTree::getVisibleChildAt(uint reference) const { - if (reference >= (uint)m_ordered_subnodes->count()) + if (reference >= (uint)m_subnodes->count()) return NULL; - QList *list; - - if (m_currentOrderingIndex == -1) - list = m_subnodes; - else - list = m_ordered_subnodes; + QList *list = m_subnodes; uint n = 0; for (int i = 0; i < list->size(); ++i) @@ -381,8 +302,8 @@ MythGenericTree* MythGenericTree::getSelectedChild(bool onlyVisible) const { MythGenericTree *selectedChild = NULL; - if (m_selected_subnode) - selectedChild = m_selected_subnode; + if (m_selectedSubnode) + selectedChild = m_selectedSubnode; else if (onlyVisible) selectedChild = getVisibleChildAt(0); else @@ -437,16 +358,6 @@ MythGenericTree* MythGenericTree::nextSibling(int number_down) return m_parent->getChildAt(position + number_down); } -QList::iterator MythGenericTree::getFirstChildIterator() const -{ - QList::iterator it; - if (m_currentOrderingIndex == -1) - it = m_subnodes->begin(); - else - it = m_ordered_subnodes->begin(); - return it; -} - MythGenericTree* MythGenericTree::getParent() const { if (m_parent) @@ -454,116 +365,6 @@ MythGenericTree* MythGenericTree::getParent() const return NULL; } -void MythGenericTree::setAttribute(uint attribute_position, int value_of_attribute) -{ - // You can use attributes for anything you like. Mythmusic, for example, - // stores a value for random ordering in the first "column" (0) and a value - // for "intelligent" (1) ordering in the second column - - if (m_attributes->size() < (int)(attribute_position + 1)) - m_attributes->resize(attribute_position + 1); - (*m_attributes)[attribute_position] = value_of_attribute; -} - -int MythGenericTree::getAttribute(uint which_one) const -{ - if (m_attributes->size() < (int)(which_one + 1)) - { - LOG(VB_GENERAL, LOG_ERR, - "Asked a MythGenericTree node for a non-existent attribute"); - return 0; - } - - return m_attributes->at(which_one); -} - -void MythGenericTree::setOrderingIndex(int ordering_index) -{ - m_currentOrderingIndex = ordering_index; - reorderSubnodes(); -} - -void MythGenericTree::reorderSubnodes() -{ - // The nodes are there, we just want to re-order them according to - // attribute column defined by ordering_index - - m_ordered_subnodes->Sort(SortableMythGenericTreeList::SORT_ATTRIBUTE, - m_currentOrderingIndex); -} - -void MythGenericTree::addYourselfIfSelectable(QList *flat_list) -{ - if (m_selectable) - flat_list->append(this); - - QList::iterator it; - it = m_subnodes->begin(); - MythGenericTree *child; - while ((child = *it) != 0) - { - child->addYourselfIfSelectable(flat_list); - ++it; - } -} - -void MythGenericTree::buildFlatListOfSubnodes(bool scrambled_parents) -{ - // This builds a flat list of every selectable child according to the - // current ordering index. - - m_flatenedSubnodes->clear(); - - QList::iterator it; - it = m_subnodes->begin(); - MythGenericTree *child; - while ((child = *it) != 0) - { - child->addYourselfIfSelectable(m_flatenedSubnodes); - ++it; - } - - if (m_currentOrderingIndex > -1) - m_flatenedSubnodes->SetAttributeIndex(m_currentOrderingIndex); -} - -MythGenericTree* MythGenericTree::nextPrevFromFlatList(bool forward_or_backward, - bool wrap_around, - MythGenericTree *active) const -{ - int i = m_flatenedSubnodes->indexOf(active); - if (i < 0) - { - LOG(VB_GENERAL, LOG_ERR, "Can't find active item on flatened list"); - return NULL; - } - - if (forward_or_backward) - { - ++i; - if (i >= (int)m_flatenedSubnodes->count()) - { - if (wrap_around) - i = 0; - else - return NULL; - } - } - else - { - --i; - if (i < 0) - { - if (wrap_around) - i = m_flatenedSubnodes->count() - 1; - else - return NULL; - } - } - - return m_flatenedSubnodes->at(i); -} - MythGenericTree* MythGenericTree::getChildByName(const QString &a_name) const { QList *children = getAllChildren(); @@ -577,7 +378,7 @@ MythGenericTree* MythGenericTree::getChildByName(const QString &a_name) const child = *it; if (!child) continue; - if (child->getString() == a_name) + if (child->GetText() == a_name) return child; } } @@ -608,7 +409,7 @@ MythGenericTree* MythGenericTree::getChildById(int an_int) const void MythGenericTree::sortByString() { - m_ordered_subnodes->Sort(SortableMythGenericTreeList::SORT_STRING); + m_subnodes->Sort(SortableMythGenericTreeList::SORT_STRING); QList *children = getAllChildren(); if (children && children->count() > 0) @@ -626,24 +427,9 @@ void MythGenericTree::sortByString() } } -void MythGenericTree::sortByAttributeThenByString(int which_attribute) -{ - m_ordered_subnodes->Sort(SortableMythGenericTreeList::SORT_ATT_THEN_STRING, - which_attribute); - - QList::iterator it; - it = m_subnodes->begin(); - MythGenericTree *child; - while ((child = *it) != 0) - { - child->sortByAttributeThenByString(which_attribute); - ++it; - } -} - void MythGenericTree::sortBySelectable() { - m_ordered_subnodes->Sort(SortableMythGenericTreeList::SORT_SELECTABLE); + m_subnodes->Sort(SortableMythGenericTreeList::SORT_SELECTABLE); QList::iterator it; it = m_subnodes->begin(); @@ -657,10 +443,7 @@ void MythGenericTree::sortBySelectable() void MythGenericTree::deleteAllChildren() { - m_flatenedSubnodes->clear(); - m_ordered_subnodes->clear(); - m_selected_subnode = NULL; - m_currentOrderingIndex = -1; + m_selectedSubnode = NULL; MythGenericTree *child; while (!m_subnodes->isEmpty()) { @@ -671,34 +454,6 @@ void MythGenericTree::deleteAllChildren() m_subnodes->clear(); } -void MythGenericTree::reOrderAsSorted() -{ - // - // Arrange (recursively) my subnodes in the same order as my ordered - // subnodes - // - - if (m_subnodes->count() != m_ordered_subnodes->count()) - { - LOG(VB_GENERAL, LOG_ERR, "Can't reOrderAsSorted(), because the number " - "of subnodes is different than the number of ordered subnodes"); - return; - } - - m_subnodes->clear(); - m_currentOrderingIndex = -1; - - QList::iterator it; - it = m_ordered_subnodes->begin(); - MythGenericTree *child; - while ((child = *it) != 0) - { - m_subnodes->append(child); - child->reOrderAsSorted(); - ++it; - } -} - void MythGenericTree::MoveItemUpDown(MythGenericTree *item, bool flag) { if (item == m_subnodes->first() && flag) @@ -736,7 +491,7 @@ void MythGenericTree::SetVisible(bool visible) MythUIButtonListItem *MythGenericTree::CreateListButton(MythUIButtonList *list) { - MythUIButtonListItem *item = new MythUIButtonListItem(list, getString()); + MythUIButtonListItem *item = new MythUIButtonListItem(list, GetText()); item->SetData(qVariantFromValue(this)); item->SetTextFromMap(m_strings); item->SetImageFromMap(m_imageFilenames); diff --git a/mythtv/libs/libmythui/mythgenerictree.h b/mythtv/libs/libmythui/mythgenerictree.h index 837733a3069..c6c072f4be2 100644 --- a/mythtv/libs/libmythui/mythgenerictree.h +++ b/mythtv/libs/libmythui/mythgenerictree.h @@ -42,8 +42,6 @@ class MUI_PUBLIC MythGenericTree MythGenericTree *nextSibling(int number_down); MythGenericTree *prevSibling(int number_up); - QList::iterator getFirstChildIterator() const; - MythGenericTree *getSelectedChild(bool onlyVisible = false) const; MythGenericTree *getVisibleChildAt(uint reference) const; MythGenericTree *getChildAt(uint reference) const; @@ -65,11 +63,6 @@ class MUI_PUBLIC MythGenericTree void setParent(MythGenericTree* a_parent) { m_parent = a_parent; } MythGenericTree *getParent(void) const; - // Deprecated - const QString getString(void) const { return m_text; } - void setString(const QString &str) { m_text = str; } - // End deprecated - void SetText(const QString &text, const QString &name="", const QString &state=""); void SetTextFromMap(InfoMap &infoMap, const QString &state=""); @@ -101,27 +94,12 @@ class MUI_PUBLIC MythGenericTree void IncVisibleCount() { m_visibleCount++; } void DecVisibleCount() { m_visibleCount--; } - void setAttribute(uint attribute_position, int value_of_attribute); - int getAttribute(uint which_one) const; - IntVector *getAttributes(void) const { return m_attributes; } - - void setOrderingIndex(int ordering_index); - int getOrderingIndex(void) const { return m_currentOrderingIndex; } - void becomeSelectedChild(void); - void setSelectedChild(MythGenericTree* a_node) { m_selected_subnode = a_node; } - - void addYourselfIfSelectable(QList *flat_list); - void buildFlatListOfSubnodes(bool scrambled_parents); - - MythGenericTree *nextPrevFromFlatList(bool forward_or_back, bool wrap_around, - MythGenericTree *active) const; + void setSelectedChild(MythGenericTree* a_node) { m_selectedSubnode = a_node; } void sortByString(); - void sortByAttributeThenByString(int which_attribute); void sortBySelectable(); void deleteAllChildren(); - void reOrderAsSorted(); // only changes m_subnodes. resort it if you want the others to change void MoveItemUpDown(MythGenericTree *item, bool flag); @@ -140,16 +118,12 @@ class MUI_PUBLIC MythGenericTree uint m_visibleCount; SortableMythGenericTreeList *m_subnodes; - SortableMythGenericTreeList *m_ordered_subnodes; - SortableMythGenericTreeList *m_flatenedSubnodes; - MythGenericTree *m_selected_subnode; - IntVector *m_attributes; + MythGenericTree *m_selectedSubnode; MythGenericTree *m_parent; bool m_selectable; bool m_visible; - int m_currentOrderingIndex; }; Q_DECLARE_METATYPE(MythGenericTree*) diff --git a/mythtv/libs/libmythui/mythuibuttontree.cpp b/mythtv/libs/libmythui/mythuibuttontree.cpp index b71ccb8d8fc..983d2faa9ca 100644 --- a/mythtv/libs/libmythui/mythuibuttontree.cpp +++ b/mythtv/libs/libmythui/mythuibuttontree.cpp @@ -303,7 +303,7 @@ bool MythUIButtonTree::SetNodeByString(QStringList route) if (!route.isEmpty()) { - if (route[0] == m_rootNode->getString()) + if (route[0] == m_rootNode->GetText()) { if (route.size() > 1) { diff --git a/mythtv/programs/mythfrontend/videodlg.cpp b/mythtv/programs/mythfrontend/videodlg.cpp index e8f2628bc8e..dc94f12ca47 100644 --- a/mythtv/programs/mythfrontend/videodlg.cpp +++ b/mythtv/programs/mythfrontend/videodlg.cpp @@ -1162,7 +1162,7 @@ void VideoDialog::loadData() // check if the node name is the same as the currently selected // one in the saved tree list. if yes then we are on the right // way down the video tree to find the last saved position - if (node->getString().compare(lastTreeNodePath.at(i)) == 0) + if (node->GetText().compare(lastTreeNodePath.at(i)) == 0) { // set the folder as the new node so we can travel further down // dont do this if its the last part of the saved video path tree @@ -1235,14 +1235,14 @@ void VideoDialog::UpdateItem(MythUIButtonListItem *item) MythGenericTree *parent = node->getParent(); - if (parent && metadata && ((QString::compare(parent->getString(), + if (parent && metadata && ((QString::compare(parent->GetText(), metadata->GetTitle(), Qt::CaseInsensitive) == 0) || - parent->getString().startsWith(tr("Season"), Qt::CaseInsensitive))) + parent->GetText().startsWith(tr("Season"), Qt::CaseInsensitive))) item->SetText(metadata->GetSubtitle()); else if (metadata && !metadata->GetSubtitle().isEmpty()) item->SetText(QString("%1: %2").arg(metadata->GetTitle()).arg(metadata->GetSubtitle())); else - item->SetText(metadata ? metadata->GetTitle() : node->getString()); + item->SetText(metadata ? metadata->GetTitle() : node->GetText()); QString coverimage = GetCoverImage(node); QString screenshot = GetScreenshot(node); @@ -1250,9 +1250,9 @@ void VideoDialog::UpdateItem(MythUIButtonListItem *item) QString fanart = GetFanart(node); if (!screenshot.isEmpty() && parent && metadata && - ((QString::compare(parent->getString(), + ((QString::compare(parent->GetText(), metadata->GetTitle(), Qt::CaseInsensitive) == 0) || - parent->getString().startsWith(tr("Season"), Qt::CaseInsensitive))) + parent->GetText().startsWith(tr("Season"), Qt::CaseInsensitive))) { item->SetImage(screenshot); } @@ -1289,14 +1289,14 @@ void VideoDialog::UpdateItem(MythUIButtonListItem *item) { item->SetText(QString("%1").arg(node->visibleChildCount()), "childcount"); item->DisplayState("subfolder", "nodetype"); - item->SetText(node->getString(), "title"); - item->SetText(node->getString()); + item->SetText(node->GetText(), "title"); + item->SetText(node->GetText()); } else if (nodeInt == kUpFolder) { item->DisplayState("upfolder", "nodetype"); - item->SetText(node->getString(), "title"); - item->SetText(node->getString()); + item->SetText(node->GetText(), "title"); + item->SetText(node->GetText()); } if (item == GetItemCurrent()) @@ -1326,8 +1326,6 @@ void VideoDialog::fetchVideos() m_d->m_treeLoaded = true; - m_d->m_rootNode->setOrderingIndex(kNodeSort); - // Move a node down if there is a single directory item here... if (m_d->m_rootNode->childCount() == 1) { @@ -1870,7 +1868,7 @@ QString VideoDialog::GetFirstImage(MythGenericTree *node, QString type, if (levels < maxRecurse) { test_file = GetFirstImage(subDirs[i], type, - node->getString(), levels + 1); + node->GetText(), levels + 1); if (!test_file.isEmpty()) { icon_file = test_file; @@ -2144,7 +2142,7 @@ void VideoDialog::searchComplete(QString string) for (it = children->begin(); it != children->end(); ++it) { MythGenericTree *child = *it; - QString title = child->getString(); + QString title = child->GetText(); int id = child->getPosition(); idTitle.insert(id, title); } @@ -2182,7 +2180,7 @@ void VideoDialog::searchStart(void) for (it = children->begin(); it != children->end(); ++it) { MythGenericTree *child = *it; - childList << child->getString(); + childList << child->GetText(); } MythScreenStack *popupStack = @@ -2310,7 +2308,7 @@ void VideoDialog::UpdateText(MythUIButtonListItem *item) if (m_d->m_currentNode) { CheckedSet(m_crumbText, m_d->m_currentNode->getRouteByString().join(" > ")); - CheckedSet(this, "foldername", m_d->m_currentNode->getString()); + CheckedSet(this, "foldername", m_d->m_currentNode->GetText()); } if (node && node->getInt() == kSubFolder) @@ -3377,7 +3375,7 @@ void VideoDialog::VideoAutoSearch(MythGenericTree *node) MGTreeChildList *lchildren = node->getAllChildren(); LOG(VB_GENERAL, LOG_DEBUG, - QString("Fetching details in %1").arg(node->getString())); + QString("Fetching details in %1").arg(node->GetText())); for (MGTreeChildList::const_iterator p = lchildren->begin(); p != lchildren->end(); ++p) diff --git a/mythtv/programs/mythfrontend/videolist.cpp b/mythtv/programs/mythfrontend/videolist.cpp index 4e46fd54ae6..0cd21e528b0 100644 --- a/mythtv/programs/mythfrontend/videolist.cpp +++ b/mythtv/programs/mythfrontend/videolist.cpp @@ -283,14 +283,6 @@ struct to_metadata_ptr } }; -// TODO: AEW We don't actually use this now -// Ordering of items on a tree level (low -> high) -enum NodeOrder { - kOrderUp, - kOrderSub, - kOrderItem -}; - static MythGenericTree *AddDirNode( MythGenericTree *where_to_add, QString name, QString fqPath, bool add_up_dirs, @@ -299,8 +291,6 @@ static MythGenericTree *AddDirNode( // Add the subdir node... MythGenericTree *sub_node = where_to_add->addNode(name, kSubFolder, false); - sub_node->setAttribute(kNodeSort, kOrderSub); - sub_node->setOrderingIndex(kNodeSort); sub_node->SetData(QVariant::fromValue(TreeNodeData(fqPath, host, prefix))); sub_node->SetText(name, "title"); sub_node->DisplayState("subfolder", "nodetype"); @@ -309,10 +299,8 @@ static MythGenericTree *AddDirNode( if (add_up_dirs) { MythGenericTree *up_node = - sub_node->addNode(where_to_add->getString(), kUpFolder, + sub_node->addNode(where_to_add->GetText(), kUpFolder, true, false); - up_node->setAttribute(kNodeSort, kOrderUp); - up_node->setOrderingIndex(kNodeSort); up_node->DisplayState("subfolder", "nodetype"); } @@ -323,8 +311,6 @@ static int AddFileNode(MythGenericTree *where_to_add, QString name, VideoMetadata *metadata) { MythGenericTree *sub_node = where_to_add->addNode(name, 0, true); - sub_node->setAttribute(kNodeSort, kOrderItem); - sub_node->setOrderingIndex(kNodeSort); sub_node->SetData(QVariant::fromValue(TreeNodeData(metadata))); // Text