diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7b0d00f10..c27b019ad 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -30,13 +30,17 @@ MainWindow::MainWindow() : mSettings(tr("CppCheck"), tr("CppCheck-GUI")), mActionExit(tr("E&xit"), this), mActionCheckFiles(tr("&Check files(s)"), this), - mActionCheckDirectory(tr("&Check directory"), this), + mActionClearResults(tr("Clear &results"), this), + mActionReCheck(tr("Recheck files"), this), + mActionCheckDirectory(tr("Check &directory"), this), mActionSettings(tr("&Settings"), this), mResults(mSettings) { QMenu *menu = menuBar()->addMenu(tr("&File")); menu->addAction(&mActionCheckFiles); menu->addAction(&mActionCheckDirectory); + menu->addAction(&mActionReCheck); + menu->addAction(&mActionClearResults); menu->addSeparator(); menu->addAction(&mActionExit); @@ -50,6 +54,8 @@ MainWindow::MainWindow() : connect(&mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(&mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(&mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); + connect(&mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); + connect(&mActionReCheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(&mThread, SIGNAL(Done()), this, SLOT(CheckDone())); LoadSettings(); mThread.Initialize(&mResults); @@ -102,8 +108,8 @@ void MainWindow::DoCheckFiles(QFileDialog::FileMode mode) mThread.ClearFiles(); mThread.SetFiles(RemoveUnacceptedFiles(fileNames)); mSettings.setValue(tr("Check path"), dialog.directory().absolutePath()); - mActionCheckFiles.setDisabled(true); - mThread.Check(GetCppCheckSettings()); + EnableCheckButtons(false); + mThread.Check(GetCppCheckSettings(),false); } } @@ -125,7 +131,7 @@ Settings MainWindow::GetCppCheckSettings() result._checkCodingStyle = true; result._errorsOnly = false; result._verbose = true; - result._force = true; + result._force = mSettings.value(tr("Check force"), 1).toBool(); result._xml = false; result._unusedFunctions = true; result._security = true; @@ -186,7 +192,7 @@ QStringList MainWindow::RemoveUnacceptedFiles(const QStringList &list) void MainWindow::CheckDone() { - mActionCheckFiles.setDisabled(false); + EnableCheckButtons(true); } void MainWindow::ProgramSettings() @@ -198,3 +204,23 @@ void MainWindow::ProgramSettings() } } + +void MainWindow::ReCheck() +{ + ClearResults(); + EnableCheckButtons(false); + mThread.Check(GetCppCheckSettings(),true); +} + +void MainWindow::ClearResults() +{ + mResults.Clear(); +} + +void MainWindow::EnableCheckButtons(bool enable) +{ + mActionCheckFiles.setEnabled(enable); + mActionReCheck.setEnabled(enable); + mActionCheckDirectory.setEnabled(enable); +} + diff --git a/gui/mainwindow.h b/gui/mainwindow.h index b0ccb5fcc..c735fd0f5 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -49,6 +49,8 @@ public slots: * */ void CheckFiles(); + void ReCheck(); + void ClearResults(); /** * @brief Slot for check directory menu item @@ -66,6 +68,7 @@ protected slots: */ void CheckDone(); protected: + void EnableCheckButtons(bool enable); void DoCheckFiles(QFileDialog::FileMode mode); QStringList GetFilesRecursively(const QString &path); QStringList RemoveDuplicates(const QStringList &list); @@ -102,6 +105,19 @@ protected: */ QAction mActionCheckFiles; + /** + * @brief Menu action to clear results + * + */ + QAction mActionClearResults; + + /** + * @brief Menu action to re check + * + */ + QAction mActionReCheck; + + /** * @brief Menu action to check a directory * diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 4b55c58c3..716378072 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -72,15 +72,11 @@ void ResultsTree::AddErrorItem(const QString &file, mModel.appendRow(fileitem); } - //qDebug() << "Adding error for file" << realfile << ". Message is" << message; - QList list; list << CreateItem(severity); list << CreateItem(QString("%1").arg(lines[0])); list << CreateItem(message); fileitem->appendRow(list); - - //qDebug()<<"\n"; } QStandardItem *ResultsTree::FindFileItem(const QString &name) diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index eed089cdf..396608d13 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -33,22 +33,23 @@ ThreadHandler::~ThreadHandler() void ThreadHandler::ClearFiles() { + mLastFiles.clear(); mResults.ClearFiles(); } void ThreadHandler::SetFiles(const QStringList &files) { mResults.SetFiles(files); + mLastFiles = files; QString file; - qDebug() << "Files to check:"; - foreach(file, files) - { - qDebug() << file; - } } -void ThreadHandler::Check(Settings settings) +void ThreadHandler::Check(Settings settings, bool recheck) { + if (recheck && mRunningThreadCount == 0) { + mResults.SetFiles(mLastFiles); + } + if (mResults.GetFileCount() == 0 || mRunningThreadCount > 0 || settings._jobs <= 0) { qDebug() << "Can't start checking if there's no files to check or if check is in progress."; @@ -126,8 +127,6 @@ void ThreadHandler::Stop() { mThreads[i]->terminate(); } - - mResults.ClearFiles(); } void ThreadHandler::Initialize(ResultsView *view) diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 4a704f300..fb0fb89c6 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -57,7 +57,7 @@ public: */ void SetFiles(const QStringList &files); - void Check(Settings settings); + void Check(Settings settings, bool recheck); signals: @@ -66,6 +66,7 @@ protected slots: void Stop(); void ThreadDone(); protected: + QStringList mLastFiles; void RemoveThreads(); ThreadResult mResults; QList mThreads;