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(); }
void MainWindow::DoCheckFiles(const QStringList &files) { if (files.isEmpty()) { return; } ClearResults(); FileList pathList; pathList.AddPathList(files); if (mProject) pathList.AddIngoreList(mProject->GetProjectFile()->GetIgnoredPaths()); QStringList fileNames = pathList.GetFileList(); mUI.mResults->Clear(); mThread->ClearFiles(); if (fileNames.isEmpty()) { QMessageBox msg(QMessageBox::Warning, tr("Cppcheck"), tr("No suitable files found to check!"), QMessageBox::Ok, this); msg.exec(); return; } mUI.mResults->CheckingStarted(fileNames.count()); mThread->SetFiles(fileNames); QDir inf(mCurrentDirectory); const QString checkPath = inf.canonicalPath(); mSettings->setValue(SETTINGS_CHECK_PATH, checkPath); CheckLockDownUI(); // lock UI while checking mUI.mResults->SetCheckDirectory(checkPath); Settings checkSettings = GetCppcheckSettings(); if (mProject) qDebug() << "Checking project file" << mProject->GetProjectFile()->GetFilename(); mThread->Check(checkSettings, false); }
void MainWindow::DoCheckFiles(const QStringList &files) { if (files.isEmpty()) { return; } ClearResults(); FileList pathList; pathList.AddPathList(files); QStringList fileNames = pathList.GetFileList(); mUI.mResults->Clear(); mThread->ClearFiles(); if (fileNames.isEmpty()) { QMessageBox msg(QMessageBox::Warning, tr("Cppcheck"), tr("No suitable files found to check!"), QMessageBox::Ok, this); msg.exec(); return; } mUI.mResults->CheckingStarted(fileNames.count()); mThread->SetFiles(fileNames); QDir inf(mCurrentDirectory); const QString checkPath = inf.canonicalPath(); mSettings->setValue(SETTINGS_CHECK_PATH, checkPath); EnableCheckButtons(false); mUI.mActionSettings->setEnabled(false); mUI.mActionOpenXML->setEnabled(false); mUI.mResults->SetCheckDirectory(checkPath); Settings checkSettings = GetCppcheckSettings(); EnableProjectActions(false); EnableProjectOpenActions(false); mThread->Check(checkSettings, false); }