qtoolbar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbar.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);-
17-
18-
19-
20-
21-
22void QToolBarPrivate::init()-
23{-
24 QToolBar * const q = q_func();-
25 q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));-
26 q->setBackgroundRole(QPalette::Button);-
27 q->setAttribute(Qt::WA_Hover);-
28 q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);-
29 q->setProperty("_q_platform_MacUseNSWindow", QVariant(true));-
30-
31 QStyle *style = q->style();-
32 int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);-
33 iconSize = QSize(e, e);-
34-
35 layout = new QToolBarLayout(q);-
36 layout->updateMarginAndSpacing();-
37-
38 toggleViewAction = new QAction(q);-
39 toggleViewAction->setCheckable(true);-
40 q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q ));-
41 QObject::connect(toggleViewAction, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "100"), q, qFlagLocation("1""_q_toggleView(bool)" "\0" __FILE__ ":" "100"));-
42}
never executed: end of block
0
43-
44void QToolBarPrivate::_q_toggleView(bool b)-
45{-
46 QToolBar * const q = q_func();-
47 if (b == q->isHidden()
b == q->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
48 if (b
bDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
49 q->show();
never executed: q->show();
0
50 else-
51 q->close();
never executed: q->close();
0
52 }-
53}
never executed: end of block
0
54-
55void QToolBarPrivate::_q_updateIconSize(const QSize &sz)-
56{-
57 QToolBar * const q = q_func();-
58 if (!explicitIconSize
!explicitIconSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
59-
60 q->setIconSize(sz);-
61 explicitIconSize = false;-
62 }
never executed: end of block
0
63}
never executed: end of block
0
64-
65void QToolBarPrivate::_q_updateToolButtonStyle(Qt::ToolButtonStyle style)-
66{-
67 QToolBar * const q = q_func();-
68 if (!explicitToolButtonStyle
!explicitToolButtonStyleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
69 q->setToolButtonStyle(style);-
70 explicitToolButtonStyle = false;-
71 }
never executed: end of block
0
72}
never executed: end of block
0
73-
74void QToolBarPrivate::updateWindowFlags(bool floating, bool unplug)-
75{-
76 QToolBar * const q = q_func();-
77 Qt::WindowFlags flags = floating
floatingDescription
TRUEnever evaluated
FALSEnever evaluated
? Qt::Tool : Qt::Widget;
0
78-
79 flags |= Qt::FramelessWindowHint;-
80-
81 if (unplug
unplugDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
82 flags |= Qt::X11BypassWindowManagerHint;
never executed: flags |= Qt::X11BypassWindowManagerHint;
0
83-
84 q->setWindowFlags(flags);-
85}
never executed: end of block
0
86-
87void QToolBarPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)-
88{-
89 QToolBar * const q = q_func();-
90 bool visible = !q->isHidden();-
91 bool wasFloating = q->isFloating();-
92-
93 q->hide();-
94-
95 updateWindowFlags(floating, unplug);-
96-
97 if (floating != wasFloating
floating != wasFloatingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
98 layout->checkUsePopupMenu();
never executed: layout->checkUsePopupMenu();
0
99-
100 if (!rect.isNull()
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
101 q->setGeometry(rect);
never executed: q->setGeometry(rect);
0
102-
103 if (visible
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
104 q->show();
never executed: q->show();
0
105-
106 if (floating != wasFloating
floating != wasFloatingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
107 q->topLevelChanged(floating);
never executed: q->topLevelChanged(floating);
0
108}
never executed: end of block
0
109-
110void QToolBarPrivate::initDrag(const QPoint &pos)-
111{-
112 QToolBar * const q = q_func();-
113-
114 if (state != 0
state != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
115 return;
never executed: return;
0
116-
117 QMainWindow *win = qobject_cast<QMainWindow*>(parent);-
118 ((!(win != 0)) ? qt_assert("win != 0",__FILE__,177) : qt_noop());-
119 QMainWindowLayout *layout = qt_mainwindow_layout(win);-
120 ((!(layout != 0)) ? qt_assert("layout != 0",__FILE__,179) : qt_noop());-
121 if (layout->pluggingWidget != 0
layout->pluggingWidget != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
122 return;
never executed: return;
0
123-
124 state = new DragState;-
125 state->pressPos = pos;-
126 state->dragging = false;-
127 state->moving = false;-
128 state->widgetItem = 0;-
129-
130 if (q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
131 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
132}
never executed: end of block
0
133-
134void QToolBarPrivate::startDrag(bool moving)-
135{-
136 QToolBar * const q = q_func();-
137-
138 ((!(state != 0)) ? qt_assert("state != 0",__FILE__,197) : qt_noop());-
139-
140 if ((moving
movingDescription
TRUEnever evaluated
FALSEnever evaluated
&& state->moving
state->movingDescription
TRUEnever evaluated
FALSEnever evaluated
) || state->dragging
state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
141 return;
never executed: return;
0
142-
143 QMainWindow *win = qobject_cast<QMainWindow*>(parent);-
144 ((!(win != 0)) ? qt_assert("win != 0",__FILE__,203) : qt_noop());-
145 QMainWindowLayout *layout = qt_mainwindow_layout(win);-
146 ((!(layout != 0)) ? qt_assert("layout != 0",__FILE__,205) : qt_noop());-
147-
148 if (!moving
!movingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
149 state->widgetItem = layout->unplug(q);-
150 ((!(state->widgetItem != 0)) ? qt_assert("state->widgetItem != 0",__FILE__,209) : qt_noop());-
151 }
never executed: end of block
0
152 state->dragging = !moving;-
153 state->moving = moving;-
154}
never executed: end of block
0
155-
156void QToolBarPrivate::endDrag()-
157{-
158 QToolBar * const q = q_func();-
159 ((!(state != 0)) ? qt_assert("state != 0",__FILE__,218) : qt_noop());-
160-
161 q->releaseMouse();-
162-
163 if (state->dragging
state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
164 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));-
165 ((!(layout != 0)) ? qt_assert("layout != 0",__FILE__,224) : qt_noop());-
166-
167 if (!layout->plug(state->widgetItem)
!layout->plug(...e->widgetItem)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
168 if (q->isFloatable()
q->isFloatable()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
169 layout->restore();-
170 setWindowState(true);-
171-
172 q->activateWindow();-
173 }
never executed: end of block
else {
0
174 layout->revert(state->widgetItem);-
175 }
never executed: end of block
0
176 }-
177 }
never executed: end of block
0
178-
179 delete state;-
180 state = 0;-
181}
never executed: end of block
0
182-
183bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)-
184{-
185 QToolBar * const q = q_func();-
186 QStyleOptionToolBar opt;-
187 q->initStyleOption(&opt);-
188 if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false
q->style()->su...os()) == falseDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
189 return
never executed: return false;
false;
never executed: return false;
0
190 }-
191-
192 if (event->button() != Qt::LeftButton
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
193 return
never executed: return true;
true;
never executed: return true;
0
194-
195 if (!layout->movable()
!layout->movable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
196 return
never executed: return true;
true;
never executed: return true;
0
197-
198 initDrag(event->pos());-
199 return
never executed: return true;
true;
never executed: return true;
0
200}-
201-
202bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*)-
203{-
204 if (state != 0
state != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
205 endDrag();-
206 return
never executed: return true;
true;
never executed: return true;
0
207 } else {-
208-
209-
210-
211-
212-
213-
214-
215 return
never executed: return false;
false;
never executed: return false;
0
216 }-
217}-
218-
219bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)-
220{-
221 QToolBar * const q = q_func();-
222-
223 if (!state
!stateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
224 return
never executed: return false;
false;
never executed: return false;
0
225 }-
226-
227 QMainWindow *win = qobject_cast<QMainWindow*>(parent);-
228 if (win == 0
win == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
229 return
never executed: return true;
true;
never executed: return true;
0
230-
231 QMainWindowLayout *layout = qt_mainwindow_layout(win);-
232 ((!(layout != 0)) ? qt_assert("layout != 0",__FILE__,314) : qt_noop());-
233-
234 if (layout->pluggingWidget == 0
layout->pluggingWidget == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
235 && (
(event->pos() ...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()
(event->pos() ...DragDistance()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
236 const bool wasDragging = state->dragging;-
237 const bool moving = !q->isWindow()
!q->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
orientation == Qt::Vertical ?
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
0
238 event->x() >= 0
event->x() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& event->x() < q->width()
event->x() < q->width()Description
TRUEnever evaluated
FALSEnever evaluated
:
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
0
239 event->y() >= 0
event->y() >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& event->y() < q->height()
event->y() < q->height()Description
TRUEnever evaluated
FALSEnever evaluated
)
(orientation =...< q->height())Description
TRUEnever evaluated
FALSEnever evaluated
;
0
240-
241 startDrag(moving);-
242 if (!moving
!movingDescription
TRUEnever evaluated
FALSEnever evaluated
&& !wasDragging
!wasDraggingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
243-
244-
245-
246 q->grabMouse();-
247-
248 }
never executed: end of block
0
249 }
never executed: end of block
0
250-
251 if (state->dragging
state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
252 QPoint pos = event->globalPos();-
253-
254-
255 if (q->isLeftToRight()
q->isLeftToRight()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
256 pos -= state->pressPos;
never executed: pos -= state->pressPos;
0
257 else-
258 pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
never executed: pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
0
259-
260 q->move(pos);-
261 layout->hover(state->widgetItem, event->globalPos());-
262 }
never executed: end of block
else if (state->moving
state->movingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
263-
264 const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y());-
265 const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos);-
266 int pos = 0;-
267-
268 QPoint delta = event->globalPos() - globalPressPos;-
269 if (orientation == Qt::Vertical
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
270 pos = q->y() + delta.y();-
271 }
never executed: end of block
else {
0
272 if (q->isRightToLeft()
q->isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
273 pos = win->width() - q->width() - q->x() - delta.x();-
274 }
never executed: end of block
else {
0
275 pos = q->x() + delta.x();-
276 }
never executed: end of block
0
277 }-
278-
279 layout->moveToolBar(q, pos);-
280 }
never executed: end of block
0
281 return
never executed: return true;
true;
never executed: return true;
0
282}-
283-
284void QToolBarPrivate::unplug(const QRect &_r)-
285{-
286 QToolBar * const q = q_func();-
287 QRect r = _r;-
288 r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));-
289 setWindowState(true, true, r);-
290 layout->setExpanded(false);-
291}
never executed: end of block
0
292-
293void QToolBarPrivate::plug(const QRect &r)-
294{-
295 setWindowState(false, false, r);-
296}
never executed: end of block
0
297QToolBar::QToolBar(QWidget *parent)-
298 : QWidget(*new QToolBarPrivate, parent, 0)-
299{-
300 QToolBarPrivate * const d = d_func();-
301 d->init();-
302}
never executed: end of block
0
303QToolBar::QToolBar(const QString &title, QWidget *parent)-
304 : QWidget(*new QToolBarPrivate, parent, 0)-
305{-
306 QToolBarPrivate * const d = d_func();-
307 d->init();-
308 setWindowTitle(title);-
309}
never executed: end of block
0
310-
311-
312-
313-
314-
315QToolBar::~QToolBar()-
316{-
317}-
318void QToolBar::setMovable(bool movable)-
319{-
320 QToolBarPrivate * const d = d_func();-
321 if (!movable == !d->movable
!movable == !d->movableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
322 return;
never executed: return;
0
323 d->movable = movable;-
324 d->layout->invalidate();-
325 movableChanged(d->movable);-
326}
never executed: end of block
0
327-
328bool QToolBar::isMovable() const-
329{-
330 const QToolBarPrivate * const d = d_func();-
331 return
never executed: return d->movable;
d->movable;
never executed: return d->movable;
0
332}-
333-
334-
335-
336-
337-
338-
339-
340bool QToolBar::isFloatable() const-
341{-
342 const QToolBarPrivate * const d = d_func();-
343 return
never executed: return d->floatable;
d->floatable;
never executed: return d->floatable;
0
344}-
345-
346void QToolBar::setFloatable(bool floatable)-
347{-
348 QToolBarPrivate * const d = d_func();-
349 d->floatable = floatable;-
350}
never executed: end of block
0
351bool QToolBar::isFloating() const-
352{-
353 return
never executed: return isWindow();
isWindow();
never executed: return isWindow();
0
354}-
355void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas)-
356{-
357 QToolBarPrivate * const d = d_func();-
358 areas &= Qt::ToolBarArea_Mask;-
359 if (areas == d->allowedAreas
areas == d->allowedAreasDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
360 return;
never executed: return;
0
361 d->allowedAreas = areas;-
362 allowedAreasChanged(d->allowedAreas);-
363}
never executed: end of block
0
364-
365Qt::ToolBarAreas QToolBar::allowedAreas() const-
366{-
367 const QToolBarPrivate * const d = d_func();-
368 return
never executed: return d->allowedAreas;
d->allowedAreas;
never executed: return d->allowedAreas;
0
369}-
370void QToolBar::setOrientation(Qt::Orientation orientation)-
371{-
372 QToolBarPrivate * const d = d_func();-
373 if (orientation == d->orientation
orientation == d->orientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
374 return;
never executed: return;
0
375-
376 d->orientation = orientation;-
377-
378 if (orientation == Qt::Vertical
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
379 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
never executed: setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
0
380 else-
381 setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
never executed: setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
0
382-
383 d->layout->invalidate();-
384 d->layout->activate();-
385-
386 orientationChanged(d->orientation);-
387}
never executed: end of block
0
388-
389Qt::Orientation QToolBar::orientation() const-
390{ const QToolBarPrivate * const d = d_func(); return
never executed: return d->orientation;
d->orientation;
never executed: return d->orientation;
}
0
391QSize QToolBar::iconSize() const-
392{ const QToolBarPrivate * const d = d_func(); return
never executed: return d->iconSize;
d->iconSize;
never executed: return d->iconSize;
}
0
393-
394void QToolBar::setIconSize(const QSize &iconSize)-
395{-
396 QToolBarPrivate * const d = d_func();-
397 QSize sz = iconSize;-
398 if (!sz.isValid()
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
399 QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());-
400 if (mw
mwDescription
TRUEnever evaluated
FALSEnever evaluated
&& mw->layout()
mw->layout()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
401 QLayout *layout = mw->layout();-
402 int i = 0;-
403 QLayoutItem *item = 0;-
404 do {-
405 item = layout->itemAt(i++);-
406 if (item
itemDescription
TRUEnever evaluated
FALSEnever evaluated
&& (
(item->widget() == this)Description
TRUEnever evaluated
FALSEnever evaluated
item->widget() == this)
(item->widget() == this)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
407 sz = mw->iconSize();
never executed: sz = mw->iconSize();
0
408 }
never executed: end of block
while (!sz.isValid()
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
&& item != 0
item != 0Description
TRUEnever evaluated
FALSEnever evaluated
);
0
409 }
never executed: end of block
0
410 }
never executed: end of block
0
411 if (!sz.isValid()
!sz.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
412 const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);-
413 sz = QSize(metric, metric);-
414 }
never executed: end of block
0
415 if (d->iconSize != sz
d->iconSize != szDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
416 d->iconSize = sz;-
417 setMinimumSize(0, 0);-
418 iconSizeChanged(d->iconSize);-
419 }
never executed: end of block
0
420 d->explicitIconSize = iconSize.isValid();-
421-
422 d->layout->invalidate();-
423}
never executed: end of block
0
424Qt::ToolButtonStyle QToolBar::toolButtonStyle() const-
425{ const QToolBarPrivate * const d = d_func(); return
never executed: return d->toolButtonStyle;
d->toolButtonStyle;
never executed: return d->toolButtonStyle;
}
0
426-
427void QToolBar::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)-
428{-
429 QToolBarPrivate * const d = d_func();-
430 d->explicitToolButtonStyle = true;-
431 if (d->toolButtonStyle == toolButtonStyle
d->toolButtonS...oolButtonStyleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
432 return;
never executed: return;
0
433 d->toolButtonStyle = toolButtonStyle;-
434 setMinimumSize(0, 0);-
435 toolButtonStyleChanged(d->toolButtonStyle);-
436}
never executed: end of block
0
437-
438-
439-
440-
441-
442-
443void QToolBar::clear()-
444{-
445 QList<QAction *> actions = this->actions();-
446 for(int i = 0; i < actions.size()
i < actions.size()Description
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
447 removeAction(actions.at(i));
never executed: removeAction(actions.at(i));
0
448}
never executed: end of block
0
449-
450-
451-
452-
453-
454-
455-
456QAction *QToolBar::addAction(const QString &text)-
457{-
458 QAction *action = new QAction(text, this);-
459 addAction(action);-
460 return
never executed: return action;
action;
never executed: return action;
0
461}-
462-
463-
464-
465-
466-
467-
468-
469QAction *QToolBar::addAction(const QIcon &icon, const QString &text)-
470{-
471 QAction *action = new QAction(icon, text, this);-
472 addAction(action);-
473 return
never executed: return action;
action;
never executed: return action;
0
474}-
475QAction *QToolBar::addAction(const QString &text,-
476 const QObject *receiver, const char* member)-
477{-
478 QAction *action = new QAction(text, this);-
479 QObject::connect(action, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "780"), receiver, member);-
480 addAction(action);-
481 return
never executed: return action;
action;
never executed: return action;
0
482}-
483QAction *QToolBar::addAction(const QIcon &icon, const QString &text,-
484 const QObject *receiver, const char* member)-
485{-
486 QAction *action = new QAction(icon, text, this);-
487 QObject::connect(action, qFlagLocation("2""triggered(bool)" "\0" __FILE__ ":" "797"), receiver, member);-
488 addAction(action);-
489 return
never executed: return action;
action;
never executed: return action;
0
490}-
491QAction *QToolBar::addSeparator()-
492{-
493 QAction *action = new QAction(this);-
494 action->setSeparator(true);-
495 addAction(action);-
496 return
never executed: return action;
action;
never executed: return action;
0
497}-
498-
499-
500-
501-
502-
503-
504-
505QAction *QToolBar::insertSeparator(QAction *before)-
506{-
507 QAction *action = new QAction(this);-
508 action->setSeparator(true);-
509 insertAction(before, action);-
510 return
never executed: return action;
action;
never executed: return action;
0
511}-
512QAction *QToolBar::addWidget(QWidget *widget)-
513{-
514 QWidgetAction *action = new QWidgetAction(this);-
515 action->setDefaultWidget(widget);-
516 action->d_func()->autoCreated = true;-
517 addAction(action);-
518 return
never executed: return action;
action;
never executed: return action;
0
519}-
520QAction *QToolBar::insertWidget(QAction *before, QWidget *widget)-
521{-
522 QWidgetAction *action = new QWidgetAction(this);-
523 action->setDefaultWidget(widget);-
524 action->d_func()->autoCreated = true;-
525 insertAction(before, action);-
526 return
never executed: return action;
action;
never executed: return action;
0
527}-
528-
529-
530-
531-
532-
533-
534-
535QRect QToolBar::actionGeometry(QAction *action) const-
536{-
537 const QToolBarPrivate * const d = d_func();-
538-
539 int index = d->layout->indexOf(action);-
540 if (index == -1
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
541 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
542 return
never executed: return d->layout->itemAt(index)->widget()->geometry();
d->layout->itemAt(index)->widget()->geometry();
never executed: return d->layout->itemAt(index)->widget()->geometry();
0
543}-
544-
545-
546-
547-
548-
549-
550-
551QAction *QToolBar::actionAt(const QPoint &p) const-
552{-
553 const QToolBarPrivate * const d = d_func();-
554 QWidget *widget = childAt(p);-
555 int index = d->layout->indexOf(widget);-
556 if (index == -1
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
557 return
never executed: return 0;
0;
never executed: return 0;
0
558 QLayoutItem *item = d->layout->itemAt(index);-
559 return
never executed: return static_cast<QToolBarItem*>(item)->action;
static_cast<QToolBarItem*>(item)->action;
never executed: return static_cast<QToolBarItem*>(item)->action;
0
560}-
561void QToolBar::actionEvent(QActionEvent *event)-
562{-
563 QToolBarPrivate * const d = d_func();-
564 QAction *action = event->action();-
565 QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action);-
566-
567 switch (event->type()) {-
568 case
never executed: case QEvent::ActionAdded:
QEvent::ActionAdded:
never executed: case QEvent::ActionAdded:
{
0
569 ((!(widgetAction == 0 || d->layout->indexOf(widgetAction) == -1)) ? qt_assert_x("QToolBar", "widgets cannot be inserted multiple times",-
570 __FILE__-
571 ,-
572 998-
573 ) : qt_noop())-
574 ;-
575-
576-
577-
578-
579-
580-
581 if (widgetAction != 0
widgetAction != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& widgetAction->d_func()->autoCreated
widgetAction->...)->autoCreatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
582 widgetAction->setParent(this);
never executed: widgetAction->setParent(this);
0
583-
584 int index = d->layout->count();-
585 if (event->before()
event->before()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
586 index = d->layout->indexOf(event->before());-
587 ((!(index != -1)) ? qt_assert_x("QToolBar::insertAction", "internal error",__FILE__,1011) : qt_noop());-
588 }
never executed: end of block
0
589 d->layout->insertAction(index, action);-
590 break;
never executed: break;
0
591 }-
592-
593 case
never executed: case QEvent::ActionChanged:
QEvent::ActionChanged:
never executed: case QEvent::ActionChanged:
0
594 d->layout->invalidate();-
595 break;
never executed: break;
0
596-
597 case
never executed: case QEvent::ActionRemoved:
QEvent::ActionRemoved:
never executed: case QEvent::ActionRemoved:
{
0
598 int index = d->layout->indexOf(action);-
599 if (index != -1
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
600 delete d->layout->takeAt(index);-
601 }
never executed: end of block
0
602 break;
never executed: break;
0
603 }-
604-
605 default
never executed: default:
:
never executed: default:
0
606 ((!(false)) ? qt_assert_x("QToolBar::actionEvent", "internal error",__FILE__,1030) : qt_noop());-
607 }
never executed: end of block
0
608}-
609-
610-
611void QToolBar::changeEvent(QEvent *event)-
612{-
613 QToolBarPrivate * const d = d_func();-
614 switch (event->type()) {-
615 case
never executed: case QEvent::WindowTitleChange:
QEvent::WindowTitleChange:
never executed: case QEvent::WindowTitleChange:
0
616 d->toggleViewAction->setText(windowTitle());-
617 break;
never executed: break;
0
618 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
619 d->layout->invalidate();-
620 if (!d->explicitIconSize
!d->explicitIconSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
621 setIconSize(QSize());
never executed: setIconSize(QSize());
0
622 d->layout->updateMarginAndSpacing();-
623 break;
never executed: break;
0
624 case
never executed: case QEvent::LayoutDirectionChange:
QEvent::LayoutDirectionChange:
never executed: case QEvent::LayoutDirectionChange:
0
625 d->layout->invalidate();-
626 break;
never executed: break;
0
627 default
never executed: default:
:
never executed: default:
0
628 break;
never executed: break;
0
629 }-
630 QWidget::changeEvent(event);-
631}
never executed: end of block
0
632-
633-
634void QToolBar::paintEvent(QPaintEvent *)-
635{-
636 QToolBarPrivate * const d = d_func();-
637-
638 QPainter p(this);-
639 QStyle *style = this->style();-
640 QStyleOptionToolBar opt;-
641 initStyleOption(&opt);-
642-
643 if (d->layout->expanded
d->layout->expandedDescription
TRUEnever evaluated
FALSEnever evaluated
|| d->layout->animating
d->layout->animatingDescription
TRUEnever evaluated
FALSEnever evaluated
|| isWindow()
isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
644-
645-
646 p.fillRect(opt.rect, palette().background());-
647 style->drawControl(QStyle::CE_ToolBar, &opt, &p, this);-
648 style->drawPrimitive(QStyle::PE_FrameMenu, &opt, &p, this);-
649 }
never executed: end of block
else {
0
650 style->drawControl(QStyle::CE_ToolBar, &opt, &p, this);-
651 }
never executed: end of block
0
652-
653 opt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &opt, this);-
654 if (opt.rect.isValid()
opt.rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
655 style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);
never executed: style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &opt, &p, this);
0
656}
never executed: end of block
0
657-
658-
659-
660-
661-
662-
663-
664static bool waitForPopup(QToolBar *tb, QWidget *popup)-
665{-
666 if (popup == 0
popup == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| popup->isHidden()
popup->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
667 return
never executed: return false;
false;
never executed: return false;
0
668-
669 QWidget *w = popup;-
670 while (w != 0
w != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
671 if (w == tb
w == tbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
672 return
never executed: return true;
true;
never executed: return true;
0
673 w = w->parentWidget();-
674 }
never executed: end of block
0
675-
676 QMenu *menu = qobject_cast<QMenu*>(popup);-
677 if (menu == 0
menu == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
678 return
never executed: return false;
false;
never executed: return false;
0
679-
680 QAction *action = menu->menuAction();-
681 QList<QWidget*> widgets = action->associatedWidgets();-
682 for (int i = 0; i < widgets.count()
i < widgets.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
683 if (waitForPopup(tb, widgets.at(i))
waitForPopup(t...widgets.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
684 return
never executed: return true;
true;
never executed: return true;
0
685 }
never executed: end of block
0
686-
687 return
never executed: return false;
false;
never executed: return false;
0
688}-
689bool QToolBar::event(QEvent *event)-
690{-
691 QToolBarPrivate * const d = d_func();-
692-
693 switch (event->type()) {-
694 case
never executed: case QEvent::Timer:
QEvent::Timer:
never executed: case QEvent::Timer:
0
695 if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()
d->waitForPopu...nt)->timerId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
696 QWidget *w = QApplication::activePopupWidget();-
697 if (!waitForPopup(this, w)
!waitForPopup(this, w)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
698 d->waitForPopupTimer.stop();-
699 if (!this->underMouse()
!this->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
700 d->layout->setExpanded(false);
never executed: d->layout->setExpanded(false);
0
701 }
never executed: end of block
0
702 }
never executed: end of block
0
703 break;
never executed: break;
0
704 case
never executed: case QEvent::Hide:
QEvent::Hide:
never executed: case QEvent::Hide:
0
705 if (!isHidden()
!isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
706 break;
never executed: break;
0
707-
708 case
never executed: case QEvent::Show:
QEvent::Show:
never executed: case QEvent::Show:
code before this statement never executed: case QEvent::Show:
0
709 d->toggleViewAction->setChecked(event->type() == QEvent::Show);-
710-
711-
712-
713 visibilityChanged(event->type() == QEvent::Show);-
714 break;
never executed: break;
0
715 case
never executed: case QEvent::ParentChange:
QEvent::ParentChange:
never executed: case QEvent::ParentChange:
0
716 d->layout->checkUsePopupMenu();-
717 break;
never executed: break;
0
718-
719 case
never executed: case QEvent::MouseButtonPress:
QEvent::MouseButtonPress:
never executed: case QEvent::MouseButtonPress:
{
0
720 if (d->mousePressEvent(static_cast<QMouseEvent*>(event))
d->mousePressE...vent*>(event))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
721 return
never executed: return true;
true;
never executed: return true;
0
722 break;
never executed: break;
0
723 }-
724 case
never executed: case QEvent::MouseButtonRelease:
QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
725 if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event))
d->mouseReleas...vent*>(event))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
726 return
never executed: return true;
true;
never executed: return true;
0
727 break;
never executed: break;
0
728 case
never executed: case QEvent::HoverEnter:
QEvent::HoverEnter:
never executed: case QEvent::HoverEnter:
0
729 case
never executed: case QEvent::HoverLeave:
QEvent::HoverLeave:
never executed: case QEvent::HoverLeave:
0
730-
731 return
never executed: return true;
true;
never executed: return true;
0
732 case
never executed: case QEvent::HoverMove:
QEvent::HoverMove:
never executed: case QEvent::HoverMove:
{
0
733-
734 QHoverEvent *e = static_cast<QHoverEvent*>(event);-
735 QStyleOptionToolBar opt;-
736 initStyleOption(&opt);-
737 if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos())
style()->subEl...ains(e->pos())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
738 setCursor(Qt::SizeAllCursor);
never executed: setCursor(Qt::SizeAllCursor);
0
739 else-
740 unsetCursor();
never executed: unsetCursor();
0
741-
742 break;
never executed: break;
0
743 }-
744 case
never executed: case QEvent::MouseMove:
QEvent::MouseMove:
never executed: case QEvent::MouseMove:
0
745 if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event))
d->mouseMoveEv...vent*>(event))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
746 return
never executed: return true;
true;
never executed: return true;
0
747 break;
never executed: break;
0
748 case
never executed: case QEvent::Leave:
QEvent::Leave:
never executed: case QEvent::Leave:
0
749 if (d->state != 0
d->state != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& d->state->dragging
d->state->draggingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
750-
751-
752-
753-
754-
755-
756-
757 }
never executed: end of block
else {
0
758 if (!d->layout->expanded
!d->layout->expandedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
759 break;
never executed: break;
0
760-
761 QWidget *w = QApplication::activePopupWidget();-
762 if (waitForPopup(this, w)
waitForPopup(this, w)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
763 d->waitForPopupTimer.start(500, this);-
764 break;
never executed: break;
0
765 }-
766-
767 d->waitForPopupTimer.stop();-
768 d->layout->setExpanded(false);-
769 break;
never executed: break;
0
770 }-
771 default
never executed: default:
:
never executed: default:
code before this statement never executed: default:
0
772 break;
never executed: break;
0
773 }-
774 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
775}-
776QAction *QToolBar::toggleViewAction() const-
777{ const QToolBarPrivate * const d = d_func(); return
never executed: return d->toggleViewAction;
d->toggleViewAction;
never executed: return d->toggleViewAction;
}
0
778QWidget *QToolBar::widgetForAction(QAction *action) const-
779{-
780 const QToolBarPrivate * const d = d_func();-
781-
782 int index = d->layout->indexOf(action);-
783 if (index == -1
index == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
784 return
never executed: return 0;
0;
never executed: return 0;
0
785-
786 return
never executed: return d->layout->itemAt(index)->widget();
d->layout->itemAt(index)->widget();
never executed: return d->layout->itemAt(index)->widget();
0
787}-
788-
789extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);-
790-
791-
792-
793-
794void QToolBar::initStyleOption(QStyleOptionToolBar *option) const-
795{-
796 const QToolBarPrivate * const d = d_func();-
797-
798 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
799 return;
never executed: return;
0
800-
801 option->initFrom(this);-
802 if (orientation() == Qt::Horizontal
orientation() ...Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
803 option->state |= QStyle::State_Horizontal;
never executed: option->state |= QStyle::State_Horizontal;
0
804 option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this);-
805 option->features = d->layout->movable()
d->layout->movable()Description
TRUEnever evaluated
FALSEnever evaluated
0
806 ? QStyleOptionToolBar::Movable-
807 : QStyleOptionToolBar::None;-
808-
809 option->toolBarArea = Qt::NoToolBarArea;-
810-
811-
812 QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());-
813-
814 if (!mainWindow
!mainWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
815 return;
never executed: return;
0
816-
817 QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);-
818 ((!(layout != 0)) ? qt_assert_x("QToolBar::initStyleOption()", "QMainWindow->layout() != QMainWindowLayout",-
819 __FILE__-
820 ,-
821 1288-
822 ) : qt_noop())-
823 ;-
824-
825 layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this));-
826}
never executed: end of block
0
827-
828-
829-
Switch to Source codePreprocessed file

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