summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-01-11 08:34:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-18 15:09:38 +0100
commitd6506c129d698c677f2d7418759b147007ca15a2 (patch)
tree524d484b1690384c37ad4a837644af3c3e75d509 /src/plugins/platforms/cocoa
parent7024bc70917b6837e2d1e37b1d52350a28d978c5 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm14
1 files changed, 9 insertions, 5 deletions
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; 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(QCFString::toNSString)(filter)];
- if (filters->at(i).startsWith(selectedFilter))
- [mPopUpButton selectItemAtIndex:i];
}
+ if (filterToUse != -1)
+ [mPopUpButton selectItemAtIndex:filterToUse];
}
}