Ticket #7425: mythvideo-remember-tree-and-gallery-position.patch

File mythvideo-remember-tree-and-gallery-position.patch, 7.3 KB (added by Robert S, 14 years ago)

Remember video position also in gallery view mode

  • libs/libmythui/mythuibuttontree.cpp

    bool MythUIButtonTree::SetCurrentNode(MythGenericTree *node) 
    347347}
    348348
    349349/*!
     350 * \brief Set depth of the currently selected list
     351 *
     352 * \param depth Depth of the tree for currently selected node
     353 *
     354 * \return True if successful
     355 */
     356bool MythUIButtonTree::SetCurrentDepth(int depth) {
     357    bool listadvance = true;
     358    for(int position=0; position < depth - 1 && listadvance; position++)
     359        listadvance = SwitchList(true);
     360 
     361    return listadvance;
     362}
     363
     364/*!
    350365 * \brief Remove the item from the tree
    351366 *
    352367 * \param item Item to be removed
    void MythUIButtonTree::SetActive(bool active) 
    413428 *
    414429 * \param right If true move to the right or away from the root, if false move to
    415430 *              the left or towards the root
     431 *
     432 * \return True if successful
    416433 */
    417 void MythUIButtonTree::SwitchList(bool right)
     434bool MythUIButtonTree::SwitchList(bool right)
    418435{
    419436    bool doUpdate = false;
    420437    if (right)
    void MythUIButtonTree::SwitchList(bool right) 
    427444            doUpdate = true;
    428445        }
    429446        else
    430             return;
     447            return false;
    431448    }
    432449    else if (!right)
    433450    {
    void MythUIButtonTree::SwitchList(bool right) 
    439456            doUpdate = true;
    440457        }
    441458        else
    442             return;
     459            return false;
    443460    }
    444461
    445462    if (doUpdate)
    void MythUIButtonTree::SwitchList(bool right) 
    451468        m_activeList = m_buttonlists[m_activeListID];
    452469        m_activeList->Select();
    453470    }
     471    return true;
    454472}
    455473
    456474/*!
  • libs/libmythui/mythuibuttontree.h

    class MPUBLIC MythUIButtonTree : public MythUIType 
    2727    bool SetNodeByString(QStringList route);
    2828    bool SetNodeById(QList<int> route);
    2929    bool SetCurrentNode(MythGenericTree *node);
     30    bool SetCurrentDepth(int depth);
    3031    MythGenericTree* GetCurrentNode(void) const { return m_currentNode; }
    3132
    3233    void SetActive(bool active);
    class MPUBLIC MythUIButtonTree : public MythUIType 
    5556    void SetTreeState(bool refreshAll = false);
    5657    bool UpdateList(MythUIButtonList *list, MythGenericTree *node);
    5758
    58     void SwitchList(bool right);
     59    bool SwitchList(bool right);
    5960
    6061    bool m_active;
    6162    bool m_initialized;
  • mythvideo/mythvideo/videodlg.cpp

     
    14151415        }
    14161416
    14171417        m_rememberPosition =
    1418                 gContext->GetNumSetting("mythvideo.VideoTreeRemember", 0);
     1418                gContext->GetNumSetting("mythvideo.VideoTreeRemember", 1);
     1419        m_lastTreeNodePath =
     1420                gContext->GetSetting("mythvideo.VideoTreeLastActive", "");
    14191421
    14201422        m_isFileBrowser = gContext->GetNumSetting("VideoDialogNoDB", 0);
    14211423        m_groupType = gContext->GetNumSetting("mythvideo.db_group_type", 0);
     
    14341436        delete m_scanner;
    14351437        StopAllRunningImageDownloads();
    14361438
    1437         if (m_rememberPosition && m_lastTreeNodePath.length())
     1439        if (m_rememberPosition && m_lastTreeNodePath.length() > 0)
    14381440        {
    1439             gContext->SaveSetting("mythvideo.VideoTreeLastActive",
    1440                     m_lastTreeNodePath);
     1441            // append the last active filename to the node path so we can
     1442            // preselect the filename and not only the directory next time
     1443            m_lastTreeNodePath.append("\n").append(m_currentNode->getSelectedChild()->getString());
     1444            gContext->SaveSetting("mythvideo.VideoTreeLastActive", m_lastTreeNodePath);
    14411445        }
    14421446    }
    14431447
     
    18001804
    18011805            if (m_d->m_rememberPosition)
    18021806            {
    1803                 QStringList route =
    1804                         gContext->GetSetting("mythvideo.VideoTreeLastActive",
    1805                                 "").split("\n");
    1806                 m_videoButtonTree->SetNodeByString(route);
     1807                QStringList route = m_d->m_lastTreeNodePath.split("\n");
     1808                route.removeFirst();
     1809
     1810                if (m_videoButtonTree->SetNodeByString(route))
     1811                                     m_videoButtonTree->SetCurrentDepth(route.length());
    18071812            }
    18081813        }
     
    18201824        if (!m_d->m_currentNode)
    18211825            return;
    18221826
    1823         MythGenericTree *selectedNode = m_d->m_currentNode->getSelectedChild();
     1827        MythGenericTree *selectedNode =
     1828                m_d->m_currentNode->getSelectedChild();
     1829
     1830        MythGenericTree *lastSelectedNode =
     1831                m_d->m_currentNode->getChildByName(
     1832                        m_d->m_lastTreeNodePath.split("\n").last());
    18241833
    18251834        typedef QList<MythGenericTree *> MGTreeChildList;
    18261835        MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren();
     
    18381847
    18391848                UpdateItem(item);
    18401849
    1841                 if (*p == selectedNode)
    1842                     m_videoButtonList->SetItemCurrent(item);
     1850                if (m_d->m_rememberPosition &&
     1851                    m_d->m_type == DLG_GALLERY )
     1852                {
     1853                    if (*p == lastSelectedNode)
     1854                        m_videoButtonList->SetItemCurrent(item);
     1855                }
     1856                else
     1857                {
     1858                    if (*p == selectedNode)
     1859                        m_videoButtonList->SetItemCurrent(item);
     1860                }
    18431861            }
    18441862        }
    18451863    }
     
    19801997
    19811998    if (!m_d->m_currentNode || m_d->m_rootNode != oldroot)
    19821999        SetCurrentNode(m_d->m_rootNode);
     2000
     2001    if (m_d->m_rememberPosition &&
     2002        m_d->m_lastTreeNodePath.length() > 0 &&
     2003        m_d->m_type == DLG_GALLERY )
     2004    {
     2005        // Get the list of the last video tree path directories and remove the first
     2006        // two elements of the route since it is the name of the root 'Video Home' element
     2007        QStringList routeList = m_d->m_lastTreeNodePath.split("\n");
     2008        routeList.removeFirst();
     2009        routeList.removeFirst();
     2010
     2011        routeList.removeLast();
     2012
     2013        // continue if we have a path
     2014        if (routeList.size() > 0)
     2015        {
     2016            // use the root node as the current node
     2017            m_d->m_currentNode = m_d->m_rootNode;
     2018
     2019            // go through the path list and set the current node
     2020            for (int i = 0; i < routeList.size(); i++)
     2021            {
     2022                // get the node that has the name of the path in the routelist
     2023                MythGenericTree *node = m_d->m_currentNode->getChildByName(routeList.at(i));
     2024                if (node != NULL)
     2025                {
     2026                    if (node->getInt() == kSubFolder &&
     2027                        node->getString().compare(routeList.at(i)) == 0 &&
     2028                        node->childCount() > 1)
     2029                    {
     2030                        SetCurrentNode(node);
     2031                    }
     2032                }
     2033            }
     2034            SetCurrentNode(m_d->m_currentNode);
     2035        }
     2036    }
    19832037}
    19842038
    19852039/** \fn VideoDialog::RemoteImageCheck(QString host, QString filename)
     
    29202972    if (m_d->m_currentNode)
    29212973        CheckedSet(m_crumbText, m_d->m_currentNode->getRouteByString().join(" > "));
    29222974
     2975    m_d->m_lastTreeNodePath = m_d->m_currentNode->getRouteByString().join("\n");
     2976
    29232977    if (node && node->getInt() == kSubFolder)
    29242978        CheckedSet(this, "childcount",
    29252979                   QString("%1").arg(node->visibleChildCount()));