From: George Tasker Date: Mon, 29 Jan 2001 23:01:21 +0000 (+0000) Subject: The new SORT parameter for SelectViewType() and SelectDocumentType() sorted the displ... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8658ef93e3d5c6db51d1acb460b16b983774edd5?ds=inline The new SORT parameter for SelectViewType() and SelectDocumentType() sorted the displayed list, but the view/template returned as the one selected was corresponding to the template from the original unsorted list of templates. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 02fdca8fe4..b745d1fbb1 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1441,15 +1441,34 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, wxDocTemplate **data = new wxDocTemplate *[noTemplates]; int i; int n = 0; - for (i = 0; i < noTemplates; i++) - { - if (templates[i]->IsVisible()) - { - strings.Add(templates[i]->m_description); - data[n] = templates[i]; - n ++; - } - } + for (i = 0; i < noTemplates; i++) + { + if (templates[i]->IsVisible()) + { + strings.Add(templates[i]->m_description); + if (!sort) + { + data[n] = templates[i]; + n ++; + } + } + } // for + + if (sort) + { + // Yes, this will be slow, but template lists + // are typically short. + int j; + n = strings.Count(); + for (i = 0; i < n; i++) + { + for (j = 0; j < noTemplates; j++) + { + if (strings[i] == templates[j]->m_description) + data[i] = templates[j]; + } + } + } wxDocTemplate *theTemplate; @@ -1495,11 +1514,30 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, if ( templ->IsVisible() && !templ->GetViewName().empty() ) { strings.Add(templ->m_viewTypeName); - data[n] = templ; - n ++; + if (!sort) + { + data[n] = templ; + n ++; + } } } + if (sort) + { + // Yes, this will be slow, but template lists + // are typically short. + int j; + n = strings.Count(); + for (i = 0; i < n; i++) + { + for (j = 0; j < noTemplates; j++) + { + if (strings[i] == templates[j]->m_viewTypeName) + data[i] = templates[j]; + } + } + } + wxDocTemplate *theTemplate; // the same logic as above