Ticket #7425: mythvideo-remember-tree-and-gallery-position.patch
File mythvideo-remember-tree-and-gallery-position.patch, 7.3 KB (added by , 14 years ago) |
---|
-
libs/libmythui/mythuibuttontree.cpp
bool MythUIButtonTree::SetCurrentNode(MythGenericTree *node) 347 347 } 348 348 349 349 /*! 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 */ 356 bool 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 /*! 350 365 * \brief Remove the item from the tree 351 366 * 352 367 * \param item Item to be removed … … void MythUIButtonTree::SetActive(bool active) 413 428 * 414 429 * \param right If true move to the right or away from the root, if false move to 415 430 * the left or towards the root 431 * 432 * \return True if successful 416 433 */ 417 voidMythUIButtonTree::SwitchList(bool right)434 bool MythUIButtonTree::SwitchList(bool right) 418 435 { 419 436 bool doUpdate = false; 420 437 if (right) … … void MythUIButtonTree::SwitchList(bool right) 427 444 doUpdate = true; 428 445 } 429 446 else 430 return ;447 return false; 431 448 } 432 449 else if (!right) 433 450 { … … void MythUIButtonTree::SwitchList(bool right) 439 456 doUpdate = true; 440 457 } 441 458 else 442 return ;459 return false; 443 460 } 444 461 445 462 if (doUpdate) … … void MythUIButtonTree::SwitchList(bool right) 451 468 m_activeList = m_buttonlists[m_activeListID]; 452 469 m_activeList->Select(); 453 470 } 471 return true; 454 472 } 455 473 456 474 /*! -
libs/libmythui/mythuibuttontree.h
class MPUBLIC MythUIButtonTree : public MythUIType 27 27 bool SetNodeByString(QStringList route); 28 28 bool SetNodeById(QList<int> route); 29 29 bool SetCurrentNode(MythGenericTree *node); 30 bool SetCurrentDepth(int depth); 30 31 MythGenericTree* GetCurrentNode(void) const { return m_currentNode; } 31 32 32 33 void SetActive(bool active); … … class MPUBLIC MythUIButtonTree : public MythUIType 55 56 void SetTreeState(bool refreshAll = false); 56 57 bool UpdateList(MythUIButtonList *list, MythGenericTree *node); 57 58 58 voidSwitchList(bool right);59 bool SwitchList(bool right); 59 60 60 61 bool m_active; 61 62 bool m_initialized; -
mythvideo/mythvideo/videodlg.cpp
1415 1415 } 1416 1416 1417 1417 m_rememberPosition = 1418 gContext->GetNumSetting("mythvideo.VideoTreeRemember", 0); 1418 gContext->GetNumSetting("mythvideo.VideoTreeRemember", 1); 1419 m_lastTreeNodePath = 1420 gContext->GetSetting("mythvideo.VideoTreeLastActive", ""); 1419 1421 1420 1422 m_isFileBrowser = gContext->GetNumSetting("VideoDialogNoDB", 0); 1421 1423 m_groupType = gContext->GetNumSetting("mythvideo.db_group_type", 0); … … 1434 1436 delete m_scanner; 1435 1437 StopAllRunningImageDownloads(); 1436 1438 1437 if (m_rememberPosition && m_lastTreeNodePath.length() )1439 if (m_rememberPosition && m_lastTreeNodePath.length() > 0) 1438 1440 { 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); 1441 1445 } 1442 1446 } 1443 1447 … … 1800 1804 1801 1805 if (m_d->m_rememberPosition) 1802 1806 { 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()); 1807 1812 } 1808 1813 } … … 1820 1824 if (!m_d->m_currentNode) 1821 1825 return; 1822 1826 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()); 1824 1833 1825 1834 typedef QList<MythGenericTree *> MGTreeChildList; 1826 1835 MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren(); … … 1838 1847 1839 1848 UpdateItem(item); 1840 1849 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 } 1843 1861 } 1844 1862 } 1845 1863 } … … 1980 1997 1981 1998 if (!m_d->m_currentNode || m_d->m_rootNode != oldroot) 1982 1999 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 } 1983 2037 } 1984 2038 1985 2039 /** \fn VideoDialog::RemoteImageCheck(QString host, QString filename) … … 2920 2972 if (m_d->m_currentNode) 2921 2973 CheckedSet(m_crumbText, m_d->m_currentNode->getRouteByString().join(" > ")); 2922 2974 2975 m_d->m_lastTreeNodePath = m_d->m_currentNode->getRouteByString().join("\n"); 2976 2923 2977 if (node && node->getInt() == kSubFolder) 2924 2978 CheckedSet(this, "childcount", 2925 2979 QString("%1").arg(node->visibleChildCount()));