void PreviewWidget::progressUpdated(Subject& subject, const string& signal, const boost::any& value) { Progress* pProgress = dynamic_cast<Progress*>(&subject); if (NN(pProgress)) { // Get the current Progress values string label = ""; int iPercent = 0; ReportingLevel reportLevel = NORMAL; pProgress->getProgress(label, iPercent, reportLevel); // Set the label text if there is new text QString strOldLabel = mpProgressLabel->text(); QString strLabel; if (label.empty() == false) { strLabel = QString::fromStdString(label); } if (strLabel != strOldLabel) { mpProgressLabel->setText(strLabel); mpProgressLabel->repaint(); } // Set the progress percentage only if it is a new value int iOldPercent = mpProgressBar->value(); if (iPercent != iOldPercent) { mpProgressBar->setValue(iPercent); } } }
void reportMessage(const char* pMessage, void* pClientData) { Progress* pProgress = reinterpret_cast<Progress*>(pClientData); if ((pProgress != NULL) && (pMessage != NULL)) { std::string currentMessage; int percent = 0; ReportingLevel level; pProgress->getProgress(currentMessage, percent, level); pProgress->updateProgress(std::string(pMessage), percent, NORMAL); } }