| 896 | void VideoDialog::LoadPosition(bool force) |
| 897 | { |
| 898 | if(!force && !m_d->m_rememberPosition) { |
| 899 | //Don't restore position |
| 900 | return; |
| 901 | } |
| 902 | |
| 903 | if (m_d->m_type == DLG_TREE) |
| 904 | { |
| 905 | QStringList route = |
| 906 | gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", |
| 907 | "").split("\n"); |
| 908 | m_videoButtonTree->SetNodeByString(route); |
| 909 | } else if (m_d->m_type == DLG_GALLERY || m_d->m_type == DLG_BROWSER) { |
| 910 | MythGenericTree *selectedNode = m_d->m_currentNode->getSelectedChild(); |
| 911 | QStringList lastTreeNodePath = gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", "").split("\n"); |
| 912 | if (lastTreeNodePath.size() > 0) |
| 913 | { |
| 914 | MythGenericTree *node; |
| 915 | |
| 916 | // go through the path list and set the current node |
| 917 | for (int i = 0; i < lastTreeNodePath.size(); i++) |
| 918 | { |
| 919 | node = m_d->m_currentNode->getChildByName(lastTreeNodePath.at(i)); |
| 920 | if (node != NULL) |
| 921 | { |
| 922 | // check if the node name is the same as the currently selected |
| 923 | // one in the saved tree list. if yes then we are on the right |
| 924 | // way down the video tree to find the last saved position |
| 925 | if (node->getString().compare(lastTreeNodePath.at(i)) == 0) |
| 926 | { |
| 927 | // set the folder as the new node so we can travel further down |
| 928 | // dont do this if its the last part of the saved video path tree |
| 929 | if (node->getInt() == kSubFolder && |
| 930 | node->childCount() > 1 && |
| 931 | i < lastTreeNodePath.size()-1) |
| 932 | { |
| 933 | SetCurrentNode(node); |
| 934 | } |
| 935 | // in the last run the selectedNode will be the last |
| 936 | // entry of the saved tree node. |
| 937 | if (lastTreeNodePath.at(i) == lastTreeNodePath.last()) |
| 938 | selectedNode = node; |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | typedef QList<MythGenericTree *> MGTreeChildList; |
| 945 | MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren(); |
| 946 | |
| 947 | for (MGTreeChildList::const_iterator p = lchildren->begin(); |
| 948 | p != lchildren->end(); ++p) |
| 949 | { |
| 950 | if (*p != NULL) |
| 951 | { |
| 952 | MythUIButtonListItem *item = |
| 953 | new MythUIButtonListItem(m_videoButtonList, QString(), 0, |
| 954 | true, MythUIButtonListItem::NotChecked); |
| 955 | |
| 956 | item->SetData(qVariantFromValue(*p)); |
| 957 | |
| 958 | UpdateItem(item); |
| 959 | |
| 960 | if (*p == selectedNode) |
| 961 | m_videoButtonList->SetItemCurrent(item); |
| 962 | } |
| 963 | } |
| 964 | } |
| 965 | } |
| 966 | |
1140 | | MythGenericTree *selectedNode = m_d->m_currentNode->getSelectedChild(); |
1141 | | |
1142 | | // restore the last saved position in the video tree if this is the first |
1143 | | // time this method is called and the option is set in the database |
1144 | | if (m_d->m_firstLoadPass) |
1145 | | { |
1146 | | if (m_d->m_rememberPosition) |
1147 | | { |
1148 | | QStringList lastTreeNodePath = gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", "").split("\n"); |
1149 | | |
1150 | | if (m_d->m_type == DLG_GALLERY || m_d->m_type == DLG_BROWSER) |
1151 | | { |
1152 | | if (lastTreeNodePath.size() > 0) |
1153 | | { |
1154 | | MythGenericTree *node; |
1155 | | |
1156 | | // go through the path list and set the current node |
1157 | | for (int i = 0; i < lastTreeNodePath.size(); i++) |
1158 | | { |
1159 | | node = m_d->m_currentNode->getChildByName(lastTreeNodePath.at(i)); |
1160 | | if (node != NULL) |
1161 | | { |
1162 | | // check if the node name is the same as the currently selected |
1163 | | // one in the saved tree list. if yes then we are on the right |
1164 | | // way down the video tree to find the last saved position |
1165 | | if (node->getString().compare(lastTreeNodePath.at(i)) == 0) |
1166 | | { |
1167 | | // set the folder as the new node so we can travel further down |
1168 | | // dont do this if its the last part of the saved video path tree |
1169 | | if (node->getInt() == kSubFolder && |
1170 | | node->childCount() > 1 && |
1171 | | i < lastTreeNodePath.size()-1) |
1172 | | { |
1173 | | SetCurrentNode(node); |
1174 | | } |
1175 | | // in the last run the selectedNode will be the last |
1176 | | // entry of the saved tree node. |
1177 | | if (lastTreeNodePath.at(i) == lastTreeNodePath.last()) |
1178 | | selectedNode = node; |
1179 | | } |
1180 | | } |
1181 | | } |
1182 | | m_d->m_firstLoadPass = false; |
1183 | | } |
1184 | | } |
1185 | | } |
1186 | | } |
1187 | | |
1188 | | typedef QList<MythGenericTree *> MGTreeChildList; |
1189 | | MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren(); |
1190 | | |
1191 | | for (MGTreeChildList::const_iterator p = lchildren->begin(); |
1192 | | p != lchildren->end(); ++p) |
1193 | | { |
1194 | | if (*p != NULL) |
1195 | | { |
1196 | | MythUIButtonListItem *item = |
1197 | | new MythUIButtonListItem(m_videoButtonList, QString(), 0, |
1198 | | true, MythUIButtonListItem::NotChecked); |
1199 | | |
1200 | | item->SetData(qVariantFromValue(*p)); |
1201 | | |
1202 | | UpdateItem(item); |
1203 | | |
1204 | | if (*p == selectedNode) |
1205 | | m_videoButtonList->SetItemCurrent(item); |
1206 | | } |
1207 | | } |