Пример #1
0
void MainWindow::CheckCode(const QString& code, const QString& filename)
{
    // Initialize dummy ThreadResult as ErrorLogger
    ThreadResult result;
    result.SetFiles(QStringList(filename));
    connect(&result, SIGNAL(Progress(int, const QString&)),
            mUI.mResults, SLOT(Progress(int, const QString&)));
    connect(&result, SIGNAL(Error(const ErrorItem &)),
            mUI.mResults, SLOT(Error(const ErrorItem &)));
    connect(&result, SIGNAL(Log(const QString &)),
            this, SLOT(Log(const QString &)));
    connect(&result, SIGNAL(DebugError(const ErrorItem &)),
            this, SLOT(DebugError(const ErrorItem &)));

    // Create CppCheck instance
    CppCheck cppcheck(result, true);
    cppcheck.settings() = GetCppcheckSettings();

    // Check
    CheckLockDownUI();
    ClearResults();
    mUI.mResults->CheckingStarted(1);
    cppcheck.check(filename.toStdString(), code.toStdString());
    CheckDone();
}
Пример #2
0
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
    QDialog(parent),
    mUI(new Ui::NewSuppressionDialog)
{
    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("");
}