Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions gui/resultsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "applicationlist.h"
#include "checkstatistics.h"

// The maximum value for the progress bar
const int PROGRESS_MAX = 1024;

ResultsView::ResultsView(QWidget * parent) :
QWidget(parent),
mErrorsFound(false),
Expand Down Expand Up @@ -74,13 +77,15 @@ void ResultsView::Clear()
mStatistics->Clear();

//Clear the progressbar
mUI.mProgress->setMaximum(100);
mUI.mProgress->setMaximum(PROGRESS_MAX);
mUI.mProgress->setValue(0);
mUI.mProgress->setFormat(tr("%p%"));
}

void ResultsView::Progress(int value)
void ResultsView::Progress(int value, const QString& description)
{
mUI.mProgress->setValue(value);
mUI.mProgress->setFormat(tr("%p% (%1)").arg(description));
}

void ResultsView::Error(const ErrorItem &item)
Expand Down Expand Up @@ -184,12 +189,16 @@ void ResultsView::SetCheckDirectory(const QString &dir)
void ResultsView::CheckingStarted(int count)
{
mUI.mProgress->setVisible(true);
mUI.mProgress->setMaximum(count);
mUI.mProgress->setMaximum(PROGRESS_MAX);
mUI.mProgress->setValue(0);
mUI.mProgress->setFormat(tr("%p% (%1 of %2 files checked)").arg(0).arg(count));
}

void ResultsView::CheckingFinished()
{
mUI.mProgress->setVisible(false);
mUI.mProgress->setFormat("%p%");

//Should we inform user of non visible/not found errors?
if (mShowNoErrorsMessage)
{
Expand Down
4 changes: 2 additions & 2 deletions gui/resultsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ public slots:
* @brief Slot for updating the checking progress
*
* @param value Current progress value
* @param description Description to accompany the progress
*/
void Progress(int value);
void Progress(int value, const QString& description);

/**
* @brief Slot for new error to be displayed
Expand Down Expand Up @@ -225,7 +226,6 @@ public slots:

CheckStatistics *mStatistics;


private:
};
/// @}
Expand Down
4 changes: 2 additions & 2 deletions gui/threadhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ void ThreadHandler::Stop()
void ThreadHandler::Initialize(ResultsView *view)
{

connect(&mResults, SIGNAL(Progress(int)),
view, SLOT(Progress(int)));
connect(&mResults, SIGNAL(Progress(int, const QString&)),
view, SLOT(Progress(int, const QString&)));

connect(&mResults, SIGNAL(Error(const ErrorItem &)),
view, SLOT(Error(const ErrorItem &)));
Expand Down
35 changes: 29 additions & 6 deletions gui/threadresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include <QFile>
#include <QString>
#include <QMutexLocker>
#include <QList>
Expand All @@ -26,7 +26,10 @@
#include "errorlogger.h"
#include "threadresult.h"

ThreadResult::ThreadResult() : mMaxProgress(0), mProgress(0)
// The maximum value for the progress bar
const double PROGRESS_MAX = 1024.0;

ThreadResult::ThreadResult() : mMaxProgress(0), mProgress(0), mFilesChecked(0), mTotalFiles(0)
{
//ctor
}
Expand All @@ -44,9 +47,17 @@ void ThreadResult::reportOut(const std::string &outmsg)
void ThreadResult::FileChecked(const QString &file)
{
QMutexLocker locker(&mutex);
Q_UNUSED(file); //For later use maybe?
mProgress++;
emit Progress(mProgress);

mProgress += QFile(file).size();
mFilesChecked ++;

if (mMaxProgress > 0)
{
const int value = static_cast<int>(PROGRESS_MAX * mProgress / mMaxProgress);
const QString description = tr("%1 of %2 files checked").arg(mFilesChecked).arg(mTotalFiles);

emit Progress(value, description);
}
}

void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
Expand Down Expand Up @@ -96,13 +107,25 @@ void ThreadResult::SetFiles(const QStringList &files)
QMutexLocker locker(&mutex);
mFiles = files;
mProgress = 0;
mMaxProgress = files.size();
mFilesChecked = 0;
mTotalFiles = files.size();

// Determine the total size of all of the files to check, so that we can
// show an accurate progress estimate
quint64 sizeOfFiles = 0;
foreach(const QString& file, files)
{
sizeOfFiles += QFile(file).size();
}
mMaxProgress = sizeOfFiles;
}

void ThreadResult::ClearFiles()
{
QMutexLocker locker(&mutex);
mFiles.clear();
mFilesChecked = 0;
mTotalFiles = 0;
}

int ThreadResult::GetFileCount()
Expand Down
20 changes: 16 additions & 4 deletions gui/threadresult.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ public slots:
/**
* @brief Progress signal
* @param value Current progress
* @param description Description of the current stage
*/
void Progress(int value);
void Progress(int value, const QString& description);

/**
* @brief Signal of a new error
Expand Down Expand Up @@ -125,14 +126,25 @@ public slots:
* @brief Max progress
*
*/
int mMaxProgress;
quint64 mMaxProgress;

/**
* @brief Current progress
*
*/
int mProgress;
private:
quint64 mProgress;

/**
* @brief Current number of files checked
*
*/
unsigned long mFilesChecked;

/**
* @brief Total number of files
*
*/
unsigned long mTotalFiles;
};
/// @}
#endif // THREADRESULT_H