18#include "doubleprogressdialog.h"
19#include "ui_doubleprogressdialog.h"
23DoubleProgressDialog::DoubleProgressDialog(
QWidget *parent) :
29 major =
new ProgressBarControl(ui->majorProgressBar);
30 minor =
new ProgressBarControl(ui->minorProgressBar);
32 setCancelButton(ui->cancelButton);
35DoubleProgressDialog::~DoubleProgressDialog()
40QString DoubleProgressDialog::getStatus() {
41 return ui->progressStatus->text();
44void DoubleProgressDialog::setStatus(
QString msg)
46 ui->progressStatus->setText(msg);
49DoubleProgressDialog::ProgressBarControl::ProgressBarControl(
QProgressBar *b)
54void DoubleProgressDialog::ProgressBarControl::setMin(
float minimum)
57 if(max < min) setMax(min);
58 bar->setMinimum(convertUnits(min));
61void DoubleProgressDialog::ProgressBarControl::setMax(
float maximum)
64 if(min > max) setMin(max);
65 bar->setMaximum(convertUnits(max));
68void DoubleProgressDialog::ProgressBarControl::setValue(
float value)
70 val = qBound(min,
value, max);
71 bar->setValue(convertUnits(val));
74int DoubleProgressDialog::ProgressBarControl::getPrecision()
76 return static_cast<int>(qLn(unitFactor) / qLn(10));
79void DoubleProgressDialog::ProgressBarControl::setPrecision(
int e)
81 int oldFactor = unitFactor;
82 unitFactor =
static_cast<int>(qPow(10, e));
84 min *= unitFactor /
static_cast<float>(oldFactor);
85 max *= unitFactor /
static_cast<float>(oldFactor);
86 val *= unitFactor /
static_cast<float>(oldFactor);
89int DoubleProgressDialog::ProgressBarControl::convertUnits(
float value)
91 return qRound(
value * unitFactor);