56 #include <QProgressDialog> 92 Progress(
double maxProgress = 1.0) : parent(0), maxProgress(maxProgress), currentProgress(0.0), dialog_padding(0)
95 if (parent) parent->childGoesBye(
this);
98 void setMaxProgress(
double value) {
100 if (currentProgress != 0.0) progressChanged();
104 void connectToDialog(QProgressDialog *dlg) {
106 dialog->setMaximum(100000);
115 return getProgress() / maxProgress;
118 double getProgress()
const {
119 double result = currentProgress;
124 for (std::set<ChildRecord>::const_iterator it = children.begin(); it != children.end(); ++it) {
125 result += it->child->getNormalizedProgress() * it->contribution;
128 return std::min(maxProgress, result);
135 progress->parent =
this;
140 children.insert(
ChildRecord(progress, contribution));
143 void increment(
double amount) {
144 currentProgress += amount;
153 inline void progressChanged() {
154 if (parent) parent->onChildProgress(
this);
158 inline void updateDialog() {
165 inline void childGoesBye(
Progress *child) {
169 std::set<ChildRecord>::iterator it = children.find(
ChildRecord(child, 0));
170 currentProgress += it->contribution;
180 ChildRecord(
Progress *child,
double contribution) : child(child), contribution(contribution) {}
182 bool operator==(
const ChildRecord &rhs)
const {
return child == rhs.child; }
183 bool operator<(
const ChildRecord &rhs)
const {
return child < rhs.child; }
188 std::set<ChildRecord> children;
190 double maxProgress, currentProgress;
194 QProgressDialog *dialog;
200 void *dialog_padding;
void addSubProgress(Progress *progress, double contribution)
Namespace providing different geometric functions concerning angles.
double getNormalizedProgress() const