widgets/qdockwidget.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); -
14 -
15 -
16extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); -
17 -
18static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) -
19{ return (priv->features & feature) == feature; }
-
20 -
21static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) -
22{ return (dockwidget->features() & feature) == feature; }
-
23class QDockWidgetTitleButton : public QAbstractButton -
24{ -
25 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
26 -
27public: -
28 QDockWidgetTitleButton(QDockWidget *dockWidget); -
29 -
30 QSize sizeHint() const; -
31 inline QSize minimumSizeHint() const -
32 { return sizeHint(); }
-
33 -
34 void enterEvent(QEvent *event); -
35 void leaveEvent(QEvent *event); -
36 void paintEvent(QPaintEvent *event); -
37}; -
38 -
39 -
40QDockWidgetTitleButton::QDockWidgetTitleButton(QDockWidget *dockWidget) -
41 : QAbstractButton(dockWidget) -
42{ -
43 setFocusPolicy(Qt::NoFocus); -
44}
-
45 -
46QSize QDockWidgetTitleButton::sizeHint() const -
47{ -
48 ensurePolished(); -
49 -
50 int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this); -
51 if (!icon().isNull()) {
-
52 int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); -
53 QSize sz = icon().actualSize(QSize(iconSize, iconSize)); -
54 size += qMax(sz.width(), sz.height()); -
55 }
-
56 -
57 return QSize(size, size);
-
58} -
59 -
60void QDockWidgetTitleButton::enterEvent(QEvent *event) -
61{ -
62 if (isEnabled()) update();
-
63 QAbstractButton::enterEvent(event); -
64}
-
65 -
66void QDockWidgetTitleButton::leaveEvent(QEvent *event) -
67{ -
68 if (isEnabled()) update();
-
69 QAbstractButton::leaveEvent(event); -
70}
-
71 -
72void QDockWidgetTitleButton::paintEvent(QPaintEvent *) -
73{ -
74 QPainter p(this); -
75 -
76 QStyleOptionToolButton opt; -
77 opt.init(this); -
78 opt.state |= QStyle::State_AutoRaise; -
79 -
80 if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this))
-
81 { -
82 if (isEnabled() && underMouse() && !isChecked() && !isDown())
-
83 opt.state |= QStyle::State_Raised;
-
84 if (isChecked())
-
85 opt.state |= QStyle::State_On;
-
86 if (isDown())
-
87 opt.state |= QStyle::State_Sunken;
-
88 style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); -
89 }
-
90 -
91 opt.icon = icon(); -
92 opt.subControls = 0; -
93 opt.activeSubControls = 0; -
94 opt.features = QStyleOptionToolButton::None; -
95 opt.arrowType = Qt::NoArrow; -
96 int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); -
97 opt.iconSize = QSize(size, size); -
98 style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this); -
99}
-
100 -
101 -
102 -
103 -
104 -
105QDockWidgetLayout::QDockWidgetLayout(QWidget *parent) -
106 : QLayout(parent), verticalTitleBar(false), item_list(RoleCount, 0) -
107{ -
108}
-
109 -
110QDockWidgetLayout::~QDockWidgetLayout() -
111{ -
112 qDeleteAll(item_list); -
113}
-
114 -
115bool QDockWidgetLayout::nativeWindowDeco() const -
116{ -
117 return nativeWindowDeco(parentWidget()->isWindow());
-
118} -
119 -
120static bool isXcb() -
121{ -
122 static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive); -
123 return xcb;
-
124} -
125 -
126bool QDockWidgetLayout::nativeWindowDeco(bool floating) const -
127{ -
128 -
129 -
130 -
131 return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0);
-
132 -
133} -
134 -
135 -
136void QDockWidgetLayout::addItem(QLayoutItem*) -
137{ -
138 QMessageLogger("widgets/qdockwidget.cpp", 228, __PRETTY_FUNCTION__).warning() << "QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()"; -
139 return;
-
140} -
141 -
142QLayoutItem *QDockWidgetLayout::itemAt(int index) const -
143{ -
144 int cnt = 0; -
145 for (int i = 0; i < item_list.count(); ++i) {
-
146 QLayoutItem *item = item_list.at(i); -
147 if (item == 0)
-
148 continue;
-
149 if (index == cnt++)
-
150 return item;
-
151 }
-
152 return 0;
-
153} -
154 -
155QLayoutItem *QDockWidgetLayout::takeAt(int index) -
156{ -
157 int j = 0; -
158 for (int i = 0; i < item_list.count(); ++i) {
-
159 QLayoutItem *item = item_list.at(i); -
160 if (item == 0)
-
161 continue;
-
162 if (index == j) {
-
163 item_list[i] = 0; -
164 invalidate(); -
165 return item;
-
166 } -
167 ++j; -
168 }
-
169 return 0;
-
170} -
171 -
172int QDockWidgetLayout::count() const -
173{ -
174 int result = 0; -
175 for (int i = 0; i < item_list.count(); ++i) {
-
176 if (item_list.at(i))
-
177 ++result;
-
178 }
-
179 return result;
-
180} -
181 -
182QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) const -
183{ -
184 QSize result = content; -
185 -
186 if (verticalTitleBar) {
-
187 result.setHeight(qMax(result.height(), minimumTitleWidth())); -
188 result.setWidth(qMax(content.width(), 0)); -
189 } else {
-
190 result.setHeight(qMax(result.height(), 0)); -
191 result.setWidth(qMax(content.width(), minimumTitleWidth())); -
192 }
-
193 -
194 QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); -
195 const bool nativeDeco = nativeWindowDeco(floating); -
196 -
197 int fw = floating && !nativeDeco
-
198 ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w) -
199 : 0; -
200 -
201 const int th = titleHeight(); -
202 if (!nativeDeco) {
-
203 if (verticalTitleBar)
-
204 result += QSize(th + 2*fw, 2*fw);
-
205 else -
206 result += QSize(2*fw, th + 2*fw);
-
207 } -
208 -
209 result.setHeight(qMin(result.height(), (int) ((1<<24)-1))); -
210 result.setWidth(qMin(result.width(), (int) ((1<<24)-1))); -
211 -
212 if (content.width() < 0)
-
213 result.setWidth(-1);
-
214 if (content.height() < 0)
-
215 result.setHeight(-1);
-
216 -
217 int left, top, right, bottom; -
218 w->getContentsMargins(&left, &top, &right, &bottom); -
219 -
220 QSize min = w->minimumSize() - QSize(left + right, top + bottom); -
221 QSize max = w->maximumSize() - QSize(left + right, top + bottom); -
222 -
223 -
224 -
225 -
226 -
227 -
228 -
229 uint explicitMin = 0; -
230 uint explicitMax = 0; -
231 if (w->d_func()->extra != 0) {
-
232 explicitMin = w->d_func()->extra->explicitMinSize; -
233 explicitMax = w->d_func()->extra->explicitMaxSize; -
234 }
-
235 -
236 if (!(explicitMin & Qt::Horizontal) || min.width() == 0)
-
237 min.setWidth(-1);
-
238 if (!(explicitMin & Qt::Vertical) || min.height() == 0)
-
239 min.setHeight(-1);
-
240 -
241 if (!(explicitMax & Qt::Horizontal))
-
242 max.setWidth(((1<<24)-1));
-
243 if (!(explicitMax & Qt::Vertical))
-
244 max.setHeight(((1<<24)-1));
-
245 -
246 return result.boundedTo(max).expandedTo(min);
-
247} -
248 -
249QSize QDockWidgetLayout::sizeHint() const -
250{ -
251 QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); -
252 -
253 QSize content(-1, -1); -
254 if (item_list[Content] != 0)
-
255 content = item_list[Content]->sizeHint();
-
256 -
257 return sizeFromContent(content, w->isFloating());
-
258} -
259 -
260QSize QDockWidgetLayout::maximumSize() const -
261{ -
262 if (item_list[Content] != 0) {
-
263 const QSize content = item_list[Content]->maximumSize(); -
264 return sizeFromContent(content, parentWidget()->isWindow());
-
265 } else { -
266 return parentWidget()->maximumSize();
-
267 } -
268 -
269} -
270 -
271QSize QDockWidgetLayout::minimumSize() const -
272{ -
273 QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); -
274 -
275 QSize content(0, 0); -
276 if (item_list[Content] != 0)
-
277 content = item_list[Content]->minimumSize();
-
278 -
279 return sizeFromContent(content, w->isFloating());
-
280} -
281 -
282QWidget *QDockWidgetLayout::widgetForRole(Role r) const -
283{ -
284 QLayoutItem *item = item_list.at(r); -
285 return item == 0 ? 0 : item->widget();
-
286} -
287 -
288QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const -
289{ -
290 return item_list.at(r);
-
291} -
292 -
293void QDockWidgetLayout::setWidgetForRole(Role r, QWidget *w) -
294{ -
295 QWidget *old = widgetForRole(r); -
296 if (old != 0) {
-
297 old->hide(); -
298 removeWidget(old); -
299 }
-
300 -
301 if (w != 0) {
-
302 addChildWidget(w); -
303 item_list[r] = new QWidgetItemV2(w); -
304 w->show(); -
305 } else {
-
306 item_list[r] = 0; -
307 }
-
308 -
309 invalidate(); -
310}
-
311 -
312static inline int pick(bool vertical, const QSize &size) -
313{ -
314 return vertical ? size.height() : size.width();
-
315} -
316 -
317static inline int perp(bool vertical, const QSize &size) -
318{ -
319 return vertical ? size.width() : size.height();
-
320} -
321 -
322int QDockWidgetLayout::minimumTitleWidth() const -
323{ -
324 QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); -
325 -
326 if (QWidget *title = widgetForRole(TitleBar))
-
327 return pick(verticalTitleBar, title->minimumSizeHint());
-
328 -
329 QSize closeSize(0, 0); -
330 QSize floatSize(0, 0); -
331 if (hasFeature(q, QDockWidget::DockWidgetClosable)) {
-
332 if (QLayoutItem *item = item_list[CloseButton])
-
333 closeSize = item->widget()->sizeHint();
-
334 }
-
335 if (hasFeature(q, QDockWidget::DockWidgetFloatable)) {
-
336 if (QLayoutItem *item = item_list[FloatButton])
-
337 floatSize = item->widget()->sizeHint();
-
338 }
-
339 -
340 int titleHeight = this->titleHeight(); -
341 -
342 int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); -
343 int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); -
344 -
345 return pick(verticalTitleBar, closeSize) -
346 + pick(verticalTitleBar, floatSize) -
347 + titleHeight + 2*fw + 3*mw;
-
348} -
349 -
350int QDockWidgetLayout::titleHeight() const -
351{ -
352 QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); -
353 -
354 if (QWidget *title = widgetForRole(TitleBar))
-
355 return perp(verticalTitleBar, title->sizeHint());
-
356 -
357 QSize closeSize(0, 0); -
358 QSize floatSize(0, 0); -
359 if (QLayoutItem *item = item_list[CloseButton])
-
360 closeSize = item->widget()->sizeHint();
-
361 if (QLayoutItem *item = item_list[FloatButton])
-
362 floatSize = item->widget()->sizeHint();
-
363 -
364 int buttonHeight = qMax(perp(verticalTitleBar, closeSize), -
365 perp(verticalTitleBar, floatSize)); -
366 -
367 QFontMetrics titleFontMetrics = q->fontMetrics(); -
368 int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); -
369 -
370 return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
-
371} -
372 -
373void QDockWidgetLayout::setGeometry(const QRect &geometry) -
374{ -
375 QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); -
376 -
377 bool nativeDeco = nativeWindowDeco(); -
378 -
379 int fw = q->isFloating() && !nativeDeco
-
380 ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q) -
381 : 0; -
382 -
383 if (nativeDeco) {
-
384 if (QLayoutItem *item = item_list[Content])
-
385 item->setGeometry(geometry);
-
386 } else {
-
387 int titleHeight = this->titleHeight(); -
388 -
389 if (verticalTitleBar) {
-
390 _titleArea = QRect(QPoint(fw, fw), -
391 QSize(titleHeight, geometry.height() - (fw * 2))); -
392 } else {
-
393 _titleArea = QRect(QPoint(fw, fw), -
394 QSize(geometry.width() - (fw * 2), titleHeight)); -
395 }
-
396 -
397 if (QLayoutItem *item = item_list[TitleBar]) {
-
398 item->setGeometry(_titleArea); -
399 } else {
-
400 QStyleOptionDockWidgetV2 opt; -
401 q->initStyleOption(&opt); -
402 -
403 if (QLayoutItem *item = item_list[CloseButton]) {
-
404 if (!item->isEmpty()) {
-
405 QRect r = q->style() -
406 ->subElementRect(QStyle::SE_DockWidgetCloseButton, -
407 &opt, q); -
408 if (!r.isNull())
-
409 item->setGeometry(r);
-
410 }
-
411 }
-
412 -
413 if (QLayoutItem *item = item_list[FloatButton]) {
-
414 if (!item->isEmpty()) {
-
415 QRect r = q->style() -
416 ->subElementRect(QStyle::SE_DockWidgetFloatButton, -
417 &opt, q); -
418 if (!r.isNull())
-
419 item->setGeometry(r);
-
420 }
-
421 }
-
422 }
-
423 -
424 if (QLayoutItem *item = item_list[Content]) {
-
425 QRect r = geometry; -
426 if (verticalTitleBar) {
-
427 r.setLeft(_titleArea.right() + 1); -
428 r.adjust(0, fw, -fw, -fw); -
429 } else {
-
430 r.setTop(_titleArea.bottom() + 1); -
431 r.adjust(fw, 0, -fw, -fw); -
432 }
-
433 item->setGeometry(r); -
434 }
-
435 }
-
436} -
437 -
438void QDockWidgetLayout::setVerticalTitleBar(bool b) -
439{ -
440 if (b == verticalTitleBar)
-
441 return;
-
442 verticalTitleBar = b; -
443 invalidate(); -
444 parentWidget()->update(); -
445}
-
446 -
447 -
448 -
449 -
450 -
451QDockWidgetItem::QDockWidgetItem(QDockWidget *dockWidget) -
452 : QWidgetItem(dockWidget) -
453{ -
454}
-
455 -
456QSize QDockWidgetItem::minimumSize() const -
457{ -
458 QSize widgetMin(0, 0); -
459 if (QLayoutItem *item = dockWidgetChildItem())
-
460 widgetMin = item->minimumSize();
-
461 return dockWidgetLayout()->sizeFromContent(widgetMin, false);
-
462} -
463 -
464QSize QDockWidgetItem::maximumSize() const -
465{ -
466 if (QLayoutItem *item = dockWidgetChildItem()) {
-
467 return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false);
-
468 } else { -
469 return QSize(((1<<24)-1), ((1<<24)-1));
-
470 } -
471} -
472 -
473 -
474QSize QDockWidgetItem::sizeHint() const -
475{ -
476 if (QLayoutItem *item = dockWidgetChildItem()) {
-
477 return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false);
-
478 } else { -
479 return QWidgetItem::sizeHint();
-
480 } -
481} -
482 -
483 -
484 -
485 -
486 -
487void QDockWidgetPrivate::init() -
488{ -
489 QDockWidget * const q = q_func(); -
490 -
491 QDockWidgetLayout *layout = new QDockWidgetLayout(q); -
492 layout->setSizeConstraint(QLayout::SetMinAndMaxSize); -
493 -
494 QAbstractButton *button = new QDockWidgetTitleButton(q); -
495 button->setObjectName(QLatin1String("qt_dockwidget_floatbutton")); -
496 QObject::connect(button, "2""clicked()", q, "1""_q_toggleTopLevel()"); -
497 layout->setWidgetForRole(QDockWidgetLayout::FloatButton, button); -
498 -
499 button = new QDockWidgetTitleButton(q); -
500 button->setObjectName(QLatin1String("qt_dockwidget_closebutton")); -
501 QObject::connect(button, "2""clicked()", q, "1""close()"); -
502 layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button); -
503 -
504 resizer = new QWidgetResizeHandler(q); -
505 resizer->setMovingEnabled(false); -
506 resizer->setActive(false); -
507 -
508 -
509 toggleViewAction = new QAction(q); -
510 toggleViewAction->setCheckable(true); -
511 fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q); -
512 toggleViewAction->setText(fixedWindowTitle); -
513 QObject::connect(toggleViewAction, "2""triggered(bool)", -
514 q, "1""_q_toggleView(bool)"); -
515 -
516 -
517 updateButtons(); -
518}
-
519void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const -
520{ -
521 const QDockWidgetPrivate * const d = d_func(); -
522 -
523 if (!option)
-
524 return;
-
525 QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout()); -
526 -
527 option->initFrom(this); -
528 option->rect = dwlayout->titleArea(); -
529 option->title = d->fixedWindowTitle; -
530 option->closable = hasFeature(this, QDockWidget::DockWidgetClosable); -
531 option->movable = hasFeature(this, QDockWidget::DockWidgetMovable); -
532 option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable); -
533 -
534 QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout()); -
535 QStyleOptionDockWidgetV2 *v2 -
536 = qstyleoption_cast<QStyleOptionDockWidgetV2*>(option); -
537 if (v2 != 0)
-
538 v2->verticalTitleBar = l->verticalTitleBar;
-
539}
-
540 -
541void QDockWidgetPrivate::_q_toggleView(bool b) -
542{ -
543 QDockWidget * const q = q_func(); -
544 if (b == q->isHidden()) {
-
545 if (b)
-
546 q->show();
-
547 else -
548 q->close();
-
549 } -
550}
-
551 -
552void QDockWidgetPrivate::updateButtons() -
553{ -
554 QDockWidget * const q = q_func(); -
555 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); -
556 -
557 QStyleOptionDockWidget opt; -
558 q->initStyleOption(&opt); -
559 -
560 bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; -
561 bool nativeDeco = dwLayout->nativeWindowDeco(); -
562 bool hideButtons = nativeDeco || customTitleBar;
-
563 -
564 bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable); -
565 bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable); -
566 -
567 QAbstractButton *button -
568 = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton)); -
569 button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q)); -
570 button->setVisible(canFloat && !hideButtons); -
571 -
572 button -
573 = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton)); -
574 button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q)); -
575 button->setVisible(canClose && !hideButtons); -
576 -
577 q->setAttribute(Qt::WA_ContentsPropagated, -
578 (canFloat || canClose) && !hideButtons); -
579 -
580 layout->invalidate(); -
581}
-
582 -
583void QDockWidgetPrivate::_q_toggleTopLevel() -
584{ -
585 QDockWidget * const q = q_func(); -
586 q->setFloating(!q->isFloating()); -
587}
-
588 -
589void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) -
590{ -
591 if (state != 0)
-
592 return;
-
593 -
594 QMainWindow *win = qobject_cast<QMainWindow*>(parent); -
595 qt_noop(); -
596 QMainWindowLayout *layout = qt_mainwindow_layout(win); -
597 qt_noop(); -
598 if (layout->pluggingWidget != 0)
-
599 return;
-
600 -
601 state = new QDockWidgetPrivate::DragState; -
602 state->pressPos = pos; -
603 state->dragging = false; -
604 state->widgetItem = 0; -
605 state->ownWidgetItem = false; -
606 state->nca = nca; -
607 state->ctrlDrag = false; -
608}
-
609 -
610void QDockWidgetPrivate::startDrag() -
611{ -
612 QDockWidget * const q = q_func(); -
613 -
614 if (state == 0 || state->dragging)
-
615 return;
-
616 -
617 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); -
618 qt_noop(); -
619 -
620 state->widgetItem = layout->unplug(q); -
621 if (state->widgetItem == 0) {
-
622 -
623 -
624 -
625 -
626 state->widgetItem = new QDockWidgetItem(q); -
627 state->ownWidgetItem = true; -
628 }
-
629 -
630 if (state->ctrlDrag)
-
631 layout->restore();
-
632 -
633 state->dragging = true; -
634}
-
635 -
636void QDockWidgetPrivate::endDrag(bool abort) -
637{ -
638 QDockWidget * const q = q_func(); -
639 qt_noop(); -
640 -
641 q->releaseMouse(); -
642 -
643 if (state->dragging) {
-
644 QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); -
645 qt_noop(); -
646 -
647 if (abort || !mwLayout->plug(state->widgetItem)) {
-
648 if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
-
649 if (state->ownWidgetItem)
-
650 delete state->widgetItem;
-
651 mwLayout->restore(); -
652 if (isXcb()) {
-
653 -
654 Qt::WindowFlags flags = q->windowFlags(); -
655 flags &= ~Qt::X11BypassWindowManagerHint; -
656 q->setWindowFlags(flags); -
657 resizer->setActive(QWidgetResizeHandler::Resize, true); -
658 q->show(); -
659 } else {
-
660 QDockWidgetLayout *myLayout -
661 = qobject_cast<QDockWidgetLayout*>(layout); -
662 resizer->setActive(QWidgetResizeHandler::Resize, -
663 myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0); -
664 }
-
665 undockedGeometry = q->geometry(); -
666 q->activateWindow(); -
667 } else {
-
668 mwLayout->revert(state->widgetItem); -
669 }
-
670 } -
671 }
-
672 delete state; -
673 state = 0; -
674}
-
675 -
676bool QDockWidgetPrivate::isAnimating() const -
677{ -
678 const QDockWidget * const q = q_func(); -
679 -
680 QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent); -
681 if (mainWin == 0)
-
682 return false;
-
683 -
684 QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin); -
685 if (mainWinLayout == 0)
-
686 return false;
-
687 -
688 return (void*)mainWinLayout->pluggingWidget == (void*)q;
-
689} -
690 -
691bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) -
692{ -
693 -
694 QDockWidget * const q = q_func(); -
695 -
696 QDockWidgetLayout *dwLayout -
697 = qobject_cast<QDockWidgetLayout*>(layout); -
698 -
699 if (!dwLayout->nativeWindowDeco()) {
-
700 QRect titleArea = dwLayout->titleArea(); -
701 -
702 if (event->button() != Qt::LeftButton ||
-
703 !titleArea.contains(event->pos()) ||
-
704 -
705 -
706 (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
-
707 qobject_cast<QMainWindow*>(parent) == 0 ||
-
708 isAnimating() || state != 0) {
-
709 return false;
-
710 } -
711 -
712 initDrag(event->pos(), false); -
713 -
714 if (state)
-
715 state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
-
716 -
717 return true;
-
718 } -
719 -
720 -
721 return false;
-
722} -
723 -
724bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event) -
725{ -
726 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); -
727 -
728 if (!dwLayout->nativeWindowDeco()) {
-
729 QRect titleArea = dwLayout->titleArea(); -
730 -
731 if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
-
732 hasFeature(this, QDockWidget::DockWidgetFloatable)) {
-
733 _q_toggleTopLevel(); -
734 return true;
-
735 } -
736 }
-
737 return false;
-
738} -
739 -
740bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) -
741{ -
742 bool ret = false; -
743 -
744 QDockWidget * const q = q_func(); -
745 -
746 if (!state)
-
747 return ret;
-
748 -
749 QDockWidgetLayout *dwlayout -
750 = qobject_cast<QDockWidgetLayout *>(layout); -
751 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); -
752 if (!dwlayout->nativeWindowDeco()) {
-
753 if (!state->dragging
-
754 && mwlayout->pluggingWidget == 0
-
755 && (event->pos() - state->pressPos).manhattanLength() -
756 > QApplication::startDragDistance()) {
-
757 startDrag(); -
758 -
759 -
760 -
761 q->grabMouse(); -
762 -
763 ret = true; -
764 }
-
765 }
-
766 -
767 if (state->dragging && !state->nca) {
-
768 QPoint pos = event->globalPos() - state->pressPos; -
769 q->move(pos); -
770 -
771 if (!state->ctrlDrag)
-
772 mwlayout->hover(state->widgetItem, event->globalPos());
-
773 -
774 ret = true; -
775 }
-
776 -
777 -
778 return ret;
-
779} -
780 -
781bool QDockWidgetPrivate::mouseReleaseEvent(QMouseEvent *event) -
782{ -
783 -
784 -
785 if (event->button() == Qt::LeftButton && state && !state->nca) {
-
786 endDrag(); -
787 return true;
-
788 } -
789 -
790 -
791 return false;
-
792} -
793 -
794void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) -
795{ -
796 QDockWidget * const q = q_func(); -
797 -
798 int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); -
799 -
800 QRect geo = q->geometry(); -
801 QRect titleRect = q->frameGeometry(); -
802 -
803 -
804 -
805 -
806 -
807 -
808 -
809 { -
810 titleRect.setLeft(geo.left()); -
811 titleRect.setRight(geo.right()); -
812 titleRect.setBottom(geo.top() - 1); -
813 titleRect.adjust(0, fw, 0, 0); -
814 } -
815 -
816 switch (event->type()) { -
817 case QEvent::NonClientAreaMouseButtonPress: -
818 if (!titleRect.contains(event->globalPos()))
-
819 break;
-
820 if (state != 0)
-
821 break;
-
822 if (qobject_cast<QMainWindow*>(parent) == 0)
-
823 break;
-
824 if (isAnimating())
-
825 break;
-
826 initDrag(event->pos(), true); -
827 if (state == 0)
-
828 break;
-
829 -
830 -
831 -
832 -
833 state->ctrlDrag = event->modifiers() & Qt::ControlModifier; -
834 -
835 startDrag(); -
836 break;
-
837 case QEvent::NonClientAreaMouseMove: -
838 if (state == 0 || !state->dragging)
-
839 break;
-
840 -
841 -
842 if (state->nca) {
-
843 endDrag(); -
844 }
-
845 -
846 break;
-
847 case QEvent::NonClientAreaMouseButtonRelease: -
848 -
849 -
850 -
851 -
852 break;
-
853 case QEvent::NonClientAreaMouseButtonDblClick: -
854 _q_toggleTopLevel(); -
855 break;
-
856 default: -
857 break;
-
858 } -
859}
-
860 -
861void QDockWidgetPrivate::moveEvent(QMoveEvent *event) -
862{ -
863 QDockWidget * const q = q_func(); -
864 -
865 if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
-
866 return;
-
867 -
868 -
869 -
870 -
871 if (state->ctrlDrag)
-
872 return;
-
873 -
874 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); -
875 qt_noop(); -
876 -
877 QPoint globalMousePos = event->pos() + state->pressPos; -
878 layout->hover(state->widgetItem, globalMousePos); -
879}
-
880 -
881void QDockWidgetPrivate::unplug(const QRect &rect) -
882{ -
883 QDockWidget * const q = q_func(); -
884 QRect r = rect; -
885 r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); -
886 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); -
887 if (dwLayout->nativeWindowDeco(true))
-
888 r.adjust(0, dwLayout->titleHeight(), 0, 0);
-
889 setWindowState(true, true, r); -
890}
-
891 -
892void QDockWidgetPrivate::plug(const QRect &rect) -
893{ -
894 setWindowState(false, false, rect); -
895}
-
896 -
897static void setFrameStrutEventsEnabled(const QWidget *w, bool enabled) -
898{ -
899 if (const QWindow *window = w->windowHandle())
never evaluated: const QWindow *window = w->windowHandle()
0
900 if (QPlatformWindow *platformWindow = window->handle())
never evaluated: QPlatformWindow *platformWindow = window->handle()
0
901 if (platformWindow->frameStrutEventsEnabled() != enabled)
never evaluated: platformWindow->frameStrutEventsEnabled() != enabled
0
902 platformWindow->setFrameStrutEventsEnabled(enabled);
never executed: platformWindow->setFrameStrutEventsEnabled(enabled);
0
903}
never executed: }
0
904 -
905void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) -
906{ -
907 QDockWidget * const q = q_func(); -
908 -
909 if (!floating && parent) {
evaluated: !floating
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:13
evaluated: parent
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-13
910 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); -
911 if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
partially evaluated: mwlayout
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
evaluated: mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
0-9
912 return;
executed: return;
Execution Count:1
1
913 }
executed: }
Execution Count:8
8
914 -
915 bool wasFloating = q->isFloating(); -
916 bool hidden = q->isHidden(); -
917 -
918 if (q->isVisible())
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
919 q->hide();
executed: q->hide();
Execution Count:14
14
920 -
921 Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
evaluated: floating
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:9
9-13
922 -
923 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); -
924 const bool nativeDeco = dwLayout->nativeWindowDeco(floating); -
925 -
926 if (nativeDeco) {
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
927 flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; -
928 if (hasFeature(this, QDockWidget::DockWidgetClosable))
never evaluated: hasFeature(this, QDockWidget::DockWidgetClosable)
0
929 flags |= Qt::WindowCloseButtonHint;
never executed: flags |= Qt::WindowCloseButtonHint;
0
930 } else {
never executed: }
0
931 flags |= Qt::FramelessWindowHint; -
932 }
executed: }
Execution Count:22
22
933 -
934 if (unplug)
evaluated: unplug
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:19
3-19
935 flags |= Qt::X11BypassWindowManagerHint;
executed: flags |= Qt::X11BypassWindowManagerHint;
Execution Count:3
3
936 -
937 q->setWindowFlags(flags); -
938 -
939 -
940 if (!rect.isNull())
evaluated: !rect.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:21
1-21
941 q->setGeometry(rect);
executed: q->setGeometry(rect);
Execution Count:1
1
942 -
943 updateButtons(); -
944 -
945 if (!hidden)
evaluated: !hidden
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:5
5-17
946 q->show();
executed: q->show();
Execution Count:17
17
947 -
948 if (floating != wasFloating) {
evaluated: floating != wasFloating
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
949 q->topLevelChanged(floating); -
950 if (!floating && parent) {
evaluated: !floating
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
evaluated: parent
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-8
951 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); -
952 if (mwlayout)
partially evaluated: mwlayout
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
953 q->dockLocationChanged(mwlayout->dockWidgetArea(q));
executed: q->dockLocationChanged(mwlayout->dockWidgetArea(q));
Execution Count:5
5
954 }
executed: }
Execution Count:5
5
955 }
executed: }
Execution Count:14
14
956 -
957 if (floating && nativeDeco)
evaluated: floating
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:9
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
958 if (const QWindow *window = q->windowHandle())0
if (QPlatformWindow *platformWindow = window->handle())
platformWindow->setFrameStrutEventsEnabled(q, true);
never executed: setFrameStrutEventsEnabled(q, true);
959 -
960 resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco); -
961}
executed: }
Execution Count:22
22
962QDockWidget::QDockWidget(QWidget *parent, Qt::WindowFlags flags) -
963 : QWidget(*new QDockWidgetPrivate, parent, flags) -
964{ -
965 QDockWidgetPrivate * const d = d_func(); -
966 d->init(); -
967}
-
968QDockWidget::QDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) -
969 : QWidget(*new QDockWidgetPrivate, parent, flags) -
970{ -
971 QDockWidgetPrivate * const d = d_func(); -
972 d->init(); -
973 setWindowTitle(title); -
974}
-
975 -
976 -
977 -
978 -
979QDockWidget::~QDockWidget() -
980{ } -
981 -
982 -
983 -
984 -
985 -
986 -
987 -
988QWidget *QDockWidget::widget() const -
989{ -
990 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); -
991 return layout->widgetForRole(QDockWidgetLayout::Content);
-
992} -
993void QDockWidget::setWidget(QWidget *widget) -
994{ -
995 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); -
996 layout->setWidgetForRole(QDockWidgetLayout::Content, widget); -
997}
-
998void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) -
999{ -
1000 QDockWidgetPrivate * const d = d_func(); -
1001 features &= DockWidgetFeatureMask; -
1002 if (d->features == features)
-
1003 return;
-
1004 const bool closableChanged = (d->features ^ features) & DockWidgetClosable; -
1005 d->features = features; -
1006 QDockWidgetLayout *layout -
1007 = qobject_cast<QDockWidgetLayout*>(this->layout()); -
1008 layout->setVerticalTitleBar(features & DockWidgetVerticalTitleBar); -
1009 d->updateButtons(); -
1010 d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable); -
1011 featuresChanged(d->features); -
1012 update(); -
1013 if (closableChanged && layout->nativeWindowDeco()) {
-
1014 -
1015 d->setWindowState(true , true ); -
1016 }
-
1017}
-
1018 -
1019QDockWidget::DockWidgetFeatures QDockWidget::features() const -
1020{ -
1021 const QDockWidgetPrivate * const d = d_func(); -
1022 return d->features;
-
1023} -
1024void QDockWidget::setFloating(bool floating) -
1025{ -
1026 QDockWidgetPrivate * const d = d_func(); -
1027 -
1028 -
1029 if (d->state != 0)
-
1030 d->endDrag(true);
-
1031 -
1032 QRect r = d->undockedGeometry; -
1033 -
1034 d->setWindowState(floating, false, floating ? r : QRect()); -
1035 -
1036 if (floating && r.isNull()) {
-
1037 if (x() < 0 || y() < 0)
-
1038 move(QPoint());
-
1039 setAttribute(Qt::WA_Moved, false); -
1040 }
-
1041}
-
1042void QDockWidget::setAllowedAreas(Qt::DockWidgetAreas areas) -
1043{ -
1044 QDockWidgetPrivate * const d = d_func(); -
1045 areas &= Qt::DockWidgetArea_Mask; -
1046 if (areas == d->allowedAreas)
-
1047 return;
-
1048 d->allowedAreas = areas; -
1049 allowedAreasChanged(d->allowedAreas); -
1050}
-
1051 -
1052Qt::DockWidgetAreas QDockWidget::allowedAreas() const -
1053{ -
1054 const QDockWidgetPrivate * const d = d_func(); -
1055 return d->allowedAreas;
-
1056} -
1057void QDockWidget::changeEvent(QEvent *event) -
1058{ -
1059 QDockWidgetPrivate * const d = d_func(); -
1060 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); -
1061 -
1062 switch (event->type()) { -
1063 case QEvent::ModifiedChange: -
1064 case QEvent::WindowTitleChange: -
1065 update(layout->titleArea()); -
1066 -
1067 d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this); -
1068 d->toggleViewAction->setText(d->fixedWindowTitle); -
1069 -
1070 -
1071 { -
1072 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); -
1073 if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
-
1074 if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
-
1075 info->updateTabBar();
-
1076 }
-
1077 } -
1078 -
1079 break;
-
1080 default: -
1081 break;
-
1082 } -
1083 QWidget::changeEvent(event); -
1084}
-
1085 -
1086 -
1087void QDockWidget::closeEvent(QCloseEvent *event) -
1088{ -
1089 QDockWidgetPrivate * const d = d_func(); -
1090 if (d->state)
-
1091 d->endDrag(true);
-
1092 QWidget::closeEvent(event); -
1093}
-
1094 -
1095 -
1096void QDockWidget::paintEvent(QPaintEvent *event) -
1097{ -
1098 (void)event; -
1099 -
1100 QDockWidgetLayout *layout -
1101 = qobject_cast<QDockWidgetLayout*>(this->layout()); -
1102 bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; -
1103 bool nativeDeco = layout->nativeWindowDeco(); -
1104 -
1105 if (!nativeDeco && !customTitleBar) {
-
1106 QStylePainter p(this); -
1107 -
1108 -
1109 if (isFloating()) {
-
1110 QStyleOptionFrame framOpt; -
1111 framOpt.init(this); -
1112 p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt); -
1113 }
-
1114 -
1115 -
1116 -
1117 QStyleOptionDockWidgetV2 titleOpt; -
1118 initStyleOption(&titleOpt); -
1119 p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt); -
1120 }
-
1121}
-
1122 -
1123 -
1124bool QDockWidget::event(QEvent *event) -
1125{ -
1126 QDockWidgetPrivate * const d = d_func(); -
1127 -
1128 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); -
1129 QMainWindowLayout *layout = qt_mainwindow_layout(win); -
1130 -
1131 switch (event->type()) { -
1132 -
1133 case QEvent::Hide: -
1134 if (layout != 0)
evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:4
4-15
1135 layout->keepSize(this);
executed: layout->keepSize(this);
Execution Count:15
15
1136 d->toggleViewAction->setChecked(false); -
1137 visibilityChanged(false); -
1138 break;
executed: break;
Execution Count:19
19
1139 case QEvent::Show: -
1140 if (static_cast<QDockWidgetLayout *>(QDockWidget::layout())->nativeWindowDeco(isFloating()))
partially evaluated: static_cast<QDockWidgetLayout *>(QDockWidget::layout())->nativeWindowDeco(isFloating())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
1141 setFrameStrutEventsEnabled(this, true);
never executed: setFrameStrutEventsEnabled(this, true);
0
1142 d->toggleViewAction->setChecked(true); -
1143 visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0); -
1144 break;
executed: break;
Execution Count:34
34
1145 -
1146 case QEvent::ApplicationLayoutDirectionChange: -
1147 case QEvent::LayoutDirectionChange: -
1148 case QEvent::StyleChange: -
1149 case QEvent::ParentChange: -
1150 d->updateButtons(); -
1151 break;
executed: break;
Execution Count:15
15
1152 case QEvent::ZOrderChange: { -
1153 bool onTop = false; -
1154 if (win != 0) {
evaluated: win != 0
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:3
3-18
1155 const QObjectList &siblings = win->children(); -
1156 onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
partially evaluated: siblings.count() > 0
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
evaluated: siblings.last() == (QObject*)this
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:7
0-18
1157 }
executed: }
Execution Count:18
18
1158 if (!isFloating() && layout != 0 && onTop)
evaluated: !isFloating()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:12
partially evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
evaluated: onTop
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
0-12
1159 layout->raise(this);
executed: layout->raise(this);
Execution Count:4
4
1160 break;
executed: break;
Execution Count:21
21
1161 } -
1162 case QEvent::WindowActivate: -
1163 case QEvent::WindowDeactivate: -
1164 update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea()); -
1165 break;
executed: break;
Execution Count:18
18
1166 case QEvent::ContextMenu: -
1167 if (d->state) {
never evaluated: d->state
0
1168 event->accept(); -
1169 return true;
never executed: return true;
0
1170 } -
1171 break;
never executed: break;
0
1172 -
1173 -
1174 case QEvent::MouseButtonPress: -
1175 if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mousePressEvent(static_cast<QMouseEvent *>(event))
0
1176 return true;
never executed: return true;
0
1177 break;
never executed: break;
0
1178 case QEvent::MouseButtonDblClick: -
1179 if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event))
0
1180 return true;
never executed: return true;
0
1181 break;
never executed: break;
0
1182 case QEvent::MouseMove: -
1183 if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseMoveEvent(static_cast<QMouseEvent *>(event))
0
1184 return true;
never executed: return true;
0
1185 break;
never executed: break;
0
1186 case QEvent::MouseButtonRelease: -
1187 if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseReleaseEvent(static_cast<QMouseEvent *>(event))
0
1188 return true;
never executed: return true;
0
1189 break;
never executed: break;
0
1190 case QEvent::NonClientAreaMouseMove: -
1191 case QEvent::NonClientAreaMouseButtonPress: -
1192 case QEvent::NonClientAreaMouseButtonRelease: -
1193 case QEvent::NonClientAreaMouseButtonDblClick: -
1194 d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event)); -
1195 return true;
executed: return true;
Execution Count:2
2
1196 case QEvent::Move: -
1197 d->moveEvent(static_cast<QMoveEvent*>(event)); -
1198 break;
executed: break;
Execution Count:37
37
1199 case QEvent::Resize: -
1200 -
1201 if (isFloating() && layout != 0 && layout->pluggingWidget != this)
evaluated: isFloating()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:20
evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
partially evaluated: layout->pluggingWidget != this
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-20
1202 d->undockedGeometry = geometry();
executed: d->undockedGeometry = geometry();
Execution Count:8
8
1203 break;
executed: break;
Execution Count:35
35
1204 default: -
1205 break;
executed: break;
Execution Count:671
671
1206 } -
1207 return QWidget::event(event);
executed: return QWidget::event(event);
Execution Count:850
850
1208} -
1209QAction * QDockWidget::toggleViewAction() const -
1210{ -
1211 const QDockWidgetPrivate * const d = d_func(); -
1212 return d->toggleViewAction;
-
1213} -
1214void QDockWidget::setTitleBarWidget(QWidget *widget) -
1215{ -
1216 QDockWidgetPrivate * const d = d_func(); -
1217 QDockWidgetLayout *layout -
1218 = qobject_cast<QDockWidgetLayout*>(this->layout()); -
1219 layout->setWidgetForRole(QDockWidgetLayout::TitleBar, widget); -
1220 d->updateButtons(); -
1221 if (isWindow()) {
-
1222 -
1223 d->setWindowState(true , true ); -
1224 }
-
1225}
-
1226QWidget *QDockWidget::titleBarWidget() const -
1227{ -
1228 QDockWidgetLayout *layout -
1229 = qobject_cast<QDockWidgetLayout*>(this->layout()); -
1230 return layout->widgetForRole(QDockWidgetLayout::TitleBar);
-
1231} -
1232 -
1233 -
1234 -
1235 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial