2018-04-09 06:43:48 +02:00
|
|
|
#include "newsuppressiondialog.h"
|
|
|
|
#include "ui_newsuppressiondialog.h"
|
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
|
|
|
|
|
|
|
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:
|
|
|
|
virtual void reportOut(const std::string &/*outmsg*/) {}
|
|
|
|
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) {
|
|
|
|
errorIds << QString::fromStdString(msg._id);
|
|
|
|
}
|
|
|
|
QStringList errorIds;
|
|
|
|
};
|
|
|
|
|
|
|
|
QErrorLogger errorLogger;
|
|
|
|
CppCheck cppcheck(errorLogger,false);
|
|
|
|
cppcheck.getErrorMessages();
|
|
|
|
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));
|
|
|
|
}
|