| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qtoolbar.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_TOOLBAR | - |
| 45 | | - |
| 46 | #include <qapplication.h> | - |
| 47 | #include <qcombobox.h> | - |
| 48 | #include <qevent.h> | - |
| 49 | #include <qlayout.h> | - |
| 50 | #include <qmainwindow.h> | - |
| 51 | #include <qmenu.h> | - |
| 52 | #include <qmenubar.h> | - |
| 53 | #include <qrubberband.h> | - |
| 54 | #include <qsignalmapper.h> | - |
| 55 | #include <qstylepainter.h> | - |
| 56 | #include <qtoolbutton.h> | - |
| 57 | #include <qwidgetaction.h> | - |
| 58 | #include <qtimer.h> | - |
| 59 | #include <private/qwidgetaction_p.h> | - |
| 60 | #ifdef Q_WS_MAC | - |
| 61 | #include <private/qt_mac_p.h> | - |
| 62 | #include <private/qt_cocoa_helpers_mac_p.h> | - |
| 63 | #endif | - |
| 64 | | - |
| 65 | #include <private/qmainwindowlayout_p.h> | - |
| 66 | | - |
| 67 | #include "qtoolbar_p.h" | - |
| 68 | #include "qtoolbarseparator_p.h" | - |
| 69 | #include "qtoolbarlayout_p.h" | - |
| 70 | | - |
| 71 | #include "qdebug.h" | - |
| 72 | | - |
| 73 | #define POPUP_TIMER_INTERVAL 500 | - |
| 74 | | - |
| 75 | QT_BEGIN_NAMESPACE | - |
| 76 | | - |
| 77 | #ifdef Q_WS_MAC | - |
| 78 | static void qt_mac_updateToolBarButtonHint(QWidget *parentWidget) | - |
| 79 | { | - |
| 80 | if (!(parentWidget->windowFlags() & Qt::CustomizeWindowHint)) | - |
| 81 | parentWidget->setWindowFlags(parentWidget->windowFlags() | Qt::MacWindowToolBarButtonHint); | - |
| 82 | } | - |
| 83 | #endif | - |
| 84 | | - |
| 85 | // qmainwindow.cpp | - |
| 86 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); | - |
| 87 | | - |
| 88 | /****************************************************************************** | - |
| 89 | ** QToolBarPrivate | - |
| 90 | */ | - |
| 91 | | - |
| 92 | void QToolBarPrivate::init() | - |
| 93 | { | - |
| 94 | Q_Q(QToolBar); executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 95 | q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); executed (the execution status of this line is deduced): q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); | - |
| 96 | q->setBackgroundRole(QPalette::Button); executed (the execution status of this line is deduced): q->setBackgroundRole(QPalette::Button); | - |
| 97 | q->setAttribute(Qt::WA_Hover); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_Hover); | - |
| 98 | q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar); | - |
| 99 | | - |
| 100 | QStyle *style = q->style(); executed (the execution status of this line is deduced): QStyle *style = q->style(); | - |
| 101 | int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); executed (the execution status of this line is deduced): int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); | - |
| 102 | iconSize = QSize(e, e); executed (the execution status of this line is deduced): iconSize = QSize(e, e); | - |
| 103 | | - |
| 104 | layout = new QToolBarLayout(q); executed (the execution status of this line is deduced): layout = new QToolBarLayout(q); | - |
| 105 | layout->updateMarginAndSpacing(); executed (the execution status of this line is deduced): layout->updateMarginAndSpacing(); | - |
| 106 | | - |
| 107 | #ifdef Q_WS_MAC | - |
| 108 | if (q->parentWidget() && q->parentWidget()->isWindow()) { | - |
| 109 | // Make sure that the window has the "toolbar" button. | - |
| 110 | QWidget *parentWidget = q->parentWidget(); | - |
| 111 | qt_mac_updateToolBarButtonHint(parentWidget); | - |
| 112 | reinterpret_cast<QToolBar *>(parentWidget)->d_func()->createWinId(); // Please let me create your winId... | - |
| 113 | extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp | - |
| 114 | macWindowToolbarShow(q->parentWidget(), true); | - |
| 115 | } | - |
| 116 | #endif | - |
| 117 | | - |
| 118 | toggleViewAction = new QAction(q); executed (the execution status of this line is deduced): toggleViewAction = new QAction(q); | - |
| 119 | toggleViewAction->setCheckable(true); executed (the execution status of this line is deduced): toggleViewAction->setCheckable(true); | - |
| 120 | q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q )); executed (the execution status of this line is deduced): q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q )); | - |
| 121 | QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), q, SLOT(_q_toggleView(bool))); executed (the execution status of this line is deduced): QObject::connect(toggleViewAction, "2""triggered(bool)", q, "1""_q_toggleView(bool)"); | - |
| 122 | } executed: }Execution Count:16 | 16 |
| 123 | | - |
| 124 | void QToolBarPrivate::_q_toggleView(bool b) | - |
| 125 | { | - |
| 126 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 127 | if (b == q->isHidden()) { never evaluated: b == q->isHidden() | 0 |
| 128 | if (b) | 0 |
| 129 | q->show(); never executed: q->show(); | 0 |
| 130 | else | - |
| 131 | q->close(); never executed: q->close(); | 0 |
| 132 | } | - |
| 133 | } | 0 |
| 134 | | - |
| 135 | void QToolBarPrivate::_q_updateIconSize(const QSize &sz) | - |
| 136 | { | - |
| 137 | Q_Q(QToolBar); executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 138 | if (!explicitIconSize) { partially evaluated: !explicitIconSize| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 139 | // iconSize not explicitly set | - |
| 140 | q->setIconSize(sz); executed (the execution status of this line is deduced): q->setIconSize(sz); | - |
| 141 | explicitIconSize = false; executed (the execution status of this line is deduced): explicitIconSize = false; | - |
| 142 | } executed: }Execution Count:2 | 2 |
| 143 | } executed: }Execution Count:2 | 2 |
| 144 | | - |
| 145 | void QToolBarPrivate::_q_updateToolButtonStyle(Qt::ToolButtonStyle style) | - |
| 146 | { | - |
| 147 | Q_Q(QToolBar); executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 148 | if (!explicitToolButtonStyle) { partially evaluated: !explicitToolButtonStyle| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 149 | q->setToolButtonStyle(style); executed (the execution status of this line is deduced): q->setToolButtonStyle(style); | - |
| 150 | explicitToolButtonStyle = false; executed (the execution status of this line is deduced): explicitToolButtonStyle = false; | - |
| 151 | } executed: }Execution Count:2 | 2 |
| 152 | } executed: }Execution Count:2 | 2 |
| 153 | | - |
| 154 | void QToolBarPrivate::updateWindowFlags(bool floating, bool unplug) | - |
| 155 | { | - |
| 156 | Q_Q(QToolBar); executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 157 | Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; partially evaluated: floating| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 158 | | - |
| 159 | flags |= Qt::FramelessWindowHint; executed (the execution status of this line is deduced): flags |= Qt::FramelessWindowHint; | - |
| 160 | | - |
| 161 | if (unplug) { partially evaluated: unplug| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 162 | flags |= Qt::X11BypassWindowManagerHint; never executed (the execution status of this line is deduced): flags |= Qt::X11BypassWindowManagerHint; | - |
| 163 | #ifdef Q_WS_MAC | - |
| 164 | flags |= Qt::WindowStaysOnTopHint; | - |
| 165 | #endif | - |
| 166 | } | 0 |
| 167 | | - |
| 168 | q->setWindowFlags(flags); executed (the execution status of this line is deduced): q->setWindowFlags(flags); | - |
| 169 | } executed: }Execution Count:2 | 2 |
| 170 | | - |
| 171 | void QToolBarPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) | - |
| 172 | { | - |
| 173 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 174 | bool visible = !q->isHidden(); never executed (the execution status of this line is deduced): bool visible = !q->isHidden(); | - |
| 175 | bool wasFloating = q->isFloating(); // ...is also currently using popup menus never executed (the execution status of this line is deduced): bool wasFloating = q->isFloating(); | - |
| 176 | | - |
| 177 | q->hide(); never executed (the execution status of this line is deduced): q->hide(); | - |
| 178 | | - |
| 179 | updateWindowFlags(floating, unplug); never executed (the execution status of this line is deduced): updateWindowFlags(floating, unplug); | - |
| 180 | | - |
| 181 | if (floating != wasFloating) never evaluated: floating != wasFloating | 0 |
| 182 | layout->checkUsePopupMenu(); never executed: layout->checkUsePopupMenu(); | 0 |
| 183 | | - |
| 184 | if (!rect.isNull()) never evaluated: !rect.isNull() | 0 |
| 185 | q->setGeometry(rect); never executed: q->setGeometry(rect); | 0 |
| 186 | | - |
| 187 | if (visible) | 0 |
| 188 | q->show(); never executed: q->show(); | 0 |
| 189 | | - |
| 190 | if (floating != wasFloating) never evaluated: floating != wasFloating | 0 |
| 191 | emit q->topLevelChanged(floating); never executed: q->topLevelChanged(floating); | 0 |
| 192 | } | 0 |
| 193 | | - |
| 194 | void QToolBarPrivate::initDrag(const QPoint &pos) | - |
| 195 | { | - |
| 196 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 197 | | - |
| 198 | if (state != 0) never evaluated: state != 0 | 0 |
| 199 | return; | 0 |
| 200 | | - |
| 201 | QMainWindow *win = qobject_cast<QMainWindow*>(parent); never executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parent); | - |
| 202 | Q_ASSERT(win != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 203 | QMainWindowLayout *layout = qt_mainwindow_layout(win); never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(win); | - |
| 204 | Q_ASSERT(layout != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 205 | if (layout->pluggingWidget != 0) // the main window is animating a docking operation never evaluated: layout->pluggingWidget != 0 | 0 |
| 206 | return; | 0 |
| 207 | | - |
| 208 | state = new DragState; never executed (the execution status of this line is deduced): state = new DragState; | - |
| 209 | state->pressPos = pos; never executed (the execution status of this line is deduced): state->pressPos = pos; | - |
| 210 | state->dragging = false; never executed (the execution status of this line is deduced): state->dragging = false; | - |
| 211 | state->moving = false; never executed (the execution status of this line is deduced): state->moving = false; | - |
| 212 | state->widgetItem = 0; never executed (the execution status of this line is deduced): state->widgetItem = 0; | - |
| 213 | | - |
| 214 | if (q->isRightToLeft()) never evaluated: q->isRightToLeft() | 0 |
| 215 | state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y()); never executed: state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y()); | 0 |
| 216 | } | 0 |
| 217 | | - |
| 218 | void QToolBarPrivate::startDrag(bool moving) | - |
| 219 | { | - |
| 220 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 221 | | - |
| 222 | Q_ASSERT(state != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 223 | | - |
| 224 | if ((moving && state->moving) || state->dragging) never evaluated: moving never evaluated: state->moving never evaluated: state->dragging | 0 |
| 225 | return; | 0 |
| 226 | | - |
| 227 | QMainWindow *win = qobject_cast<QMainWindow*>(parent); never executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parent); | - |
| 228 | Q_ASSERT(win != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 229 | QMainWindowLayout *layout = qt_mainwindow_layout(win); never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(win); | - |
| 230 | Q_ASSERT(layout != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 231 | | - |
| 232 | if (!moving) { | 0 |
| 233 | state->widgetItem = layout->unplug(q); never executed (the execution status of this line is deduced): state->widgetItem = layout->unplug(q); | - |
| 234 | Q_ASSERT(state->widgetItem != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 235 | } | 0 |
| 236 | state->dragging = !moving; never executed (the execution status of this line is deduced): state->dragging = !moving; | - |
| 237 | state->moving = moving; never executed (the execution status of this line is deduced): state->moving = moving; | - |
| 238 | } | 0 |
| 239 | | - |
| 240 | void QToolBarPrivate::endDrag() | - |
| 241 | { | - |
| 242 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 243 | Q_ASSERT(state != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 244 | | - |
| 245 | q->releaseMouse(); never executed (the execution status of this line is deduced): q->releaseMouse(); | - |
| 246 | | - |
| 247 | if (state->dragging) { never evaluated: state->dragging | 0 |
| 248 | QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); | - |
| 249 | Q_ASSERT(layout != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 250 | | - |
| 251 | if (!layout->plug(state->widgetItem)) { never evaluated: !layout->plug(state->widgetItem) | 0 |
| 252 | if (q->isFloatable()) { never evaluated: q->isFloatable() | 0 |
| 253 | layout->restore(); never executed (the execution status of this line is deduced): layout->restore(); | - |
| 254 | #if defined(Q_WS_X11) || defined(Q_WS_MAC) | - |
| 255 | setWindowState(true); // gets rid of the X11BypassWindowManager window flag | - |
| 256 | // and activates the resizer | - |
| 257 | #endif | - |
| 258 | q->activateWindow(); never executed (the execution status of this line is deduced): q->activateWindow(); | - |
| 259 | } else { | 0 |
| 260 | layout->revert(state->widgetItem); never executed (the execution status of this line is deduced): layout->revert(state->widgetItem); | - |
| 261 | } | 0 |
| 262 | } | - |
| 263 | } | 0 |
| 264 | | - |
| 265 | delete state; never executed (the execution status of this line is deduced): delete state; | - |
| 266 | state = 0; never executed (the execution status of this line is deduced): state = 0; | - |
| 267 | } | 0 |
| 268 | | - |
| 269 | bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) | - |
| 270 | { | - |
| 271 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 272 | QStyleOptionToolBar opt; never executed (the execution status of this line is deduced): QStyleOptionToolBar opt; | - |
| 273 | q->initStyleOption(&opt); never executed (the execution status of this line is deduced): q->initStyleOption(&opt); | - |
| 274 | if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) { never evaluated: q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false | 0 |
| 275 | #ifdef Q_WS_MAC | - |
| 276 | // When using the unified toolbar on Mac OS X, the user can click and | - |
| 277 | // drag between toolbar contents to move the window. Make this work by | - |
| 278 | // implementing the standard mouse-dragging code and then call | - |
| 279 | // window->move() in mouseMoveEvent below. | - |
| 280 | if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parent)) { | - |
| 281 | if (mainWindow->toolBarArea(q) == Qt::TopToolBarArea | - |
| 282 | && mainWindow->unifiedTitleAndToolBarOnMac() | - |
| 283 | && q->childAt(event->pos()) == 0) { | - |
| 284 | macWindowDragging = true; | - |
| 285 | macWindowDragPressPosition = event->pos(); | - |
| 286 | return true; | - |
| 287 | } | - |
| 288 | } | - |
| 289 | #endif | - |
| 290 | return false; never executed: return false; | 0 |
| 291 | } | - |
| 292 | | - |
| 293 | if (event->button() != Qt::LeftButton) never evaluated: event->button() != Qt::LeftButton | 0 |
| 294 | return true; never executed: return true; | 0 |
| 295 | | - |
| 296 | if (!layout->movable()) never evaluated: !layout->movable() | 0 |
| 297 | return true; never executed: return true; | 0 |
| 298 | | - |
| 299 | initDrag(event->pos()); never executed (the execution status of this line is deduced): initDrag(event->pos()); | - |
| 300 | return true; never executed: return true; | 0 |
| 301 | } | - |
| 302 | | - |
| 303 | bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*) | - |
| 304 | { | - |
| 305 | if (state != 0) { never evaluated: state != 0 | 0 |
| 306 | endDrag(); never executed (the execution status of this line is deduced): endDrag(); | - |
| 307 | return true; never executed: return true; | 0 |
| 308 | } else { | - |
| 309 | #ifdef Q_WS_MAC | - |
| 310 | if (!macWindowDragging) | - |
| 311 | return false; | - |
| 312 | macWindowDragging = false; | - |
| 313 | macWindowDragPressPosition = QPoint(); | - |
| 314 | return true; | - |
| 315 | #endif | - |
| 316 | return false; never executed: return false; | 0 |
| 317 | } | - |
| 318 | } | - |
| 319 | | - |
| 320 | bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) | - |
| 321 | { | - |
| 322 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 323 | | - |
| 324 | if (!state) { | 0 |
| 325 | #ifdef Q_WS_MAC | - |
| 326 | if (!macWindowDragging) | - |
| 327 | return false; | - |
| 328 | QWidget *w = q->window(); | - |
| 329 | const QPoint delta = event->pos() - macWindowDragPressPosition; | - |
| 330 | w->move(w->pos() + delta); | - |
| 331 | return true; | - |
| 332 | #endif | - |
| 333 | return false; never executed: return false; | 0 |
| 334 | } | - |
| 335 | | - |
| 336 | QMainWindow *win = qobject_cast<QMainWindow*>(parent); never executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parent); | - |
| 337 | if (win == 0) never evaluated: win == 0 | 0 |
| 338 | return true; never executed: return true; | 0 |
| 339 | | - |
| 340 | QMainWindowLayout *layout = qt_mainwindow_layout(win); never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(win); | - |
| 341 | Q_ASSERT(layout != 0); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 342 | | - |
| 343 | if (layout->pluggingWidget == 0 never evaluated: layout->pluggingWidget == 0 | 0 |
| 344 | && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { never evaluated: (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance() | 0 |
| 345 | const bool wasDragging = state->dragging; never executed (the execution status of this line is deduced): const bool wasDragging = state->dragging; | - |
| 346 | const bool moving = !q->isWindow() && (orientation == Qt::Vertical ? never evaluated: !q->isWindow() never evaluated: orientation == Qt::Vertical | 0 |
| 347 | event->x() >= 0 && event->x() < q->width() : never executed (the execution status of this line is deduced): event->x() >= 0 && event->x() < q->width() : | - |
| 348 | event->y() >= 0 && event->y() < q->height()); never executed (the execution status of this line is deduced): event->y() >= 0 && event->y() < q->height()); | - |
| 349 | | - |
| 350 | startDrag(moving); never executed (the execution status of this line is deduced): startDrag(moving); | - |
| 351 | if (!moving && !wasDragging) { never evaluated: !moving never evaluated: !wasDragging | 0 |
| 352 | #ifdef Q_WS_WIN | - |
| 353 | grabMouseWhileInWindow(); | - |
| 354 | #else | - |
| 355 | q->grabMouse(); never executed (the execution status of this line is deduced): q->grabMouse(); | - |
| 356 | #endif | - |
| 357 | } | 0 |
| 358 | } | 0 |
| 359 | | - |
| 360 | if (state->dragging) { never evaluated: state->dragging | 0 |
| 361 | QPoint pos = event->globalPos(); never executed (the execution status of this line is deduced): QPoint pos = event->globalPos(); | - |
| 362 | // if we are right-to-left, we move so as to keep the right edge the same distance | - |
| 363 | // from the mouse | - |
| 364 | if (q->isLeftToRight()) never evaluated: q->isLeftToRight() | 0 |
| 365 | pos -= state->pressPos; never executed: pos -= state->pressPos; | 0 |
| 366 | else | - |
| 367 | pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y()); never executed: pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y()); | 0 |
| 368 | | - |
| 369 | q->move(pos); never executed (the execution status of this line is deduced): q->move(pos); | - |
| 370 | layout->hover(state->widgetItem, event->globalPos()); never executed (the execution status of this line is deduced): layout->hover(state->widgetItem, event->globalPos()); | - |
| 371 | } else if (state->moving) { never executed: } never evaluated: state->moving | 0 |
| 372 | | - |
| 373 | const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL never executed (the execution status of this line is deduced): const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); | - |
| 374 | const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos); never executed (the execution status of this line is deduced): const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos); | - |
| 375 | int pos = 0; never executed (the execution status of this line is deduced): int pos = 0; | - |
| 376 | | - |
| 377 | QPoint delta = event->globalPos() - globalPressPos; never executed (the execution status of this line is deduced): QPoint delta = event->globalPos() - globalPressPos; | - |
| 378 | if (orientation == Qt::Vertical) { never evaluated: orientation == Qt::Vertical | 0 |
| 379 | pos = q->y() + delta.y(); never executed (the execution status of this line is deduced): pos = q->y() + delta.y(); | - |
| 380 | } else { | 0 |
| 381 | if (q->isRightToLeft()) { never evaluated: q->isRightToLeft() | 0 |
| 382 | pos = win->width() - q->width() - q->x() - delta.x(); never executed (the execution status of this line is deduced): pos = win->width() - q->width() - q->x() - delta.x(); | - |
| 383 | } else { | 0 |
| 384 | pos = q->x() + delta.x(); never executed (the execution status of this line is deduced): pos = q->x() + delta.x(); | - |
| 385 | } | 0 |
| 386 | } | - |
| 387 | | - |
| 388 | layout->moveToolBar(q, pos); never executed (the execution status of this line is deduced): layout->moveToolBar(q, pos); | - |
| 389 | } | 0 |
| 390 | return true; never executed: return true; | 0 |
| 391 | } | - |
| 392 | | - |
| 393 | void QToolBarPrivate::unplug(const QRect &_r) | - |
| 394 | { | - |
| 395 | Q_Q(QToolBar); never executed (the execution status of this line is deduced): QToolBar * const q = q_func(); | - |
| 396 | QRect r = _r; never executed (the execution status of this line is deduced): QRect r = _r; | - |
| 397 | r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); never executed (the execution status of this line is deduced): r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); | - |
| 398 | setWindowState(true, true, r); never executed (the execution status of this line is deduced): setWindowState(true, true, r); | - |
| 399 | layout->setExpanded(false); never executed (the execution status of this line is deduced): layout->setExpanded(false); | - |
| 400 | } | 0 |
| 401 | | - |
| 402 | void QToolBarPrivate::plug(const QRect &r) | - |
| 403 | { | - |
| 404 | setWindowState(false, false, r); never executed (the execution status of this line is deduced): setWindowState(false, false, r); | - |
| 405 | } | 0 |
| 406 | | - |
| 407 | /****************************************************************************** | - |
| 408 | ** QToolBar | - |
| 409 | */ | - |
| 410 | | - |
| 411 | /*! | - |
| 412 | \class QToolBar | - |
| 413 | | - |
| 414 | \brief The QToolBar class provides a movable panel that contains a | - |
| 415 | set of controls. | - |
| 416 | | - |
| 417 | \ingroup mainwindow-classes | - |
| 418 | \inmodule QtWidgets | - |
| 419 | | - |
| 420 | Toolbar buttons are added by adding \e actions, using addAction() | - |
| 421 | or insertAction(). Groups of buttons can be separated using | - |
| 422 | addSeparator() or insertSeparator(). If a toolbar button is not | - |
| 423 | appropriate, a widget can be inserted instead using addWidget() or | - |
| 424 | insertWidget(). Examples of suitable widgets are QSpinBox, | - |
| 425 | QDoubleSpinBox, and QComboBox. When a toolbar button is pressed, it | - |
| 426 | emits the actionTriggered() signal. | - |
| 427 | | - |
| 428 | A toolbar can be fixed in place in a particular area (e.g., at the | - |
| 429 | top of the window), or it can be movable between toolbar areas; | - |
| 430 | see setMovable(), isMovable(), allowedAreas() and isAreaAllowed(). | - |
| 431 | | - |
| 432 | When a toolbar is resized in such a way that it is too small to | - |
| 433 | show all the items it contains, an extension button will appear as | - |
| 434 | the last item in the toolbar. Pressing the extension button will | - |
| 435 | pop up a menu containing the items that does not currently fit in | - |
| 436 | the toolbar. | - |
| 437 | | - |
| 438 | When a QToolBar is not a child of a QMainWindow, it loses the ability | - |
| 439 | to populate the extension pop up with widgets added to the toolbar using | - |
| 440 | addWidget(). Please use widget actions created by inheriting QWidgetAction | - |
| 441 | and implementing QWidgetAction::createWidget() instead. | - |
| 442 | | - |
| 443 | \sa QToolButton, QMenu, QAction, {Application Example} | - |
| 444 | */ | - |
| 445 | | - |
| 446 | /*! | - |
| 447 | \fn bool QToolBar::isAreaAllowed(Qt::ToolBarArea area) const | - |
| 448 | | - |
| 449 | Returns true if this toolbar is dockable in the given \a area; | - |
| 450 | otherwise returns false. | - |
| 451 | */ | - |
| 452 | | - |
| 453 | /*! | - |
| 454 | \fn void QToolBar::addAction(QAction *action) | - |
| 455 | \overload | - |
| 456 | | - |
| 457 | Appends the \a action to the toolbar's list of actions. | - |
| 458 | | - |
| 459 | \sa QMenu::addAction(), QWidget::addAction() | - |
| 460 | */ | - |
| 461 | | - |
| 462 | /*! | - |
| 463 | \fn void QToolBar::actionTriggered(QAction *action) | - |
| 464 | | - |
| 465 | This signal is emitted when an action in this toolbar is triggered. | - |
| 466 | This happens when the action's tool button is pressed, or when the | - |
| 467 | action is triggered in some other way outside the toolbar. The parameter | - |
| 468 | holds the triggered \a action. | - |
| 469 | */ | - |
| 470 | | - |
| 471 | /*! | - |
| 472 | \fn void QToolBar::allowedAreasChanged(Qt::ToolBarAreas allowedAreas) | - |
| 473 | | - |
| 474 | This signal is emitted when the collection of allowed areas for the | - |
| 475 | toolbar is changed. The new areas in which the toolbar can be positioned | - |
| 476 | are specified by \a allowedAreas. | - |
| 477 | | - |
| 478 | \sa allowedAreas | - |
| 479 | */ | - |
| 480 | | - |
| 481 | /*! | - |
| 482 | \fn void QToolBar::iconSizeChanged(const QSize &iconSize) | - |
| 483 | | - |
| 484 | This signal is emitted when the icon size is changed. The \a | - |
| 485 | iconSize parameter holds the toolbar's new icon size. | - |
| 486 | | - |
| 487 | \sa iconSize, QMainWindow::iconSize | - |
| 488 | */ | - |
| 489 | | - |
| 490 | /*! | - |
| 491 | \fn void QToolBar::movableChanged(bool movable) | - |
| 492 | | - |
| 493 | This signal is emitted when the toolbar becomes movable or fixed. | - |
| 494 | If the toolbar can be moved, \a movable is true; otherwise it is | - |
| 495 | false. | - |
| 496 | | - |
| 497 | \sa movable | - |
| 498 | */ | - |
| 499 | | - |
| 500 | /*! | - |
| 501 | \fn void QToolBar::orientationChanged(Qt::Orientation orientation) | - |
| 502 | | - |
| 503 | This signal is emitted when the orientation of the toolbar changes. | - |
| 504 | The \a orientation parameter holds the toolbar's new orientation. | - |
| 505 | | - |
| 506 | \sa orientation | - |
| 507 | */ | - |
| 508 | | - |
| 509 | /*! | - |
| 510 | \fn void QToolBar::toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle) | - |
| 511 | | - |
| 512 | This signal is emitted when the tool button style is changed. The | - |
| 513 | \a toolButtonStyle parameter holds the toolbar's new tool button | - |
| 514 | style. | - |
| 515 | | - |
| 516 | \sa toolButtonStyle, QMainWindow::toolButtonStyle | - |
| 517 | */ | - |
| 518 | | - |
| 519 | /*! | - |
| 520 | \since 4.6 | - |
| 521 | | - |
| 522 | \fn void QToolBar::topLevelChanged(bool topLevel) | - |
| 523 | | - |
| 524 | This signal is emitted when the \l floating property changes. | - |
| 525 | The \a topLevel parameter is true if the toolbar is now floating; | - |
| 526 | otherwise it is false. | - |
| 527 | | - |
| 528 | \sa isWindow() | - |
| 529 | */ | - |
| 530 | | - |
| 531 | | - |
| 532 | /*! | - |
| 533 | \fn void QToolBar::visibilityChanged(bool visible) | - |
| 534 | \since 4.7 | - |
| 535 | | - |
| 536 | This signal is emitted when the toolbar becomes \a visible (or | - |
| 537 | invisible). This happens when the widget is hidden or shown. | - |
| 538 | */ | - |
| 539 | | - |
| 540 | /*! | - |
| 541 | Constructs a QToolBar with the given \a parent. | - |
| 542 | */ | - |
| 543 | QToolBar::QToolBar(QWidget *parent) | - |
| 544 | : QWidget(*new QToolBarPrivate, parent, 0) | - |
| 545 | { | - |
| 546 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 547 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 548 | } executed: }Execution Count:16 | 16 |
| 549 | | - |
| 550 | /*! | - |
| 551 | Constructs a QToolBar with the given \a parent. | - |
| 552 | | - |
| 553 | The given window \a title identifies the toolbar and is shown in | - |
| 554 | the context menu provided by QMainWindow. | - |
| 555 | | - |
| 556 | \sa setWindowTitle() | - |
| 557 | */ | - |
| 558 | QToolBar::QToolBar(const QString &title, QWidget *parent) | - |
| 559 | : QWidget(*new QToolBarPrivate, parent, 0) | - |
| 560 | { | - |
| 561 | Q_D(QToolBar); never executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 562 | d->init(); never executed (the execution status of this line is deduced): d->init(); | - |
| 563 | setWindowTitle(title); never executed (the execution status of this line is deduced): setWindowTitle(title); | - |
| 564 | } | 0 |
| 565 | | - |
| 566 | | - |
| 567 | /*! | - |
| 568 | Destroys the toolbar. | - |
| 569 | */ | - |
| 570 | QToolBar::~QToolBar() | - |
| 571 | { | - |
| 572 | // Remove the toolbar button if there is nothing left. | - |
| 573 | QMainWindow *mainwindow = qobject_cast<QMainWindow *>(parentWidget()); executed (the execution status of this line is deduced): QMainWindow *mainwindow = qobject_cast<QMainWindow *>(parentWidget()); | - |
| 574 | if (mainwindow) { evaluated: mainwindow| yes Evaluation Count:1 | yes Evaluation Count:15 |
| 1-15 |
| 575 | #ifdef Q_WS_MAC | - |
| 576 | QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow); | - |
| 577 | if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty() | - |
| 578 | && mainwindow->testAttribute(Qt::WA_WState_Created)) | - |
| 579 | macWindowToolbarShow(mainwindow, false); | - |
| 580 | #endif | - |
| 581 | } executed: }Execution Count:1 | 1 |
| 582 | } executed: }Execution Count:16 | 16 |
| 583 | | - |
| 584 | /*! \property QToolBar::movable | - |
| 585 | \brief whether the user can move the toolbar within the toolbar area, | - |
| 586 | or between toolbar areas. | - |
| 587 | | - |
| 588 | By default, this property is true. | - |
| 589 | | - |
| 590 | This property only makes sense if the toolbar is in a | - |
| 591 | QMainWindow. | - |
| 592 | | - |
| 593 | \sa allowedAreas | - |
| 594 | */ | - |
| 595 | | - |
| 596 | void QToolBar::setMovable(bool movable) | - |
| 597 | { | - |
| 598 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 599 | if (!movable == !d->movable) partially evaluated: !movable == !d->movable| yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
| 600 | return; executed: return;Execution Count:16 | 16 |
| 601 | d->movable = movable; never executed (the execution status of this line is deduced): d->movable = movable; | - |
| 602 | d->layout->invalidate(); never executed (the execution status of this line is deduced): d->layout->invalidate(); | - |
| 603 | emit movableChanged(d->movable); never executed (the execution status of this line is deduced): movableChanged(d->movable); | - |
| 604 | } | 0 |
| 605 | | - |
| 606 | bool QToolBar::isMovable() const | - |
| 607 | { | - |
| 608 | Q_D(const QToolBar); executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 609 | return d->movable; executed: return d->movable;Execution Count:250 | 250 |
| 610 | } | - |
| 611 | | - |
| 612 | /*! | - |
| 613 | \property QToolBar::floatable | - |
| 614 | \brief whether the toolbar can be dragged and dropped as an independent window. | - |
| 615 | | - |
| 616 | The default is true. | - |
| 617 | */ | - |
| 618 | bool QToolBar::isFloatable() const | - |
| 619 | { | - |
| 620 | Q_D(const QToolBar); never executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 621 | return d->floatable; never executed: return d->floatable; | 0 |
| 622 | } | - |
| 623 | | - |
| 624 | void QToolBar::setFloatable(bool floatable) | - |
| 625 | { | - |
| 626 | Q_D(QToolBar); never executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 627 | d->floatable = floatable; never executed (the execution status of this line is deduced): d->floatable = floatable; | - |
| 628 | } | 0 |
| 629 | | - |
| 630 | /*! | - |
| 631 | \property QToolBar::floating | - |
| 632 | \brief whether the toolbar is an independent window. | - |
| 633 | | - |
| 634 | By default, this property is true. | - |
| 635 | | - |
| 636 | \sa QWidget::isWindow() | - |
| 637 | */ | - |
| 638 | bool QToolBar::isFloating() const | - |
| 639 | { | - |
| 640 | return isWindow(); executed: return isWindow();Execution Count:11 | 11 |
| 641 | } | - |
| 642 | | - |
| 643 | /*! | - |
| 644 | \property QToolBar::allowedAreas | - |
| 645 | \brief areas where the toolbar may be placed | - |
| 646 | | - |
| 647 | The default is Qt::AllToolBarAreas. | - |
| 648 | | - |
| 649 | This property only makes sense if the toolbar is in a | - |
| 650 | QMainWindow. | - |
| 651 | | - |
| 652 | \sa movable | - |
| 653 | */ | - |
| 654 | | - |
| 655 | void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas) | - |
| 656 | { | - |
| 657 | Q_D(QToolBar); never executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 658 | areas &= Qt::ToolBarArea_Mask; never executed (the execution status of this line is deduced): areas &= Qt::ToolBarArea_Mask; | - |
| 659 | if (areas == d->allowedAreas) never evaluated: areas == d->allowedAreas | 0 |
| 660 | return; | 0 |
| 661 | d->allowedAreas = areas; never executed (the execution status of this line is deduced): d->allowedAreas = areas; | - |
| 662 | emit allowedAreasChanged(d->allowedAreas); never executed (the execution status of this line is deduced): allowedAreasChanged(d->allowedAreas); | - |
| 663 | } | 0 |
| 664 | | - |
| 665 | Qt::ToolBarAreas QToolBar::allowedAreas() const | - |
| 666 | { | - |
| 667 | Q_D(const QToolBar); never executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 668 | #ifdef Q_WS_MAC | - |
| 669 | if (QMainWindow *window = qobject_cast<QMainWindow *>(parentWidget())) { | - |
| 670 | if (window->unifiedTitleAndToolBarOnMac()) // Don't allow drags to the top (for now). | - |
| 671 | return (d->allowedAreas & ~Qt::TopToolBarArea); | - |
| 672 | } | - |
| 673 | #endif | - |
| 674 | return d->allowedAreas; never executed: return d->allowedAreas; | 0 |
| 675 | } | - |
| 676 | | - |
| 677 | /*! \property QToolBar::orientation | - |
| 678 | \brief orientation of the toolbar | - |
| 679 | | - |
| 680 | The default is Qt::Horizontal. | - |
| 681 | | - |
| 682 | This function should not be used when the toolbar is managed | - |
| 683 | by QMainWindow. You can use QMainWindow::addToolBar() or | - |
| 684 | QMainWindow::insertToolBar() if you wish to move a toolbar that | - |
| 685 | is already added to a main window to another Qt::ToolBarArea. | - |
| 686 | */ | - |
| 687 | | - |
| 688 | void QToolBar::setOrientation(Qt::Orientation orientation) | - |
| 689 | { | - |
| 690 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 691 | if (orientation == d->orientation) partially evaluated: orientation == d->orientation| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 692 | return; executed: return;Execution Count:2 | 2 |
| 693 | | - |
| 694 | d->orientation = orientation; never executed (the execution status of this line is deduced): d->orientation = orientation; | - |
| 695 | | - |
| 696 | if (orientation == Qt::Vertical) never evaluated: orientation == Qt::Vertical | 0 |
| 697 | setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); never executed: setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); | 0 |
| 698 | else | - |
| 699 | setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); never executed: setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); | 0 |
| 700 | | - |
| 701 | d->layout->invalidate(); never executed (the execution status of this line is deduced): d->layout->invalidate(); | - |
| 702 | d->layout->activate(); never executed (the execution status of this line is deduced): d->layout->activate(); | - |
| 703 | | - |
| 704 | emit orientationChanged(d->orientation); never executed (the execution status of this line is deduced): orientationChanged(d->orientation); | - |
| 705 | } | 0 |
| 706 | | - |
| 707 | Qt::Orientation QToolBar::orientation() const | - |
| 708 | { Q_D(const QToolBar); return d->orientation; } executed: return d->orientation;Execution Count:323 | 323 |
| 709 | | - |
| 710 | /*! | - |
| 711 | \property QToolBar::iconSize | - |
| 712 | \brief size of icons in the toolbar. | - |
| 713 | | - |
| 714 | The default size is determined by the application's style and is | - |
| 715 | derived from the QStyle::PM_ToolBarIconSize pixel metric. It is | - |
| 716 | the maximum size an icon can have. Icons of smaller size will not | - |
| 717 | be scaled up. | - |
| 718 | */ | - |
| 719 | | - |
| 720 | QSize QToolBar::iconSize() const | - |
| 721 | { Q_D(const QToolBar); return d->iconSize; } executed: return d->iconSize;Execution Count:9 | 9 |
| 722 | | - |
| 723 | void QToolBar::setIconSize(const QSize &iconSize) | - |
| 724 | { | - |
| 725 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 726 | QSize sz = iconSize; executed (the execution status of this line is deduced): QSize sz = iconSize; | - |
| 727 | if (!sz.isValid()) { partially evaluated: !sz.isValid()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 728 | QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget()); never executed (the execution status of this line is deduced): QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget()); | - |
| 729 | if (mw && mw->layout()) { never evaluated: mw never evaluated: mw->layout() | 0 |
| 730 | QLayout *layout = mw->layout(); never executed (the execution status of this line is deduced): QLayout *layout = mw->layout(); | - |
| 731 | int i = 0; never executed (the execution status of this line is deduced): int i = 0; | - |
| 732 | QLayoutItem *item = 0; never executed (the execution status of this line is deduced): QLayoutItem *item = 0; | - |
| 733 | do { | - |
| 734 | item = layout->itemAt(i++); never executed (the execution status of this line is deduced): item = layout->itemAt(i++); | - |
| 735 | if (item && (item->widget() == this)) never evaluated: item never evaluated: (item->widget() == this) | 0 |
| 736 | sz = mw->iconSize(); never executed: sz = mw->iconSize(); | 0 |
| 737 | } while (!sz.isValid() && item != 0); never executed: } never evaluated: !sz.isValid() never evaluated: item != 0 | 0 |
| 738 | } | 0 |
| 739 | } | 0 |
| 740 | if (!sz.isValid()) { partially evaluated: !sz.isValid()| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 741 | const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); never executed (the execution status of this line is deduced): const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); | - |
| 742 | sz = QSize(metric, metric); never executed (the execution status of this line is deduced): sz = QSize(metric, metric); | - |
| 743 | } | 0 |
| 744 | if (d->iconSize != sz) { partially evaluated: d->iconSize != sz| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 745 | d->iconSize = sz; never executed (the execution status of this line is deduced): d->iconSize = sz; | - |
| 746 | setMinimumSize(0, 0); never executed (the execution status of this line is deduced): setMinimumSize(0, 0); | - |
| 747 | emit iconSizeChanged(d->iconSize); never executed (the execution status of this line is deduced): iconSizeChanged(d->iconSize); | - |
| 748 | } | 0 |
| 749 | d->explicitIconSize = iconSize.isValid(); executed (the execution status of this line is deduced): d->explicitIconSize = iconSize.isValid(); | - |
| 750 | | - |
| 751 | d->layout->invalidate(); executed (the execution status of this line is deduced): d->layout->invalidate(); | - |
| 752 | } executed: }Execution Count:2 | 2 |
| 753 | | - |
| 754 | /*! | - |
| 755 | \property QToolBar::toolButtonStyle | - |
| 756 | \brief the style of toolbar buttons | - |
| 757 | | - |
| 758 | This property defines the style of all tool buttons that are added | - |
| 759 | as \l{QAction}s. Note that if you add a QToolButton with the | - |
| 760 | addWidget() method, it will not get this button style. | - |
| 761 | | - |
| 762 | The default is Qt::ToolButtonIconOnly. | - |
| 763 | */ | - |
| 764 | | - |
| 765 | Qt::ToolButtonStyle QToolBar::toolButtonStyle() const | - |
| 766 | { Q_D(const QToolBar); return d->toolButtonStyle; } executed: return d->toolButtonStyle;Execution Count:3 | 3 |
| 767 | | - |
| 768 | void QToolBar::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) | - |
| 769 | { | - |
| 770 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 771 | d->explicitToolButtonStyle = true; executed (the execution status of this line is deduced): d->explicitToolButtonStyle = true; | - |
| 772 | if (d->toolButtonStyle == toolButtonStyle) partially evaluated: d->toolButtonStyle == toolButtonStyle| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 773 | return; executed: return;Execution Count:2 | 2 |
| 774 | d->toolButtonStyle = toolButtonStyle; never executed (the execution status of this line is deduced): d->toolButtonStyle = toolButtonStyle; | - |
| 775 | setMinimumSize(0, 0); never executed (the execution status of this line is deduced): setMinimumSize(0, 0); | - |
| 776 | emit toolButtonStyleChanged(d->toolButtonStyle); never executed (the execution status of this line is deduced): toolButtonStyleChanged(d->toolButtonStyle); | - |
| 777 | } | 0 |
| 778 | | - |
| 779 | /*! | - |
| 780 | Removes all actions from the toolbar. | - |
| 781 | | - |
| 782 | \sa removeAction() | - |
| 783 | */ | - |
| 784 | void QToolBar::clear() | - |
| 785 | { | - |
| 786 | QList<QAction *> actions = this->actions(); never executed (the execution status of this line is deduced): QList<QAction *> actions = this->actions(); | - |
| 787 | for(int i = 0; i < actions.size(); i++) never evaluated: i < actions.size() | 0 |
| 788 | removeAction(actions.at(i)); never executed: removeAction(actions.at(i)); | 0 |
| 789 | } | 0 |
| 790 | | - |
| 791 | /*! | - |
| 792 | \overload | - |
| 793 | | - |
| 794 | Creates a new action with the given \a text. This action is added to | - |
| 795 | the end of the toolbar. | - |
| 796 | */ | - |
| 797 | QAction *QToolBar::addAction(const QString &text) | - |
| 798 | { | - |
| 799 | QAction *action = new QAction(text, this); never executed (the execution status of this line is deduced): QAction *action = new QAction(text, this); | - |
| 800 | addAction(action); never executed (the execution status of this line is deduced): addAction(action); | - |
| 801 | return action; never executed: return action; | 0 |
| 802 | } | - |
| 803 | | - |
| 804 | /*! | - |
| 805 | \overload | - |
| 806 | | - |
| 807 | Creates a new action with the given \a icon and \a text. This | - |
| 808 | action is added to the end of the toolbar. | - |
| 809 | */ | - |
| 810 | QAction *QToolBar::addAction(const QIcon &icon, const QString &text) | - |
| 811 | { | - |
| 812 | QAction *action = new QAction(icon, text, this); never executed (the execution status of this line is deduced): QAction *action = new QAction(icon, text, this); | - |
| 813 | addAction(action); never executed (the execution status of this line is deduced): addAction(action); | - |
| 814 | return action; never executed: return action; | 0 |
| 815 | } | - |
| 816 | | - |
| 817 | /*! | - |
| 818 | \overload | - |
| 819 | | - |
| 820 | Creates a new action with the given \a text. This action is added to | - |
| 821 | the end of the toolbar. The action's \l{QAction::triggered()}{triggered()} | - |
| 822 | signal is connected to \a member in \a receiver. | - |
| 823 | */ | - |
| 824 | QAction *QToolBar::addAction(const QString &text, | - |
| 825 | const QObject *receiver, const char* member) | - |
| 826 | { | - |
| 827 | QAction *action = new QAction(text, this); never executed (the execution status of this line is deduced): QAction *action = new QAction(text, this); | - |
| 828 | QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); never executed (the execution status of this line is deduced): QObject::connect(action, "2""triggered(bool)", receiver, member); | - |
| 829 | addAction(action); never executed (the execution status of this line is deduced): addAction(action); | - |
| 830 | return action; never executed: return action; | 0 |
| 831 | } | - |
| 832 | | - |
| 833 | /*! | - |
| 834 | \overload | - |
| 835 | | - |
| 836 | Creates a new action with the given \a icon and \a text. This | - |
| 837 | action is added to the end of the toolbar. The action's | - |
| 838 | \l{QAction::triggered()}{triggered()} signal is connected to \a | - |
| 839 | member in \a receiver. | - |
| 840 | */ | - |
| 841 | QAction *QToolBar::addAction(const QIcon &icon, const QString &text, | - |
| 842 | const QObject *receiver, const char* member) | - |
| 843 | { | - |
| 844 | QAction *action = new QAction(icon, text, this); never executed (the execution status of this line is deduced): QAction *action = new QAction(icon, text, this); | - |
| 845 | QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); never executed (the execution status of this line is deduced): QObject::connect(action, "2""triggered(bool)", receiver, member); | - |
| 846 | addAction(action); never executed (the execution status of this line is deduced): addAction(action); | - |
| 847 | return action; never executed: return action; | 0 |
| 848 | } | - |
| 849 | | - |
| 850 | /*! | - |
| 851 | Adds a separator to the end of the toolbar. | - |
| 852 | | - |
| 853 | \sa insertSeparator() | - |
| 854 | */ | - |
| 855 | QAction *QToolBar::addSeparator() | - |
| 856 | { | - |
| 857 | QAction *action = new QAction(this); never executed (the execution status of this line is deduced): QAction *action = new QAction(this); | - |
| 858 | action->setSeparator(true); never executed (the execution status of this line is deduced): action->setSeparator(true); | - |
| 859 | addAction(action); never executed (the execution status of this line is deduced): addAction(action); | - |
| 860 | return action; never executed: return action; | 0 |
| 861 | } | - |
| 862 | | - |
| 863 | /*! | - |
| 864 | Inserts a separator into the toolbar in front of the toolbar | - |
| 865 | item associated with the \a before action. | - |
| 866 | | - |
| 867 | \sa addSeparator() | - |
| 868 | */ | - |
| 869 | QAction *QToolBar::insertSeparator(QAction *before) | - |
| 870 | { | - |
| 871 | QAction *action = new QAction(this); never executed (the execution status of this line is deduced): QAction *action = new QAction(this); | - |
| 872 | action->setSeparator(true); never executed (the execution status of this line is deduced): action->setSeparator(true); | - |
| 873 | insertAction(before, action); never executed (the execution status of this line is deduced): insertAction(before, action); | - |
| 874 | return action; never executed: return action; | 0 |
| 875 | } | - |
| 876 | | - |
| 877 | /*! | - |
| 878 | Adds the given \a widget to the toolbar as the toolbar's last | - |
| 879 | item. | - |
| 880 | | - |
| 881 | The toolbar takes ownership of \a widget. | - |
| 882 | | - |
| 883 | If you add a QToolButton with this method, the toolbar's | - |
| 884 | Qt::ToolButtonStyle will not be respected. | - |
| 885 | | - |
| 886 | \note You should use QAction::setVisible() to change the | - |
| 887 | visibility of the widget. Using QWidget::setVisible(), | - |
| 888 | QWidget::show() and QWidget::hide() does not work. | - |
| 889 | | - |
| 890 | \sa insertWidget() | - |
| 891 | */ | - |
| 892 | QAction *QToolBar::addWidget(QWidget *widget) | - |
| 893 | { | - |
| 894 | QWidgetAction *action = new QWidgetAction(this); executed (the execution status of this line is deduced): QWidgetAction *action = new QWidgetAction(this); | - |
| 895 | action->setDefaultWidget(widget); executed (the execution status of this line is deduced): action->setDefaultWidget(widget); | - |
| 896 | action->d_func()->autoCreated = true; executed (the execution status of this line is deduced): action->d_func()->autoCreated = true; | - |
| 897 | addAction(action); executed (the execution status of this line is deduced): addAction(action); | - |
| 898 | return action; executed: return action;Execution Count:4 | 4 |
| 899 | } | - |
| 900 | | - |
| 901 | /*! | - |
| 902 | Inserts the given \a widget in front of the toolbar item | - |
| 903 | associated with the \a before action. | - |
| 904 | | - |
| 905 | Note: You should use QAction::setVisible() to change the | - |
| 906 | visibility of the widget. Using QWidget::setVisible(), | - |
| 907 | QWidget::show() and QWidget::hide() does not work. | - |
| 908 | | - |
| 909 | \sa addWidget() | - |
| 910 | */ | - |
| 911 | QAction *QToolBar::insertWidget(QAction *before, QWidget *widget) | - |
| 912 | { | - |
| 913 | QWidgetAction *action = new QWidgetAction(this); never executed (the execution status of this line is deduced): QWidgetAction *action = new QWidgetAction(this); | - |
| 914 | action->setDefaultWidget(widget); never executed (the execution status of this line is deduced): action->setDefaultWidget(widget); | - |
| 915 | action->d_func()->autoCreated = true; never executed (the execution status of this line is deduced): action->d_func()->autoCreated = true; | - |
| 916 | insertAction(before, action); never executed (the execution status of this line is deduced): insertAction(before, action); | - |
| 917 | return action; never executed: return action; | 0 |
| 918 | } | - |
| 919 | | - |
| 920 | /*! | - |
| 921 | \internal | - |
| 922 | | - |
| 923 | Returns the geometry of the toolbar item associated with the given | - |
| 924 | \a action, or an invalid QRect if no matching item is found. | - |
| 925 | */ | - |
| 926 | QRect QToolBar::actionGeometry(QAction *action) const | - |
| 927 | { | - |
| 928 | Q_D(const QToolBar); executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 929 | | - |
| 930 | int index = d->layout->indexOf(action); executed (the execution status of this line is deduced): int index = d->layout->indexOf(action); | - |
| 931 | if (index == -1) partially evaluated: index == -1| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 932 | return QRect(); never executed: return QRect(); | 0 |
| 933 | return d->layout->itemAt(index)->widget()->geometry(); executed: return d->layout->itemAt(index)->widget()->geometry();Execution Count:1 | 1 |
| 934 | } | - |
| 935 | | - |
| 936 | /*! | - |
| 937 | Returns the action at point \a p. This function returns zero if no | - |
| 938 | action was found. | - |
| 939 | | - |
| 940 | \sa QWidget::childAt() | - |
| 941 | */ | - |
| 942 | QAction *QToolBar::actionAt(const QPoint &p) const | - |
| 943 | { | - |
| 944 | Q_D(const QToolBar); never executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 945 | QWidget *widget = childAt(p); never executed (the execution status of this line is deduced): QWidget *widget = childAt(p); | - |
| 946 | int index = d->layout->indexOf(widget); never executed (the execution status of this line is deduced): int index = d->layout->indexOf(widget); | - |
| 947 | if (index == -1) never evaluated: index == -1 | 0 |
| 948 | return 0; never executed: return 0; | 0 |
| 949 | QLayoutItem *item = d->layout->itemAt(index); never executed (the execution status of this line is deduced): QLayoutItem *item = d->layout->itemAt(index); | - |
| 950 | return static_cast<QToolBarItem*>(item)->action; never executed: return static_cast<QToolBarItem*>(item)->action; | 0 |
| 951 | } | - |
| 952 | | - |
| 953 | /*! \fn QAction *QToolBar::actionAt(int x, int y) const | - |
| 954 | \overload | - |
| 955 | | - |
| 956 | Returns the action at the point \a x, \a y. This function returns | - |
| 957 | zero if no action was found. | - |
| 958 | */ | - |
| 959 | | - |
| 960 | /*! \reimp */ | - |
| 961 | void QToolBar::actionEvent(QActionEvent *event) | - |
| 962 | { | - |
| 963 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 964 | QAction *action = event->action(); executed (the execution status of this line is deduced): QAction *action = event->action(); | - |
| 965 | QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action); executed (the execution status of this line is deduced): QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action); | - |
| 966 | | - |
| 967 | switch (event->type()) { | - |
| 968 | case QEvent::ActionAdded: { | - |
| 969 | Q_ASSERT_X(widgetAction == 0 || d->layout->indexOf(widgetAction) == -1, executed (the execution status of this line is deduced): qt_noop(); | - |
| 970 | "QToolBar", "widgets cannot be inserted multiple times"); | - |
| 971 | | - |
| 972 | // reparent the action to this toolbar if it has been created | - |
| 973 | // using the addAction(text) etc. convenience functions, to | - |
| 974 | // preserve Qt 4.1.x behavior. The widget is already | - |
| 975 | // reparented to us due to the createWidget call inside | - |
| 976 | // createItem() | - |
| 977 | if (widgetAction != 0 && widgetAction->d_func()->autoCreated) evaluated: widgetAction != 0| yes Evaluation Count:15 | yes Evaluation Count:1 |
evaluated: widgetAction->d_func()->autoCreated| yes Evaluation Count:4 | yes Evaluation Count:11 |
| 1-15 |
| 978 | widgetAction->setParent(this); executed: widgetAction->setParent(this);Execution Count:4 | 4 |
| 979 | | - |
| 980 | int index = d->layout->count(); executed (the execution status of this line is deduced): int index = d->layout->count(); | - |
| 981 | if (event->before()) { partially evaluated: event->before()| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 982 | index = d->layout->indexOf(event->before()); never executed (the execution status of this line is deduced): index = d->layout->indexOf(event->before()); | - |
| 983 | Q_ASSERT_X(index != -1, "QToolBar::insertAction", "internal error"); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 984 | } | 0 |
| 985 | d->layout->insertAction(index, action); executed (the execution status of this line is deduced): d->layout->insertAction(index, action); | - |
| 986 | break; executed: break;Execution Count:16 | 16 |
| 987 | } | - |
| 988 | | - |
| 989 | case QEvent::ActionChanged: | - |
| 990 | d->layout->invalidate(); executed (the execution status of this line is deduced): d->layout->invalidate(); | - |
| 991 | break; executed: break;Execution Count:3 | 3 |
| 992 | | - |
| 993 | case QEvent::ActionRemoved: { | - |
| 994 | int index = d->layout->indexOf(action); executed (the execution status of this line is deduced): int index = d->layout->indexOf(action); | - |
| 995 | if (index != -1) { evaluated: index != -1| yes Evaluation Count:6 | yes Evaluation Count:3 |
| 3-6 |
| 996 | delete d->layout->takeAt(index); executed (the execution status of this line is deduced): delete d->layout->takeAt(index); | - |
| 997 | } executed: }Execution Count:6 | 6 |
| 998 | break; executed: break;Execution Count:9 | 9 |
| 999 | } | - |
| 1000 | | - |
| 1001 | default: | - |
| 1002 | Q_ASSERT_X(false, "QToolBar::actionEvent", "internal error"); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 1003 | } | 0 |
| 1004 | } executed: }Execution Count:28 | 28 |
| 1005 | | - |
| 1006 | /*! \reimp */ | - |
| 1007 | void QToolBar::changeEvent(QEvent *event) | - |
| 1008 | { | - |
| 1009 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 1010 | switch (event->type()) { | - |
| 1011 | case QEvent::WindowTitleChange: | - |
| 1012 | d->toggleViewAction->setText(windowTitle()); executed (the execution status of this line is deduced): d->toggleViewAction->setText(windowTitle()); | - |
| 1013 | break; executed: break;Execution Count:1 | 1 |
| 1014 | case QEvent::StyleChange: | - |
| 1015 | d->layout->invalidate(); never executed (the execution status of this line is deduced): d->layout->invalidate(); | - |
| 1016 | if (!d->explicitIconSize) never evaluated: !d->explicitIconSize | 0 |
| 1017 | setIconSize(QSize()); never executed: setIconSize(QSize()); | 0 |
| 1018 | d->layout->updateMarginAndSpacing(); never executed (the execution status of this line is deduced): d->layout->updateMarginAndSpacing(); | - |
| 1019 | break; | 0 |
| 1020 | case QEvent::LayoutDirectionChange: | - |
| 1021 | d->layout->invalidate(); never executed (the execution status of this line is deduced): d->layout->invalidate(); | - |
| 1022 | break; | 0 |
| 1023 | default: | - |
| 1024 | break; executed: break;Execution Count:29 | 29 |
| 1025 | } | - |
| 1026 | QWidget::changeEvent(event); executed (the execution status of this line is deduced): QWidget::changeEvent(event); | - |
| 1027 | } executed: }Execution Count:30 | 30 |
| 1028 | | - |
| 1029 | /*! \reimp */ | - |
| 1030 | void QToolBar::paintEvent(QPaintEvent *) | - |
| 1031 | { | - |
| 1032 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 1033 | | - |
| 1034 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
| 1035 | QStyle *style = this->style(); executed (the execution status of this line is deduced): QStyle *style = this->style(); | - |
| 1036 | QStyleOptionToolBar opt; executed (the execution status of this line is deduced): QStyleOptionToolBar opt; | - |
| 1037 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 1038 | | - |
| 1039 | if (d->layout->expanded || d->layout->animating || isWindow()) { partially evaluated: d->layout->expanded| no Evaluation Count:0 | yes Evaluation Count:7 |
partially evaluated: d->layout->animating| no Evaluation Count:0 | yes Evaluation Count:7 |
evaluated: isWindow()| yes Evaluation Count:1 | yes Evaluation Count:6 |
| 0-7 |
| 1040 | //if the toolbar is expended, we need to fill the background with the window color | - |
| 1041 | //because some styles may expects that. | - |
| 1042 | p.fillRect(opt.rect, palette().background()); executed (the execution status of this line is deduced): p.fillRect(opt.rect, palette().background()); | - |
| 1043 | style->drawControl(QStyle::CE_ToolBar, &opt, &p, this); executed (the execution status of this line is deduced): style->drawControl(QStyle::CE_ToolBar, &opt, &p, this); | - |
| 1044 | style->drawPrimitive(QStyle::PE_FrameMenu, &opt, &p, this); executed (the execution status of this line is deduced): style->drawPrimitive(QStyle::PE_FrameMenu, &opt, &p, this); | - |
| 1045 | } else { executed: }Execution Count:1 | 1 |
| 1046 | style->drawControl(QStyle::CE_ToolBar, &opt, &p, this); executed (the execution status of this line is deduced): style->drawControl(QStyle::CE_ToolBar, &opt, &p, this); | - |
| 1047 | } executed: }Execution Count:6 | 6 |
| 1048 | | - |
| 1049 | opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this); executed (the execution status of this line is deduced): opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this); | - |
| 1050 | if (opt.rect.isValid()) evaluated: opt.rect.isValid()| yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
| 1051 | style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this); executed: style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);Execution Count:6 | 6 |
| 1052 | } executed: }Execution Count:7 | 7 |
| 1053 | | - |
| 1054 | /* | - |
| 1055 | Checks if an expanded toolbar has to wait for this popup to close before | - |
| 1056 | the toolbar collapses. This is true if | - |
| 1057 | 1) the popup has the toolbar in its parent chain, | - |
| 1058 | 2) the popup is a menu whose menuAction is somewhere in the toolbar. | - |
| 1059 | */ | - |
| 1060 | static bool waitForPopup(QToolBar *tb, QWidget *popup) | - |
| 1061 | { | - |
| 1062 | if (popup == 0 || popup->isHidden()) never evaluated: popup == 0 never evaluated: popup->isHidden() | 0 |
| 1063 | return false; never executed: return false; | 0 |
| 1064 | | - |
| 1065 | QWidget *w = popup; never executed (the execution status of this line is deduced): QWidget *w = popup; | - |
| 1066 | while (w != 0) { | 0 |
| 1067 | if (w == tb) | 0 |
| 1068 | return true; never executed: return true; | 0 |
| 1069 | w = w->parentWidget(); never executed (the execution status of this line is deduced): w = w->parentWidget(); | - |
| 1070 | } | 0 |
| 1071 | | - |
| 1072 | QMenu *menu = qobject_cast<QMenu*>(popup); never executed (the execution status of this line is deduced): QMenu *menu = qobject_cast<QMenu*>(popup); | - |
| 1073 | if (menu == 0) never evaluated: menu == 0 | 0 |
| 1074 | return false; never executed: return false; | 0 |
| 1075 | | - |
| 1076 | QAction *action = menu->menuAction(); never executed (the execution status of this line is deduced): QAction *action = menu->menuAction(); | - |
| 1077 | QList<QWidget*> widgets = action->associatedWidgets(); never executed (the execution status of this line is deduced): QList<QWidget*> widgets = action->associatedWidgets(); | - |
| 1078 | for (int i = 0; i < widgets.count(); ++i) { never evaluated: i < widgets.count() | 0 |
| 1079 | if (waitForPopup(tb, widgets.at(i))) never evaluated: waitForPopup(tb, widgets.at(i)) | 0 |
| 1080 | return true; never executed: return true; | 0 |
| 1081 | } | 0 |
| 1082 | | - |
| 1083 | return false; never executed: return false; | 0 |
| 1084 | } | - |
| 1085 | | - |
| 1086 | #if defined(Q_WS_MAC) | - |
| 1087 | static bool toolbarInUnifiedToolBar(QToolBar *toolbar) | - |
| 1088 | { | - |
| 1089 | const QMainWindow *mainWindow = qobject_cast<const QMainWindow *>(toolbar->parentWidget()); | - |
| 1090 | return mainWindow && mainWindow->unifiedTitleAndToolBarOnMac() | - |
| 1091 | && mainWindow->toolBarArea(toolbar) == Qt::TopToolBarArea; | - |
| 1092 | } | - |
| 1093 | #endif | - |
| 1094 | | - |
| 1095 | /*! \reimp */ | - |
| 1096 | bool QToolBar::event(QEvent *event) | - |
| 1097 | { | - |
| 1098 | Q_D(QToolBar); executed (the execution status of this line is deduced): QToolBarPrivate * const d = d_func(); | - |
| 1099 | | - |
| 1100 | switch (event->type()) { | - |
| 1101 | case QEvent::Timer: | - |
| 1102 | if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) { never evaluated: d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId() | 0 |
| 1103 | QWidget *w = QApplication::activePopupWidget(); never executed (the execution status of this line is deduced): QWidget *w = QApplication::activePopupWidget(); | - |
| 1104 | if (!waitForPopup(this, w)) { never evaluated: !waitForPopup(this, w) | 0 |
| 1105 | d->waitForPopupTimer.stop(); never executed (the execution status of this line is deduced): d->waitForPopupTimer.stop(); | - |
| 1106 | if (!this->underMouse()) never evaluated: !this->underMouse() | 0 |
| 1107 | d->layout->setExpanded(false); never executed: d->layout->setExpanded(false); | 0 |
| 1108 | } | 0 |
| 1109 | } | 0 |
| 1110 | break; | 0 |
| 1111 | case QEvent::Hide: | - |
| 1112 | if (!isHidden()) partially evaluated: !isHidden()| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1113 | break; executed: break;Execution Count:1 | 1 |
| 1114 | // fallthrough intended | - |
| 1115 | case QEvent::Show: code before this statement never executed: case QEvent::Show: | 0 |
| 1116 | d->toggleViewAction->setChecked(event->type() == QEvent::Show); executed (the execution status of this line is deduced): d->toggleViewAction->setChecked(event->type() == QEvent::Show); | - |
| 1117 | emit visibilityChanged(event->type() == QEvent::Show); executed (the execution status of this line is deduced): visibilityChanged(event->type() == QEvent::Show); | - |
| 1118 | #if defined(Q_WS_MAC) | - |
| 1119 | if (toolbarInUnifiedToolBar(this)) { | - |
| 1120 | // I can static_cast because I did the qobject_cast in the if above, therefore | - |
| 1121 | // we must have a QMainWindowLayout here. | - |
| 1122 | QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget())); | - |
| 1123 | mwLayout->fixSizeInUnifiedToolbar(this); | - |
| 1124 | mwLayout->syncUnifiedToolbarVisibility(); | - |
| 1125 | } | - |
| 1126 | #endif // Q_WS_MAC | - |
| 1127 | break; executed: break;Execution Count:11 | 11 |
| 1128 | case QEvent::ParentChange: | - |
| 1129 | d->layout->checkUsePopupMenu(); executed (the execution status of this line is deduced): d->layout->checkUsePopupMenu(); | - |
| 1130 | #if defined(Q_WS_MAC) | - |
| 1131 | if (parentWidget() && parentWidget()->isWindow()) | - |
| 1132 | qt_mac_updateToolBarButtonHint(parentWidget()); | - |
| 1133 | #endif | - |
| 1134 | break; executed: break;Execution Count:10 | 10 |
| 1135 | | - |
| 1136 | case QEvent::MouseButtonPress: { | - |
| 1137 | if (d->mousePressEvent(static_cast<QMouseEvent*>(event))) never evaluated: d->mousePressEvent(static_cast<QMouseEvent*>(event)) | 0 |
| 1138 | return true; never executed: return true; | 0 |
| 1139 | break; | 0 |
| 1140 | } | - |
| 1141 | case QEvent::MouseButtonRelease: | - |
| 1142 | if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event))) never evaluated: d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)) | 0 |
| 1143 | return true; never executed: return true; | 0 |
| 1144 | break; | 0 |
| 1145 | case QEvent::HoverEnter: | - |
| 1146 | case QEvent::HoverLeave: | - |
| 1147 | // there's nothing special to do here and we don't want to update the whole widget | - |
| 1148 | return true; executed: return true;Execution Count:1 | 1 |
| 1149 | case QEvent::HoverMove: { | - |
| 1150 | #ifndef QT_NO_CURSOR | - |
| 1151 | QHoverEvent *e = static_cast<QHoverEvent*>(event); never executed (the execution status of this line is deduced): QHoverEvent *e = static_cast<QHoverEvent*>(event); | - |
| 1152 | QStyleOptionToolBar opt; never executed (the execution status of this line is deduced): QStyleOptionToolBar opt; | - |
| 1153 | initStyleOption(&opt); never executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
| 1154 | if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos())) never evaluated: style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()) | 0 |
| 1155 | setCursor(Qt::SizeAllCursor); never executed: setCursor(Qt::SizeAllCursor); | 0 |
| 1156 | else | - |
| 1157 | unsetCursor(); never executed: unsetCursor(); | 0 |
| 1158 | #endif | - |
| 1159 | break; | 0 |
| 1160 | } | - |
| 1161 | case QEvent::MouseMove: | - |
| 1162 | if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event))) never evaluated: d->mouseMoveEvent(static_cast<QMouseEvent*>(event)) | 0 |
| 1163 | return true; never executed: return true; | 0 |
| 1164 | break; | 0 |
| 1165 | #ifdef Q_OS_WINCE | - |
| 1166 | case QEvent::ContextMenu: | - |
| 1167 | { | - |
| 1168 | QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event); | - |
| 1169 | QWidget* child = childAt(contextMenuEvent->pos()); | - |
| 1170 | QAbstractButton* button = qobject_cast<QAbstractButton*>(child); | - |
| 1171 | if (button) | - |
| 1172 | button->setDown(false); | - |
| 1173 | } | - |
| 1174 | break; | - |
| 1175 | #endif | - |
| 1176 | case QEvent::Leave: | - |
| 1177 | if (d->state != 0 && d->state->dragging) { never evaluated: d->state != 0 never evaluated: d->state->dragging | 0 |
| 1178 | #ifdef Q_OS_WIN | - |
| 1179 | // This is a workaround for loosing the mouse on Vista. | - |
| 1180 | QPoint pos = QCursor::pos(); | - |
| 1181 | QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, | - |
| 1182 | QApplication::mouseButtons(), QApplication::keyboardModifiers()); | - |
| 1183 | d->mouseMoveEvent(&fake); | - |
| 1184 | #endif | - |
| 1185 | } else { | 0 |
| 1186 | if (!d->layout->expanded) never evaluated: !d->layout->expanded | 0 |
| 1187 | break; | 0 |
| 1188 | | - |
| 1189 | QWidget *w = QApplication::activePopupWidget(); never executed (the execution status of this line is deduced): QWidget *w = QApplication::activePopupWidget(); | - |
| 1190 | if (waitForPopup(this, w)) { never evaluated: waitForPopup(this, w) | 0 |
| 1191 | d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this); never executed (the execution status of this line is deduced): d->waitForPopupTimer.start(500, this); | - |
| 1192 | break; | 0 |
| 1193 | } | - |
| 1194 | | - |
| 1195 | d->waitForPopupTimer.stop(); never executed (the execution status of this line is deduced): d->waitForPopupTimer.stop(); | - |
| 1196 | d->layout->setExpanded(false); never executed (the execution status of this line is deduced): d->layout->setExpanded(false); | - |
| 1197 | break; | 0 |
| 1198 | } | - |
| 1199 | default: | - |
| 1200 | break; executed: break;Execution Count:285 | 285 |
| 1201 | } | - |
| 1202 | return QWidget::event(event); executed: return QWidget::event(event);Execution Count:307 | 307 |
| 1203 | } | - |
| 1204 | | - |
| 1205 | /*! | - |
| 1206 | Returns a checkable action that can be used to show or hide this | - |
| 1207 | toolbar. | - |
| 1208 | | - |
| 1209 | The action's text is set to the toolbar's window title. | - |
| 1210 | | - |
| 1211 | \sa QAction::text, QWidget::windowTitle | - |
| 1212 | */ | - |
| 1213 | QAction *QToolBar::toggleViewAction() const | - |
| 1214 | { Q_D(const QToolBar); return d->toggleViewAction; } never executed: return d->toggleViewAction; | 0 |
| 1215 | | - |
| 1216 | /*! | - |
| 1217 | \since 4.2 | - |
| 1218 | | - |
| 1219 | Returns the widget associated with the specified \a action. | - |
| 1220 | | - |
| 1221 | \sa addWidget() | - |
| 1222 | */ | - |
| 1223 | QWidget *QToolBar::widgetForAction(QAction *action) const | - |
| 1224 | { | - |
| 1225 | Q_D(const QToolBar); never executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 1226 | | - |
| 1227 | int index = d->layout->indexOf(action); never executed (the execution status of this line is deduced): int index = d->layout->indexOf(action); | - |
| 1228 | if (index == -1) never evaluated: index == -1 | 0 |
| 1229 | return 0; never executed: return 0; | 0 |
| 1230 | | - |
| 1231 | return d->layout->itemAt(index)->widget(); never executed: return d->layout->itemAt(index)->widget(); | 0 |
| 1232 | } | - |
| 1233 | | - |
| 1234 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); | - |
| 1235 | | - |
| 1236 | /*! | - |
| 1237 | \internal | - |
| 1238 | */ | - |
| 1239 | void QToolBar::initStyleOption(QStyleOptionToolBar *option) const | - |
| 1240 | { | - |
| 1241 | Q_D(const QToolBar); executed (the execution status of this line is deduced): const QToolBarPrivate * const d = d_func(); | - |
| 1242 | | - |
| 1243 | if (!option) partially evaluated: !option| no Evaluation Count:0 | yes Evaluation Count:158 |
| 0-158 |
| 1244 | return; | 0 |
| 1245 | | - |
| 1246 | option->initFrom(this); executed (the execution status of this line is deduced): option->initFrom(this); | - |
| 1247 | if (orientation() == Qt::Horizontal) partially evaluated: orientation() == Qt::Horizontal| yes Evaluation Count:158 | no Evaluation Count:0 |
| 0-158 |
| 1248 | option->state |= QStyle::State_Horizontal; executed: option->state |= QStyle::State_Horizontal;Execution Count:158 | 158 |
| 1249 | option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this); executed (the execution status of this line is deduced): option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this); | - |
| 1250 | option->features = d->layout->movable() evaluated: d->layout->movable()| yes Evaluation Count:33 | yes Evaluation Count:125 |
| 33-125 |
| 1251 | ? QStyleOptionToolBar::Movable executed (the execution status of this line is deduced): ? QStyleOptionToolBar::Movable | - |
| 1252 | : QStyleOptionToolBar::None; executed (the execution status of this line is deduced): : QStyleOptionToolBar::None; | - |
| 1253 | // if the tool bar is not in a QMainWindow, this will make the painting right | - |
| 1254 | option->toolBarArea = Qt::NoToolBarArea; executed (the execution status of this line is deduced): option->toolBarArea = Qt::NoToolBarArea; | - |
| 1255 | | - |
| 1256 | // Add more styleoptions if the toolbar has been added to a mainwindow. | - |
| 1257 | QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget()); executed (the execution status of this line is deduced): QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget()); | - |
| 1258 | | - |
| 1259 | if (!mainWindow) evaluated: !mainWindow| yes Evaluation Count:125 | yes Evaluation Count:33 |
| 33-125 |
| 1260 | return; executed: return;Execution Count:125 | 125 |
| 1261 | | - |
| 1262 | QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); | - |
| 1263 | Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()", executed (the execution status of this line is deduced): qt_noop(); | - |
| 1264 | "QMainWindow->layout() != QMainWindowLayout"); | - |
| 1265 | | - |
| 1266 | layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this)); executed (the execution status of this line is deduced): layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this)); | - |
| 1267 | } executed: }Execution Count:33 | 33 |
| 1268 | | - |
| 1269 | QT_END_NAMESPACE | - |
| 1270 | | - |
| 1271 | #include "moc_qtoolbar.cpp" | - |
| 1272 | | - |
| 1273 | #endif // QT_NO_TOOLBAR | - |
| 1274 | | - |
| | |