void CompositeProgressWidget::display(OperationList operations) { QString status; int now = 0; int max = 0; int noProgressData=0; switch (operations.count()) { case 0: { status = i18nc("The operation has completed", "Finished"); now=max=1; } break; case 1: { QPointer<Operation> op = operations.at(0); if (!op) break;; status = op->name(); now = op->currentProgress(); max = op->maxProgress(); } break; default: { now = max =0; foreach (QPointer<Operation> op, operations) { if (!op) continue; status += op->name()+", "; if (op->maxProgress() != 0) { now += op->currentProgress(); max += op->maxProgress(); } else { noProgressData++; } } //get rid of last ", " status = status.left(status.count()-2); if (noProgressData != 0) { //there are processes without progress data if (operations.count() == noProgressData) { now=max=0; } else { int averageMax = max / (operations.count() - noProgressData); max += (averageMax*noProgressData); } } } } foreach (ProgressWidget *widget, progressWidgets) { if ((!widget->operation()) || (!operations.contains(widget->operation()))) { popupWidget->layout()->removeWidget(widget); progressWidgets.removeAll(widget); widget->deleteLater(); } else { operations.removeAll(widget->operation()); widget->update(); } } foreach (QPointer<Operation> op, operations) { if (!op) continue; ProgressWidget *widget = new ProgressWidget(op, ProgressWidget::Compact, designatedParent); popupWidget->layout()->addWidget(widget); progressWidgets << widget; } if (progressWidgets.count() > 0) { togglePopup->setEnabled(true); if (togglePopup->isChecked()) showDetails(true); //resize / move } else { showDetails(false); //hide empty widget togglePopup->setEnabled(false); togglePopup->setChecked(false); } if (status.size() > 60) status = "..."+status.right(60); statusLabel->setText(status); bar->setValue(now); bar->setMaximum(max); }