From d6506c129d698c677f2d7418759b147007ca15a2 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 --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 22fbf80bfe..7992461032 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -493,14 +493,18 @@ static QString strippedText(QString s) [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(QCFString::toNSString)(filter)]; - if (filters->at(i).startsWith(selectedFilter)) - [mPopUpButton selectItemAtIndex:i]; } + if (filterToUse != -1) + [mPopUpButton selectItemAtIndex:filterToUse]; } } -- cgit v1.2.3