widgets/qdockwidget.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qdockwidget.h" -
43 -
44#ifndef QT_NO_DOCKWIDGET -
45#include <qaction.h> -
46#include <qapplication.h> -
47#include <qdesktopwidget.h> -
48#include <qdrawutil.h> -
49#include <qevent.h> -
50#include <qfontmetrics.h> -
51#include <qwindow.h> -
52#include <qmainwindow.h> -
53#include <qrubberband.h> -
54#include <qstylepainter.h> -
55#include <qtoolbutton.h> -
56#include <qdebug.h> -
57 -
58#include <qpa/qplatformwindow.h> -
59#include <private/qwidgetresizehandler_p.h> -
60 -
61#include "qdockwidget_p.h" -
62#include "qmainwindowlayout_p.h" -
63#ifdef Q_WS_MAC -
64#include <private/qapplication_p.h> -
65#include <private/qt_mac_p.h> -
66#include <private/qmacstyle_mac_p.h> -
67#endif -
68 -
69QT_BEGIN_NAMESPACE -
70 -
71extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp -
72 -
73// qmainwindow.cpp -
74extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); -
75 -
76static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) -
77{ return (priv->features & feature) == feature; }
executed: return (priv->features & feature) == feature;
Execution Count:156
156
78 -
79static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) -
80{ return (dockwidget->features() & feature) == feature; }
executed: return (dockwidget->features() & feature) == feature;
Execution Count:1706
1706
81 -
82 -
83/* -
84 A Dock Window: -
85 -
86 [+] is the float button -
87 [X] is the close button -
88 -
89 +-------------------------------+ -
90 | Dock Window Title [+][X]| -
91 +-------------------------------+ -
92 | | -
93 | place to put the single | -
94 | QDockWidget child (this space | -
95 | does not yet have a name) | -
96 | | -
97 | | -
98 | | -
99 | | -
100 | | -
101 | | -
102 | | -
103 | | -
104 | | -
105 +-------------------------------+ -
106 -
107*/ -
108 -
109/****************************************************************************** -
110** QDockWidgetTitleButton -
111*/ -
112 -
113class QDockWidgetTitleButton : public QAbstractButton -
114{ -
115 Q_OBJECT -
116 -
117public: -
118 QDockWidgetTitleButton(QDockWidget *dockWidget); -
119 -
120 QSize sizeHint() const; -
121 inline QSize minimumSizeHint() const -
122 { return sizeHint(); }
executed: return sizeHint();
Execution Count:58
58
123 -
124 void enterEvent(QEvent *event); -
125 void leaveEvent(QEvent *event); -
126 void paintEvent(QPaintEvent *event); -
127}; -
128 -
129 -
130QDockWidgetTitleButton::QDockWidgetTitleButton(QDockWidget *dockWidget) -
131 : QAbstractButton(dockWidget) -
132{ -
133 setFocusPolicy(Qt::NoFocus);
executed (the execution status of this line is deduced): setFocusPolicy(Qt::NoFocus);
-
134}
executed: }
Execution Count:50
50
135 -
136QSize QDockWidgetTitleButton::sizeHint() const -
137{ -
138 ensurePolished();
executed (the execution status of this line is deduced): ensurePolished();
-
139 -
140 int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
executed (the execution status of this line is deduced): int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
-
141 if (!icon().isNull()) {
partially evaluated: !icon().isNull()
TRUEFALSE
yes
Evaluation Count:3886
no
Evaluation Count:0
0-3886
142 int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
executed (the execution status of this line is deduced): int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
-
143 QSize sz = icon().actualSize(QSize(iconSize, iconSize));
executed (the execution status of this line is deduced): QSize sz = icon().actualSize(QSize(iconSize, iconSize));
-
144 size += qMax(sz.width(), sz.height());
executed (the execution status of this line is deduced): size += qMax(sz.width(), sz.height());
-
145 }
executed: }
Execution Count:3886
3886
146 -
147 return QSize(size, size);
executed: return QSize(size, size);
Execution Count:3886
3886
148} -
149 -
150void QDockWidgetTitleButton::enterEvent(QEvent *event) -
151{ -
152 if (isEnabled()) update();
never executed: update();
never evaluated: isEnabled()
0
153 QAbstractButton::enterEvent(event);
never executed (the execution status of this line is deduced): QAbstractButton::enterEvent(event);
-
154}
never executed: }
0
155 -
156void QDockWidgetTitleButton::leaveEvent(QEvent *event) -
157{ -
158 if (isEnabled()) update();
never executed: update();
never evaluated: isEnabled()
0
159 QAbstractButton::leaveEvent(event);
never executed (the execution status of this line is deduced): QAbstractButton::leaveEvent(event);
-
160}
never executed: }
0
161 -
162void QDockWidgetTitleButton::paintEvent(QPaintEvent *) -
163{ -
164 QPainter p(this);
executed (the execution status of this line is deduced): QPainter p(this);
-
165 -
166 QStyleOptionToolButton opt;
executed (the execution status of this line is deduced): QStyleOptionToolButton opt;
-
167 opt.init(this);
executed (the execution status of this line is deduced): opt.init(this);
-
168 opt.state |= QStyle::State_AutoRaise;
executed (the execution status of this line is deduced): opt.state |= QStyle::State_AutoRaise;
-
169 -
170 if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this))
partially evaluated: style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this)
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
0-42
171 { -
172 if (isEnabled() && underMouse() && !isChecked() && !isDown())
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
partially evaluated: underMouse()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
never evaluated: !isChecked()
never evaluated: !isDown()
0-42
173 opt.state |= QStyle::State_Raised;
never executed: opt.state |= QStyle::State_Raised;
0
174 if (isChecked())
partially evaluated: isChecked()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
175 opt.state |= QStyle::State_On;
never executed: opt.state |= QStyle::State_On;
0
176 if (isDown())
partially evaluated: isDown()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
177 opt.state |= QStyle::State_Sunken;
never executed: opt.state |= QStyle::State_Sunken;
0
178 style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this);
executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this);
-
179 }
executed: }
Execution Count:42
42
180 -
181 opt.icon = icon();
executed (the execution status of this line is deduced): opt.icon = icon();
-
182 opt.subControls = 0;
executed (the execution status of this line is deduced): opt.subControls = 0;
-
183 opt.activeSubControls = 0;
executed (the execution status of this line is deduced): opt.activeSubControls = 0;
-
184 opt.features = QStyleOptionToolButton::None;
executed (the execution status of this line is deduced): opt.features = QStyleOptionToolButton::None;
-
185 opt.arrowType = Qt::NoArrow;
executed (the execution status of this line is deduced): opt.arrowType = Qt::NoArrow;
-
186 int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
executed (the execution status of this line is deduced): int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
-
187 opt.iconSize = QSize(size, size);
executed (the execution status of this line is deduced): opt.iconSize = QSize(size, size);
-
188 style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
executed (the execution status of this line is deduced): style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
-
189}
executed: }
Execution Count:42
42
190 -
191/****************************************************************************** -
192** QDockWidgetLayout -
193*/ -
194 -
195QDockWidgetLayout::QDockWidgetLayout(QWidget *parent) -
196 : QLayout(parent), verticalTitleBar(false), item_list(RoleCount, 0) -
197{ -
198}
executed: }
Execution Count:25
25
199 -
200QDockWidgetLayout::~QDockWidgetLayout() -
201{ -
202 qDeleteAll(item_list);
executed (the execution status of this line is deduced): qDeleteAll(item_list);
-
203}
executed: }
Execution Count:24
24
204 -
205bool QDockWidgetLayout::nativeWindowDeco() const -
206{ -
207 return nativeWindowDeco(parentWidget()->isWindow());
executed: return nativeWindowDeco(parentWidget()->isWindow());
Execution Count:174
174
208} -
209 -
210static bool isXcb() -
211{ -
212 static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive); -
213 return xcb;
executed: return xcb;
Execution Count:808
808
214} -
215 -
216bool QDockWidgetLayout::nativeWindowDeco(bool floating) const -
217{ -
218#ifdef Q_OS_WINCE -
219 return false; -
220#else -
221 return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0);
executed: return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0);
Execution Count:808
808
222#endif -
223} -
224 -
225 -
226void QDockWidgetLayout::addItem(QLayoutItem*) -
227{ -
228 qWarning() << "QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()";
never executed (the execution status of this line is deduced): QMessageLogger("widgets/qdockwidget.cpp", 228, __PRETTY_FUNCTION__).warning() << "QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()";
-
229 return;
never executed: return;
0
230} -
231 -
232QLayoutItem *QDockWidgetLayout::itemAt(int index) const -
233{ -
234 int cnt = 0;
executed (the execution status of this line is deduced): int cnt = 0;
-
235 for (int i = 0; i < item_list.count(); ++i) {
evaluated: i < item_list.count()
TRUEFALSE
yes
Evaluation Count:503
yes
Evaluation Count:51
51-503
236 QLayoutItem *item = item_list.at(i);
executed (the execution status of this line is deduced): QLayoutItem *item = item_list.at(i);
-
237 if (item == 0)
evaluated: item == 0
TRUEFALSE
yes
Evaluation Count:176
yes
Evaluation Count:327
176-327
238 continue;
executed: continue;
Execution Count:176
176
239 if (index == cnt++)
evaluated: index == cnt++
TRUEFALSE
yes
Evaluation Count:128
yes
Evaluation Count:199
128-199
240 return item;
executed: return item;
Execution Count:128
128
241 }
executed: }
Execution Count:199
199
242 return 0;
executed: return 0;
Execution Count:51
51
243} -
244 -
245QLayoutItem *QDockWidgetLayout::takeAt(int index) -
246{ -
247 int j = 0;
executed (the execution status of this line is deduced): int j = 0;
-
248 for (int i = 0; i < item_list.count(); ++i) {
partially evaluated: i < item_list.count()
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
249 QLayoutItem *item = item_list.at(i);
executed (the execution status of this line is deduced): QLayoutItem *item = item_list.at(i);
-
250 if (item == 0)
evaluated: item == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:16
2-16
251 continue;
executed: continue;
Execution Count:2
2
252 if (index == j) {
evaluated: index == j
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:4
4-12
253 item_list[i] = 0;
executed (the execution status of this line is deduced): item_list[i] = 0;
-
254 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
255 return item;
executed: return item;
Execution Count:12
12
256 } -
257 ++j;
executed (the execution status of this line is deduced): ++j;
-
258 }
executed: }
Execution Count:4
4
259 return 0;
never executed: return 0;
0
260} -
261 -
262int QDockWidgetLayout::count() const -
263{ -
264 int result = 0;
never executed (the execution status of this line is deduced): int result = 0;
-
265 for (int i = 0; i < item_list.count(); ++i) {
never evaluated: i < item_list.count()
0
266 if (item_list.at(i))
never evaluated: item_list.at(i)
0
267 ++result;
never executed: ++result;
0
268 }
never executed: }
0
269 return result;
never executed: return result;
0
270} -
271 -
272QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) const -
273{ -
274 QSize result = content;
executed (the execution status of this line is deduced): QSize result = content;
-
275 -
276 if (verticalTitleBar) {
partially evaluated: verticalTitleBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:613
0-613
277 result.setHeight(qMax(result.height(), minimumTitleWidth()));
never executed (the execution status of this line is deduced): result.setHeight(qMax(result.height(), minimumTitleWidth()));
-
278 result.setWidth(qMax(content.width(), 0));
never executed (the execution status of this line is deduced): result.setWidth(qMax(content.width(), 0));
-
279 } else {
never executed: }
0
280 result.setHeight(qMax(result.height(), 0));
executed (the execution status of this line is deduced): result.setHeight(qMax(result.height(), 0));
-
281 result.setWidth(qMax(content.width(), minimumTitleWidth()));
executed (the execution status of this line is deduced): result.setWidth(qMax(content.width(), minimumTitleWidth()));
-
282 }
executed: }
Execution Count:613
613
283 -
284 QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
executed (the execution status of this line is deduced): QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
-
285 const bool nativeDeco = nativeWindowDeco(floating);
executed (the execution status of this line is deduced): const bool nativeDeco = nativeWindowDeco(floating);
-
286 -
287 int fw = floating && !nativeDeco
evaluated: floating
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:577
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:36
no
Evaluation Count:0
0-577
288 ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w)
executed (the execution status of this line is deduced): ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w)
-
289 : 0;
executed (the execution status of this line is deduced): : 0;
-
290 -
291 const int th = titleHeight();
executed (the execution status of this line is deduced): const int th = titleHeight();
-
292 if (!nativeDeco) {
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:613
no
Evaluation Count:0
0-613
293 if (verticalTitleBar)
partially evaluated: verticalTitleBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:613
0-613
294 result += QSize(th + 2*fw, 2*fw);
never executed: result += QSize(th + 2*fw, 2*fw);
0
295 else -
296 result += QSize(2*fw, th + 2*fw);
executed: result += QSize(2*fw, th + 2*fw);
Execution Count:613
613
297 } -
298 -
299 result.setHeight(qMin(result.height(), (int) QWIDGETSIZE_MAX));
executed (the execution status of this line is deduced): result.setHeight(qMin(result.height(), (int) ((1<<24)-1)));
-
300 result.setWidth(qMin(result.width(), (int) QWIDGETSIZE_MAX));
executed (the execution status of this line is deduced): result.setWidth(qMin(result.width(), (int) ((1<<24)-1)));
-
301 -
302 if (content.width() < 0)
evaluated: content.width() < 0
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:557
56-557
303 result.setWidth(-1);
executed: result.setWidth(-1);
Execution Count:56
56
304 if (content.height() < 0)
evaluated: content.height() < 0
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:557
56-557
305 result.setHeight(-1);
executed: result.setHeight(-1);
Execution Count:56
56
306 -
307 int left, top, right, bottom;
executed (the execution status of this line is deduced): int left, top, right, bottom;
-
308 w->getContentsMargins(&left, &top, &right, &bottom);
executed (the execution status of this line is deduced): w->getContentsMargins(&left, &top, &right, &bottom);
-
309 //we need to subtract the contents margin (it will be added by the caller) -
310 QSize min = w->minimumSize() - QSize(left + right, top + bottom);
executed (the execution status of this line is deduced): QSize min = w->minimumSize() - QSize(left + right, top + bottom);
-
311 QSize max = w->maximumSize() - QSize(left + right, top + bottom);
executed (the execution status of this line is deduced): QSize max = w->maximumSize() - QSize(left + right, top + bottom);
-
312 -
313 /* A floating dockwidget will automatically get its minimumSize set to the layout's -
314 minimum size + deco. We're *not* interested in this, we only take minimumSize() -
315 into account if the user set it herself. Otherwise we end up expanding the result -
316 of a calculation for a non-floating dock widget to a floating dock widget's -
317 minimum size + window decorations. */ -
318 -
319 uint explicitMin = 0;
executed (the execution status of this line is deduced): uint explicitMin = 0;
-
320 uint explicitMax = 0;
executed (the execution status of this line is deduced): uint explicitMax = 0;
-
321 if (w->d_func()->extra != 0) {
evaluated: w->d_func()->extra != 0
TRUEFALSE
yes
Evaluation Count:448
yes
Evaluation Count:165
165-448
322 explicitMin = w->d_func()->extra->explicitMinSize;
executed (the execution status of this line is deduced): explicitMin = w->d_func()->extra->explicitMinSize;
-
323 explicitMax = w->d_func()->extra->explicitMaxSize;
executed (the execution status of this line is deduced): explicitMax = w->d_func()->extra->explicitMaxSize;
-
324 }
executed: }
Execution Count:448
448
325 -
326 if (!(explicitMin & Qt::Horizontal) || min.width() == 0)
evaluated: !(explicitMin & Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:600
yes
Evaluation Count:13
partially evaluated: min.width() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-600
327 min.setWidth(-1);
executed: min.setWidth(-1);
Execution Count:600
600
328 if (!(explicitMin & Qt::Vertical) || min.height() == 0)
evaluated: !(explicitMin & Qt::Vertical)
TRUEFALSE
yes
Evaluation Count:600
yes
Evaluation Count:13
partially evaluated: min.height() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-600
329 min.setHeight(-1);
executed: min.setHeight(-1);
Execution Count:600
600
330 -
331 if (!(explicitMax & Qt::Horizontal))
partially evaluated: !(explicitMax & Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:613
no
Evaluation Count:0
0-613
332 max.setWidth(QWIDGETSIZE_MAX);
executed: max.setWidth(((1<<24)-1));
Execution Count:613
613
333 if (!(explicitMax & Qt::Vertical))
partially evaluated: !(explicitMax & Qt::Vertical)
TRUEFALSE
yes
Evaluation Count:613
no
Evaluation Count:0
0-613
334 max.setHeight(QWIDGETSIZE_MAX);
executed: max.setHeight(((1<<24)-1));
Execution Count:613
613
335 -
336 return result.boundedTo(max).expandedTo(min);
executed: return result.boundedTo(max).expandedTo(min);
Execution Count:613
613
337} -
338 -
339QSize QDockWidgetLayout::sizeHint() const -
340{ -
341 QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
executed (the execution status of this line is deduced): QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
-
342 -
343 QSize content(-1, -1);
executed (the execution status of this line is deduced): QSize content(-1, -1);
-
344 if (item_list[Content] != 0)
evaluated: item_list[Content] != 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:56
2-56
345 content = item_list[Content]->sizeHint();
executed: content = item_list[Content]->sizeHint();
Execution Count:2
2
346 -
347 return sizeFromContent(content, w->isFloating());
executed: return sizeFromContent(content, w->isFloating());
Execution Count:58
58
348} -
349 -
350QSize QDockWidgetLayout::maximumSize() const -
351{ -
352 if (item_list[Content] != 0) {
evaluated: item_list[Content] != 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:28
9-28
353 const QSize content = item_list[Content]->maximumSize();
executed (the execution status of this line is deduced): const QSize content = item_list[Content]->maximumSize();
-
354 return sizeFromContent(content, parentWidget()->isWindow());
executed: return sizeFromContent(content, parentWidget()->isWindow());
Execution Count:9
9
355 } else { -
356 return parentWidget()->maximumSize();
executed: return parentWidget()->maximumSize();
Execution Count:28
28
357 } -
358 -
359} -
360 -
361QSize QDockWidgetLayout::minimumSize() const -
362{ -
363 QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
executed (the execution status of this line is deduced): QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
-
364 -
365 QSize content(0, 0);
executed (the execution status of this line is deduced): QSize content(0, 0);
-
366 if (item_list[Content] != 0)
evaluated: item_list[Content] != 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:76
9-76
367 content = item_list[Content]->minimumSize();
executed: content = item_list[Content]->minimumSize();
Execution Count:9
9
368 -
369 return sizeFromContent(content, w->isFloating());
executed: return sizeFromContent(content, w->isFloating());
Execution Count:85
85
370} -
371 -
372QWidget *QDockWidgetLayout::widgetForRole(Role r) const -
373{ -
374 QLayoutItem *item = item_list.at(r);
executed (the execution status of this line is deduced): QLayoutItem *item = item_list.at(r);
-
375 return item == 0 ? 0 : item->widget();
executed: return item == 0 ? 0 : item->widget();
Execution Count:2259
2259
376} -
377 -
378QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const -
379{ -
380 return item_list.at(r);
executed: return item_list.at(r);
Execution Count:681
681
381} -
382 -
383void QDockWidgetLayout::setWidgetForRole(Role r, QWidget *w) -
384{ -
385 QWidget *old = widgetForRole(r);
executed (the execution status of this line is deduced): QWidget *old = widgetForRole(r);
-
386 if (old != 0) {
evaluated: old != 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:62
8-62
387 old->hide();
executed (the execution status of this line is deduced): old->hide();
-
388 removeWidget(old);
executed (the execution status of this line is deduced): removeWidget(old);
-
389 }
executed: }
Execution Count:8
8
390 -
391 if (w != 0) {
evaluated: w != 0
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:5
5-65
392 addChildWidget(w);
executed (the execution status of this line is deduced): addChildWidget(w);
-
393 item_list[r] = new QWidgetItemV2(w);
executed (the execution status of this line is deduced): item_list[r] = new QWidgetItemV2(w);
-
394 w->show();
executed (the execution status of this line is deduced): w->show();
-
395 } else {
executed: }
Execution Count:65
65
396 item_list[r] = 0;
executed (the execution status of this line is deduced): item_list[r] = 0;
-
397 }
executed: }
Execution Count:5
5
398 -
399 invalidate();
executed (the execution status of this line is deduced): invalidate();
-
400}
executed: }
Execution Count:70
70
401 -
402static inline int pick(bool vertical, const QSize &size) -
403{ -
404 return vertical ? size.height() : size.width();
executed: return vertical ? size.height() : size.width();
Execution Count:1220
1220
405} -
406 -
407static inline int perp(bool vertical, const QSize &size) -
408{ -
409 return vertical ? size.width() : size.height();
executed: return vertical ? size.width() : size.height();
Execution Count:2566
2566
410} -
411 -
412int QDockWidgetLayout::minimumTitleWidth() const -
413{ -
414 QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
executed (the execution status of this line is deduced): QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
-
415 -
416 if (QWidget *title = widgetForRole(TitleBar))
evaluated: QWidget *title = widgetForRole(TitleBar)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:607
6-607
417 return pick(verticalTitleBar, title->minimumSizeHint());
executed: return pick(verticalTitleBar, title->minimumSizeHint());
Execution Count:6
6
418 -
419 QSize closeSize(0, 0);
executed (the execution status of this line is deduced): QSize closeSize(0, 0);
-
420 QSize floatSize(0, 0);
executed (the execution status of this line is deduced): QSize floatSize(0, 0);
-
421 if (hasFeature(q, QDockWidget::DockWidgetClosable)) {
partially evaluated: hasFeature(q, QDockWidget::DockWidgetClosable)
TRUEFALSE
yes
Evaluation Count:607
no
Evaluation Count:0
0-607
422 if (QLayoutItem *item = item_list[CloseButton])
partially evaluated: QLayoutItem *item = item_list[CloseButton]
TRUEFALSE
yes
Evaluation Count:607
no
Evaluation Count:0
0-607
423 closeSize = item->widget()->sizeHint();
executed: closeSize = item->widget()->sizeHint();
Execution Count:607
607
424 }
executed: }
Execution Count:607
607
425 if (hasFeature(q, QDockWidget::DockWidgetFloatable)) {
partially evaluated: hasFeature(q, QDockWidget::DockWidgetFloatable)
TRUEFALSE
yes
Evaluation Count:607
no
Evaluation Count:0
0-607
426 if (QLayoutItem *item = item_list[FloatButton])
partially evaluated: QLayoutItem *item = item_list[FloatButton]
TRUEFALSE
yes
Evaluation Count:607
no
Evaluation Count:0
0-607
427 floatSize = item->widget()->sizeHint();
executed: floatSize = item->widget()->sizeHint();
Execution Count:607
607
428 }
executed: }
Execution Count:607
607
429 -
430 int titleHeight = this->titleHeight();
executed (the execution status of this line is deduced): int titleHeight = this->titleHeight();
-
431 -
432 int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
executed (the execution status of this line is deduced): int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
-
433 int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
executed (the execution status of this line is deduced): int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
-
434 -
435 return pick(verticalTitleBar, closeSize)
executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw;
Execution Count:607
607
436 + pick(verticalTitleBar, floatSize)
executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw;
Execution Count:607
607
437 + titleHeight + 2*fw + 3*mw;
executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw;
Execution Count:607
607
438} -
439 -
440int QDockWidgetLayout::titleHeight() const -
441{ -
442 QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
executed (the execution status of this line is deduced): QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
-
443 -
444 if (QWidget *title = widgetForRole(TitleBar))
evaluated: QWidget *title = widgetForRole(TitleBar)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1278
10-1278
445 return perp(verticalTitleBar, title->sizeHint());
executed: return perp(verticalTitleBar, title->sizeHint());
Execution Count:10
10
446 -
447 QSize closeSize(0, 0);
executed (the execution status of this line is deduced): QSize closeSize(0, 0);
-
448 QSize floatSize(0, 0);
executed (the execution status of this line is deduced): QSize floatSize(0, 0);
-
449 if (QLayoutItem *item = item_list[CloseButton])
partially evaluated: QLayoutItem *item = item_list[CloseButton]
TRUEFALSE
yes
Evaluation Count:1278
no
Evaluation Count:0
0-1278
450 closeSize = item->widget()->sizeHint();
executed: closeSize = item->widget()->sizeHint();
Execution Count:1278
1278
451 if (QLayoutItem *item = item_list[FloatButton])
partially evaluated: QLayoutItem *item = item_list[FloatButton]
TRUEFALSE
yes
Evaluation Count:1278
no
Evaluation Count:0
0-1278
452 floatSize = item->widget()->sizeHint();
executed: floatSize = item->widget()->sizeHint();
Execution Count:1278
1278
453 -
454 int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
executed (the execution status of this line is deduced): int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
-
455 perp(verticalTitleBar, floatSize));
executed (the execution status of this line is deduced): perp(verticalTitleBar, floatSize));
-
456 -
457 QFontMetrics titleFontMetrics = q->fontMetrics();
executed (the execution status of this line is deduced): QFontMetrics titleFontMetrics = q->fontMetrics();
-
458#ifdef Q_WS_MAC -
459 if (qobject_cast<QMacStyle *>(q->style())) { -
460 //### this breaks on proxy styles. (But is this code still called?) -
461 QFont font = qt_app_fonts_hash()->value("QToolButton", q->font()); -
462 titleFontMetrics = QFontMetrics(font); -
463 } -
464#endif -
465 -
466 int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
executed (the execution status of this line is deduced): int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
-
467 -
468 return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
executed: return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
Execution Count:1278
1278
469} -
470 -
471void QDockWidgetLayout::setGeometry(const QRect &geometry) -
472{ -
473 QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
executed (the execution status of this line is deduced): QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
-
474 -
475 bool nativeDeco = nativeWindowDeco();
executed (the execution status of this line is deduced): bool nativeDeco = nativeWindowDeco();
-
476 -
477 int fw = q->isFloating() && !nativeDeco
evaluated: q->isFloating()
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:33
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:35
no
Evaluation Count:0
0-35
478 ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q)
executed (the execution status of this line is deduced): ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q)
-
479 : 0;
executed (the execution status of this line is deduced): : 0;
-
480 -
481 if (nativeDeco) {
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:68
0-68
482 if (QLayoutItem *item = item_list[Content])
never evaluated: QLayoutItem *item = item_list[Content]
0
483 item->setGeometry(geometry);
never executed: item->setGeometry(geometry);
0
484 } else {
never executed: }
0
485 int titleHeight = this->titleHeight();
executed (the execution status of this line is deduced): int titleHeight = this->titleHeight();
-
486 -
487 if (verticalTitleBar) {
partially evaluated: verticalTitleBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:68
0-68
488 _titleArea = QRect(QPoint(fw, fw),
never executed (the execution status of this line is deduced): _titleArea = QRect(QPoint(fw, fw),
-
489 QSize(titleHeight, geometry.height() - (fw * 2)));
never executed (the execution status of this line is deduced): QSize(titleHeight, geometry.height() - (fw * 2)));
-
490 } else {
never executed: }
0
491 _titleArea = QRect(QPoint(fw, fw),
executed (the execution status of this line is deduced): _titleArea = QRect(QPoint(fw, fw),
-
492 QSize(geometry.width() - (fw * 2), titleHeight));
executed (the execution status of this line is deduced): QSize(geometry.width() - (fw * 2), titleHeight));
-
493 }
executed: }
Execution Count:68
68
494 -
495 if (QLayoutItem *item = item_list[TitleBar]) {
evaluated: QLayoutItem *item = item_list[TitleBar]
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:64
4-64
496 item->setGeometry(_titleArea);
executed (the execution status of this line is deduced): item->setGeometry(_titleArea);
-
497 } else {
executed: }
Execution Count:4
4
498 QStyleOptionDockWidgetV2 opt;
executed (the execution status of this line is deduced): QStyleOptionDockWidgetV2 opt;
-
499 q->initStyleOption(&opt);
executed (the execution status of this line is deduced): q->initStyleOption(&opt);
-
500 -
501 if (QLayoutItem *item = item_list[CloseButton]) {
partially evaluated: QLayoutItem *item = item_list[CloseButton]
TRUEFALSE
yes
Evaluation Count:64
no
Evaluation Count:0
0-64
502 if (!item->isEmpty()) {
evaluated: !item->isEmpty()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:1
1-63
503 QRect r = q->style()
executed (the execution status of this line is deduced): QRect r = q->style()
-
504 ->subElementRect(QStyle::SE_DockWidgetCloseButton,
executed (the execution status of this line is deduced): ->subElementRect(QStyle::SE_DockWidgetCloseButton,
-
505 &opt, q);
executed (the execution status of this line is deduced): &opt, q);
-
506 if (!r.isNull())
partially evaluated: !r.isNull()
TRUEFALSE
yes
Evaluation Count:63
no
Evaluation Count:0
0-63
507 item->setGeometry(r);
executed: item->setGeometry(r);
Execution Count:63
63
508 }
executed: }
Execution Count:63
63
509 }
executed: }
Execution Count:64
64
510 -
511 if (QLayoutItem *item = item_list[FloatButton]) {
partially evaluated: QLayoutItem *item = item_list[FloatButton]
TRUEFALSE
yes
Evaluation Count:64
no
Evaluation Count:0
0-64
512 if (!item->isEmpty()) {
partially evaluated: !item->isEmpty()
TRUEFALSE
yes
Evaluation Count:64
no
Evaluation Count:0
0-64
513 QRect r = q->style()
executed (the execution status of this line is deduced): QRect r = q->style()
-
514 ->subElementRect(QStyle::SE_DockWidgetFloatButton,
executed (the execution status of this line is deduced): ->subElementRect(QStyle::SE_DockWidgetFloatButton,
-
515 &opt, q);
executed (the execution status of this line is deduced): &opt, q);
-
516 if (!r.isNull())
partially evaluated: !r.isNull()
TRUEFALSE
yes
Evaluation Count:64
no
Evaluation Count:0
0-64
517 item->setGeometry(r);
executed: item->setGeometry(r);
Execution Count:64
64
518 }
executed: }
Execution Count:64
64
519 }
executed: }
Execution Count:64
64
520 }
executed: }
Execution Count:64
64
521 -
522 if (QLayoutItem *item = item_list[Content]) {
evaluated: QLayoutItem *item = item_list[Content]
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:50
18-50
523 QRect r = geometry;
executed (the execution status of this line is deduced): QRect r = geometry;
-
524 if (verticalTitleBar) {
partially evaluated: verticalTitleBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
525 r.setLeft(_titleArea.right() + 1);
never executed (the execution status of this line is deduced): r.setLeft(_titleArea.right() + 1);
-
526 r.adjust(0, fw, -fw, -fw);
never executed (the execution status of this line is deduced): r.adjust(0, fw, -fw, -fw);
-
527 } else {
never executed: }
0
528 r.setTop(_titleArea.bottom() + 1);
executed (the execution status of this line is deduced): r.setTop(_titleArea.bottom() + 1);
-
529 r.adjust(fw, 0, -fw, -fw);
executed (the execution status of this line is deduced): r.adjust(fw, 0, -fw, -fw);
-
530 }
executed: }
Execution Count:18
18
531 item->setGeometry(r);
executed (the execution status of this line is deduced): item->setGeometry(r);
-
532 }
executed: }
Execution Count:18
18
533 }
executed: }
Execution Count:68
68
534} -
535 -
536void QDockWidgetLayout::setVerticalTitleBar(bool b) -
537{ -
538 if (b == verticalTitleBar)
partially evaluated: b == verticalTitleBar
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
539 return;
executed: return;
Execution Count:14
14
540 verticalTitleBar = b;
never executed (the execution status of this line is deduced): verticalTitleBar = b;
-
541 invalidate();
never executed (the execution status of this line is deduced): invalidate();
-
542 parentWidget()->update();
never executed (the execution status of this line is deduced): parentWidget()->update();
-
543}
never executed: }
0
544 -
545/****************************************************************************** -
546** QDockWidgetItem -
547*/ -
548 -
549QDockWidgetItem::QDockWidgetItem(QDockWidget *dockWidget) -
550 : QWidgetItem(dockWidget) -
551{ -
552}
executed: }
Execution Count:27
27
553 -
554QSize QDockWidgetItem::minimumSize() const -
555{ -
556 QSize widgetMin(0, 0);
executed (the execution status of this line is deduced): QSize widgetMin(0, 0);
-
557 if (QLayoutItem *item = dockWidgetChildItem())
evaluated: QLayoutItem *item = dockWidgetChildItem()
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:317
74-317
558 widgetMin = item->minimumSize();
executed: widgetMin = item->minimumSize();
Execution Count:74
74
559 return dockWidgetLayout()->sizeFromContent(widgetMin, false);
executed: return dockWidgetLayout()->sizeFromContent(widgetMin, false);
Execution Count:391
391
560} -
561 -
562QSize QDockWidgetItem::maximumSize() const -
563{ -
564 if (QLayoutItem *item = dockWidgetChildItem()) {
evaluated: QLayoutItem *item = dockWidgetChildItem()
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:172
53-172
565 return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false);
executed: return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false);
Execution Count:53
53
566 } else { -
567 return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
executed: return QSize(((1<<24)-1), ((1<<24)-1));
Execution Count:172
172
568 } -
569} -
570 -
571 -
572QSize QDockWidgetItem::sizeHint() const -
573{ -
574 if (QLayoutItem *item = dockWidgetChildItem()) {
evaluated: QLayoutItem *item = dockWidgetChildItem()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:48
17-48
575 return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false);
executed: return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false);
Execution Count:17
17
576 } else { -
577 return QWidgetItem::sizeHint();
executed: return QWidgetItem::sizeHint();
Execution Count:48
48
578 } -
579} -
580 -
581/****************************************************************************** -
582** QDockWidgetPrivate -
583*/ -
584 -
585void QDockWidgetPrivate::init() -
586{ -
587 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
588 -
589 QDockWidgetLayout *layout = new QDockWidgetLayout(q);
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = new QDockWidgetLayout(q);
-
590 layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
executed (the execution status of this line is deduced): layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
-
591 -
592 QAbstractButton *button = new QDockWidgetTitleButton(q);
executed (the execution status of this line is deduced): QAbstractButton *button = new QDockWidgetTitleButton(q);
-
593 button->setObjectName(QLatin1String("qt_dockwidget_floatbutton"));
executed (the execution status of this line is deduced): button->setObjectName(QLatin1String("qt_dockwidget_floatbutton"));
-
594 QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_toggleTopLevel()));
executed (the execution status of this line is deduced): QObject::connect(button, "2""clicked()", q, "1""_q_toggleTopLevel()");
-
595 layout->setWidgetForRole(QDockWidgetLayout::FloatButton, button);
executed (the execution status of this line is deduced): layout->setWidgetForRole(QDockWidgetLayout::FloatButton, button);
-
596 -
597 button = new QDockWidgetTitleButton(q);
executed (the execution status of this line is deduced): button = new QDockWidgetTitleButton(q);
-
598 button->setObjectName(QLatin1String("qt_dockwidget_closebutton"));
executed (the execution status of this line is deduced): button->setObjectName(QLatin1String("qt_dockwidget_closebutton"));
-
599 QObject::connect(button, SIGNAL(clicked()), q, SLOT(close()));
executed (the execution status of this line is deduced): QObject::connect(button, "2""clicked()", q, "1""close()");
-
600 layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button);
executed (the execution status of this line is deduced): layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button);
-
601 -
602 resizer = new QWidgetResizeHandler(q);
executed (the execution status of this line is deduced): resizer = new QWidgetResizeHandler(q);
-
603 resizer->setMovingEnabled(false);
executed (the execution status of this line is deduced): resizer->setMovingEnabled(false);
-
604 resizer->setActive(false);
executed (the execution status of this line is deduced): resizer->setActive(false);
-
605 -
606#ifndef QT_NO_ACTION -
607 toggleViewAction = new QAction(q);
executed (the execution status of this line is deduced): toggleViewAction = new QAction(q);
-
608 toggleViewAction->setCheckable(true);
executed (the execution status of this line is deduced): toggleViewAction->setCheckable(true);
-
609 fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);
executed (the execution status of this line is deduced): fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);
-
610 toggleViewAction->setText(fixedWindowTitle);
executed (the execution status of this line is deduced): toggleViewAction->setText(fixedWindowTitle);
-
611 QObject::connect(toggleViewAction, SIGNAL(triggered(bool)),
executed (the execution status of this line is deduced): QObject::connect(toggleViewAction, "2""triggered(bool)",
-
612 q, SLOT(_q_toggleView(bool)));
executed (the execution status of this line is deduced): q, "1""_q_toggleView(bool)");
-
613#endif -
614 -
615 updateButtons();
executed (the execution status of this line is deduced): updateButtons();
-
616}
executed: }
Execution Count:25
25
617 -
618/*! -
619 Initialize \a option with the values from this QDockWidget. This method -
620 is useful for subclasses when they need a QStyleOptionDockWidget, but don't want -
621 to fill in all the information themselves. -
622 -
623 \sa QStyleOption::initFrom() -
624*/ -
625void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const -
626{ -
627 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
628 -
629 if (!option)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:164
0-164
630 return;
never executed: return;
0
631 QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout());
-
632 -
633 option->initFrom(this);
executed (the execution status of this line is deduced): option->initFrom(this);
-
634 option->rect = dwlayout->titleArea();
executed (the execution status of this line is deduced): option->rect = dwlayout->titleArea();
-
635 option->title = d->fixedWindowTitle;
executed (the execution status of this line is deduced): option->title = d->fixedWindowTitle;
-
636 option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
executed (the execution status of this line is deduced): option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
-
637 option->movable = hasFeature(this, QDockWidget::DockWidgetMovable);
executed (the execution status of this line is deduced): option->movable = hasFeature(this, QDockWidget::DockWidgetMovable);
-
638 option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable);
executed (the execution status of this line is deduced): option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable);
-
639 -
640 QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout());
-
641 QStyleOptionDockWidgetV2 *v2
executed (the execution status of this line is deduced): QStyleOptionDockWidgetV2 *v2
-
642 = qstyleoption_cast<QStyleOptionDockWidgetV2*>(option);
executed (the execution status of this line is deduced): = qstyleoption_cast<QStyleOptionDockWidgetV2*>(option);
-
643 if (v2 != 0)
partially evaluated: v2 != 0
TRUEFALSE
yes
Evaluation Count:164
no
Evaluation Count:0
0-164
644 v2->verticalTitleBar = l->verticalTitleBar;
executed: v2->verticalTitleBar = l->verticalTitleBar;
Execution Count:164
164
645}
executed: }
Execution Count:164
164
646 -
647void QDockWidgetPrivate::_q_toggleView(bool b) -
648{ -
649 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
650 if (b == q->isHidden()) {
partially evaluated: b == q->isHidden()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
651 if (b)
evaluated: b
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
652 q->show();
executed: q->show();
Execution Count:1
1
653 else -
654 q->close();
executed: q->close();
Execution Count:2
2
655 } -
656}
executed: }
Execution Count:3
3
657 -
658void QDockWidgetPrivate::updateButtons() -
659{ -
660 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
661 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
executed (the execution status of this line is deduced): QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
-
662 -
663 QStyleOptionDockWidget opt;
executed (the execution status of this line is deduced): QStyleOptionDockWidget opt;
-
664 q->initStyleOption(&opt);
executed (the execution status of this line is deduced): q->initStyleOption(&opt);
-
665 -
666 bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
executed (the execution status of this line is deduced): bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
-
667 bool nativeDeco = dwLayout->nativeWindowDeco();
executed (the execution status of this line is deduced): bool nativeDeco = dwLayout->nativeWindowDeco();
-
668 bool hideButtons = nativeDeco || customTitleBar;
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:78
evaluated: customTitleBar
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:74
0-78
669 -
670 bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable);
executed (the execution status of this line is deduced): bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable);
-
671 bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable);
executed (the execution status of this line is deduced): bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable);
-
672 -
673 QAbstractButton *button
executed (the execution status of this line is deduced): QAbstractButton *button
-
674 = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton));
executed (the execution status of this line is deduced): = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton));
-
675 button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q));
executed (the execution status of this line is deduced): button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q));
-
676 button->setVisible(canFloat && !hideButtons);
executed (the execution status of this line is deduced): button->setVisible(canFloat && !hideButtons);
-
677 -
678 button
executed (the execution status of this line is deduced): button
-
679 = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton));
executed (the execution status of this line is deduced): = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton));
-
680 button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q));
executed (the execution status of this line is deduced): button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q));
-
681 button->setVisible(canClose && !hideButtons);
executed (the execution status of this line is deduced): button->setVisible(canClose && !hideButtons);
-
682 -
683 q->setAttribute(Qt::WA_ContentsPropagated,
executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_ContentsPropagated,
-
684 (canFloat || canClose) && !hideButtons);
executed (the execution status of this line is deduced): (canFloat || canClose) && !hideButtons);
-
685 -
686 layout->invalidate();
executed (the execution status of this line is deduced): layout->invalidate();
-
687}
executed: }
Execution Count:78
78
688 -
689void QDockWidgetPrivate::_q_toggleTopLevel() -
690{ -
691 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
692 q->setFloating(!q->isFloating());
executed (the execution status of this line is deduced): q->setFloating(!q->isFloating());
-
693}
executed: }
Execution Count:2
2
694 -
695void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) -
696{ -
697 if (state != 0)
never evaluated: state != 0
0
698 return;
never executed: return;
0
699 -
700 QMainWindow *win = qobject_cast<QMainWindow*>(parent);
never executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parent);
-
701 Q_ASSERT(win != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
702 QMainWindowLayout *layout = qt_mainwindow_layout(win);
never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(win);
-
703 Q_ASSERT(layout != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
704 if (layout->pluggingWidget != 0) // the main window is animating a docking operation
never evaluated: layout->pluggingWidget != 0
0
705 return;
never executed: return;
0
706 -
707 state = new QDockWidgetPrivate::DragState;
never executed (the execution status of this line is deduced): state = new QDockWidgetPrivate::DragState;
-
708 state->pressPos = pos;
never executed (the execution status of this line is deduced): state->pressPos = pos;
-
709 state->dragging = false;
never executed (the execution status of this line is deduced): state->dragging = false;
-
710 state->widgetItem = 0;
never executed (the execution status of this line is deduced): state->widgetItem = 0;
-
711 state->ownWidgetItem = false;
never executed (the execution status of this line is deduced): state->ownWidgetItem = false;
-
712 state->nca = nca;
never executed (the execution status of this line is deduced): state->nca = nca;
-
713 state->ctrlDrag = false;
never executed (the execution status of this line is deduced): state->ctrlDrag = false;
-
714}
never executed: }
0
715 -
716void QDockWidgetPrivate::startDrag() -
717{ -
718 Q_Q(QDockWidget);
never executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
719 -
720 if (state == 0 || state->dragging)
never evaluated: state == 0
never evaluated: state->dragging
0
721 return;
never executed: return;
0
722 -
723 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
-
724 Q_ASSERT(layout != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
725 -
726 state->widgetItem = layout->unplug(q);
never executed (the execution status of this line is deduced): state->widgetItem = layout->unplug(q);
-
727 if (state->widgetItem == 0) {
never evaluated: state->widgetItem == 0
0
728 /* I have a QMainWindow parent, but I was never inserted with -
729 QMainWindow::addDockWidget, so the QMainWindowLayout has no -
730 widget item for me. :( I have to create it myself, and then -
731 delete it if I don't get dropped into a dock area. */ -
732 state->widgetItem = new QDockWidgetItem(q);
never executed (the execution status of this line is deduced): state->widgetItem = new QDockWidgetItem(q);
-
733 state->ownWidgetItem = true;
never executed (the execution status of this line is deduced): state->ownWidgetItem = true;
-
734 }
never executed: }
0
735 -
736 if (state->ctrlDrag)
never evaluated: state->ctrlDrag
0
737 layout->restore();
never executed: layout->restore();
0
738 -
739 state->dragging = true;
never executed (the execution status of this line is deduced): state->dragging = true;
-
740}
never executed: }
0
741 -
742void QDockWidgetPrivate::endDrag(bool abort) -
743{ -
744 Q_Q(QDockWidget);
never executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
745 Q_ASSERT(state != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
746 -
747 q->releaseMouse();
never executed (the execution status of this line is deduced): q->releaseMouse();
-
748 -
749 if (state->dragging) {
never evaluated: state->dragging
0
750 QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
never executed (the execution status of this line is deduced): QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
-
751 Q_ASSERT(mwLayout != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
752 -
753 if (abort || !mwLayout->plug(state->widgetItem)) {
never evaluated: abort
never evaluated: !mwLayout->plug(state->widgetItem)
0
754 if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
never evaluated: hasFeature(this, QDockWidget::DockWidgetFloatable)
0
755 if (state->ownWidgetItem)
never evaluated: state->ownWidgetItem
0
756 delete state->widgetItem;
never executed: delete state->widgetItem;
0
757 mwLayout->restore();
never executed (the execution status of this line is deduced): mwLayout->restore();
-
758 if (isXcb()) {
never evaluated: isXcb()
0
759 // get rid of the X11BypassWindowManager window flag and activate the resizer -
760 Qt::WindowFlags flags = q->windowFlags();
never executed (the execution status of this line is deduced): Qt::WindowFlags flags = q->windowFlags();
-
761 flags &= ~Qt::X11BypassWindowManagerHint;
never executed (the execution status of this line is deduced): flags &= ~Qt::X11BypassWindowManagerHint;
-
762 q->setWindowFlags(flags);
never executed (the execution status of this line is deduced): q->setWindowFlags(flags);
-
763 resizer->setActive(QWidgetResizeHandler::Resize, true);
never executed (the execution status of this line is deduced): resizer->setActive(QWidgetResizeHandler::Resize, true);
-
764 q->show();
never executed (the execution status of this line is deduced): q->show();
-
765 } else {
never executed: }
0
766 QDockWidgetLayout *myLayout
never executed (the execution status of this line is deduced): QDockWidgetLayout *myLayout
-
767 = qobject_cast<QDockWidgetLayout*>(layout);
never executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(layout);
-
768 resizer->setActive(QWidgetResizeHandler::Resize,
never executed (the execution status of this line is deduced): resizer->setActive(QWidgetResizeHandler::Resize,
-
769 myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0);
never executed (the execution status of this line is deduced): myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0);
-
770 }
never executed: }
0
771 undockedGeometry = q->geometry();
never executed (the execution status of this line is deduced): undockedGeometry = q->geometry();
-
772 q->activateWindow();
never executed (the execution status of this line is deduced): q->activateWindow();
-
773 } else {
never executed: }
0
774 mwLayout->revert(state->widgetItem);
never executed (the execution status of this line is deduced): mwLayout->revert(state->widgetItem);
-
775 }
never executed: }
0
776 } -
777 }
never executed: }
0
778 delete state;
never executed (the execution status of this line is deduced): delete state;
-
779 state = 0;
never executed (the execution status of this line is deduced): state = 0;
-
780}
never executed: }
0
781 -
782bool QDockWidgetPrivate::isAnimating() const -
783{ -
784 Q_Q(const QDockWidget);
never executed (the execution status of this line is deduced): const QDockWidget * const q = q_func();
-
785 -
786 QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent);
never executed (the execution status of this line is deduced): QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent);
-
787 if (mainWin == 0)
never evaluated: mainWin == 0
0
788 return false;
never executed: return false;
0
789 -
790 QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
never executed (the execution status of this line is deduced): QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
-
791 if (mainWinLayout == 0)
never evaluated: mainWinLayout == 0
0
792 return false;
never executed: return false;
0
793 -
794 return (void*)mainWinLayout->pluggingWidget == (void*)q;
never executed: return (void*)mainWinLayout->pluggingWidget == (void*)q;
0
795} -
796 -
797bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) -
798{ -
799#if !defined(QT_NO_MAINWINDOW) -
800 Q_Q(QDockWidget);
never executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
801 -
802 QDockWidgetLayout *dwLayout
never executed (the execution status of this line is deduced): QDockWidgetLayout *dwLayout
-
803 = qobject_cast<QDockWidgetLayout*>(layout);
never executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(layout);
-
804 -
805 if (!dwLayout->nativeWindowDeco()) {
never evaluated: !dwLayout->nativeWindowDeco()
0
806 QRect titleArea = dwLayout->titleArea();
never executed (the execution status of this line is deduced): QRect titleArea = dwLayout->titleArea();
-
807 -
808 if (event->button() != Qt::LeftButton ||
never evaluated: event->button() != Qt::LeftButton
0
809 !titleArea.contains(event->pos()) ||
never evaluated: !titleArea.contains(event->pos())
0
810 // check if the tool window is movable... do nothing if it
never executed (the execution status of this line is deduced):
-
811 // is not (but allow moving if the window is floating)
never executed (the execution status of this line is deduced):
-
812 (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
never evaluated: !hasFeature(this, QDockWidget::DockWidgetMovable)
never evaluated: !q->isFloating()
0
813 qobject_cast<QMainWindow*>(parent) == 0 ||
never evaluated: qobject_cast<QMainWindow*>(parent) == 0
0
814 isAnimating() || state != 0) {
never evaluated: isAnimating()
never evaluated: state != 0
0
815 return false;
never executed: return false;
0
816 } -
817 -
818 initDrag(event->pos(), false);
never executed (the execution status of this line is deduced): initDrag(event->pos(), false);
-
819 -
820 if (state)
never evaluated: state
0
821 state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
never executed: state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
never evaluated: hasFeature(this, QDockWidget::DockWidgetFloatable)
never evaluated: event->modifiers() & Qt::ControlModifier
0
822 -
823 return true;
never executed: return true;
0
824 } -
825 -
826#endif // !defined(QT_NO_MAINWINDOW) -
827 return false;
never executed: return false;
0
828} -
829 -
830bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event) -
831{ -
832 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
never executed (the execution status of this line is deduced): QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
-
833 -
834 if (!dwLayout->nativeWindowDeco()) {
never evaluated: !dwLayout->nativeWindowDeco()
0
835 QRect titleArea = dwLayout->titleArea();
never executed (the execution status of this line is deduced): QRect titleArea = dwLayout->titleArea();
-
836 -
837 if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
never evaluated: event->button() == Qt::LeftButton
never evaluated: titleArea.contains(event->pos())
0
838 hasFeature(this, QDockWidget::DockWidgetFloatable)) {
never evaluated: hasFeature(this, QDockWidget::DockWidgetFloatable)
0
839 _q_toggleTopLevel();
never executed (the execution status of this line is deduced): _q_toggleTopLevel();
-
840 return true;
never executed: return true;
0
841 } -
842 }
never executed: }
0
843 return false;
never executed: return false;
0
844} -
845 -
846bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) -
847{ -
848 bool ret = false;
never executed (the execution status of this line is deduced): bool ret = false;
-
849#if !defined(QT_NO_MAINWINDOW) -
850 Q_Q(QDockWidget);
never executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
851 -
852 if (!state)
never evaluated: !state
0
853 return ret;
never executed: return ret;
0
854 -
855 QDockWidgetLayout *dwlayout
never executed (the execution status of this line is deduced): QDockWidgetLayout *dwlayout
-
856 = qobject_cast<QDockWidgetLayout *>(layout);
never executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout *>(layout);
-
857 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
never executed (the execution status of this line is deduced): QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
-
858 if (!dwlayout->nativeWindowDeco()) {
never evaluated: !dwlayout->nativeWindowDeco()
0
859 if (!state->dragging
never evaluated: !state->dragging
0
860 && mwlayout->pluggingWidget == 0
never evaluated: mwlayout->pluggingWidget == 0
0
861 && (event->pos() - state->pressPos).manhattanLength()
never evaluated: (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()
0
862 > QApplication::startDragDistance()) {
never evaluated: (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()
0
863 startDrag();
never executed (the execution status of this line is deduced): startDrag();
-
864#ifdef Q_WS_WIN -
865 grabMouseWhileInWindow(); -
866#else -
867 q->grabMouse();
never executed (the execution status of this line is deduced): q->grabMouse();
-
868#endif -
869 ret = true;
never executed (the execution status of this line is deduced): ret = true;
-
870 }
never executed: }
0
871 }
never executed: }
0
872 -
873 if (state->dragging && !state->nca) {
never evaluated: state->dragging
never evaluated: !state->nca
0
874 QPoint pos = event->globalPos() - state->pressPos;
never executed (the execution status of this line is deduced): QPoint pos = event->globalPos() - state->pressPos;
-
875 q->move(pos);
never executed (the execution status of this line is deduced): q->move(pos);
-
876 -
877 if (!state->ctrlDrag)
never evaluated: !state->ctrlDrag
0
878 mwlayout->hover(state->widgetItem, event->globalPos());
never executed: mwlayout->hover(state->widgetItem, event->globalPos());
0
879 -
880 ret = true;
never executed (the execution status of this line is deduced): ret = true;
-
881 }
never executed: }
0
882 -
883#endif // !defined(QT_NO_MAINWINDOW) -
884 return ret;
never executed: return ret;
0
885} -
886 -
887bool QDockWidgetPrivate::mouseReleaseEvent(QMouseEvent *event) -
888{ -
889#if !defined(QT_NO_MAINWINDOW) -
890 -
891 if (event->button() == Qt::LeftButton && state && !state->nca) {
never evaluated: event->button() == Qt::LeftButton
never evaluated: state
never evaluated: !state->nca
0
892 endDrag();
never executed (the execution status of this line is deduced): endDrag();
-
893 return true; //filter out the event
never executed: return true;
0
894 } -
895 -
896#endif // !defined(QT_NO_MAINWINDOW) -
897 return false;
never executed: return false;
0
898} -
899 -
900void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) -
901{ -
902 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
903 -
904 int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
executed (the execution status of this line is deduced): int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
-
905 -
906 QRect geo = q->geometry();
executed (the execution status of this line is deduced): QRect geo = q->geometry();
-
907 QRect titleRect = q->frameGeometry();
executed (the execution status of this line is deduced): QRect titleRect = q->frameGeometry();
-
908#ifdef Q_WS_MAC -
909 if ((features & QDockWidget::DockWidgetVerticalTitleBar)) { -
910 titleRect.setTop(geo.top()); -
911 titleRect.setBottom(geo.bottom()); -
912 titleRect.setRight(geo.left() - 1); -
913 } else -
914#endif -
915 { -
916 titleRect.setLeft(geo.left());
executed (the execution status of this line is deduced): titleRect.setLeft(geo.left());
-
917 titleRect.setRight(geo.right());
executed (the execution status of this line is deduced): titleRect.setRight(geo.right());
-
918 titleRect.setBottom(geo.top() - 1);
executed (the execution status of this line is deduced): titleRect.setBottom(geo.top() - 1);
-
919 titleRect.adjust(0, fw, 0, 0);
executed (the execution status of this line is deduced): titleRect.adjust(0, fw, 0, 0);
-
920 } -
921 -
922 switch (event->type()) { -
923 case QEvent::NonClientAreaMouseButtonPress: -
924 if (!titleRect.contains(event->globalPos()))
never evaluated: !titleRect.contains(event->globalPos())
0
925 break;
never executed: break;
0
926 if (state != 0)
never evaluated: state != 0
0
927 break;
never executed: break;
0
928 if (qobject_cast<QMainWindow*>(parent) == 0)
never evaluated: qobject_cast<QMainWindow*>(parent) == 0
0
929 break;
never executed: break;
0
930 if (isAnimating())
never evaluated: isAnimating()
0
931 break;
never executed: break;
0
932 initDrag(event->pos(), true);
never executed (the execution status of this line is deduced): initDrag(event->pos(), true);
-
933 if (state == 0)
never evaluated: state == 0
0
934 break;
never executed: break;
0
935#ifdef Q_WS_WIN -
936 // On Windows, NCA mouse events don't contain modifier info -
937 state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000; -
938#else -
939 state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
never executed (the execution status of this line is deduced): state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
-
940#endif -
941 startDrag();
never executed (the execution status of this line is deduced): startDrag();
-
942 break;
never executed: break;
0
943 case QEvent::NonClientAreaMouseMove: -
944 if (state == 0 || !state->dragging)
never evaluated: state == 0
never evaluated: !state->dragging
0
945 break;
never executed: break;
0
946 -
947#ifndef Q_OS_MAC -
948 if (state->nca) {
never evaluated: state->nca
0
949 endDrag();
never executed (the execution status of this line is deduced): endDrag();
-
950 }
never executed: }
0
951#endif -
952 break;
never executed: break;
0
953 case QEvent::NonClientAreaMouseButtonRelease: -
954#ifdef Q_OS_MAC -
955 if (state) -
956 endDrag(); -
957#endif -
958 break;
never executed: break;
0
959 case QEvent::NonClientAreaMouseButtonDblClick: -
960 _q_toggleTopLevel();
executed (the execution status of this line is deduced): _q_toggleTopLevel();
-
961 break;
executed: break;
Execution Count:2
2
962 default: -
963 break;
never executed: break;
0
964 } -
965}
executed: }
Execution Count:2
2
966 -
967void QDockWidgetPrivate::moveEvent(QMoveEvent *event) -
968{ -
969 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
970 -
971 if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
partially evaluated: state == 0
TRUEFALSE
yes
Evaluation Count:35
no
Evaluation Count:0
never evaluated: !state->dragging
never evaluated: !state->nca
never evaluated: !q->isWindow()
0-35
972 return;
executed: return;
Execution Count:35
35
973 -
974 // When the native window frame is being dragged, all we get is these mouse -
975 // move events. -
976 -
977 if (state->ctrlDrag)
never evaluated: state->ctrlDrag
0
978 return;
never executed: return;
0
979 -
980 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
never executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
-
981 Q_ASSERT(layout != 0);
never executed (the execution status of this line is deduced): qt_noop();
-
982 -
983 QPoint globalMousePos = event->pos() + state->pressPos;
never executed (the execution status of this line is deduced): QPoint globalMousePos = event->pos() + state->pressPos;
-
984 layout->hover(state->widgetItem, globalMousePos);
never executed (the execution status of this line is deduced): layout->hover(state->widgetItem, globalMousePos);
-
985}
never executed: }
0
986 -
987void QDockWidgetPrivate::unplug(const QRect &rect) -
988{ -
989 Q_Q(QDockWidget);
never executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
990 QRect r = rect;
never executed (the execution status of this line is deduced): QRect r = rect;
-
991 r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
never executed (the execution status of this line is deduced): r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
-
992 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
never executed (the execution status of this line is deduced): QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
-
993 if (dwLayout->nativeWindowDeco(true))
never evaluated: dwLayout->nativeWindowDeco(true)
0
994 r.adjust(0, dwLayout->titleHeight(), 0, 0);
never executed: r.adjust(0, dwLayout->titleHeight(), 0, 0);
0
995 setWindowState(true, true, r);
never executed (the execution status of this line is deduced): setWindowState(true, true, r);
-
996}
never executed: }
0
997 -
998void QDockWidgetPrivate::plug(const QRect &rect) -
999{ -
1000 setWindowState(false, false, rect);
never executed (the execution status of this line is deduced): setWindowState(false, false, rect);
-
1001}
never executed: }
0
1002 -
1003void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) -
1004{ -
1005 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
1006 -
1007 if (!floating && parent) {
evaluated: !floating
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:12
evaluated: parent
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-12
1008 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
executed (the execution status of this line is deduced): QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
-
1009 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
1010 return; // this dockwidget can't be redocked
executed: return;
Execution Count:1
1
1011 }
executed: }
Execution Count:8
8
1012 -
1013 bool wasFloating = q->isFloating();
executed (the execution status of this line is deduced): bool wasFloating = q->isFloating();
-
1014 bool hidden = q->isHidden();
executed (the execution status of this line is deduced): bool hidden = q->isHidden();
-
1015 -
1016 if (q->isVisible())
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:8
8-13
1017 q->hide();
executed: q->hide();
Execution Count:13
13
1018 -
1019 Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
evaluated: floating
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:9
9-12
1020 -
1021 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
executed (the execution status of this line is deduced): QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
-
1022 const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
executed (the execution status of this line is deduced): const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
-
1023 -
1024 if (nativeDeco) {
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
1025 flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
never executed (the execution status of this line is deduced): flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
-
1026 if (hasFeature(this, QDockWidget::DockWidgetClosable))
never evaluated: hasFeature(this, QDockWidget::DockWidgetClosable)
0
1027 flags |= Qt::WindowCloseButtonHint;
never executed: flags |= Qt::WindowCloseButtonHint;
0
1028 } else {
never executed: }
0
1029 flags |= Qt::FramelessWindowHint;
executed (the execution status of this line is deduced): flags |= Qt::FramelessWindowHint;
-
1030 }
executed: }
Execution Count:21
21
1031 -
1032 if (unplug)
evaluated: unplug
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:18
3-18
1033 flags |= Qt::X11BypassWindowManagerHint;
executed: flags |= Qt::X11BypassWindowManagerHint;
Execution Count:3
3
1034 -
1035 q->setWindowFlags(flags);
executed (the execution status of this line is deduced): q->setWindowFlags(flags);
-
1036 -
1037 -
1038 if (!rect.isNull())
evaluated: !rect.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20
1-20
1039 q->setGeometry(rect);
executed: q->setGeometry(rect);
Execution Count:1
1
1040 -
1041 updateButtons();
executed (the execution status of this line is deduced): updateButtons();
-
1042 -
1043 if (!hidden)
evaluated: !hidden
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:5
5-16
1044 q->show();
executed: q->show();
Execution Count:16
16
1045 -
1046 if (floating != wasFloating) {
evaluated: floating != wasFloating
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:8
8-13
1047 emit q->topLevelChanged(floating);
executed (the execution status of this line is deduced): q->topLevelChanged(floating);
-
1048 if (!floating && parent) {
evaluated: !floating
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:7
evaluated: parent
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-7
1049 QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
executed (the execution status of this line is deduced): QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
-
1050 if (mwlayout)
partially evaluated: mwlayout
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1051 emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
executed: q->dockLocationChanged(mwlayout->dockWidgetArea(q));
Execution Count:5
5
1052 }
executed: }
Execution Count:5
5
1053 }
executed: }
Execution Count:13
13
1054 -
1055 if (floating && nativeDeco)
evaluated: floating
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:9
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1056 if (const QWindow *window = q->windowHandle())
never evaluated: const QWindow *window = q->windowHandle()
0
1057 if (QPlatformWindow *platformWindow = window->handle())
never evaluated: QPlatformWindow *platformWindow = window->handle()
0
1058 platformWindow->setFrameStrutEventsEnabled(true);
never executed: platformWindow->setFrameStrutEventsEnabled(true);
0
1059 -
1060 resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
executed (the execution status of this line is deduced): resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
-
1061}
executed: }
Execution Count:21
21
1062 -
1063/*! -
1064 \class QDockWidget -
1065 -
1066 \brief The QDockWidget class provides a widget that can be docked -
1067 inside a QMainWindow or floated as a top-level window on the -
1068 desktop. -
1069 -
1070 \ingroup mainwindow-classes -
1071 \inmodule QtWidgets -
1072 -
1073 QDockWidget provides the concept of dock widgets, also know as -
1074 tool palettes or utility windows. Dock windows are secondary -
1075 windows placed in the \e {dock widget area} around the -
1076 \l{QMainWindow::centralWidget()}{central widget} in a -
1077 QMainWindow. -
1078 -
1079 \image mainwindow-docks.png -
1080 -
1081 Dock windows can be moved inside their current area, moved into -
1082 new areas and floated (e.g., undocked) by the end-user. The -
1083 QDockWidget API allows the programmer to restrict the dock widgets -
1084 ability to move, float and close, as well as the areas in which -
1085 they can be placed. -
1086 -
1087 \section1 Appearance -
1088 -
1089 A QDockWidget consists of a title bar and the content area. The -
1090 title bar displays the dock widgets -
1091 \l{QWidget::windowTitle()}{window title}, -
1092 a \e float button and a \e close button. -
1093 Depending on the state of the QDockWidget, the \e float and \e -
1094 close buttons may be either disabled or not shown at all. -
1095 -
1096 The visual appearance of the title bar and buttons is dependent -
1097 on the \l{QStyle}{style} in use. -
1098 -
1099 A QDockWidget acts as a wrapper for its child widget, set with setWidget(). -
1100 Custom size hints, minimum and maximum sizes and size policies should be -
1101 implemented in the child widget. QDockWidget will respect them, adjusting -
1102 its own constraints to include the frame and title. Size constraints -
1103 should not be set on the QDockWidget itself, because they change depending -
1104 on whether it is docked; a docked QDockWidget has no frame and a smaller title -
1105 bar. -
1106 -
1107 \sa QMainWindow, {Dock Widgets Example} -
1108*/ -
1109 -
1110/*! -
1111 \enum QDockWidget::DockWidgetFeature -
1112 -
1113 \value DockWidgetClosable The dock widget can be closed. On some systems the dock -
1114 widget always has a close button when it's floating -
1115 (for example on MacOS 10.5). -
1116 \value DockWidgetMovable The dock widget can be moved between docks -
1117 by the user. -
1118 \value DockWidgetFloatable The dock widget can be detached from the -
1119 main window, and floated as an independent -
1120 window. -
1121 \value DockWidgetVerticalTitleBar The dock widget displays a vertical title -
1122 bar on its left side. This can be used to -
1123 increase the amount of vertical space in -
1124 a QMainWindow. -
1125 \value AllDockWidgetFeatures (Deprecated) The dock widget can be closed, moved, -
1126 and floated. Since new features might be added in future -
1127 releases, the look and behavior of dock widgets might -
1128 change if you use this flag. Please specify individual -
1129 flags instead. -
1130 \value NoDockWidgetFeatures The dock widget cannot be closed, moved, -
1131 or floated. -
1132 -
1133 \omitvalue DockWidgetFeatureMask -
1134 \omitvalue Reserved -
1135*/ -
1136 -
1137/*! -
1138 \property QDockWidget::windowTitle -
1139 \brief the dock widget title (caption) -
1140 -
1141 By default, this property contains an empty string. -
1142*/ -
1143 -
1144/*! -
1145 Constructs a QDockWidget with parent \a parent and window flags \a -
1146 flags. The dock widget will be placed in the left dock widget -
1147 area. -
1148*/ -
1149QDockWidget::QDockWidget(QWidget *parent, Qt::WindowFlags flags) -
1150 : QWidget(*new QDockWidgetPrivate, parent, flags) -
1151{ -
1152 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1153 d->init();
executed (the execution status of this line is deduced): d->init();
-
1154}
executed: }
Execution Count:23
23
1155 -
1156/*! -
1157 Constructs a QDockWidget with parent \a parent and window flags \a -
1158 flags. The dock widget will be placed in the left dock widget -
1159 area. -
1160 -
1161 The window title is set to \a title. This title is used when the -
1162 QDockWidget is docked and undocked. It is also used in the context -
1163 menu provided by QMainWindow. -
1164 -
1165 \sa setWindowTitle() -
1166*/ -
1167QDockWidget::QDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) -
1168 : QWidget(*new QDockWidgetPrivate, parent, flags) -
1169{ -
1170 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1171 d->init();
executed (the execution status of this line is deduced): d->init();
-
1172 setWindowTitle(title);
executed (the execution status of this line is deduced): setWindowTitle(title);
-
1173}
executed: }
Execution Count:2
2
1174 -
1175/*! -
1176 Destroys the dock widget. -
1177*/ -
1178QDockWidget::~QDockWidget() -
1179{ } -
1180 -
1181/*! -
1182 Returns the widget for the dock widget. This function returns zero -
1183 if the widget has not been set. -
1184 -
1185 \sa setWidget() -
1186*/ -
1187QWidget *QDockWidget::widget() const -
1188{ -
1189 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1190 return layout->widgetForRole(QDockWidgetLayout::Content);
executed: return layout->widgetForRole(QDockWidgetLayout::Content);
Execution Count:32
32
1191} -
1192 -
1193/*! -
1194 Sets the widget for the dock widget to \a widget. -
1195 -
1196 If the dock widget is visible when \a widget is added, you must -
1197 \l{QWidget::}{show()} it explicitly. -
1198 -
1199 Note that you must add the layout of the \a widget before you call -
1200 this function; if not, the \a widget will not be visible. -
1201 -
1202 \sa widget() -
1203*/ -
1204void QDockWidget::setWidget(QWidget *widget) -
1205{ -
1206 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1207 layout->setWidgetForRole(QDockWidgetLayout::Content, widget);
executed (the execution status of this line is deduced): layout->setWidgetForRole(QDockWidgetLayout::Content, widget);
-
1208}
executed: }
Execution Count:17
17
1209 -
1210/*! -
1211 \property QDockWidget::features -
1212 \brief whether the dock widget is movable, closable, and floatable -
1213 -
1214 By default, this property is set to a combination of DockWidgetClosable, -
1215 DockWidgetMovable and DockWidgetFloatable. -
1216 -
1217 \sa DockWidgetFeature -
1218*/ -
1219 -
1220void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) -
1221{ -
1222 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1223 features &= DockWidgetFeatureMask;
executed (the execution status of this line is deduced): features &= DockWidgetFeatureMask;
-
1224 if (d->features == features)
evaluated: d->features == features
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:14
9-14
1225 return;
executed: return;
Execution Count:9
9
1226 const bool closableChanged = (d->features ^ features) & DockWidgetClosable;
executed (the execution status of this line is deduced): const bool closableChanged = (d->features ^ features) & DockWidgetClosable;
-
1227 d->features = features;
executed (the execution status of this line is deduced): d->features = features;
-
1228 QDockWidgetLayout *layout
executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1229 = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1230 layout->setVerticalTitleBar(features & DockWidgetVerticalTitleBar);
executed (the execution status of this line is deduced): layout->setVerticalTitleBar(features & DockWidgetVerticalTitleBar);
-
1231 d->updateButtons();
executed (the execution status of this line is deduced): d->updateButtons();
-
1232 d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable);
executed (the execution status of this line is deduced): d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable);
-
1233 emit featuresChanged(d->features);
executed (the execution status of this line is deduced): featuresChanged(d->features);
-
1234 update();
executed (the execution status of this line is deduced): update();
-
1235 if (closableChanged && layout->nativeWindowDeco()) {
evaluated: closableChanged
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
partially evaluated: layout->nativeWindowDeco()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-9
1236 //this ensures the native decoration is drawn -
1237 d->setWindowState(true /*floating*/, true /*unplug*/);
never executed (the execution status of this line is deduced): d->setWindowState(true , true );
-
1238 }
never executed: }
0
1239}
executed: }
Execution Count:14
14
1240 -
1241QDockWidget::DockWidgetFeatures QDockWidget::features() const -
1242{ -
1243 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
1244 return d->features;
executed: return d->features;
Execution Count:1775
1775
1245} -
1246 -
1247/*! -
1248 \property QDockWidget::floating -
1249 \brief whether the dock widget is floating -
1250 -
1251 A floating dock widget is presented to the user as an independent -
1252 window "on top" of its parent QMainWindow, instead of being -
1253 docked in the QMainWindow. -
1254 -
1255 By default, this property is true. -
1256 -
1257 \sa isWindow() -
1258*/ -
1259void QDockWidget::setFloating(bool floating) -
1260{ -
1261 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1262 -
1263 // the initial click of a double-click may have started a drag... -
1264 if (d->state != 0)
partially evaluated: d->state != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
1265 d->endDrag(true);
never executed: d->endDrag(true);
0
1266 -
1267 QRect r = d->undockedGeometry;
executed (the execution status of this line is deduced): QRect r = d->undockedGeometry;
-
1268 -
1269 d->setWindowState(floating, false, floating ? r : QRect());
executed (the execution status of this line is deduced): d->setWindowState(floating, false, floating ? r : QRect());
-
1270 -
1271 if (floating && r.isNull()) {
evaluated: floating
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:10
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
1-10
1272 if (x() < 0 || y() < 0) //may happen if we have been hidden
evaluated: x() < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
partially evaluated: y() < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1273 move(QPoint());
executed: move(QPoint());
Execution Count:1
1
1274 setAttribute(Qt::WA_Moved, false); //we want it at the default position
executed (the execution status of this line is deduced): setAttribute(Qt::WA_Moved, false);
-
1275 }
executed: }
Execution Count:8
8
1276}
executed: }
Execution Count:19
19
1277 -
1278/*! -
1279 \property QDockWidget::allowedAreas -
1280 \brief areas where the dock widget may be placed -
1281 -
1282 The default is Qt::AllDockWidgetAreas. -
1283 -
1284 \sa Qt::DockWidgetArea -
1285*/ -
1286 -
1287void QDockWidget::setAllowedAreas(Qt::DockWidgetAreas areas) -
1288{ -
1289 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1290 areas &= Qt::DockWidgetArea_Mask;
executed (the execution status of this line is deduced): areas &= Qt::DockWidgetArea_Mask;
-
1291 if (areas == d->allowedAreas)
evaluated: areas == d->allowedAreas
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:9
8-9
1292 return;
executed: return;
Execution Count:8
8
1293 d->allowedAreas = areas;
executed (the execution status of this line is deduced): d->allowedAreas = areas;
-
1294 emit allowedAreasChanged(d->allowedAreas);
executed (the execution status of this line is deduced): allowedAreasChanged(d->allowedAreas);
-
1295}
executed: }
Execution Count:9
9
1296 -
1297Qt::DockWidgetAreas QDockWidget::allowedAreas() const -
1298{ -
1299 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
1300 return d->allowedAreas;
executed: return d->allowedAreas;
Execution Count:61
61
1301} -
1302 -
1303/*! -
1304 \fn bool QDockWidget::isAreaAllowed(Qt::DockWidgetArea area) const -
1305 -
1306 Returns true if this dock widget can be placed in the given \a area; -
1307 otherwise returns false. -
1308*/ -
1309 -
1310/*! \reimp */ -
1311void QDockWidget::changeEvent(QEvent *event) -
1312{ -
1313 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1314 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1315 -
1316 switch (event->type()) { -
1317 case QEvent::ModifiedChange: -
1318 case QEvent::WindowTitleChange: -
1319 update(layout->titleArea());
executed (the execution status of this line is deduced): update(layout->titleArea());
-
1320#ifndef QT_NO_ACTION -
1321 d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this);
executed (the execution status of this line is deduced): d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this);
-
1322 d->toggleViewAction->setText(d->fixedWindowTitle);
executed (the execution status of this line is deduced): d->toggleViewAction->setText(d->fixedWindowTitle);
-
1323#endif -
1324#ifndef QT_NO_TABBAR -
1325 { -
1326 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
-
1327 if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
evaluated: QMainWindowLayout *winLayout = qt_mainwindow_layout(win)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1328 if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
partially evaluated: QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1329 info->updateTabBar();
never executed: info->updateTabBar();
0
1330 }
executed: }
Execution Count:1
1
1331 } -
1332#endif // QT_NO_TABBAR -
1333 break;
executed: break;
Execution Count:2
2
1334 default: -
1335 break;
executed: break;
Execution Count:49
49
1336 } -
1337 QWidget::changeEvent(event);
executed (the execution status of this line is deduced): QWidget::changeEvent(event);
-
1338}
executed: }
Execution Count:51
51
1339 -
1340/*! \reimp */ -
1341void QDockWidget::closeEvent(QCloseEvent *event) -
1342{ -
1343 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1344 if (d->state)
partially evaluated: d->state
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1345 d->endDrag(true);
never executed: d->endDrag(true);
0
1346 QWidget::closeEvent(event);
executed (the execution status of this line is deduced): QWidget::closeEvent(event);
-
1347}
executed: }
Execution Count:2
2
1348 -
1349/*! \reimp */ -
1350void QDockWidget::paintEvent(QPaintEvent *event) -
1351{ -
1352 Q_UNUSED(event)
executed (the execution status of this line is deduced): (void)event;
-
1353 -
1354 QDockWidgetLayout *layout
executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1355 = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1356 bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
executed (the execution status of this line is deduced): bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
-
1357 bool nativeDeco = layout->nativeWindowDeco();
executed (the execution status of this line is deduced): bool nativeDeco = layout->nativeWindowDeco();
-
1358 -
1359 if (!nativeDeco && !customTitleBar) {
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
partially evaluated: !customTitleBar
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
1360 QStylePainter p(this);
executed (the execution status of this line is deduced): QStylePainter p(this);
-
1361 // ### Add PixelMetric to change spacers, so style may show border -
1362 // when not floating. -
1363 if (isFloating()) {
evaluated: isFloating()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:12
10-12
1364 QStyleOptionFrame framOpt;
executed (the execution status of this line is deduced): QStyleOptionFrame framOpt;
-
1365 framOpt.init(this);
executed (the execution status of this line is deduced): framOpt.init(this);
-
1366 p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
executed (the execution status of this line is deduced): p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
-
1367 }
executed: }
Execution Count:10
10
1368 -
1369 // Title must be painted after the frame, since the areas overlap, and -
1370 // the title may wish to extend out to all sides (eg. XP style) -
1371 QStyleOptionDockWidgetV2 titleOpt;
executed (the execution status of this line is deduced): QStyleOptionDockWidgetV2 titleOpt;
-
1372 initStyleOption(&titleOpt);
executed (the execution status of this line is deduced): initStyleOption(&titleOpt);
-
1373 p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
executed (the execution status of this line is deduced): p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
-
1374 }
executed: }
Execution Count:22
22
1375}
executed: }
Execution Count:22
22
1376 -
1377/*! \reimp */ -
1378bool QDockWidget::event(QEvent *event) -
1379{ -
1380 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1381 -
1382 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
-
1383 QMainWindowLayout *layout = qt_mainwindow_layout(win);
executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(win);
-
1384 -
1385 switch (event->type()) { -
1386#ifndef QT_NO_ACTION -
1387 case QEvent::Hide: -
1388 if (layout != 0)
evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:4
4-14
1389 layout->keepSize(this);
executed: layout->keepSize(this);
Execution Count:14
14
1390 d->toggleViewAction->setChecked(false);
executed (the execution status of this line is deduced): d->toggleViewAction->setChecked(false);
-
1391 emit visibilityChanged(false);
executed (the execution status of this line is deduced): visibilityChanged(false);
-
1392 break;
executed: break;
Execution Count:18
18
1393 case QEvent::Show: -
1394 d->toggleViewAction->setChecked(true);
executed (the execution status of this line is deduced): d->toggleViewAction->setChecked(true);
-
1395 emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
executed (the execution status of this line is deduced): visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
-
1396 break;
executed: break;
Execution Count:31
31
1397#endif -
1398 case QEvent::ApplicationLayoutDirectionChange: -
1399 case QEvent::LayoutDirectionChange: -
1400 case QEvent::StyleChange: -
1401 case QEvent::ParentChange: -
1402 d->updateButtons();
executed (the execution status of this line is deduced): d->updateButtons();
-
1403 break;
executed: break;
Execution Count:15
15
1404 case QEvent::ZOrderChange: { -
1405 bool onTop = false;
executed (the execution status of this line is deduced): bool onTop = false;
-
1406 if (win != 0) {
evaluated: win != 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:3
3-17
1407 const QObjectList &siblings = win->children();
executed (the execution status of this line is deduced): const QObjectList &siblings = win->children();
-
1408 onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
partially evaluated: siblings.count() > 0
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
evaluated: siblings.last() == (QObject*)this
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:6
0-17
1409 }
executed: }
Execution Count:17
17
1410 if (!isFloating() && layout != 0 && onTop)
evaluated: !isFloating()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:11
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-11
1411 layout->raise(this);
executed: layout->raise(this);
Execution Count:4
4
1412 break;
executed: break;
Execution Count:20
20
1413 } -
1414 case QEvent::WindowActivate: -
1415 case QEvent::WindowDeactivate: -
1416 update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
executed (the execution status of this line is deduced): update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
-
1417 break;
executed: break;
Execution Count:15
15
1418 case QEvent::ContextMenu: -
1419 if (d->state) {
never evaluated: d->state
0
1420 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
1421 return true;
never executed: return true;
0
1422 } -
1423 break;
never executed: break;
0
1424 // return true after calling the handler since we don't want -
1425 // them to be passed onto the default handlers -
1426 case QEvent::MouseButtonPress: -
1427 if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mousePressEvent(static_cast<QMouseEvent *>(event))
0
1428 return true;
never executed: return true;
0
1429 break;
never executed: break;
0
1430 case QEvent::MouseButtonDblClick: -
1431 if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event))
0
1432 return true;
never executed: return true;
0
1433 break;
never executed: break;
0
1434 case QEvent::MouseMove: -
1435 if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseMoveEvent(static_cast<QMouseEvent *>(event))
0
1436 return true;
never executed: return true;
0
1437 break;
never executed: break;
0
1438#ifdef Q_WS_WIN -
1439 case QEvent::Leave: -
1440 if (d->state != 0 && d->state->dragging && !d->state->nca) { -
1441 // This is a workaround for loosing the mouse on Vista. -
1442 QPoint pos = QCursor::pos(); -
1443 QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, -
1444 QApplication::mouseButtons(), QApplication::keyboardModifiers()); -
1445 d->mouseMoveEvent(&fake); -
1446 } -
1447 break; -
1448#endif -
1449 case QEvent::MouseButtonRelease: -
1450 if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseReleaseEvent(static_cast<QMouseEvent *>(event))
0
1451 return true;
never executed: return true;
0
1452 break;
never executed: break;
0
1453 case QEvent::NonClientAreaMouseMove: -
1454 case QEvent::NonClientAreaMouseButtonPress: -
1455 case QEvent::NonClientAreaMouseButtonRelease: -
1456 case QEvent::NonClientAreaMouseButtonDblClick: -
1457 d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
executed (the execution status of this line is deduced): d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
-
1458 return true;
executed: return true;
Execution Count:2
2
1459 case QEvent::Move: -
1460 d->moveEvent(static_cast<QMoveEvent*>(event));
executed (the execution status of this line is deduced): d->moveEvent(static_cast<QMoveEvent*>(event));
-
1461 break;
executed: break;
Execution Count:35
35
1462 case QEvent::Resize: -
1463 // if the mainwindow is plugging us, we don't want to update undocked geometry -
1464 if (isFloating() && layout != 0 && layout->pluggingWidget != this)
evaluated: isFloating()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:18
evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
partially evaluated: layout->pluggingWidget != this
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-18
1465 d->undockedGeometry = geometry();
executed: d->undockedGeometry = geometry();
Execution Count:7
7
1466 break;
executed: break;
Execution Count:32
32
1467 default: -
1468 break;
executed: break;
Execution Count:594
594
1469 } -
1470 return QWidget::event(event);
executed: return QWidget::event(event);
Execution Count:760
760
1471} -
1472 -
1473#ifndef QT_NO_ACTION -
1474/*! -
1475 Returns a checkable action that can be used to show or close this -
1476 dock widget. -
1477 -
1478 The action's text is set to the dock widget's window title. -
1479 -
1480 \sa QAction::text, QWidget::windowTitle -
1481 */ -
1482QAction * QDockWidget::toggleViewAction() const -
1483{ -
1484 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
1485 return d->toggleViewAction;
executed: return d->toggleViewAction;
Execution Count:1
1
1486} -
1487#endif // QT_NO_ACTION -
1488 -
1489/*! -
1490 \fn void QDockWidget::featuresChanged(QDockWidget::DockWidgetFeatures features) -
1491 -
1492 This signal is emitted when the \l features property changes. The -
1493 \a features parameter gives the new value of the property. -
1494*/ -
1495 -
1496/*! -
1497 \fn void QDockWidget::topLevelChanged(bool topLevel) -
1498 -
1499 This signal is emitted when the \l floating property changes. -
1500 The \a topLevel parameter is true if the dock widget is now floating; -
1501 otherwise it is false. -
1502 -
1503 \sa isWindow() -
1504*/ -
1505 -
1506/*! -
1507 \fn void QDockWidget::allowedAreasChanged(Qt::DockWidgetAreas allowedAreas) -
1508 -
1509 This signal is emitted when the \l allowedAreas property changes. The -
1510 \a allowedAreas parameter gives the new value of the property. -
1511*/ -
1512 -
1513/*! -
1514 \fn void QDockWidget::visibilityChanged(bool visible) -
1515 \since 4.3 -
1516 -
1517 This signal is emitted when the dock widget becomes \a visible (or -
1518 invisible). This happens when the widget is hidden or shown, as -
1519 well as when it is docked in a tabbed dock area and its tab -
1520 becomes selected or unselected. -
1521*/ -
1522 -
1523/*! -
1524 \fn void QDockWidget::dockLocationChanged(Qt::DockWidgetArea area) -
1525 \since 4.3 -
1526 -
1527 This signal is emitted when the dock widget is moved to another -
1528 dock \a area, or is moved to a different location in its current -
1529 dock area. This happens when the dock widget is moved -
1530 programmatically or is dragged to a new location by the user. -
1531*/ -
1532 -
1533/*! -
1534 \since 4.3 -
1535 -
1536 Sets an arbitrary \a widget as the dock widget's title bar. If \a widget -
1537 is 0, any custom title bar widget previously set on the dock widget is -
1538 removed, but not deleted, and the default title bar will be used -
1539 instead. -
1540 -
1541 If a title bar widget is set, QDockWidget will not use native window -
1542 decorations when it is floated. -
1543 -
1544 Here are some tips for implementing custom title bars: -
1545 -
1546 \list -
1547 \li Mouse events that are not explicitly handled by the title bar widget -
1548 must be ignored by calling QMouseEvent::ignore(). These events then -
1549 propagate to the QDockWidget parent, which handles them in the usual -
1550 manner, moving when the title bar is dragged, docking and undocking -
1551 when it is double-clicked, etc. -
1552 -
1553 \li When DockWidgetVerticalTitleBar is set on QDockWidget, the title -
1554 bar widget is repositioned accordingly. In resizeEvent(), the title -
1555 bar should check what orientation it should assume: -
1556 \snippet code/src_gui_widgets_qdockwidget.cpp 0 -
1557 -
1558 \li The title bar widget must have a valid QWidget::sizeHint() and -
1559 QWidget::minimumSizeHint(). These functions should take into account -
1560 the current orientation of the title bar. -
1561 -
1562 \li It is not possible to remove a title bar from a dock widget. However, -
1563 a similar effect can be achieved by setting a default constructed -
1564 QWidget as the title bar widget. -
1565 \endlist -
1566 -
1567 Using qobject_cast() as shown above, the title bar widget has full access -
1568 to its parent QDockWidget. Hence it can perform such operations as docking -
1569 and hiding in response to user actions. -
1570 -
1571 \sa titleBarWidget(), DockWidgetVerticalTitleBar -
1572*/ -
1573 -
1574void QDockWidget::setTitleBarWidget(QWidget *widget) -
1575{ -
1576 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1577 QDockWidgetLayout *layout
executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1578 = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1579 layout->setWidgetForRole(QDockWidgetLayout::TitleBar, widget);
executed (the execution status of this line is deduced): layout->setWidgetForRole(QDockWidgetLayout::TitleBar, widget);
-
1580 d->updateButtons();
executed (the execution status of this line is deduced): d->updateButtons();
-
1581 if (isWindow()) {
partially evaluated: isWindow()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1582 //this ensures the native decoration is drawn -
1583 d->setWindowState(true /*floating*/, true /*unplug*/);
executed (the execution status of this line is deduced): d->setWindowState(true , true );
-
1584 }
executed: }
Execution Count:3
3
1585}
executed: }
Execution Count:3
3
1586 -
1587/*! -
1588 \since 4.3 -
1589 Returns the custom title bar widget set on the QDockWidget, or 0 if no -
1590 custom title bar has been set. -
1591 -
1592 \sa setTitleBarWidget() -
1593*/ -
1594 -
1595QWidget *QDockWidget::titleBarWidget() const -
1596{ -
1597 QDockWidgetLayout *layout
never executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1598 = qobject_cast<QDockWidgetLayout*>(this->layout());
never executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1599 return layout->widgetForRole(QDockWidgetLayout::TitleBar);
never executed: return layout->widgetForRole(QDockWidgetLayout::TitleBar);
0
1600} -
1601 -
1602QT_END_NAMESPACE -
1603 -
1604#include "qdockwidget.moc" -
1605#include "moc_qdockwidget.cpp" -
1606 -
1607#endif // QT_NO_DOCKWIDGET -
1608 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial