"Fossies" - the Fresh Open Source Software Archive

Member "cppcheck-1.89/gui/newsuppressiondialog.cpp" (1 Sep 2019, 1933 Bytes) of package /windows/misc/cppcheck-1.89.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "newsuppressiondialog.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.88_vs_1.89.

    1 #include "newsuppressiondialog.h"
    2 #include "ui_newsuppressiondialog.h"
    3 #include "cppcheck.h"
    4 #include "errorlogger.h"
    5 #include "suppressions.h"
    6 
    7 NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
    8     QDialog(parent),
    9     mUI(new Ui::NewSuppressionDialog)
   10 {
   11     mUI->setupUi(this);
   12 
   13     class QErrorLogger : public ErrorLogger {
   14     public:
   15         virtual void reportOut(const std::string &/*outmsg*/) {}
   16         virtual void reportErr(const ErrorLogger::ErrorMessage &msg) {
   17             errorIds << QString::fromStdString(msg.id);
   18         }
   19         QStringList errorIds;
   20     };
   21 
   22     QErrorLogger errorLogger;
   23     CppCheck cppcheck(errorLogger,false);
   24     cppcheck.getErrorMessages();
   25     errorLogger.errorIds.sort();
   26 
   27     mUI->mComboErrorId->addItems(errorLogger.errorIds);
   28     mUI->mComboErrorId->setCurrentIndex(-1);
   29     mUI->mComboErrorId->setCurrentText("");
   30 }
   31 
   32 NewSuppressionDialog::~NewSuppressionDialog()
   33 {
   34     delete mUI;
   35 }
   36 
   37 Suppressions::Suppression NewSuppressionDialog::getSuppression() const
   38 {
   39     Suppressions::Suppression ret;
   40     ret.errorId = mUI->mComboErrorId->currentText().toStdString();
   41     if (ret.errorId.empty())
   42         ret.errorId = "*";
   43     ret.fileName = mUI->mTextFileName->text().toStdString();
   44     if (!mUI->mTextLineNumber->text().isEmpty())
   45         ret.lineNumber = mUI->mTextLineNumber->text().toInt();
   46     ret.symbolName = mUI->mTextSymbolName->text().toStdString();
   47     return ret;
   48 }
   49 
   50 void NewSuppressionDialog::setSuppression(const Suppressions::Suppression &suppression)
   51 {
   52     setWindowTitle(tr("Edit suppression"));
   53     mUI->mComboErrorId->setCurrentText(QString::fromStdString(suppression.errorId));
   54     mUI->mTextFileName->setText(QString::fromStdString(suppression.fileName));
   55     mUI->mTextLineNumber->setText(suppression.lineNumber > 0 ? QString::number(suppression.lineNumber) : QString());
   56     mUI->mTextSymbolName->setText(QString::fromStdString(suppression.symbolName));
   57 }