From 09d9cfdecea261176f9bc8133cdb498b456f0294 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 11 Jan 2013 08:34:20 +0100 Subject: Make sure the correct name filter is selected in the Mac file dialog Since we have to add the filters one by one to the Mac file dialog it was finding the one that would match the filter by comparing the start of the filter string. However it would continue to check the start of other filters even if it had already found the one it should be using. Now it uses either an exact match or the first one that it matches the start of. Change-Id: Ie6441acd48e45ec9c712afc12a2ea47755835bb3 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit d6506c129d698c677f2d7418759b147007ca15a2) --- src/gui/dialogs/qfiledialog_mac.mm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 982d5e6..4c1c74b 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -507,14 +507,18 @@ QT_USE_NAMESPACE [mPopUpButton setTarget:self]; [mPopUpButton setAction:@selector(filterChanged:)]; - QStringList *filters = mNameFilterDropDownList; - if (filters->size() > 0){ + if (mNameFilterDropDownList->size() > 0) { + int filterToUse = -1; for (int i=0; isize(); ++i) { - QString filter = hideDetails ? [self removeExtensions:filters->at(i)] : filters->at(i); + QString currentFilter = mNameFilterDropDownList->at(i); + if (selectedFilter == currentFilter || + (filterToUse == -1 && currentFilter.startsWith(selectedFilter))) + filterToUse = i; + QString filter = hideDetails ? [self removeExtensions:currentFilter] : currentFilter; [mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(filter)]; - if (filters->at(i).startsWith(selectedFilter)) - [mPopUpButton selectItemAtIndex:i]; } + if (filterToUse != -1) + [mPopUpButton selectItemAtIndex:filterToUse]; } } -- cgit v0.12