From e1342435ca888006feb1b06e5672e84f2b062c89 Mon Sep 17 00:00:00 2001 From: Aleksandr Pikalev Date: Sun, 18 Oct 2015 18:19:05 +0300 Subject: [PATCH] Fixed #7063 (GUI: better extensions filtering) Make filtering case insensitive to let check *.C, *.CPP, etc files. Show in file open dialog only files that could be checked. --- gui/filelist.cpp | 2 +- gui/filelist.h | 4 ++-- gui/mainwindow.cpp | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gui/filelist.cpp b/gui/filelist.cpp index 3f3496b5a..d281f8e07 100644 --- a/gui/filelist.cpp +++ b/gui/filelist.cpp @@ -35,7 +35,7 @@ bool FileList::FilterMatches(const QFileInfo &inf) const QStringList filters = FileList::GetDefaultFilters(); QString ext("*."); ext += inf.suffix(); - if (filters.contains(ext)) + if (filters.contains(ext, Qt::CaseInsensitive)) return true; } return false; diff --git a/gui/filelist.h b/gui/filelist.h index 9f085e883..284a62c80 100644 --- a/gui/filelist.h +++ b/gui/filelist.h @@ -68,14 +68,14 @@ public: */ void AddExcludeList(const QStringList &paths); -protected: - /** * @brief Return list of default filename extensions included. * @return list of default filename extensions included. */ static QStringList GetDefaultFilters(); +protected: + /** * @brief Test if filename matches the filename extensions filtering. * @return true if filename matches filtering. diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7ac7c23d2..9048b1997 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -435,9 +435,11 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode) // QFileDialog::getExistingDirectory() because they show native Windows // selection dialog which is a lot more usable than Qt:s own dialog. if (mode == QFileDialog::ExistingFiles) { + selected = QFileDialog::getOpenFileNames(this, tr("Select files to check"), - GetPath(SETTINGS_LAST_CHECK_PATH)); + GetPath(SETTINGS_LAST_CHECK_PATH), + tr("C/C++ Source (%1)").arg(FileList::GetDefaultFilters().join(" "))); if (selected.isEmpty()) mCurrentDirectory.clear(); else {