| Line | Source | Count | 
| 1 |  | - | 
| 2 |  | - | 
| 3 |  | - | 
| 4 |  | - | 
| 5 |  | - | 
| 6 |  | - | 
| 7 |  | - | 
| 8 |  | - | 
| 9 |  | - | 
| 10 |  | - | 
| 11 |  | - | 
| 12 |  | - | 
| 13 |  | - | 
| 14 |  | - | 
| 15 |  | - | 
| 16 |  | - | 
| 17 |  | - | 
| 18 |  | - | 
| 19 |  | - | 
| 20 |  | - | 
| 21 |  | - | 
| 22 |  | - | 
| 23 |  | - | 
| 24 |  | - | 
| 25 |  | - | 
| 26 |  | - | 
| 27 |  | - | 
| 28 |  | - | 
| 29 |  | - | 
| 30 |  | - | 
| 31 |  | - | 
| 32 |  | - | 
| 33 |  | - | 
| 34 |  | - | 
| 35 |  | - | 
| 36 |  | - | 
| 37 |  | - | 
| 38 |  | - | 
| 39 |  | - | 
| 40 | #include "qstatusbar.h" | - | 
| 41 | #ifndef QT_NO_STATUSBAR | - | 
| 42 |  | - | 
| 43 | #include "qlist.h" | - | 
| 44 | #include "qdebug.h" | - | 
| 45 | #include "qevent.h" | - | 
| 46 | #include "qlayout.h" | - | 
| 47 | #include "qpainter.h" | - | 
| 48 | #include "qtimer.h" | - | 
| 49 | #include "qstyle.h" | - | 
| 50 | #include "qstyleoption.h" | - | 
| 51 | #include "qsizegrip.h" | - | 
| 52 | #include "qmainwindow.h" | - | 
| 53 |  | - | 
| 54 | #ifndef QT_NO_ACCESSIBILITY | - | 
| 55 | #include "qaccessible.h" | - | 
| 56 | #endif | - | 
| 57 |  | - | 
| 58 | #include <private/qlayoutengine_p.h> | - | 
| 59 | #include <private/qwidget_p.h> | - | 
| 60 |  | - | 
| 61 | QT_BEGIN_NAMESPACE | - | 
| 62 |  | - | 
| 63 | class QStatusBarPrivate : public QWidgetPrivate | - | 
| 64 | { | - | 
| 65 |     Q_DECLARE_PUBLIC(QStatusBar) | - | 
| 66 | public: | - | 
| 67 |     QStatusBarPrivate() {} | - | 
| 68 |  | - | 
| 69 |     struct SBItem { | - | 
| 70 |         SBItem(QWidget* widget, int stretch, bool permanent) | - | 
| 71 |             : s(stretch), w(widget), p(permanent) {} | - | 
| 72 |         int s; | - | 
| 73 |         QWidget * w; | - | 
| 74 |         bool p; | - | 
| 75 |     }; | - | 
| 76 |  | - | 
| 77 |     QList<SBItem *> items; | - | 
| 78 |     QString tempItem; | - | 
| 79 |  | - | 
| 80 |     QBoxLayout * box; | - | 
| 81 |     QTimer * timer; | - | 
| 82 |  | - | 
| 83 | #ifndef QT_NO_SIZEGRIP | - | 
| 84 |     QSizeGrip * resizer; | - | 
| 85 |     bool showSizeGrip; | - | 
| 86 | #endif | - | 
| 87 |  | - | 
| 88 |     int savedStrut; | - | 
| 89 |  | - | 
| 90 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | 
| 91 |     QPoint dragStart; | - | 
| 92 | #endif | - | 
| 93 |  | - | 
| 94 |     int indexToLastNonPermanentWidget() const | - | 
| 95 |     { | - | 
| 96 |         int i = items.size() - 1; | - | 
| 97 |         for (; i >= 0; --i) { | - | 
| 98 |             SBItem *item = items.at(i); | - | 
| 99 |             if (!(item && item->p)) | - | 
| 100 |                 break; | - | 
| 101 |         } | - | 
| 102 |         return i; | - | 
| 103 |     } | - | 
| 104 |  | - | 
| 105 | #ifndef QT_NO_SIZEGRIP | - | 
| 106 |     void tryToShowSizeGrip() | - | 
| 107 |     { | - | 
| 108 |         if (!showSizeGrip) | - | 
| 109 |             return; | - | 
| 110 |         showSizeGrip = false; | - | 
| 111 |         if (!resizer || resizer->isVisible()) | - | 
| 112 |             return; | - | 
| 113 |         resizer->setAttribute(Qt::WA_WState_ExplicitShowHide, false); | - | 
| 114 |         QMetaObject::invokeMethod(resizer, "_q_showIfNotHidden", Qt::DirectConnection); | - | 
| 115 |         resizer->setAttribute(Qt::WA_WState_ExplicitShowHide, false); | - | 
| 116 |     } | - | 
| 117 | #endif | - | 
| 118 |  | - | 
| 119 |     QRect messageRect() const; | - | 
| 120 | }; | - | 
| 121 |  | - | 
| 122 |  | - | 
| 123 | QRect QStatusBarPrivate::messageRect() const | - | 
| 124 | { | - | 
| 125 |     Q_Q(const QStatusBar); | - | 
| 126 |     bool rtl = q->layoutDirection() == Qt::RightToLeft; | - | 
| 127 |  | - | 
| 128 |     int left = 6; | - | 
| 129 |     int right = q->width() - 12; | - | 
| 130 |  | - | 
| 131 | #ifndef QT_NO_SIZEGRIP | - | 
| 132 |     if (resizer && resizer->isVisible()) { | - | 
| 133 |         if (rtl) | - | 
| 134 |             left = resizer->x() + resizer->width(); | - | 
| 135 |         else | - | 
| 136 |             right = resizer->x(); | - | 
| 137 |     } | - | 
| 138 | #endif | - | 
| 139 |  | - | 
| 140 |     for (int i=0; i<items.size(); ++i) { | - | 
| 141 |         QStatusBarPrivate::SBItem* item = items.at(i); | - | 
| 142 |         if (!item) | - | 
| 143 |             break; | - | 
| 144 |         if (item->p && item->w->isVisible()) { | - | 
| 145 |                 if (item->p) { | - | 
| 146 |                     if (rtl) | - | 
| 147 |                         left = qMax(left, item->w->x() + item->w->width() + 2); | - | 
| 148 |                     else | - | 
| 149 |                         right = qMin(right, item->w->x() - 2); | - | 
| 150 |                 } | - | 
| 151 |                 break; | - | 
| 152 |         } | - | 
| 153 |     } | - | 
| 154 |     return QRect(left, 0, right-left, q->height()); | - | 
| 155 | } | - | 
| 156 |  | - | 
| 157 |  | - | 
| 158 |  | - | 
| 159 |  | - | 
| 160 |  | - | 
| 161 |  | - | 
| 162 |  | - | 
| 163 |  | - | 
| 164 |  | - | 
| 165 |  | - | 
| 166 |  | - | 
| 167 |  | - | 
| 168 |  | - | 
| 169 |  | - | 
| 170 |  | - | 
| 171 |  | - | 
| 172 |  | - | 
| 173 |  | - | 
| 174 |  | - | 
| 175 |  | - | 
| 176 |  | - | 
| 177 |  | - | 
| 178 |  | - | 
| 179 |  | - | 
| 180 |  | - | 
| 181 |  | - | 
| 182 |  | - | 
| 183 |  | - | 
| 184 |  | - | 
| 185 |  | - | 
| 186 |  | - | 
| 187 |  | - | 
| 188 |  | - | 
| 189 |  | - | 
| 190 |  | - | 
| 191 |  | - | 
| 192 |  | - | 
| 193 |  | - | 
| 194 |  | - | 
| 195 |  | - | 
| 196 |  | - | 
| 197 |  | - | 
| 198 |  | - | 
| 199 |  | - | 
| 200 |  | - | 
| 201 |  | - | 
| 202 |  | - | 
| 203 |  | - | 
| 204 |  | - | 
| 205 |  | - | 
| 206 |  | - | 
| 207 |  | - | 
| 208 |  | - | 
| 209 |  | - | 
| 210 |  | - | 
| 211 |  | - | 
| 212 |  | - | 
| 213 |  | - | 
| 214 |  | - | 
| 215 |  | - | 
| 216 |  | - | 
| 217 |  | - | 
| 218 |  | - | 
| 219 |  | - | 
| 220 |  | - | 
| 221 |  | - | 
| 222 |  | - | 
| 223 |  | - | 
| 224 |  | - | 
| 225 |  | - | 
| 226 |  | - | 
| 227 |  | - | 
| 228 |  | - | 
| 229 | QStatusBar::QStatusBar(QWidget * parent) | - | 
| 230 |     : QWidget(*new QStatusBarPrivate, parent, 0) | - | 
| 231 | { | - | 
| 232 |     Q_D(QStatusBar); | - | 
| 233 |     d->box = 0; | - | 
| 234 |     d->timer = 0; | - | 
| 235 |  | - | 
| 236 | #ifndef QT_NO_SIZEGRIP | - | 
| 237 |     d->resizer = 0; | - | 
| 238 |     setSizeGripEnabled(true);  | - | 
| 239 | #else | - | 
| 240 |     reformat(); | - | 
| 241 | #endif | - | 
| 242 | } | - | 
| 243 |  | - | 
| 244 |  | - | 
| 245 |  | - | 
| 246 |  | - | 
| 247 |  | - | 
| 248 | QStatusBar::~QStatusBar() | - | 
| 249 | { | - | 
| 250 |     Q_D(QStatusBar); | - | 
| 251 |     while (!d->items.isEmpty()) | - | 
| 252 |         delete d->items.takeFirst(); | - | 
| 253 | } | - | 
| 254 |  | - | 
| 255 |  | - | 
| 256 |  | - | 
| 257 |  | - | 
| 258 |  | - | 
| 259 |  | - | 
| 260 |  | - | 
| 261 |  | - | 
| 262 |  | - | 
| 263 |  | - | 
| 264 |  | - | 
| 265 |  | - | 
| 266 |  | - | 
| 267 |  | - | 
| 268 |  | - | 
| 269 |  | - | 
| 270 | void QStatusBar::addWidget(QWidget * widget, int stretch) | - | 
| 271 | { | - | 
| 272 |     if (!widget) | - | 
| 273 |         return; | - | 
| 274 |     insertWidget(d_func()->indexToLastNonPermanentWidget() + 1, widget, stretch); | - | 
| 275 | } | - | 
| 276 |  | - | 
| 277 |  | - | 
| 278 |  | - | 
| 279 |  | - | 
| 280 |  | - | 
| 281 |  | - | 
| 282 |  | - | 
| 283 |  | - | 
| 284 |  | - | 
| 285 |  | - | 
| 286 |  | - | 
| 287 |  | - | 
| 288 |  | - | 
| 289 |  | - | 
| 290 |  | - | 
| 291 |  | - | 
| 292 |  | - | 
| 293 |  | - | 
| 294 |  | - | 
| 295 |  | - | 
| 296 | int QStatusBar::insertWidget(int index, QWidget *widget, int stretch) | - | 
| 297 | { | - | 
| 298 |     if (!widget)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 299 |         return -1; never executed: return -1;  | 0 | 
| 300 |  | - | 
| 301 |     Q_D(QStatusBar); | - | 
| 302 |     QStatusBarPrivate::SBItem* item = new QStatusBarPrivate::SBItem(widget, stretch, false); | - | 
| 303 |  | - | 
| 304 |     int idx = d->indexToLastNonPermanentWidget(); | - | 
| 305 |     if (Q_UNLIKELY(index < 0 || index > d->items.size() || (idx >= 0 && index > idx + 1))))) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 306 |         qWarning("QStatusBar::insertWidget: Index out of range (%d), appending widget", index); | - | 
| 307 |         index = idx + 1; | - | 
| 308 |     } never executed: end of block  | 0 | 
| 309 |     d->items.insert(index, item); | - | 
| 310 |  | - | 
| 311 |     if (!d->tempItem.isEmpty())| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 312 |         widget->hide(); never executed: widget->hide();  | 0 | 
| 313 |  | - | 
| 314 |     reformat(); | - | 
| 315 |     if (!widget->isHidden() || !widget->testAttribute(Qt::WA_WState_ExplicitShowHide))| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 316 |         widget->show(); never executed: widget->show();  | 0 | 
| 317 |  | - | 
| 318 |     return index; never executed: return index;  | 0 | 
| 319 | } | - | 
| 320 |  | - | 
| 321 |  | - | 
| 322 |  | - | 
| 323 |  | - | 
| 324 |  | - | 
| 325 |  | - | 
| 326 |  | - | 
| 327 |  | - | 
| 328 |  | - | 
| 329 |  | - | 
| 330 |  | - | 
| 331 |  | - | 
| 332 |  | - | 
| 333 |  | - | 
| 334 |  | - | 
| 335 | void QStatusBar::addPermanentWidget(QWidget * widget, int stretch) | - | 
| 336 | { | - | 
| 337 |     if (!widget) | - | 
| 338 |         return; | - | 
| 339 |     insertPermanentWidget(d_func()->items.size(), widget, stretch); | - | 
| 340 | } | - | 
| 341 |  | - | 
| 342 |  | - | 
| 343 |  | - | 
| 344 |  | - | 
| 345 |  | - | 
| 346 |  | - | 
| 347 |  | - | 
| 348 |  | - | 
| 349 |  | - | 
| 350 |  | - | 
| 351 |  | - | 
| 352 |  | - | 
| 353 |  | - | 
| 354 |  | - | 
| 355 |  | - | 
| 356 |  | - | 
| 357 |  | - | 
| 358 |  | - | 
| 359 |  | - | 
| 360 |  | - | 
| 361 | int QStatusBar::insertPermanentWidget(int index, QWidget *widget, int stretch) | - | 
| 362 | { | - | 
| 363 |     if (!widget)| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 364 |         return -1; never executed: return -1;  | 0 | 
| 365 |  | - | 
| 366 |     Q_D(QStatusBar); | - | 
| 367 |     QStatusBarPrivate::SBItem* item = new QStatusBarPrivate::SBItem(widget, stretch, true); | - | 
| 368 |  | - | 
| 369 |     int idx = d->indexToLastNonPermanentWidget(); | - | 
| 370 |     if (Q_UNLIKELY(index < 0 || index > d->items.size() || (idx >= 0 && index <= idx))))) {| TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 371 |         qWarning("QStatusBar::insertPermanentWidget: Index out of range (%d), appending widget", index); | - | 
| 372 |         index = d->items.size(); | - | 
| 373 |     } never executed: end of block  | 0 | 
| 374 |     d->items.insert(index, item); | - | 
| 375 |  | - | 
| 376 |     reformat(); | - | 
| 377 |     if (!widget->isHidden() || !widget->testAttribute(Qt::WA_WState_ExplicitShowHide))| TRUE | never evaluated |  | FALSE | never evaluated |  
 | TRUE | never evaluated |  | FALSE | never evaluated |  
  | 0 | 
| 378 |         widget->show(); never executed: widget->show();  | 0 | 
| 379 |  | - | 
| 380 |     return index; never executed: return index;  | 0 | 
| 381 | } | - | 
| 382 |  | - | 
| 383 |  | - | 
| 384 |  | - | 
| 385 |  | - | 
| 386 |  | - | 
| 387 |  | - | 
| 388 |  | - | 
| 389 |  | - | 
| 390 |  | - | 
| 391 |  | - | 
| 392 |  | - | 
| 393 | void QStatusBar::removeWidget(QWidget *widget) | - | 
| 394 | { | - | 
| 395 |     if (!widget) | - | 
| 396 |         return; | - | 
| 397 |  | - | 
| 398 |     Q_D(QStatusBar); | - | 
| 399 |     bool found = false; | - | 
| 400 |     QStatusBarPrivate::SBItem* item; | - | 
| 401 |     for (int i=0; i<d->items.size(); ++i) { | - | 
| 402 |         item = d->items.at(i); | - | 
| 403 |         if (!item) | - | 
| 404 |             break; | - | 
| 405 |         if (item->w == widget) { | - | 
| 406 |             d->items.removeAt(i); | - | 
| 407 |             item->w->hide(); | - | 
| 408 |             delete item; | - | 
| 409 |             found = true; | - | 
| 410 |             break; | - | 
| 411 |         } | - | 
| 412 |     } | - | 
| 413 |  | - | 
| 414 |     if (found) | - | 
| 415 |         reformat(); | - | 
| 416 | #if defined(QT_DEBUG) | - | 
| 417 |     else | - | 
| 418 |         qDebug("QStatusBar::removeWidget(): Widget not found."); | - | 
| 419 | #endif | - | 
| 420 | } | - | 
| 421 |  | - | 
| 422 |  | - | 
| 423 |  | - | 
| 424 |  | - | 
| 425 |  | - | 
| 426 |  | - | 
| 427 |  | - | 
| 428 |  | - | 
| 429 |  | - | 
| 430 |  | - | 
| 431 | bool QStatusBar::isSizeGripEnabled() const | - | 
| 432 | { | - | 
| 433 | #ifdef QT_NO_SIZEGRIP | - | 
| 434 |     return false; | - | 
| 435 | #else | - | 
| 436 |     Q_D(const QStatusBar); | - | 
| 437 |     return !!d->resizer; | - | 
| 438 | #endif | - | 
| 439 | } | - | 
| 440 |  | - | 
| 441 | void QStatusBar::setSizeGripEnabled(bool enabled) | - | 
| 442 | { | - | 
| 443 | #ifdef QT_NO_SIZEGRIP | - | 
| 444 |     Q_UNUSED(enabled); | - | 
| 445 | #else | - | 
| 446 |     Q_D(QStatusBar); | - | 
| 447 |     if (!enabled != !d->resizer) { | - | 
| 448 |         if (enabled) { | - | 
| 449 |             d->resizer = new QSizeGrip(this); | - | 
| 450 |             d->resizer->hide(); | - | 
| 451 |             d->resizer->installEventFilter(this); | - | 
| 452 |             d->showSizeGrip = true; | - | 
| 453 |         } else { | - | 
| 454 |             delete d->resizer; | - | 
| 455 |             d->resizer = 0; | - | 
| 456 |             d->showSizeGrip = false; | - | 
| 457 |         } | - | 
| 458 |         reformat(); | - | 
| 459 |         if (d->resizer && isVisible()) | - | 
| 460 |             d->tryToShowSizeGrip(); | - | 
| 461 |     } | - | 
| 462 | #endif | - | 
| 463 | } | - | 
| 464 |  | - | 
| 465 |  | - | 
| 466 |  | - | 
| 467 |  | - | 
| 468 |  | - | 
| 469 |  | - | 
| 470 |  | - | 
| 471 |  | - | 
| 472 | void QStatusBar::reformat() | - | 
| 473 | { | - | 
| 474 |     Q_D(QStatusBar); | - | 
| 475 |     if (d->box) | - | 
| 476 |         delete d->box; | - | 
| 477 |  | - | 
| 478 |     QBoxLayout *vbox; | - | 
| 479 | #ifndef QT_NO_SIZEGRIP | - | 
| 480 |     if (d->resizer) { | - | 
| 481 |         d->box = new QHBoxLayout(this); | - | 
| 482 |         d->box->setMargin(0); | - | 
| 483 |         vbox = new QVBoxLayout; | - | 
| 484 |         d->box->addLayout(vbox); | - | 
| 485 |     } else | - | 
| 486 | #endif | - | 
| 487 |     { | - | 
| 488 |         vbox = d->box = new QVBoxLayout(this); | - | 
| 489 |         d->box->setMargin(0); | - | 
| 490 |     } | - | 
| 491 |     vbox->addSpacing(3); | - | 
| 492 |     QBoxLayout* l = new QHBoxLayout; | - | 
| 493 |     vbox->addLayout(l); | - | 
| 494 |     l->addSpacing(2); | - | 
| 495 |     l->setSpacing(6); | - | 
| 496 |  | - | 
| 497 |     int maxH = fontMetrics().height(); | - | 
| 498 |  | - | 
| 499 |     int i; | - | 
| 500 |     QStatusBarPrivate::SBItem* item; | - | 
| 501 |     for (i=0,item=0; i<d->items.size(); ++i) { | - | 
| 502 |         item = d->items.at(i); | - | 
| 503 |         if (!item || item->p) | - | 
| 504 |             break; | - | 
| 505 |         l->addWidget(item->w, item->s); | - | 
| 506 |         int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight()); | - | 
| 507 |         maxH = qMax(maxH, itemH); | - | 
| 508 |     } | - | 
| 509 |  | - | 
| 510 |     l->addStretch(0); | - | 
| 511 |  | - | 
| 512 |     for (item=0; i<d->items.size(); ++i) { | - | 
| 513 |         item = d->items.at(i); | - | 
| 514 |         if (!item) | - | 
| 515 |             break; | - | 
| 516 |         l->addWidget(item->w, item->s); | - | 
| 517 |         int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight()); | - | 
| 518 |         maxH = qMax(maxH, itemH); | - | 
| 519 |     } | - | 
| 520 | #ifndef QT_NO_SIZEGRIP | - | 
| 521 |     if (d->resizer) { | - | 
| 522 |         maxH = qMax(maxH, d->resizer->sizeHint().height()); | - | 
| 523 |         d->box->addSpacing(1); | - | 
| 524 |         d->box->addWidget(d->resizer, 0, Qt::AlignBottom); | - | 
| 525 |     } | - | 
| 526 | #endif | - | 
| 527 |     l->addStrut(maxH); | - | 
| 528 |     d->savedStrut = maxH; | - | 
| 529 |     vbox->addSpacing(2); | - | 
| 530 |     d->box->activate(); | - | 
| 531 |     update(); | - | 
| 532 | } | - | 
| 533 |  | - | 
| 534 |  | - | 
| 535 |  | - | 
| 536 |  | - | 
| 537 |  | - | 
| 538 |  | - | 
| 539 |  | - | 
| 540 |  | - | 
| 541 |  | - | 
| 542 |  | - | 
| 543 |  | - | 
| 544 |  | - | 
| 545 |  | - | 
| 546 |  | - | 
| 547 |  | - | 
| 548 | void QStatusBar::showMessage(const QString &message, int timeout) | - | 
| 549 | { | - | 
| 550 |     Q_D(QStatusBar); | - | 
| 551 |  | - | 
| 552 |     if (timeout > 0) { | - | 
| 553 |         if (!d->timer) { | - | 
| 554 |             d->timer = new QTimer(this); | - | 
| 555 |             connect(d->timer, SIGNAL(timeout()), this, SLOT(clearMessage())); | - | 
| 556 |         } | - | 
| 557 |         d->timer->start(timeout); | - | 
| 558 |     } else if (d->timer) { | - | 
| 559 |         delete d->timer; | - | 
| 560 |         d->timer = 0; | - | 
| 561 |     } | - | 
| 562 |     if (d->tempItem == message) | - | 
| 563 |         return; | - | 
| 564 |     d->tempItem = message; | - | 
| 565 |  | - | 
| 566 |     hideOrShow(); | - | 
| 567 | } | - | 
| 568 |  | - | 
| 569 |  | - | 
| 570 |  | - | 
| 571 |  | - | 
| 572 |  | - | 
| 573 |  | - | 
| 574 |  | - | 
| 575 | void QStatusBar::clearMessage() | - | 
| 576 | { | - | 
| 577 |     Q_D(QStatusBar); | - | 
| 578 |     if (d->tempItem.isEmpty()) | - | 
| 579 |         return; | - | 
| 580 |     if (d->timer) { | - | 
| 581 |         qDeleteInEventHandler(d->timer); | - | 
| 582 |         d->timer = 0; | - | 
| 583 |     } | - | 
| 584 |     d->tempItem.clear(); | - | 
| 585 |     hideOrShow(); | - | 
| 586 | } | - | 
| 587 |  | - | 
| 588 |  | - | 
| 589 |  | - | 
| 590 |  | - | 
| 591 |  | - | 
| 592 |  | - | 
| 593 |  | - | 
| 594 | QString QStatusBar::currentMessage() const | - | 
| 595 | { | - | 
| 596 |     Q_D(const QStatusBar); | - | 
| 597 |     return d->tempItem; | - | 
| 598 | } | - | 
| 599 |  | - | 
| 600 |  | - | 
| 601 |  | - | 
| 602 |  | - | 
| 603 |  | - | 
| 604 |  | - | 
| 605 |  | - | 
| 606 |  | - | 
| 607 |  | - | 
| 608 |  | - | 
| 609 |  | - | 
| 610 |  | - | 
| 611 |  | - | 
| 612 |  | - | 
| 613 |  | - | 
| 614 |  | - | 
| 615 |  | - | 
| 616 | void QStatusBar::hideOrShow() | - | 
| 617 | { | - | 
| 618 |     Q_D(QStatusBar); | - | 
| 619 |     bool haveMessage = !d->tempItem.isEmpty(); | - | 
| 620 |  | - | 
| 621 |     QStatusBarPrivate::SBItem* item = 0; | - | 
| 622 |     for (int i=0; i<d->items.size(); ++i) { | - | 
| 623 |         item = d->items.at(i); | - | 
| 624 |         if (!item || item->p) | - | 
| 625 |             break; | - | 
| 626 |         if (haveMessage && item->w->isVisible()) { | - | 
| 627 |             item->w->hide(); | - | 
| 628 |             item->w->setAttribute(Qt::WA_WState_ExplicitShowHide, false); | - | 
| 629 |         } else if (!haveMessage && !item->w->testAttribute(Qt::WA_WState_ExplicitShowHide)) { | - | 
| 630 |             item->w->show(); | - | 
| 631 |         } | - | 
| 632 |     } | - | 
| 633 |  | - | 
| 634 |     emit messageChanged(d->tempItem); | - | 
| 635 |  | - | 
| 636 | #ifndef QT_NO_ACCESSIBILITY | - | 
| 637 |     if (QAccessible::isActive()) { | - | 
| 638 |         QAccessibleEvent event(this, QAccessible::NameChanged); | - | 
| 639 |         QAccessible::updateAccessibility(&event); | - | 
| 640 |     } | - | 
| 641 | #endif | - | 
| 642 |  | - | 
| 643 |     repaint(d->messageRect()); | - | 
| 644 | } | - | 
| 645 |  | - | 
| 646 |  | - | 
| 647 |  | - | 
| 648 |  | - | 
| 649 | void QStatusBar::showEvent(QShowEvent *) | - | 
| 650 | { | - | 
| 651 | #ifndef QT_NO_SIZEGRIP | - | 
| 652 |     Q_D(QStatusBar); | - | 
| 653 |     if (d->resizer && d->showSizeGrip) | - | 
| 654 |         d->tryToShowSizeGrip(); | - | 
| 655 | #endif | - | 
| 656 | } | - | 
| 657 |  | - | 
| 658 |  | - | 
| 659 |  | - | 
| 660 |  | - | 
| 661 |  | - | 
| 662 |  | - | 
| 663 |  | - | 
| 664 |  | - | 
| 665 | void QStatusBar::paintEvent(QPaintEvent *event) | - | 
| 666 | { | - | 
| 667 |     Q_D(QStatusBar); | - | 
| 668 |     bool haveMessage = !d->tempItem.isEmpty(); | - | 
| 669 |  | - | 
| 670 |     QPainter p(this); | - | 
| 671 |     QStyleOption opt; | - | 
| 672 |     opt.initFrom(this); | - | 
| 673 |     style()->drawPrimitive(QStyle::PE_PanelStatusBar, &opt, &p, this); | - | 
| 674 |  | - | 
| 675 |     for (int i=0; i<d->items.size(); ++i) { | - | 
| 676 |         QStatusBarPrivate::SBItem* item = d->items.at(i); | - | 
| 677 |         if (item && item->w->isVisible() && (!haveMessage || item->p)) { | - | 
| 678 |             QRect ir = item->w->geometry().adjusted(-2, -1, 2, 1); | - | 
| 679 |             if (event->rect().intersects(ir)) { | - | 
| 680 |                 QStyleOption opt(0); | - | 
| 681 |                 opt.rect = ir; | - | 
| 682 |                 opt.palette = palette(); | - | 
| 683 |                 opt.state = QStyle::State_None; | - | 
| 684 |                 style()->drawPrimitive(QStyle::PE_FrameStatusBarItem, &opt, &p, item->w); | - | 
| 685 |             } | - | 
| 686 |         } | - | 
| 687 |     } | - | 
| 688 |     if (haveMessage) { | - | 
| 689 |         p.setPen(palette().foreground().color()); | - | 
| 690 |         p.drawText(d->messageRect(), Qt::AlignLeading | Qt::AlignVCenter | Qt::TextSingleLine, d->tempItem); | - | 
| 691 |     } | - | 
| 692 | } | - | 
| 693 |  | - | 
| 694 |  | - | 
| 695 |  | - | 
| 696 |  | - | 
| 697 | void QStatusBar::resizeEvent(QResizeEvent * e) | - | 
| 698 | { | - | 
| 699 |     QWidget::resizeEvent(e); | - | 
| 700 | } | - | 
| 701 |  | - | 
| 702 |  | - | 
| 703 |  | - | 
| 704 |  | - | 
| 705 |  | - | 
| 706 | bool QStatusBar::event(QEvent *e) | - | 
| 707 | { | - | 
| 708 |     Q_D(QStatusBar); | - | 
| 709 |  | - | 
| 710 |     if (e->type() == QEvent::LayoutRequest | - | 
| 711 |         ) { | - | 
| 712 |          | - | 
| 713 |         int maxH = fontMetrics().height(); | - | 
| 714 |  | - | 
| 715 |         QStatusBarPrivate::SBItem* item = 0; | - | 
| 716 |         for (int i=0; i<d->items.size(); ++i) { | - | 
| 717 |             item = d->items.at(i); | - | 
| 718 |             if (!item) | - | 
| 719 |                 break; | - | 
| 720 |             int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight()); | - | 
| 721 |             maxH = qMax(maxH, itemH); | - | 
| 722 |         } | - | 
| 723 |  | - | 
| 724 | #ifndef QT_NO_SIZEGRIP | - | 
| 725 |         if (d->resizer) | - | 
| 726 |             maxH = qMax(maxH, d->resizer->sizeHint().height()); | - | 
| 727 | #endif | - | 
| 728 |  | - | 
| 729 |         if (maxH != d->savedStrut) | - | 
| 730 |             reformat(); | - | 
| 731 |         else | - | 
| 732 |             update(); | - | 
| 733 |     } | - | 
| 734 |     if (e->type() == QEvent::ChildRemoved) { | - | 
| 735 |         QStatusBarPrivate::SBItem* item = 0; | - | 
| 736 |         for (int i=0; i<d->items.size(); ++i) { | - | 
| 737 |             item = d->items.at(i); | - | 
| 738 |             if (!item) | - | 
| 739 |                 break; | - | 
| 740 |             if (item->w == ((QChildEvent*)e)->child()) { | - | 
| 741 |                 d->items.removeAt(i); | - | 
| 742 |                 delete item; | - | 
| 743 |             } | - | 
| 744 |         } | - | 
| 745 |     } | - | 
| 746 |  | - | 
| 747 |  | - | 
| 748 |  | - | 
| 749 | #ifndef Q_DEAD_CODE_FROM_QT4_MAC | - | 
| 750 |     return QWidget::event(e); | - | 
| 751 | #else | - | 
| 752 |     if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_4) | - | 
| 753 |         return QWidget::event(e); | - | 
| 754 |  | - | 
| 755 |      | - | 
| 756 |      | - | 
| 757 |     if (parent() == 0 || qobject_cast<QMainWindow *>(parent()) == 0 || | - | 
| 758 |         qobject_cast<QMainWindow *>(parent())->unifiedTitleAndToolBarOnMac() == false ) | - | 
| 759 |         return QWidget::event(e); | - | 
| 760 |  | - | 
| 761 |      | - | 
| 762 |     QMouseEvent *mouseEvent; | - | 
| 763 |     if (e->type() == QEvent::MouseButtonPress || | - | 
| 764 |         e->type() == QEvent::MouseMove || | - | 
| 765 |         e->type() == QEvent::MouseButtonRelease) { | - | 
| 766 |         mouseEvent = static_cast <QMouseEvent*>(e); | - | 
| 767 |     } else { | - | 
| 768 |         return QWidget::event(e); | - | 
| 769 |     } | - | 
| 770 |  | - | 
| 771 |      | - | 
| 772 |     if (e->type() == QEvent::MouseButtonPress && (mouseEvent->button() == Qt::LeftButton)) { | - | 
| 773 |         d->dragStart = mouseEvent->pos(); | - | 
| 774 |     } else if (e->type() == QEvent::MouseMove){ | - | 
| 775 |         if (d->dragStart == QPoint()) | - | 
| 776 |             return QWidget::event(e); | - | 
| 777 |         QPoint pos = mouseEvent->pos(); | - | 
| 778 |         QPoint delta = (pos - d->dragStart); | - | 
| 779 |         window()->move(window()->pos() + delta); | - | 
| 780 |     } else if (e->type() == QEvent::MouseButtonRelease && (mouseEvent->button() == Qt::LeftButton)){ | - | 
| 781 |         d->dragStart = QPoint(); | - | 
| 782 |     } else { | - | 
| 783 |         return QWidget::event(e); | - | 
| 784 |     } | - | 
| 785 |  | - | 
| 786 |     return true; | - | 
| 787 | #endif | - | 
| 788 | } | - | 
| 789 |  | - | 
| 790 | QT_END_NAMESPACE | - | 
| 791 |  | - | 
| 792 | #include "moc_qstatusbar.cpp" | - | 
| 793 |  | - | 
| 794 | #endif | - | 
 |  |  |