diff options
author | David Boddie <david.boddie@nokia.com> | 2011-02-23 17:38:46 (GMT) |
---|---|---|
committer | David Boddie <david.boddie@nokia.com> | 2011-02-23 17:38:46 (GMT) |
commit | 4501731349406110ecde2d260a8ab1e1bcedf179 (patch) | |
tree | 5ec176e26bbd207741ca40a1704e654c30fb8571 /src/gui/dialogs | |
parent | 3c982b5d214cc7a37ace1d956ac8fb0b9a281722 (diff) | |
parent | 0442b383dced6b5cc31e4fc2bf939e3125354f82 (diff) | |
download | Qt-4501731349406110ecde2d260a8ab1e1bcedf179.zip Qt-4501731349406110ecde2d260a8ab1e1bcedf179.tar.gz Qt-4501731349406110ecde2d260a8ab1e1bcedf179.tar.bz2 |
Merge commit 'refs/merge-requests/1108' of git://gitorious.org/qt/qt into merge-requests/1108
Conflicts:
doc/src/declarative/basictypes.qdoc
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r-- | src/gui/dialogs/qfiledialog_symbian.cpp | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/gui/dialogs/qfiledialog_symbian.cpp index b8ea5e5..ed98950 100644 --- a/src/gui/dialogs/qfiledialog_symbian.cpp +++ b/src/gui/dialogs/qfiledialog_symbian.cpp @@ -54,6 +54,9 @@ QT_BEGIN_NAMESPACE +extern QStringList qt_make_filter_list(const QString &filter); // defined in qfiledialog.cpp +extern QStringList qt_clean_filter_list(const QString &filter); // defined in qfiledialog.cpp + enum DialogMode { DialogOpen, DialogSave, DialogFolder }; #if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3) class CExtensionFilter : public MAknFileFilter @@ -61,56 +64,39 @@ class CExtensionFilter : public MAknFileFilter public: void setFilter(const QString filter) { - filterList.clear(); - if (filter.left(2) == QLatin1String("*.")) { - //Filter has only extensions - filterList << filter.split(QLatin1String(" ")); - return; - } else { - //Extensions are in parenthesis and there may be several filters - QStringList separatedFilters(filter.split(QLatin1String(";;"))); - for (int i = 0; i < separatedFilters.size(); i++) { - if (separatedFilters.at(i).contains(QLatin1String("(*)"))) { - filterList << QLatin1String("(*)"); - return; - } - } - QRegExp rx(QLatin1String("\\(([^\\)]*)\\)")); - int pos = 0; - while ((pos = rx.indexIn(filter, pos)) != -1) { - filterList << rx.cap(1).split(QLatin1String(" ")); - pos += rx.matchedLength(); - } + QStringList unparsedFiltersList = qt_make_filter_list(filter); + QStringList filterList; + filterRxList.clear(); + + foreach (QString unparsedFilter, unparsedFiltersList) { + filterList << qt_clean_filter_list(unparsedFilter); + } + foreach (QString currentFilter, filterList) { + QRegExp filterRx(currentFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + filterRxList << filterRx; } } TBool Accept(const TDesC &/*aDriveAndPath*/, const TEntry &aEntry) const { - if (aEntry.IsDir()) - return ETrue; - //If no filter for files, all can be accepted - if (filterList.isEmpty()) + if (filterRxList.isEmpty()) return ETrue; - if (filterList == QStringList(QLatin1String("(*)"))) + if (aEntry.IsDir()) return ETrue; - for (int i = 0; i < filterList.size(); ++i) { - QString extension = filterList.at(i); - //remove '*' from the beginning of the extension - if (extension.at(0) == QLatin1Char('*')) - extension = extension.mid(1); - + foreach (QRegExp rx, filterRxList) { QString fileName = qt_TDesC2QString(aEntry.iName); - if (fileName.endsWith(extension)) + if (rx.exactMatch(fileName)) return ETrue; } + return EFalse; } private: - QStringList filterList; + QList<QRegExp> filterRxList; }; #endif |