Ticket #10672: mythtv-video-metadata-editor-return-behavior.patch

File mythtv-video-metadata-editor-return-behavior.patch, 8.1 KB (added by adiemus <mythtv@…>, 13 months ago)

Patch to return to the just edited file when exiting the video metadata edit dialog

  • mythtv/programs/mythfrontend/videodlg.cpp

    diff --git a/mythtv/programs/mythfrontend/videodlg.cpp b/mythtv/programs/mythfrontend/videodlg.cpp
    index 829b77b..bf3f481 100644
    a b void VideoDialog::SavePosition(void) 
    889889    gCoreContext->SaveSetting("mythvideo.VideoTreeLastActive", m_d->m_lastTreeNodePath); 
    890890} 
    891891 
     892void VideoDialog::LoadPosition(bool force) 
     893{ 
     894        if(!force && !m_d->m_rememberPosition) { 
     895                //Don't restore position 
     896                return; 
     897        } 
     898 
     899        if (m_d->m_type == DLG_TREE) 
     900    { 
     901        QStringList route = 
     902            gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", 
     903                "").split("\n"); 
     904            m_videoButtonTree->SetNodeByString(route); 
     905    } else if (m_d->m_type == DLG_GALLERY || m_d->m_type == DLG_BROWSER) { 
     906        MythGenericTree *selectedNode = m_d->m_currentNode->getSelectedChild(); 
     907        QStringList lastTreeNodePath = gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", "").split("\n"); 
     908        if (lastTreeNodePath.size() > 0) 
     909        { 
     910            MythGenericTree *node; 
     911 
     912            // go through the path list and set the current node 
     913            for (int i = 0; i < lastTreeNodePath.size(); i++) 
     914            { 
     915                node = m_d->m_currentNode->getChildByName(lastTreeNodePath.at(i)); 
     916                if (node != NULL) 
     917                { 
     918                    // check if the node name is the same as the currently selected 
     919                    // one in the saved tree list. if yes then we are on the right 
     920                    // way down the video tree to find the last saved position 
     921                    if (node->getString().compare(lastTreeNodePath.at(i)) == 0) 
     922                    { 
     923                        // set the folder as the new node so we can travel further down 
     924                        // dont do this if its the last part of the saved video path tree 
     925                        if (node->getInt() == kSubFolder && 
     926                            node->childCount() > 1 && 
     927                            i < lastTreeNodePath.size()-1) 
     928                        { 
     929                            SetCurrentNode(node); 
     930                        } 
     931                        // in the last run the selectedNode will be the last 
     932                        // entry of the saved tree node. 
     933                        if (lastTreeNodePath.at(i) == lastTreeNodePath.last()) 
     934                            selectedNode = node; 
     935                    } 
     936                } 
     937            } 
     938        } 
     939 
     940        typedef QList<MythGenericTree *> MGTreeChildList; 
     941        MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren(); 
     942 
     943        for (MGTreeChildList::const_iterator p = lchildren->begin(); 
     944                p != lchildren->end(); ++p) 
     945        { 
     946            if (*p != NULL) 
     947            { 
     948                MythUIButtonListItem *item = 
     949                        new MythUIButtonListItem(m_videoButtonList, QString(), 0, 
     950                                true, MythUIButtonListItem::NotChecked); 
     951 
     952                item->SetData(qVariantFromValue(*p)); 
     953 
     954                UpdateItem(item); 
     955 
     956                if (*p == selectedNode) 
     957                    m_videoButtonList->SetItemCurrent(item); 
     958            } 
     959        } 
     960    } 
     961} 
     962 
    892963bool VideoDialog::Create() 
    893964{ 
    894965    if (m_d->m_type == DLG_DEFAULT) 
    void VideoDialog::refreshData() 
    10651136 
    10661137    if (m_novideoText) 
    10671138        m_novideoText->SetVisible(noFiles); 
     1139 
     1140        LoadPosition(true); 
    10681141} 
    10691142 
    10701143void VideoDialog::scanFinished(bool dbChanged) 
    void VideoDialog::loadData() 
    11091182    if (m_d->m_type == DLG_TREE) 
    11101183    { 
    11111184        m_videoButtonTree->AssignTree(m_d->m_rootNode); 
    1112  
    1113         if (m_d->m_firstLoadPass) 
    1114         { 
    1115             m_d->m_firstLoadPass = false; 
    1116  
    1117             if (m_d->m_rememberPosition) 
    1118             { 
    1119                 QStringList route = 
    1120                         gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", 
    1121                                 "").split("\n"); 
    1122                 m_videoButtonTree->SetNodeByString(route); 
    1123             } 
    1124         } 
    11251185    } 
    11261186    else 
    11271187    { 
    void VideoDialog::loadData() 
    11361196        if (!m_d->m_currentNode) 
    11371197            return; 
    11381198 
    1139         MythGenericTree *selectedNode = m_d->m_currentNode->getSelectedChild(); 
    1140  
    1141         // restore the last saved position in the video tree if this is the first 
    1142         // time this method is called and the option is set in the database 
    1143         if (m_d->m_firstLoadPass) 
    1144         { 
    1145             if (m_d->m_rememberPosition) 
    1146             { 
    1147                 QStringList lastTreeNodePath = gCoreContext->GetSetting("mythvideo.VideoTreeLastActive", "").split("\n"); 
    1148  
    1149                 if (m_d->m_type == DLG_GALLERY || m_d->m_type == DLG_BROWSER) 
    1150                 { 
    1151                     if (lastTreeNodePath.size() > 0) 
    1152                     { 
    1153                         MythGenericTree *node; 
    1154  
    1155                         // go through the path list and set the current node 
    1156                         for (int i = 0; i < lastTreeNodePath.size(); i++) 
    1157                         { 
    1158                             node = m_d->m_currentNode->getChildByName(lastTreeNodePath.at(i)); 
    1159                             if (node != NULL) 
    1160                             { 
    1161                                 // check if the node name is the same as the currently selected 
    1162                                 // one in the saved tree list. if yes then we are on the right 
    1163                                 // way down the video tree to find the last saved position 
    1164                                 if (node->getString().compare(lastTreeNodePath.at(i)) == 0) 
    1165                                 { 
    1166                                     // set the folder as the new node so we can travel further down 
    1167                                     // dont do this if its the last part of the saved video path tree 
    1168                                     if (node->getInt() == kSubFolder && 
    1169                                         node->childCount() > 1 && 
    1170                                         i < lastTreeNodePath.size()-1) 
    1171                                     { 
    1172                                         SetCurrentNode(node); 
    1173                                     } 
    1174                                     // in the last run the selectedNode will be the last 
    1175                                     // entry of the saved tree node. 
    1176                                     if (lastTreeNodePath.at(i) == lastTreeNodePath.last()) 
    1177                                         selectedNode = node; 
    1178                                 } 
    1179                             } 
    1180                         } 
    1181                         m_d->m_firstLoadPass = false; 
    1182                     } 
    1183                 } 
    1184             } 
    1185         } 
    1186  
    1187         typedef QList<MythGenericTree *> MGTreeChildList; 
    1188         MGTreeChildList *lchildren = m_d->m_currentNode->getAllChildren(); 
    1189  
    1190         for (MGTreeChildList::const_iterator p = lchildren->begin(); 
    1191                 p != lchildren->end(); ++p) 
    1192         { 
    1193             if (*p != NULL) 
    1194             { 
    1195                 MythUIButtonListItem *item = 
    1196                         new MythUIButtonListItem(m_videoButtonList, QString(), 0, 
    1197                                 true, MythUIButtonListItem::NotChecked); 
    1198  
    1199                 item->SetData(qVariantFromValue(*p)); 
    1200  
    1201                 UpdateItem(item); 
    1202  
    1203                 if (*p == selectedNode) 
    1204                     m_videoButtonList->SetItemCurrent(item); 
    1205             } 
    1206         } 
    12071199    } 
     1200                 
     1201        if (m_d->m_firstLoadPass) 
     1202    { 
     1203        m_d->m_firstLoadPass = false; 
     1204                LoadPosition(false); 
     1205        } 
    12081206 
    12091207    UpdatePosition(); 
    12101208} 
    void VideoDialog::EditMetadata() 
    34403438    if (!metadata) 
    34413439        return; 
    34423440 
     3441        SavePosition(); 
     3442 
    34433443    MythScreenStack *screenStack = GetScreenStack(); 
    34443444 
    34453445    EditMetadataDialog *md_editor = new EditMetadataDialog(screenStack, 
  • mythtv/programs/mythfrontend/videodlg.h

    diff --git a/mythtv/programs/mythfrontend/videodlg.h b/mythtv/programs/mythfrontend/videodlg.h
    index b82fa87..be18fe5 100644
    a b class VideoDialog : public MythScreenType 
    173173    void StartVideoImageSet(VideoMetadata *metadata); 
    174174 
    175175    void SavePosition(void); 
     176        void LoadPosition(bool force); 
    176177 
    177178  private slots: 
    178179