diff options
author | Alexis Menard <alexis.menard@trolltech.com> | 2009-04-15 14:30:30 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-04-15 16:14:21 (GMT) |
commit | 50d030e78386c7871a3e15029673db4591c8f8e5 (patch) | |
tree | bc425701e49833b58bddf5622114c3a1e49e9dcd /src/gui/dialogs/qfiledialog.cpp | |
parent | 5e397de5254005f26fb1b26f65e610653d39e9fa (diff) | |
download | Qt-50d030e78386c7871a3e15029673db4591c8f8e5.zip Qt-50d030e78386c7871a3e15029673db4591c8f8e5.tar.gz Qt-50d030e78386c7871a3e15029673db4591c8f8e5.tar.bz2 |
QFileDialog : Fix filters that doesn't work if whitespaces at the end
The fix is basically remove the whitespaces at the end otherwise the
reg exp will be wrong.
Task-number: 240789
Reviewed-by: jasplin
Diffstat (limited to 'src/gui/dialogs/qfiledialog.cpp')
-rw-r--r-- | src/gui/dialogs/qfiledialog.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 5131271..b20321f 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -957,25 +957,29 @@ void QFileDialog::setNameFilters(const QStringList &filters) { Q_D(QFileDialog); d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)"))); - d->nameFilters = filters; + QStringList cleanedFilters; + for (int i = 0; i < filters.count(); ++i) { + cleanedFilters << filters[i].simplified(); + } + d->nameFilters = cleanedFilters; if (d->nativeDialogInUse){ - d->setNameFilters_sys(filters); + d->setNameFilters_sys(cleanedFilters); return; } d->qFileDialogUi->fileTypeCombo->clear(); - if (filters.isEmpty()) + if (cleanedFilters.isEmpty()) return; if (testOption(HideNameFilterDetails)) { QStringList strippedFilters; - for (int i = 0; i < filters.count(); ++i) { - strippedFilters.append(filters[i].mid(0, filters[i].indexOf(QLatin1String(" (")))); + for (int i = 0; i < cleanedFilters.count(); ++i) { + strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" (")))); } d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters); } else { - d->qFileDialogUi->fileTypeCombo->addItems(filters); + d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters); } d->_q_useNameFilter(0); } |