Create a simpler task system for handling sub tasks in progress dialog.

* Remove incrementProgressAndUpdateNextStep() method
This commit is contained in:
Gaute Lindkvist
2019-03-12 11:01:49 +01:00
parent 674758fbf6
commit 749e19a879
3 changed files with 68 additions and 40 deletions

View File

@@ -50,6 +50,18 @@
namespace caf {
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ProgressTask::ProgressTask(ProgressInfo& parentTask)
: m_parentTask(parentTask)
{
}
ProgressTask::~ProgressTask()
{
m_parentTask.incrementProgress();
}
//==================================================================================================
///
/// \class caf::ProgressInfo
@@ -152,16 +164,6 @@ namespace caf {
ProgressInfoStatic::incrementProgress();
}
//--------------------------------------------------------------------------------------------------
/// Convenience method for incrementing progress and setting step size and description for next step
//--------------------------------------------------------------------------------------------------
void ProgressInfo::incrementProgressAndUpdateNextStep(size_t nextStepSize, const QString& nextDescription)
{
incrementProgress();
setNextProgressIncrement(nextStepSize);
setProgressDescription(nextDescription);
}
//--------------------------------------------------------------------------------------------------
/// To make a certain operation span more of the progress bar than one tick,
/// set the number of progress ticks that you want it to use before calling it.
@@ -176,15 +178,18 @@ namespace caf {
//--------------------------------------------------------------------------------------------------
void ProgressInfo::setNextProgressIncrement(size_t nextStepSize)
{
ProgressInfoStatic::setNextProgressIncrement(nextStepSize);
ProgressInfoStatic::setNextProgressIncrement(nextStepSize);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::ProgressTask ProgressInfo::task(const QString& description, int stepSize)
{
setProgressDescription(description);
setNextProgressIncrement(stepSize);
return caf::ProgressTask(*this);
}
//==================================================================================================
///
@@ -631,6 +636,4 @@ namespace caf {
//if (progressDialog()) progressDialog()->repaint();
}
}
} // namespace caf

View File

@@ -43,6 +43,17 @@ class QString;
namespace caf {
class ProgressInfo;
class ProgressTask
{
public:
ProgressTask(ProgressInfo& parentTask);
~ProgressTask();
private:
ProgressInfo& m_parentTask;
};
class ProgressInfo
{
public:
@@ -52,9 +63,10 @@ public:
void setProgressDescription(const QString& description);
void setProgress(size_t progressValue);
void incrementProgress();
void incrementProgressAndUpdateNextStep(size_t nextStepSize, const QString& nextDescription);
void setNextProgressIncrement(size_t nextStepSize);
ProgressTask task(const QString& description, int stepSize);
};