From a924c93f846d86782a3a0ed9cc634f385c2551ae Mon Sep 17 00:00:00 2001
From: Pasha Golovko <mythtv@golovko.org>
Date: Wed, 20 Jan 2010 14:31:11 -0800
Subject: [PATCH] Fixes #7425. Update tree position remmeber functionality for post-MythUI changes.
---
mythplugins/mythvideo/mythvideo/videodlg.cpp | 17 +++++++++++++----
mythtv/libs/libmythui/mythuibuttontree.cpp | 24 +++++++++++++++++++++---
mythtv/libs/libmythui/mythuibuttontree.h | 3 ++-
3 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/mythplugins/mythvideo/mythvideo/videodlg.cpp b/mythplugins/mythvideo/mythvideo/videodlg.cpp
index 24a6c1a..bcff8de 100644
|
a
|
b
|
class VideoDialogPrivate |
| 1432 | 1432 | |
| 1433 | 1433 | if (m_rememberPosition && m_lastTreeNodePath.length()) |
| 1434 | 1434 | { |
| | 1435 | VERBOSE(VB_GENERAL, QString("Saving tree position: %1").arg(m_lastTreeNodePath)); |
| 1435 | 1436 | gContext->SaveSetting("mythvideo.VideoTreeLastActive", |
| 1436 | 1437 | m_lastTreeNodePath); |
| 1437 | 1438 | } |
| … |
… |
void VideoDialog::loadData() |
| 1797 | 1798 | |
| 1798 | 1799 | if (m_d->m_rememberPosition) |
| 1799 | 1800 | { |
| 1800 | | QStringList route = |
| 1801 | | gContext->GetSetting("mythvideo.VideoTreeLastActive", |
| 1802 | | "").split("\n"); |
| 1803 | | m_videoButtonTree->SetNodeByString(route); |
| | 1801 | /* |
| | 1802 | * We need to remove first element of the route since it is the name of the |
| | 1803 | * root 'Video Home' element |
| | 1804 | */ |
| | 1805 | m_d->m_lastTreeNodePath = gContext->GetSetting("mythvideo.VideoTreeLastActive", ""); |
| | 1806 | QStringList route = m_d->m_lastTreeNodePath.split("\n"); |
| | 1807 | route.removeFirst(); |
| | 1808 | VERBOSE(VB_GENERAL, QString("Setting tree position: %1").arg(route.join("->"))); |
| | 1809 | if (m_videoButtonTree->SetNodeByString(route)) |
| | 1810 | m_videoButtonTree->SetCurrentDepth(route.length()); |
| | 1811 | |
| 1804 | 1812 | } |
| 1805 | 1813 | } |
| 1806 | 1814 | } |
| … |
… |
void VideoDialog::UpdateText(MythUIButtonListItem *item) |
| 2916 | 2924 | |
| 2917 | 2925 | if (m_d->m_currentNode) |
| 2918 | 2926 | CheckedSet(m_crumbText, m_d->m_currentNode->getRouteByString().join(" > ")); |
| | 2927 | m_d->m_lastTreeNodePath = m_d->m_currentNode->getRouteByString().join("\n"); |
| 2919 | 2928 | |
| 2920 | 2929 | if (node && node->getInt() == kSubFolder) |
| 2921 | 2930 | CheckedSet(this, "childcount", |
diff --git a/mythtv/libs/libmythui/mythuibuttontree.cpp b/mythtv/libs/libmythui/mythuibuttontree.cpp
index f53bf60..a53d3bd 100644
|
a
|
b
|
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 | | void MythUIButtonTree::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 | /*! |
diff --git a/mythtv/libs/libmythui/mythuibuttontree.h b/mythtv/libs/libmythui/mythuibuttontree.h
index 7bf5835..7567d3d 100644
|
a
|
b
|
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 |
| 54 | 55 | void SetTreeState(bool refreshAll = false); |
| 55 | 56 | bool UpdateList(MythUIButtonList *list, MythGenericTree *node); |
| 56 | 57 | |
| 57 | | void SwitchList(bool right); |
| | 58 | bool SwitchList(bool right); |
| 58 | 59 | |
| 59 | 60 | bool m_active; |
| 60 | 61 | bool m_initialized; |