summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-08-05 11:19:29 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-08-05 11:25:03 (GMT)
commit90480b9a25568858d1383e0aab6f5708a7dabd4f (patch)
treeefeef36bee065dad42df9d0486431058e9816b65
parentcb599c5ea32e8e5ff81318038b432272f107b1fe (diff)
downloadQt-90480b9a25568858d1383e0aab6f5708a7dabd4f.zip
Qt-90480b9a25568858d1383e0aab6f5708a7dabd4f.tar.gz
Qt-90480b9a25568858d1383e0aab6f5708a7dabd4f.tar.bz2
Fix a bug when activating HideNameFilterDetails on Windows filedialog.
The HideNameFilterDetails was not taken in account for windows file dialog. This patch fix that. For Windows Vista and later we use now the new COMMON_ITEM_DIALOG API (in master) where it add always the filter extension like *.txt so no point to take that flag in account. Task-number: None, during testing Reviewed-by: prasanth
-rw-r--r--src/gui/dialogs/qfiledialog.cpp2
-rw-r--r--src/gui/dialogs/qfiledialog_win.cpp28
2 files changed, 19 insertions, 11 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index c8ce162..6977731 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -219,7 +219,7 @@ Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook
the native file dialog is used unless you use a subclass of QFileDialog that contains the
Q_OBJECT macro.
\value ReadOnly Indicates that the model is readonly.
- \value HideNameFilterDetails Indicates if the is hidden or not.
+ \value HideNameFilterDetails Indicates if the filter extension (e.g. *.bmp) is hidden or not.
This value is obsolete and does nothing since Qt 4.5:
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 9a478aa..37a25e5 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -163,15 +163,22 @@ static QStringList qt_win_make_filters_list(const QString &filter)
}
// Makes a NUL-oriented Windows filter from a Qt filter.
-static QString qt_win_filter(const QString &filter)
+static QString qt_win_filter(const QString &filter, bool hideFiltersDetails)
{
QStringList filterLst = qt_win_make_filters_list(filter);
QStringList::Iterator it = filterLst.begin();
QString winfilters;
+ QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
for (; it != filterLst.end(); ++it) {
QString subfilter = *it;
if (!subfilter.isEmpty()) {
- winfilters += subfilter;
+ if (hideFiltersDetails) {
+ int index = r.indexIn(subfilter);
+ if (index >= 0)
+ winfilters += r.cap(1);
+ } else {
+ winfilters += subfilter;
+ }
winfilters += QChar();
winfilters += qt_win_extract_filter(subfilter);
winfilters += QChar();
@@ -377,11 +384,12 @@ QString qt_win_get_open_file_name(const QFileDialogArgs &args,
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
+ bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
QT_WA({
// Use Unicode strings and API
OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFile,
args.options);
if (idx)
@@ -395,7 +403,7 @@ QString qt_win_get_open_file_name(const QFileDialogArgs &args,
// Use ANSI strings and API
OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFile,
args.options);
if (idx)
@@ -452,7 +460,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
-
+ bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
// This block is used below for the lpstrDefExt member.
// Note that the current MSDN docs document this member wrong.
// It should rather be documented as "the default extension if no extension was given and if the
@@ -469,12 +477,11 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
defaultSaveExt.clear();
}
}
-
QT_WA({
// Use Unicode strings and API
OPENFILENAME *ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::AnyFile,
args.options);
@@ -491,7 +498,7 @@ QString qt_win_get_save_file_name(const QFileDialogArgs &args,
// Use ANSI strings and API
OPENFILENAMEA *ofn = qt_win_make_OFNA(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::AnyFile,
args.options);
QByteArray asciiExt = defaultSaveExt.toAscii();
@@ -558,10 +565,11 @@ QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(args.parent, Qt::Window);
QApplicationPrivate::enterModal(&modal_widget);
+ bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails;
QT_WA({
OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFiles,
args.options);
if (idx)
@@ -594,7 +602,7 @@ QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
} , {
OPENFILENAMEA* ofn = qt_win_make_OFNA(args.parent, args.selection,
args.directory, args.caption,
- qt_win_filter(args.filter),
+ qt_win_filter(args.filter, hideFiltersDetails),
QFileDialog::ExistingFiles,
args.options);
if (idx)