summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qfiledialog.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-01-06 13:31:34 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-01-06 13:34:56 (GMT)
commit0de487a10f3a54c46f30042b96c321f982e01a90 (patch)
tree00352de4bdd56ad903a9333164536bc2823cf16e /src/gui/dialogs/qfiledialog.cpp
parent59a2ed52a780afea84c118054fb7de2440a5d17f (diff)
downloadQt-0de487a10f3a54c46f30042b96c321f982e01a90.zip
Qt-0de487a10f3a54c46f30042b96c321f982e01a90.tar.gz
Qt-0de487a10f3a54c46f30042b96c321f982e01a90.tar.bz2
Fix default filter selection when using HideNameFilterDetails option.
When you have HideNameFilterDetails on, comparing the default filter given in parameter for selectNameFilter has to be done with the striped version of the filter, i.e. without the details. Task-number:QTBUG-4842 Reviewed-by:gabriel Reviewed-by:olivier
Diffstat (limited to 'src/gui/dialogs/qfiledialog.cpp')
-rw-r--r--src/gui/dialogs/qfiledialog.cpp43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index d952c34..3c388de 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -998,6 +998,24 @@ bool QFileDialog::isNameFilterDetailsVisible() const
}
+/*
+ Strip the filters by removing the details, e.g. (*.*).
+*/
+QStringList qt_strip_filters(const QStringList &filters)
+{
+ QStringList strippedFilters;
+ QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
+ for (int i = 0; i < filters.count(); ++i) {
+ QString filterName;
+ int index = r.indexIn(filters[i]);
+ if (index >= 0)
+ filterName = r.cap(1);
+ strippedFilters.append(filterName.simplified());
+ }
+ return strippedFilters;
+}
+
+
/*!
\since 4.4
@@ -1024,20 +1042,11 @@ void QFileDialog::setNameFilters(const QStringList &filters)
if (cleanedFilters.isEmpty())
return;
- if (testOption(HideNameFilterDetails)) {
- QStringList strippedFilters;
- QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
- for (int i = 0; i < cleanedFilters.count(); ++i) {
- QString filterName;
- int index = r.indexIn(cleanedFilters[i]);
- if (index >= 0)
- filterName = r.cap(1);
- strippedFilters.append(filterName.simplified());
- }
- d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
- } else {
+ if (testOption(HideNameFilterDetails))
+ d->qFileDialogUi->fileTypeCombo->addItems(qt_strip_filters(cleanedFilters));
+ else
d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
- }
+
d->_q_useNameFilter(0);
}
@@ -1088,8 +1097,12 @@ void QFileDialog::selectNameFilter(const QString &filter)
d->selectNameFilter_sys(filter);
return;
}
-
- int i = d->qFileDialogUi->fileTypeCombo->findText(filter);
+ int i;
+ if (testOption(HideNameFilterDetails)) {
+ i = d->qFileDialogUi->fileTypeCombo->findText(qt_strip_filters(qt_make_filter_list(filter)).first());
+ } else {
+ i = d->qFileDialogUi->fileTypeCombo->findText(filter);
+ }
if (i >= 0) {
d->qFileDialogUi->fileTypeCombo->setCurrentIndex(i);
d->_q_useNameFilter(d->qFileDialogUi->fileTypeCombo->currentIndex());