diff options
author | Andy Shaw <andy.shaw@digia.com> | 2013-01-11 07:34:20 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-30 12:43:26 (GMT) |
commit | 09d9cfdecea261176f9bc8133cdb498b456f0294 (patch) | |
tree | 8b7d21253fa46b44c1e59cc8c7e8171c2bcfdbc7 /src/gui | |
parent | 55b37f8d4a85c926dab69e4bca0add3295e1c259 (diff) | |
download | Qt-09d9cfdecea261176f9bc8133cdb498b456f0294.zip Qt-09d9cfdecea261176f9bc8133cdb498b456f0294.tar.gz Qt-09d9cfdecea261176f9bc8133cdb498b456f0294.tar.bz2 |
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 <richard.gustavsen@digia.com>
(cherry picked from commit d6506c129d698c677f2d7418759b147007ca15a2)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qfiledialog_mac.mm | 14 |
1 files 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; i<mNameFilterDropDownList->size(); ++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]; } } |