2022-01-28 15:56:11 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2023-01-28 10:16:34 +01:00
|
|
|
* Copyright (C) 2007-2023 Cppcheck team.
|
2022-01-28 15:56:11 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-04-09 06:43:48 +02:00
|
|
|
#include "newsuppressiondialog.h"
|
2022-02-02 16:17:28 +01:00
|
|
|
|
2018-04-13 17:24:58 +02:00
|
|
|
#include "cppcheck.h"
|
|
|
|
#include "errorlogger.h"
|
2019-04-18 09:52:29 +02:00
|
|
|
#include "suppressions.h"
|
2018-04-09 06:43:48 +02:00
|
|
|
|
2022-03-19 19:54:20 +01:00
|
|
|
#include "ui_newsuppressiondialog.h"
|
|
|
|
|
2022-04-13 12:24:00 +02:00
|
|
|
#include <string>
|
|
|
|
|
2023-04-08 16:08:47 +02:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2022-04-13 12:24:00 +02:00
|
|
|
class QWidget;
|
2023-04-08 16:08:47 +02:00
|
|
|
enum class Color;
|
2022-04-13 12:24:00 +02:00
|
|
|
|
2018-04-09 06:43:48 +02:00
|
|
|
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
mUI(new Ui::NewSuppressionDialog)
|
|
|
|
{
|
|
|
|
mUI->setupUi(this);
|
2018-04-13 17:24:58 +02:00
|
|
|
|
|
|
|
class QErrorLogger : public ErrorLogger {
|
|
|
|
public:
|
2022-09-27 20:03:25 +02:00
|
|
|
void reportOut(const std::string & /*outmsg*/, Color /*c*/) override {}
|
2020-05-23 07:16:49 +02:00
|
|
|
void reportErr(const ErrorMessage &msg) override {
|
2019-08-18 12:19:05 +02:00
|
|
|
errorIds << QString::fromStdString(msg.id);
|
2018-04-13 17:24:58 +02:00
|
|
|
}
|
|
|
|
QStringList errorIds;
|
|
|
|
};
|
|
|
|
|
|
|
|
QErrorLogger errorLogger;
|
2023-04-16 13:54:21 +02:00
|
|
|
CppCheck::getErrorMessages(errorLogger);
|
2018-04-13 17:24:58 +02:00
|
|
|
errorLogger.errorIds.sort();
|
|
|
|
|
|
|
|
mUI->mComboErrorId->addItems(errorLogger.errorIds);
|
|
|
|
mUI->mComboErrorId->setCurrentIndex(-1);
|
|
|
|
mUI->mComboErrorId->setCurrentText("");
|
2018-04-09 06:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NewSuppressionDialog::~NewSuppressionDialog()
|
|
|
|
{
|
|
|
|
delete mUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
Suppressions::Suppression NewSuppressionDialog::getSuppression() const
|
|
|
|
{
|
|
|
|
Suppressions::Suppression ret;
|
|
|
|
ret.errorId = mUI->mComboErrorId->currentText().toStdString();
|
2018-07-01 14:24:37 +02:00
|
|
|
if (ret.errorId.empty())
|
|
|
|
ret.errorId = "*";
|
2018-04-09 06:43:48 +02:00
|
|
|
ret.fileName = mUI->mTextFileName->text().toStdString();
|
2019-04-18 09:52:29 +02:00
|
|
|
if (!mUI->mTextLineNumber->text().isEmpty())
|
|
|
|
ret.lineNumber = mUI->mTextLineNumber->text().toInt();
|
2018-04-09 06:43:48 +02:00
|
|
|
ret.symbolName = mUI->mTextSymbolName->text().toStdString();
|
|
|
|
return ret;
|
|
|
|
}
|
2018-08-09 06:50:35 +02:00
|
|
|
|
|
|
|
void NewSuppressionDialog::setSuppression(const Suppressions::Suppression &suppression)
|
|
|
|
{
|
|
|
|
setWindowTitle(tr("Edit suppression"));
|
|
|
|
mUI->mComboErrorId->setCurrentText(QString::fromStdString(suppression.errorId));
|
|
|
|
mUI->mTextFileName->setText(QString::fromStdString(suppression.fileName));
|
|
|
|
mUI->mTextLineNumber->setText(suppression.lineNumber > 0 ? QString::number(suppression.lineNumber) : QString());
|
|
|
|
mUI->mTextSymbolName->setText(QString::fromStdString(suppression.symbolName));
|
|
|
|
}
|