| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qprogressdialog.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | static const int defaultShowTime = 4000; | - | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | static const int minWaitTime = 50; | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | class QProgressDialogPrivate : public QDialogPrivate | - | ||||||||||||||||||
| 14 | { | - | ||||||||||||||||||
| 15 | inline QProgressDialog* q_func() { return static_cast<QProgressDialog *>(q_ptr); } inline const QProgressDialog* q_func() const { return static_cast<const QProgressDialog *>(q_ptr); } friend class QProgressDialog; | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | public: | - | ||||||||||||||||||
| 18 | QProgressDialogPrivate() : label(0), cancel(0), bar(0), | - | ||||||||||||||||||
| 19 | shown_once(false), | - | ||||||||||||||||||
| 20 | cancellation_flag(false), | - | ||||||||||||||||||
| 21 | setValue_called(false), | - | ||||||||||||||||||
| 22 | showTime(defaultShowTime), | - | ||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | escapeShortcut(0), | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | useDefaultCancelText(false) | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | } never executed: end of block | 0 | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | void init(const QString &labelText, const QString &cancelText, int min, int max); | - | ||||||||||||||||||
| 31 | void layout(); | - | ||||||||||||||||||
| 32 | void retranslateStrings(); | - | ||||||||||||||||||
| 33 | void setCancelButtonText(const QString &cancelButtonText); | - | ||||||||||||||||||
| 34 | void adoptChildWidget(QWidget *c); | - | ||||||||||||||||||
| 35 | void ensureSizeIsAtLeastSizeHint(); | - | ||||||||||||||||||
| 36 | void _q_disconnectOnClose(); | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | QLabel *label; | - | ||||||||||||||||||
| 39 | QPushButton *cancel; | - | ||||||||||||||||||
| 40 | QProgressBar *bar; | - | ||||||||||||||||||
| 41 | QTimer *forceTimer; | - | ||||||||||||||||||
| 42 | bool shown_once; | - | ||||||||||||||||||
| 43 | bool cancellation_flag; | - | ||||||||||||||||||
| 44 | bool setValue_called; | - | ||||||||||||||||||
| 45 | QElapsedTimer starttime; | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | QCursor parentCursor; | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | int showTime; | - | ||||||||||||||||||
| 50 | bool autoClose; | - | ||||||||||||||||||
| 51 | bool autoReset; | - | ||||||||||||||||||
| 52 | bool forceHide; | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | QShortcut *escapeShortcut; | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | bool useDefaultCancelText; | - | ||||||||||||||||||
| 57 | QPointer<QObject> receiverToDisconnectOnClose; | - | ||||||||||||||||||
| 58 | QByteArray memberToDisconnectOnClose; | - | ||||||||||||||||||
| 59 | }; | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | void QProgressDialogPrivate::init(const QString &labelText, const QString &cancelText, | - | ||||||||||||||||||
| 62 | int min, int max) | - | ||||||||||||||||||
| 63 | { | - | ||||||||||||||||||
| 64 | QProgressDialog * const q = q_func(); | - | ||||||||||||||||||
| 65 | label = new QLabel(labelText, q); | - | ||||||||||||||||||
| 66 | bar = new QProgressBar(q); | - | ||||||||||||||||||
| 67 | bar->setRange(min, max); | - | ||||||||||||||||||
| 68 | int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); | - | ||||||||||||||||||
| 69 | label->setAlignment(Qt::Alignment(align)); | - | ||||||||||||||||||
| 70 | autoClose = true; | - | ||||||||||||||||||
| 71 | autoReset = true; | - | ||||||||||||||||||
| 72 | forceHide = false; | - | ||||||||||||||||||
| 73 | QObject::connect(q, qFlagLocation("2""canceled()" "\0" __FILE__ ":" "120"), q, qFlagLocation("1""cancel()" "\0" __FILE__ ":" "120")); | - | ||||||||||||||||||
| 74 | forceTimer = new QTimer(q); | - | ||||||||||||||||||
| 75 | QObject::connect(forceTimer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "122"), q, qFlagLocation("1""forceShow()" "\0" __FILE__ ":" "122")); | - | ||||||||||||||||||
| 76 | if (useDefaultCancelText
| 0 | ||||||||||||||||||
| 77 | retranslateStrings(); | - | ||||||||||||||||||
| 78 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 79 | q->setCancelButtonText(cancelText); | - | ||||||||||||||||||
| 80 | } never executed: end of block | 0 | ||||||||||||||||||
| 81 | starttime.start(); | - | ||||||||||||||||||
| 82 | forceTimer->start(showTime); | - | ||||||||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | void QProgressDialogPrivate::layout() | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | QProgressDialog * const q = q_func(); | - | ||||||||||||||||||
| 88 | int sp = q->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); | - | ||||||||||||||||||
| 89 | int mtb = q->style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin); | - | ||||||||||||||||||
| 90 | int mlr = qMin(q->width() / 10, mtb); | - | ||||||||||||||||||
| 91 | const bool centered = | - | ||||||||||||||||||
| 92 | bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q)); | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | int additionalSpacing = 0; | - | ||||||||||||||||||
| 95 | QSize cs = cancel
| 0 | ||||||||||||||||||
| 96 | QSize bh = bar->sizeHint(); | - | ||||||||||||||||||
| 97 | int cspc; | - | ||||||||||||||||||
| 98 | int lh = 0; | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | for (int attempt=5; attempt--
| 0 | ||||||||||||||||||
| 103 | cspc = cancel
| 0 | ||||||||||||||||||
| 104 | lh = qMax(0, q->height() - mtb - bh.height() - sp - cspc); | - | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | if (lh < q->height()/4
| 0 | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | sp /= 2; | - | ||||||||||||||||||
| 109 | mtb /= 2; | - | ||||||||||||||||||
| 110 | if (cancel
| 0 | ||||||||||||||||||
| 111 | cs.setHeight(qMax(4,cs.height()-sp-2)); | - | ||||||||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||||||||
| 113 | bh.setHeight(qMax(4,bh.height()-sp-1)); | - | ||||||||||||||||||
| 114 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 115 | break; never executed: break; | 0 | ||||||||||||||||||
| 116 | } | - | ||||||||||||||||||
| 117 | } | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | if (cancel
| 0 | ||||||||||||||||||
| 120 | cancel->setGeometry( | - | ||||||||||||||||||
| 121 | centered ? q->width()/2 - cs.width()/2 : q->width() - mlr - cs.width(), | - | ||||||||||||||||||
| 122 | q->height() - mtb - cs.height(), | - | ||||||||||||||||||
| 123 | cs.width(), cs.height()); | - | ||||||||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | if (label
| 0 | ||||||||||||||||||
| 127 | label->setGeometry(mlr, additionalSpacing, q->width() - mlr * 2, lh); never executed: label->setGeometry(mlr, additionalSpacing, q->width() - mlr * 2, lh); | 0 | ||||||||||||||||||
| 128 | bar->setGeometry(mlr, lh + sp + additionalSpacing, q->width() - mlr * 2, bh.height()); | - | ||||||||||||||||||
| 129 | } never executed: end of block | 0 | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | void QProgressDialogPrivate::retranslateStrings() | - | ||||||||||||||||||
| 132 | { | - | ||||||||||||||||||
| 133 | if (useDefaultCancelText
| 0 | ||||||||||||||||||
| 134 | setCancelButtonText(QProgressDialog::tr("Cancel")); never executed: setCancelButtonText(QProgressDialog::tr("Cancel")); | 0 | ||||||||||||||||||
| 135 | } never executed: end of block | 0 | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | void QProgressDialogPrivate::_q_disconnectOnClose() | - | ||||||||||||||||||
| 138 | { | - | ||||||||||||||||||
| 139 | QProgressDialog * const q = q_func(); | - | ||||||||||||||||||
| 140 | if (receiverToDisconnectOnClose
| 0 | ||||||||||||||||||
| 141 | QObject::disconnect(q, qFlagLocation("2""canceled()" "\0" __FILE__ ":" "188"), receiverToDisconnectOnClose, | - | ||||||||||||||||||
| 142 | memberToDisconnectOnClose); | - | ||||||||||||||||||
| 143 | receiverToDisconnectOnClose = 0; | - | ||||||||||||||||||
| 144 | } never executed: end of block | 0 | ||||||||||||||||||
| 145 | memberToDisconnectOnClose.clear(); | - | ||||||||||||||||||
| 146 | } never executed: end of block | 0 | ||||||||||||||||||
| 147 | QProgressDialog::QProgressDialog(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||
| 148 | : QDialog(*(new QProgressDialogPrivate), parent, f) | - | ||||||||||||||||||
| 149 | { | - | ||||||||||||||||||
| 150 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 151 | d->useDefaultCancelText = true; | - | ||||||||||||||||||
| 152 | d->init(QString::fromLatin1(""), QString(), 0, 100); | - | ||||||||||||||||||
| 153 | } never executed: end of block | 0 | ||||||||||||||||||
| 154 | QProgressDialog::QProgressDialog(const QString &labelText, | - | ||||||||||||||||||
| 155 | const QString &cancelButtonText, | - | ||||||||||||||||||
| 156 | int minimum, int maximum, | - | ||||||||||||||||||
| 157 | QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||||||||
| 158 | : QDialog(*(new QProgressDialogPrivate), parent, f) | - | ||||||||||||||||||
| 159 | { | - | ||||||||||||||||||
| 160 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 161 | d->init(labelText, cancelButtonText, minimum, maximum); | - | ||||||||||||||||||
| 162 | } never executed: end of block | 0 | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | QProgressDialog::~QProgressDialog() | - | ||||||||||||||||||
| 170 | { | - | ||||||||||||||||||
| 171 | } | - | ||||||||||||||||||
| 172 | void QProgressDialog::setLabel(QLabel *label) | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 175 | if (label == d->label
| 0 | ||||||||||||||||||
| 176 | if (label
| 0 | ||||||||||||||||||
| 177 | QMessageLogger(__FILE__, 357, __PRETTY_FUNCTION__).warning("QProgressDialog::setLabel: Attempt to set the same label again"); never executed: QMessageLogger(__FILE__, 357, __PRETTY_FUNCTION__).warning("QProgressDialog::setLabel: Attempt to set the same label again"); | 0 | ||||||||||||||||||
| 178 | return; never executed: return; | 0 | ||||||||||||||||||
| 179 | } | - | ||||||||||||||||||
| 180 | delete d->label; | - | ||||||||||||||||||
| 181 | d->label = label; | - | ||||||||||||||||||
| 182 | d->adoptChildWidget(label); | - | ||||||||||||||||||
| 183 | } never executed: end of block | 0 | ||||||||||||||||||
| 184 | QString QProgressDialog::labelText() const | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 187 | if (d->label
| 0 | ||||||||||||||||||
| 188 | return never executed: d->label->text();return d->label->text();never executed: return d->label->text(); | 0 | ||||||||||||||||||
| 189 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | void QProgressDialog::setLabelText(const QString &text) | - | ||||||||||||||||||
| 193 | { | - | ||||||||||||||||||
| 194 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 195 | if (d->label
| 0 | ||||||||||||||||||
| 196 | d->label->setText(text); | - | ||||||||||||||||||
| 197 | d->ensureSizeIsAtLeastSizeHint(); | - | ||||||||||||||||||
| 198 | } never executed: end of block | 0 | ||||||||||||||||||
| 199 | } never executed: end of block | 0 | ||||||||||||||||||
| 200 | void QProgressDialog::setCancelButton(QPushButton *cancelButton) | - | ||||||||||||||||||
| 201 | { | - | ||||||||||||||||||
| 202 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 203 | if (d->cancel == cancelButton
| 0 | ||||||||||||||||||
| 204 | if (cancelButton
| 0 | ||||||||||||||||||
| 205 | QMessageLogger(__FILE__, 406, __PRETTY_FUNCTION__).warning("QProgressDialog::setCancelButton: Attempt to set the same button again"); never executed: QMessageLogger(__FILE__, 406, __PRETTY_FUNCTION__).warning("QProgressDialog::setCancelButton: Attempt to set the same button again"); | 0 | ||||||||||||||||||
| 206 | return; never executed: return; | 0 | ||||||||||||||||||
| 207 | } | - | ||||||||||||||||||
| 208 | delete d->cancel; | - | ||||||||||||||||||
| 209 | d->cancel = cancelButton; | - | ||||||||||||||||||
| 210 | if (cancelButton
| 0 | ||||||||||||||||||
| 211 | connect(d->cancel, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "412"), this, qFlagLocation("2""canceled()" "\0" __FILE__ ":" "412")); | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | d->escapeShortcut = new QShortcut(QKeySequence::Cancel, this, qFlagLocation("2""canceled()" "\0" __FILE__ ":" "415")); | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | delete d->escapeShortcut; | - | ||||||||||||||||||
| 219 | d->escapeShortcut = 0; | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | } never executed: end of block | 0 | ||||||||||||||||||
| 222 | d->adoptChildWidget(cancelButton); | - | ||||||||||||||||||
| 223 | } never executed: end of block | 0 | ||||||||||||||||||
| 224 | void QProgressDialog::setCancelButtonText(const QString &cancelButtonText) | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 227 | d->useDefaultCancelText = false; | - | ||||||||||||||||||
| 228 | d->setCancelButtonText(cancelButtonText); | - | ||||||||||||||||||
| 229 | } never executed: end of block | 0 | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText) | - | ||||||||||||||||||
| 232 | { | - | ||||||||||||||||||
| 233 | QProgressDialog * const q = q_func(); | - | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | if (!cancelButtonText.isNull()
| 0 | ||||||||||||||||||
| 236 | if (cancel
| 0 | ||||||||||||||||||
| 237 | cancel->setText(cancelButtonText); | - | ||||||||||||||||||
| 238 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 239 | q->setCancelButton(new QPushButton(cancelButtonText, q)); | - | ||||||||||||||||||
| 240 | } never executed: end of block | 0 | ||||||||||||||||||
| 241 | } else { | - | ||||||||||||||||||
| 242 | q->setCancelButton(0); | - | ||||||||||||||||||
| 243 | } never executed: end of block | 0 | ||||||||||||||||||
| 244 | ensureSizeIsAtLeastSizeHint(); | - | ||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||
| 246 | void QProgressDialog::setBar(QProgressBar *bar) | - | ||||||||||||||||||
| 247 | { | - | ||||||||||||||||||
| 248 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 249 | if (!bar
| 0 | ||||||||||||||||||
| 250 | QMessageLogger(__FILE__, 469, __PRETTY_FUNCTION__).warning("QProgressDialog::setBar: Cannot set a null progress bar"); | - | ||||||||||||||||||
| 251 | return; never executed: return; | 0 | ||||||||||||||||||
| 252 | } | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | if (value() > 0
| 0 | ||||||||||||||||||
| 255 | QMessageLogger(__FILE__, 474, __PRETTY_FUNCTION__).warning("QProgressDialog::setBar: Cannot set a new progress bar " never executed: QMessageLogger(__FILE__, 474, __PRETTY_FUNCTION__).warning("QProgressDialog::setBar: Cannot set a new progress bar " "while the old one is active"); | 0 | ||||||||||||||||||
| 256 | "while the old one is active"); never executed: QMessageLogger(__FILE__, 474, __PRETTY_FUNCTION__).warning("QProgressDialog::setBar: Cannot set a new progress bar " "while the old one is active"); | 0 | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | if (bar == d->bar
| 0 | ||||||||||||||||||
| 259 | QMessageLogger(__FILE__, 478, __PRETTY_FUNCTION__).warning("QProgressDialog::setBar: Attempt to set the same progress bar again"); | - | ||||||||||||||||||
| 260 | return; never executed: return; | 0 | ||||||||||||||||||
| 261 | } | - | ||||||||||||||||||
| 262 | delete d->bar; | - | ||||||||||||||||||
| 263 | d->bar = bar; | - | ||||||||||||||||||
| 264 | d->adoptChildWidget(bar); | - | ||||||||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | void QProgressDialogPrivate::adoptChildWidget(QWidget *c) | - | ||||||||||||||||||
| 268 | { | - | ||||||||||||||||||
| 269 | QProgressDialog * const q = q_func(); | - | ||||||||||||||||||
| 270 | - | |||||||||||||||||||
| 271 | if (c
| 0 | ||||||||||||||||||
| 272 | if (c->parentWidget() == q
| 0 | ||||||||||||||||||
| 273 | c->hide(); never executed: c->hide(); | 0 | ||||||||||||||||||
| 274 | else | - | ||||||||||||||||||
| 275 | c->setParent(q, 0); never executed: c->setParent(q, 0); | 0 | ||||||||||||||||||
| 276 | } | - | ||||||||||||||||||
| 277 | ensureSizeIsAtLeastSizeHint(); | - | ||||||||||||||||||
| 278 | if (c
| 0 | ||||||||||||||||||
| 279 | c->show(); never executed: c->show(); | 0 | ||||||||||||||||||
| 280 | } never executed: end of block | 0 | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | void QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint() | - | ||||||||||||||||||
| 283 | { | - | ||||||||||||||||||
| 284 | QProgressDialog * const q = q_func(); | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | QSize size = q->sizeHint(); | - | ||||||||||||||||||
| 287 | if (q->isVisible()
| 0 | ||||||||||||||||||
| 288 | size = size.expandedTo(q->size()); never executed: size = size.expandedTo(q->size()); | 0 | ||||||||||||||||||
| 289 | q->resize(size); | - | ||||||||||||||||||
| 290 | } never executed: end of block | 0 | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | bool QProgressDialog::wasCanceled() const | - | ||||||||||||||||||
| 299 | { | - | ||||||||||||||||||
| 300 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 301 | return never executed: d->cancellation_flag;return d->cancellation_flag;never executed: return d->cancellation_flag; | 0 | ||||||||||||||||||
| 302 | } | - | ||||||||||||||||||
| 303 | int QProgressDialog::maximum() const | - | ||||||||||||||||||
| 304 | { | - | ||||||||||||||||||
| 305 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 306 | return never executed: d->bar->maximum();return d->bar->maximum();never executed: return d->bar->maximum(); | 0 | ||||||||||||||||||
| 307 | } | - | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | void QProgressDialog::setMaximum(int maximum) | - | ||||||||||||||||||
| 310 | { | - | ||||||||||||||||||
| 311 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 312 | d->bar->setMaximum(maximum); | - | ||||||||||||||||||
| 313 | } never executed: end of block | 0 | ||||||||||||||||||
| 314 | int QProgressDialog::minimum() const | - | ||||||||||||||||||
| 315 | { | - | ||||||||||||||||||
| 316 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 317 | return never executed: d->bar->minimum();return d->bar->minimum();never executed: return d->bar->minimum(); | 0 | ||||||||||||||||||
| 318 | } | - | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | void QProgressDialog::setMinimum(int minimum) | - | ||||||||||||||||||
| 321 | { | - | ||||||||||||||||||
| 322 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 323 | d->bar->setMinimum(minimum); | - | ||||||||||||||||||
| 324 | } never executed: end of block | 0 | ||||||||||||||||||
| 325 | void QProgressDialog::setRange(int minimum, int maximum) | - | ||||||||||||||||||
| 326 | { | - | ||||||||||||||||||
| 327 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 328 | d->bar->setRange(minimum, maximum); | - | ||||||||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||||||||
| 330 | void QProgressDialog::reset() | - | ||||||||||||||||||
| 331 | { | - | ||||||||||||||||||
| 332 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | if (value() >= 0
| 0 | ||||||||||||||||||
| 335 | if (parentWidget()
| 0 | ||||||||||||||||||
| 336 | parentWidget()->setCursor(d->parentCursor); never executed: parentWidget()->setCursor(d->parentCursor); | 0 | ||||||||||||||||||
| 337 | } never executed: end of block | 0 | ||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | if (d->autoClose
| 0 | ||||||||||||||||||
| 340 | hide(); never executed: hide(); | 0 | ||||||||||||||||||
| 341 | d->bar->reset(); | - | ||||||||||||||||||
| 342 | d->cancellation_flag = false; | - | ||||||||||||||||||
| 343 | d->shown_once = false; | - | ||||||||||||||||||
| 344 | d->setValue_called = false; | - | ||||||||||||||||||
| 345 | d->forceTimer->stop(); | - | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | if (d->receiverToDisconnectOnClose
| 0 | ||||||||||||||||||
| 353 | QMetaObject::invokeMethod(this, "_q_disconnectOnClose", Qt::QueuedConnection); never executed: QMetaObject::invokeMethod(this, "_q_disconnectOnClose", Qt::QueuedConnection); | 0 | ||||||||||||||||||
| 354 | } never executed: end of block | 0 | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | - | |||||||||||||||||||
| 361 | - | |||||||||||||||||||
| 362 | void QProgressDialog::cancel() | - | ||||||||||||||||||
| 363 | { | - | ||||||||||||||||||
| 364 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 365 | d->forceHide = true; | - | ||||||||||||||||||
| 366 | reset(); | - | ||||||||||||||||||
| 367 | d->forceHide = false; | - | ||||||||||||||||||
| 368 | d->cancellation_flag = true; | - | ||||||||||||||||||
| 369 | } never executed: end of block | 0 | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | - | |||||||||||||||||||
| 372 | int QProgressDialog::value() const | - | ||||||||||||||||||
| 373 | { | - | ||||||||||||||||||
| 374 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 375 | return never executed: d->bar->value();return d->bar->value();never executed: return d->bar->value(); | 0 | ||||||||||||||||||
| 376 | } | - | ||||||||||||||||||
| 377 | void QProgressDialog::setValue(int progress) | - | ||||||||||||||||||
| 378 | { | - | ||||||||||||||||||
| 379 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 380 | if (d->setValue_called
| 0 | ||||||||||||||||||
| 381 | return; never executed: return; | 0 | ||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | d->bar->setValue(progress); | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | if (d->shown_once
| 0 | ||||||||||||||||||
| 386 | if (isModal()
| 0 | ||||||||||||||||||
| 387 | QApplication::processEvents(); never executed: QApplication::processEvents(); | 0 | ||||||||||||||||||
| 388 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 389 | if ((!d->setValue_called
| 0 | ||||||||||||||||||
| 390 | d->starttime.start(); | - | ||||||||||||||||||
| 391 | d->forceTimer->start(d->showTime); | - | ||||||||||||||||||
| 392 | d->setValue_called = true; | - | ||||||||||||||||||
| 393 | return; never executed: return; | 0 | ||||||||||||||||||
| 394 | } else { | - | ||||||||||||||||||
| 395 | d->setValue_called = true; | - | ||||||||||||||||||
| 396 | bool need_show; | - | ||||||||||||||||||
| 397 | int elapsed = d->starttime.elapsed(); | - | ||||||||||||||||||
| 398 | if (elapsed >= d->showTime
| 0 | ||||||||||||||||||
| 399 | need_show = true; | - | ||||||||||||||||||
| 400 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 401 | if (elapsed > minWaitTime
| 0 | ||||||||||||||||||
| 402 | int estimate; | - | ||||||||||||||||||
| 403 | int totalSteps = maximum() - minimum(); | - | ||||||||||||||||||
| 404 | int myprogress = progress - minimum(); | - | ||||||||||||||||||
| 405 | if (myprogress == 0
never executed: myprogress = 1; | 0 | ||||||||||||||||||
| 406 | if ((
| 0 | ||||||||||||||||||
| 407 | estimate = (totalSteps - myprogress) / myprogress * elapsed; never executed: estimate = (totalSteps - myprogress) / myprogress * elapsed; | 0 | ||||||||||||||||||
| 408 | else | - | ||||||||||||||||||
| 409 | estimate = elapsed * (totalSteps - myprogress) / myprogress; never executed: estimate = elapsed * (totalSteps - myprogress) / myprogress; | 0 | ||||||||||||||||||
| 410 | need_show = estimate >= d->showTime; | - | ||||||||||||||||||
| 411 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 412 | need_show = false; | - | ||||||||||||||||||
| 413 | } never executed: end of block | 0 | ||||||||||||||||||
| 414 | } | - | ||||||||||||||||||
| 415 | if (need_show
| 0 | ||||||||||||||||||
| 416 | d->ensureSizeIsAtLeastSizeHint(); | - | ||||||||||||||||||
| 417 | show(); | - | ||||||||||||||||||
| 418 | d->shown_once = true; | - | ||||||||||||||||||
| 419 | } never executed: end of block | 0 | ||||||||||||||||||
| 420 | } never executed: end of block | 0 | ||||||||||||||||||
| 421 | } | - | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | if (progress == d->bar->maximum()
| 0 | ||||||||||||||||||
| 424 | reset(); never executed: reset(); | 0 | ||||||||||||||||||
| 425 | } never executed: end of block | 0 | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | QSize QProgressDialog::sizeHint() const | - | ||||||||||||||||||
| 434 | { | - | ||||||||||||||||||
| 435 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 436 | QSize sh = d->label
| 0 | ||||||||||||||||||
| 437 | QSize bh = d->bar->sizeHint(); | - | ||||||||||||||||||
| 438 | int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin); | - | ||||||||||||||||||
| 439 | int spacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); | - | ||||||||||||||||||
| 440 | int h = margin * 2 + bh.height() + sh.height() + spacing; | - | ||||||||||||||||||
| 441 | if (d->cancel
| 0 | ||||||||||||||||||
| 442 | h += d->cancel->sizeHint().height() + spacing; never executed: h += d->cancel->sizeHint().height() + spacing; | 0 | ||||||||||||||||||
| 443 | return never executed: QSize(qMax(200, sh.width() + 2 * margin), h);return QSize(qMax(200, sh.width() + 2 * margin), h);never executed: return QSize(qMax(200, sh.width() + 2 * margin), h); | 0 | ||||||||||||||||||
| 444 | } | - | ||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | void QProgressDialog::resizeEvent(QResizeEvent *) | - | ||||||||||||||||||
| 449 | { | - | ||||||||||||||||||
| 450 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 451 | d->layout(); | - | ||||||||||||||||||
| 452 | } never executed: end of block | 0 | ||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | void QProgressDialog::changeEvent(QEvent *ev) | - | ||||||||||||||||||
| 458 | { | - | ||||||||||||||||||
| 459 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 460 | if (ev->type() == QEvent::StyleChange
| 0 | ||||||||||||||||||
| 461 | d->layout(); | - | ||||||||||||||||||
| 462 | } never executed: else if (ev->type() == QEvent::LanguageChangeend of block
| 0 | ||||||||||||||||||
| 463 | d->retranslateStrings(); | - | ||||||||||||||||||
| 464 | } never executed: end of block | 0 | ||||||||||||||||||
| 465 | QDialog::changeEvent(ev); | - | ||||||||||||||||||
| 466 | } never executed: end of block | 0 | ||||||||||||||||||
| 467 | void QProgressDialog::setMinimumDuration(int ms) | - | ||||||||||||||||||
| 468 | { | - | ||||||||||||||||||
| 469 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 470 | d->showTime = ms; | - | ||||||||||||||||||
| 471 | if (d->bar->value() == d->bar->minimum()
| 0 | ||||||||||||||||||
| 472 | d->forceTimer->stop(); | - | ||||||||||||||||||
| 473 | d->forceTimer->start(ms); | - | ||||||||||||||||||
| 474 | } never executed: end of block | 0 | ||||||||||||||||||
| 475 | } never executed: end of block | 0 | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | int QProgressDialog::minimumDuration() const | - | ||||||||||||||||||
| 478 | { | - | ||||||||||||||||||
| 479 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 480 | return never executed: d->showTime;return d->showTime;never executed: return d->showTime; | 0 | ||||||||||||||||||
| 481 | } | - | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | - | |||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 | void QProgressDialog::closeEvent(QCloseEvent *e) | - | ||||||||||||||||||
| 489 | { | - | ||||||||||||||||||
| 490 | canceled(); | - | ||||||||||||||||||
| 491 | QDialog::closeEvent(e); | - | ||||||||||||||||||
| 492 | } never executed: end of block | 0 | ||||||||||||||||||
| 493 | void QProgressDialog::setAutoReset(bool b) | - | ||||||||||||||||||
| 494 | { | - | ||||||||||||||||||
| 495 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 496 | d->autoReset = b; | - | ||||||||||||||||||
| 497 | } never executed: end of block | 0 | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | bool QProgressDialog::autoReset() const | - | ||||||||||||||||||
| 500 | { | - | ||||||||||||||||||
| 501 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 502 | return never executed: d->autoReset;return d->autoReset;never executed: return d->autoReset; | 0 | ||||||||||||||||||
| 503 | } | - | ||||||||||||||||||
| 504 | void QProgressDialog::setAutoClose(bool close) | - | ||||||||||||||||||
| 505 | { | - | ||||||||||||||||||
| 506 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 507 | d->autoClose = close; | - | ||||||||||||||||||
| 508 | } never executed: end of block | 0 | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | bool QProgressDialog::autoClose() const | - | ||||||||||||||||||
| 511 | { | - | ||||||||||||||||||
| 512 | const QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 513 | return never executed: d->autoClose;return d->autoClose;never executed: return d->autoClose; | 0 | ||||||||||||||||||
| 514 | } | - | ||||||||||||||||||
| 515 | - | |||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | - | |||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | void QProgressDialog::showEvent(QShowEvent *e) | - | ||||||||||||||||||
| 521 | { | - | ||||||||||||||||||
| 522 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 523 | QDialog::showEvent(e); | - | ||||||||||||||||||
| 524 | d->ensureSizeIsAtLeastSizeHint(); | - | ||||||||||||||||||
| 525 | d->forceTimer->stop(); | - | ||||||||||||||||||
| 526 | } never executed: end of block | 0 | ||||||||||||||||||
| 527 | void QProgressDialog::forceShow() | - | ||||||||||||||||||
| 528 | { | - | ||||||||||||||||||
| 529 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 530 | d->forceTimer->stop(); | - | ||||||||||||||||||
| 531 | if (d->shown_once
| 0 | ||||||||||||||||||
| 532 | return; never executed: return; | 0 | ||||||||||||||||||
| 533 | - | |||||||||||||||||||
| 534 | show(); | - | ||||||||||||||||||
| 535 | d->shown_once = true; | - | ||||||||||||||||||
| 536 | } never executed: end of block | 0 | ||||||||||||||||||
| 537 | void QProgressDialog::open(QObject *receiver, const char *member) | - | ||||||||||||||||||
| 538 | { | - | ||||||||||||||||||
| 539 | QProgressDialogPrivate * const d = d_func(); | - | ||||||||||||||||||
| 540 | connect(this, qFlagLocation("2""canceled()" "\0" __FILE__ ":" "873"), receiver, member); | - | ||||||||||||||||||
| 541 | d->receiverToDisconnectOnClose = receiver; | - | ||||||||||||||||||
| 542 | d->memberToDisconnectOnClose = member; | - | ||||||||||||||||||
| 543 | QDialog::open(); | - | ||||||||||||||||||
| 544 | } never executed: end of block | 0 | ||||||||||||||||||
| 545 | - | |||||||||||||||||||
| 546 | - | |||||||||||||||||||
| 547 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |