| 34 | } |
| 35 | |
| 36 | void |
| 37 | ProgressBarDelegate::paint( |
| 38 | QPainter *painter, |
| 39 | const QStyleOptionViewItem &option, |
| 40 | const QModelIndex &index) const |
| 41 | { |
| 42 | const MultitaskControllerModel *model = |
| 43 | static_cast<const MultitaskControllerModel *>(index.model()); |
| 44 | |
| 45 | if (model != nullptr) { |
| 46 | QStyleOptionProgressBar progressBarOption; |
| 47 | qreal progress = model->data(index, Qt::DisplayRole).value<qreal>(); |
| 48 | int intProgress = static_cast<int>(progress * 100); |
| 49 | progressBarOption.rect = option.rect; |
| 50 | progressBarOption.minimum = 0; |
| 51 | progressBarOption.maximum = 100; |
| 52 | progressBarOption.progress = intProgress; |
| 53 | progressBarOption.text = QString::number(intProgress) + "%"; |
| 54 | progressBarOption.textVisible = true; |
| 55 | |
| 56 | QApplication::style()->drawControl( |
| 57 | QStyle::CE_ProgressBar, |
| 58 | &progressBarOption, |
| 59 | painter); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | BackgroundTasksDialog::BackgroundTasksDialog(QWidget *parent) : |
| 64 | QDialog(parent), |