GUI: Add button in ProjectFileDialog to exclude a file

This commit is contained in:
Daniel Marjamäki 2020-07-18 08:56:31 +02:00
parent 744b363186
commit 23008e7bc0
3 changed files with 30 additions and 6 deletions

View File

@ -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<QString,QString> 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);

View File

@ -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.
*/

View File

@ -661,7 +661,14 @@
<item>
<widget class="QPushButton" name="mBtnAddIgnorePath">
<property name="text">
<string>Add...</string>
<string>Add folder...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnAddIgnoreFile">
<property name="text">
<string>Add file...</string>
</property>
</widget>
</item>