From 382cbd618fe4f5093bb1ca3f4fca3bb35614a18d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 9 Mar 2010 11:33:58 +0100 Subject: Carbon: Native filedialog does not apply filters on app-bundles The native file dialog (and finder) handles bundles (like .app) like normal files rather than directories, unless specified otherwise. But since they are directories at the same time, we skip sending them through the name filters. This patch makes sure that we are more consistent on this matter for the carbon port. Task-number: QTBUG-834 Reviewed-by: msorvig --- src/gui/dialogs/qfiledialog_mac.mm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index da8cab5..14a5f15 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -729,6 +729,7 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void NavFileOrFolderInfo *theInfo = static_cast(info); QString file; + QString path; const QtMacFilterName &fn = fileDialogPrivate->filterInfo.filters.at(fileDialogPrivate->filterInfo.currentSelection); if (theItem->descriptorType == typeFSRef) { @@ -736,10 +737,12 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void AEGetDescData(theItem, &ref, sizeof(ref)); UInt8 str_buffer[1024]; FSRefMakePath(&ref, str_buffer, 1024); - file = QString::fromUtf8(reinterpret_cast(str_buffer)); - int slsh = file.lastIndexOf(QLatin1Char('/')); + path = QString::fromUtf8(reinterpret_cast(str_buffer)); + int slsh = path.lastIndexOf(QLatin1Char('/')); if (slsh != -1) - file = file.right(file.length() - slsh - 1); + file = path.right(path.length() - slsh - 1); + else + file = path; } QStringList reg = fn.regexp.split(QLatin1String(";")); for (QStringList::const_iterator it = reg.constBegin(); it != reg.constEnd(); ++it) { @@ -751,7 +754,13 @@ Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void if (rg.exactMatch(file)) return true; } - return (theInfo->isFolder && !file.endsWith(QLatin1String(".app"))); + + if (theInfo->isFolder) { + if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:qt_mac_QStringToNSString(path)]) + return false; + return true; + } + return false; } void QFileDialogPrivate::qt_mac_filedialog_event_proc(const NavEventCallbackMessage msg, -- cgit v0.12