diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 9d2c35fc7..6da6335d0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -221,7 +221,7 @@ void MainWindow::DoCheckFiles(const QStringList &files) return; } - mUI.mResults->CheckingStarted(); + mUI.mResults->CheckingStarted(fileNames.count()); mThread->SetFiles(RemoveUnacceptedFiles(fileNames)); QFileInfo inf(fileNames[0]); @@ -386,6 +386,7 @@ QStringList MainWindow::RemoveUnacceptedFiles(const QStringList &list) void MainWindow::CheckDone() { + mUI.mResults->CheckingFinished(); EnableCheckButtons(true); mUI.mActionSettings->setEnabled(true); if (mUI.mResults->HasResults()) diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 6d44e2b05..f0f3e37f2 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -61,48 +61,9 @@ void ResultsView::Clear() mUI.mProgress->setValue(0); } - - -void ResultsView::Progress(int value, int max) +void ResultsView::Progress(int value) { - mUI.mProgress->setMaximum(max); mUI.mProgress->setValue(value); - if (value >= max) - { - mUI.mProgress->setVisible(false); - //Should we inform user of non visible/not found errors? - if (mShowNoErrorsMessage) - { - //Tell user that we found no errors - if (!mErrorsFound) - { - QMessageBox msg(QMessageBox::Information, - tr("Cppcheck"), - tr("No errors found."), - QMessageBox::Ok, - this); - - msg.exec(); - } //If we have errors but they aren't visible, tell user about it - else if (!mUI.mTree->HasVisibleResults()) - { - QString text = tr("Errors were found, but they are configured to be hidden.\n"\ - "To toggle what kind of errors are shown, open view menu."); - QMessageBox msg(QMessageBox::Information, - tr("Cppcheck"), - text, - QMessageBox::Ok, - this); - - msg.exec(); - } - } - } - else - { - mUI.mProgress->setVisible(true); - mUI.mProgress->setEnabled(true); - } } void ResultsView::Error(const QString &file, @@ -194,9 +155,42 @@ void ResultsView::SetCheckDirectory(const QString &dir) mUI.mTree->SetCheckDirectory(dir); } -void ResultsView::CheckingStarted() +void ResultsView::CheckingStarted(int count) { mUI.mProgress->setVisible(true); + mUI.mProgress->setMaximum(count); +} + +void ResultsView::CheckingFinished() +{ + mUI.mProgress->setVisible(false); + //Should we inform user of non visible/not found errors? + if (mShowNoErrorsMessage) + { + //Tell user that we found no errors + if (!mErrorsFound) + { + QMessageBox msg(QMessageBox::Information, + tr("Cppcheck"), + tr("No errors found."), + QMessageBox::Ok, + this); + + msg.exec(); + } //If we have errors but they aren't visible, tell user about it + else if (!mUI.mTree->HasVisibleResults()) + { + QString text = tr("Errors were found, but they are configured to be hidden.\n"\ + "To toggle what kind of errors are shown, open view menu."); + QMessageBox msg(QMessageBox::Information, + tr("Cppcheck"), + text, + QMessageBox::Ok, + this); + + msg.exec(); + } + } } bool ResultsView::HasVisibleResults() const diff --git a/gui/resultsview.h b/gui/resultsview.h index 9c0887915..cb3f4abb1 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -92,9 +92,15 @@ public: /** * @brief Inform the view that checking has started * - * At the moment this only displays the progressbar + * @param count Count of files to be checked. */ - void CheckingStarted(); + void CheckingStarted(int count); + + /** + * @brief Inform the view that checking finished. + * + */ + void CheckingFinished(); /** * @brief Do we have visible results to show? @@ -138,9 +144,8 @@ public slots: * @brief Slot for updating the checking progress * * @param value Current progress value - * @param max Maximum progress value */ - void Progress(int value, int max); + void Progress(int value); /** * @brief Slot for new error to be displayed diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 4d595df95..27c68963a 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -138,8 +138,8 @@ void ThreadHandler::Stop() void ThreadHandler::Initialize(ResultsView *view) { - connect(&mResults, SIGNAL(Progress(int, int)), - view, SLOT(Progress(int, int))); + connect(&mResults, SIGNAL(Progress(int)), + view, SLOT(Progress(int))); connect(&mResults, SIGNAL(Error(const QString &, const QString &, diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index 407387bcc..56ca9ee16 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -40,7 +40,7 @@ void ThreadResult::FileChecked(const QString &file) QMutexLocker locker(&mutex); Q_UNUSED(file); //For later use maybe? mProgress++; - emit Progress(mProgress, mMaxProgress); + emit Progress(mProgress); } void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg) diff --git a/gui/threadresult.h b/gui/threadresult.h index f2712c9c6..c1b1b9a66 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -81,9 +81,8 @@ signals: /** * @brief Progress signal * @param value Current progress - * @param max Maximum progress */ - void Progress(int value, int max); + void Progress(int value); /** * @brief Signal of a new error