OpenCoverage

qtoolbar.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9