GUI: Cleanup NewSuppressionDialog interface

This commit is contained in:
Daniel Marjamäki 2018-04-13 17:24:58 +02:00
parent 3a52f217d3
commit ff2c376fe8
3 changed files with 21 additions and 25 deletions

View File

@ -1,11 +1,32 @@
#include "newsuppressiondialog.h" #include "newsuppressiondialog.h"
#include "ui_newsuppressiondialog.h" #include "ui_newsuppressiondialog.h"
#include "cppcheck.h"
#include "errorlogger.h"
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) : NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
mUI(new Ui::NewSuppressionDialog) mUI(new Ui::NewSuppressionDialog)
{ {
mUI->setupUi(this); mUI->setupUi(this);
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("");
} }
NewSuppressionDialog::~NewSuppressionDialog() NewSuppressionDialog::~NewSuppressionDialog()
@ -13,13 +34,6 @@ NewSuppressionDialog::~NewSuppressionDialog()
delete mUI; delete mUI;
} }
void NewSuppressionDialog::setErrorIds(const QStringList &errorIds)
{
mUI->mComboErrorId->addItems(errorIds);
mUI->mComboErrorId->setCurrentIndex(-1);
mUI->mComboErrorId->setCurrentText("");
}
Suppressions::Suppression NewSuppressionDialog::getSuppression() const Suppressions::Suppression NewSuppressionDialog::getSuppression() const
{ {
Suppressions::Suppression ret; Suppressions::Suppression ret;

View File

@ -15,7 +15,6 @@ public:
explicit NewSuppressionDialog(QWidget *parent = 0); explicit NewSuppressionDialog(QWidget *parent = 0);
~NewSuppressionDialog(); ~NewSuppressionDialog();
void setErrorIds(const QStringList &errorIds);
Suppressions::Suppression getSuppression() const; Suppressions::Suppression getSuppression() const;
private: private:

View File

@ -32,8 +32,6 @@
#include "checkthread.h" #include "checkthread.h"
#include "projectfile.h" #include "projectfile.h"
#include "library.h" #include "library.h"
#include "cppcheck.h"
#include "errorlogger.h"
#include "platforms.h" #include "platforms.h"
/** Platforms shown in the platform combobox */ /** Platforms shown in the platform combobox */
@ -638,22 +636,7 @@ void ProjectFileDialog::moveIncludePathDown()
void ProjectFileDialog::addSuppression() void ProjectFileDialog::addSuppression()
{ {
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();
NewSuppressionDialog dlg; NewSuppressionDialog dlg;
dlg.setErrorIds(errorLogger.errorIds);
if (dlg.exec() == QDialog::Accepted) { if (dlg.exec() == QDialog::Accepted) {
setSuppressions(mSuppressions << dlg.getSuppression()); setSuppressions(mSuppressions << dlg.getSuppression());
} }