From 23008e7bc0cae23b93269f782a4c7a15772e3c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 18 Jul 2020 08:56:31 +0200 Subject: [PATCH] GUI: Add button in ProjectFileDialog to exclude a file --- gui/projectfiledialog.cpp | 20 ++++++++++++++++---- gui/projectfiledialog.h | 7 ++++++- gui/projectfiledialog.ui | 9 ++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 52ce8c61e..70452845a 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -199,6 +199,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent) connect(mUI.mBtnEditInclude, &QPushButton::clicked, this, &ProjectFileDialog::editIncludeDir); connect(mUI.mBtnRemoveInclude, &QPushButton::clicked, this, &ProjectFileDialog::removeIncludeDir); connect(mUI.mBtnAddIgnorePath, SIGNAL(clicked()), this, SLOT(addExcludePath())); + connect(mUI.mBtnAddIgnoreFile, SIGNAL(clicked()), this, SLOT(addExcludeFile())); connect(mUI.mBtnEditIgnorePath, &QPushButton::clicked, this, &ProjectFileDialog::editExcludePath); connect(mUI.mBtnRemoveIgnorePath, &QPushButton::clicked, this, &ProjectFileDialog::removeExcludePath); connect(mUI.mBtnIncludeUp, &QPushButton::clicked, this, &ProjectFileDialog::moveIncludePathUp); @@ -718,9 +719,17 @@ void ProjectFileDialog::editIncludeDir() void ProjectFileDialog::addExcludePath() { - QString dir = getExistingDirectory(tr("Select directory to ignore"), true); - if (!dir.isEmpty()) - addExcludePath(dir); + addExcludePath(getExistingDirectory(tr("Select directory to ignore"), true)); +} + +void ProjectFileDialog::addExcludeFile() +{ + const QFileInfo inf(mProjectFile->getFilename()); + const QDir &dir = inf.absoluteDir(); + QMap filters; + filters[tr("Source files")] = "*.c *.cpp"; + filters[tr("All files")] = "*.*"; + addExcludePath(QFileDialog::getOpenFileName(this, tr("Exclude file"), dir.canonicalPath(), toFilterString(filters))); } void ProjectFileDialog::editExcludePath() @@ -803,7 +812,10 @@ int ProjectFileDialog::getSuppressionIndex(const QString &shortText) const void ProjectFileDialog::browseMisraFile() { - const QString fileName = QFileDialog::getOpenFileName(this, tr("Select MISRA rule texts file"), QDir::homePath(), tr("Misra rule texts file (%1)").arg("*.txt")); + const QString fileName = QFileDialog::getOpenFileName(this, + tr("Select MISRA rule texts file"), + QDir::homePath(), + tr("Misra rule texts file (%1)").arg("*.txt")); if (!fileName.isEmpty()) { QSettings settings; mUI.mEditMisraFile->setText(fileName); diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h index 30237a370..fef320a4f 100644 --- a/gui/projectfiledialog.h +++ b/gui/projectfiledialog.h @@ -215,10 +215,15 @@ protected slots: void editIncludeDir(); /** - * @brief Add new path to exclude. + * @brief Add new path to exclude list. */ void addExcludePath(); + /** + * @brief Add new file to exclude list. + */ + void addExcludeFile(); + /** * @brief Edit excluded path in the list. */ diff --git a/gui/projectfiledialog.ui b/gui/projectfiledialog.ui index d809dd894..4ba8af1aa 100644 --- a/gui/projectfiledialog.ui +++ b/gui/projectfiledialog.ui @@ -661,7 +661,14 @@ - Add... + Add folder... + + + + + + + Add file...