widgets/qdockwidget.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "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:162
162
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:2007
2007
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:64
64
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:54
54
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:4646
no
Evaluation Count:0
0-4646
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:4646
4646
146 -
147 return QSize(size, size);
executed: return QSize(size, size);
Execution Count:4646
4646
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:58
no
Evaluation Count:0
0-58
171 { -
172 if (isEnabled() && underMouse() && !isChecked() && !isDown())
partially evaluated: isEnabled()
TRUEFALSE
yes
Evaluation Count:58
no
Evaluation Count:0
partially evaluated: underMouse()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:58
never evaluated: !isChecked()
never evaluated: !isDown()
0-58
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:58
0-58
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:58
0-58
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:58
58
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:58
58
190 -
191/****************************************************************************** -
192** QDockWidgetLayout -
193*/ -
194 -
195QDockWidgetLayout::QDockWidgetLayout(QWidget *parent) -
196 : QLayout(parent), verticalTitleBar(false), item_list(RoleCount, 0) -
197{ -
198}
executed: }
Execution Count:27
27
199 -
200QDockWidgetLayout::~QDockWidgetLayout() -
201{ -
202 qDeleteAll(item_list);
executed (the execution status of this line is deduced): qDeleteAll(item_list);
-
203}
executed: }
Execution Count:27
27
204 -
205bool QDockWidgetLayout::nativeWindowDeco() const -
206{ -
207 return nativeWindowDeco(parentWidget()->isWindow());
executed: return nativeWindowDeco(parentWidget()->isWindow());
Execution Count:193
193
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:984
984
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:984
984
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:555
yes
Evaluation Count:56
56-555
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:181
yes
Evaluation Count:374
181-374
238 continue;
executed: continue;
Execution Count:181
181
239 if (index == cnt++)
evaluated: index == cnt++
TRUEFALSE
yes
Evaluation Count:145
yes
Evaluation Count:229
145-229
240 return item;
executed: return item;
Execution Count:145
145
241 }
executed: }
Execution Count:229
229
242 return 0;
executed: return 0;
Execution Count:56
56
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:20
no
Evaluation Count:0
0-20
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:18
2-18
251 continue;
executed: continue;
Execution Count:2
2
252 if (index == j) {
evaluated: index == j
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:4
4-14
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:14
14
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:735
0-735
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:735
735
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:38
yes
Evaluation Count:697
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
0-697
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:735
no
Evaluation Count:0
0-735
293 if (verticalTitleBar)
partially evaluated: verticalTitleBar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:735
0-735
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:735
735
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:679
56-679
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:679
56-679
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:522
yes
Evaluation Count:213
213-522
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:522
522
325 -
326 if (!(explicitMin & Qt::Horizontal) || min.width() == 0)
evaluated: !(explicitMin & Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:719
yes
Evaluation Count:16
partially evaluated: min.width() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-719
327 min.setWidth(-1);
executed: min.setWidth(-1);
Execution Count:719
719
328 if (!(explicitMin & Qt::Vertical) || min.height() == 0)
evaluated: !(explicitMin & Qt::Vertical)
TRUEFALSE
yes
Evaluation Count:719
yes
Evaluation Count:16
partially evaluated: min.height() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-719
329 min.setHeight(-1);
executed: min.setHeight(-1);
Execution Count:719
719
330 -
331 if (!(explicitMax & Qt::Horizontal))
partially evaluated: !(explicitMax & Qt::Horizontal)
TRUEFALSE
yes
Evaluation Count:735
no
Evaluation Count:0
0-735
332 max.setWidth(QWIDGETSIZE_MAX);
executed: max.setWidth(((1<<24)-1));
Execution Count:735
735
333 if (!(explicitMax & Qt::Vertical))
partially evaluated: !(explicitMax & Qt::Vertical)
TRUEFALSE
yes
Evaluation Count:735
no
Evaluation Count:0
0-735
334 max.setHeight(QWIDGETSIZE_MAX);
executed: max.setHeight(((1<<24)-1));
Execution Count:735
735
335 -
336 return result.boundedTo(max).expandedTo(min);
executed: return result.boundedTo(max).expandedTo(min);
Execution Count:735
735
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:14
yes
Evaluation Count:28
14-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:14
14
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:14
yes
Evaluation Count:76
14-76
367 content = item_list[Content]->minimumSize();
executed: content = item_list[Content]->minimumSize();
Execution Count:14
14
368 -
369 return sizeFromContent(content, w->isFloating());
executed: return sizeFromContent(content, w->isFloating());
Execution Count:90
90
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:2657
2657
376} -
377 -
378QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const -
379{ -
380 return item_list.at(r);
executed: return item_list.at(r);
Execution Count:789
789
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:68
8-68
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:71
yes
Evaluation Count:5
5-71
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:71
71
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:76
76
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:1464
1464
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:3070
3070
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:729
6-729
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:729
no
Evaluation Count:0
0-729
422 if (QLayoutItem *item = item_list[CloseButton])
partially evaluated: QLayoutItem *item = item_list[CloseButton]
TRUEFALSE
yes
Evaluation Count:729
no
Evaluation Count:0
0-729
423 closeSize = item->widget()->sizeHint();
executed: closeSize = item->widget()->sizeHint();
Execution Count:729
729
424 }
executed: }
Execution Count:729
729
425 if (hasFeature(q, QDockWidget::DockWidgetFloatable)) {
partially evaluated: hasFeature(q, QDockWidget::DockWidgetFloatable)
TRUEFALSE
yes
Evaluation Count:729
no
Evaluation Count:0
0-729
426 if (QLayoutItem *item = item_list[FloatButton])
partially evaluated: QLayoutItem *item = item_list[FloatButton]
TRUEFALSE
yes
Evaluation Count:729
no
Evaluation Count:0
0-729
427 floatSize = item->widget()->sizeHint();
executed: floatSize = item->widget()->sizeHint();
Execution Count:729
729
428 }
executed: }
Execution Count:729
729
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:729
729
436 + pick(verticalTitleBar, floatSize)
executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw;
Execution Count:729
729
437 + titleHeight + 2*fw + 3*mw;
executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw;
Execution Count:729
729
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:1530
10-1530
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:1530
no
Evaluation Count:0
0-1530
450 closeSize = item->widget()->sizeHint();
executed: closeSize = item->widget()->sizeHint();
Execution Count:1530
1530
451 if (QLayoutItem *item = item_list[FloatButton])
partially evaluated: QLayoutItem *item = item_list[FloatButton]
TRUEFALSE
yes
Evaluation Count:1530
no
Evaluation Count:0
0-1530
452 floatSize = item->widget()->sizeHint();
executed: floatSize = item->widget()->sizeHint();
Execution Count:1530
1530
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:1530
1530
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:37
yes
Evaluation Count:39
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:37
no
Evaluation Count:0
0-39
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:76
0-76
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:76
0-76
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:76
76
494 -
495 if (QLayoutItem *item = item_list[TitleBar]) {
evaluated: QLayoutItem *item = item_list[TitleBar]
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:72
4-72
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:72
no
Evaluation Count:0
0-72
502 if (!item->isEmpty()) {
evaluated: !item->isEmpty()
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:1
1-71
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:71
no
Evaluation Count:0
0-71
507 item->setGeometry(r);
executed: item->setGeometry(r);
Execution Count:71
71
508 }
executed: }
Execution Count:71
71
509 }
executed: }
Execution Count:72
72
510 -
511 if (QLayoutItem *item = item_list[FloatButton]) {
partially evaluated: QLayoutItem *item = item_list[FloatButton]
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
0-72
512 if (!item->isEmpty()) {
partially evaluated: !item->isEmpty()
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
0-72
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:72
no
Evaluation Count:0
0-72
517 item->setGeometry(r);
executed: item->setGeometry(r);
Execution Count:72
72
518 }
executed: }
Execution Count:72
72
519 }
executed: }
Execution Count:72
72
520 }
executed: }
Execution Count:72
72
521 -
522 if (QLayoutItem *item = item_list[Content]) {
evaluated: QLayoutItem *item = item_list[Content]
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:50
26-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:26
0-26
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:26
26
531 item->setGeometry(r);
executed (the execution status of this line is deduced): item->setGeometry(r);
-
532 }
executed: }
Execution Count:26
26
533 }
executed: }
Execution Count:76
76
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:29
29
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:141
yes
Evaluation Count:303
141-303
558 widgetMin = item->minimumSize();
executed: widgetMin = item->minimumSize();
Execution Count:141
141
559 return dockWidgetLayout()->sizeFromContent(widgetMin, false);
executed: return dockWidgetLayout()->sizeFromContent(widgetMin, false);
Execution Count:444
444
560} -
561 -
562QSize QDockWidgetItem::maximumSize() const -
563{ -
564 if (QLayoutItem *item = dockWidgetChildItem()) {
evaluated: QLayoutItem *item = dockWidgetChildItem()
TRUEFALSE
yes
Evaluation Count:99
yes
Evaluation Count:168
99-168
565 return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false);
executed: return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false);
Execution Count:99
99
566 } else { -
567 return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
executed: return QSize(((1<<24)-1), ((1<<24)-1));
Execution Count:168
168
568 } -
569} -
570 -
571 -
572QSize QDockWidgetItem::sizeHint() const -
573{ -
574 if (QLayoutItem *item = dockWidgetChildItem()) {
evaluated: QLayoutItem *item = dockWidgetChildItem()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:48
30-48
575 return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false);
executed: return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false);
Execution Count:30
30
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:27
27
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:183
0-183
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:183
no
Evaluation Count:0
0-183
644 v2->verticalTitleBar = l->verticalTitleBar;
executed: v2->verticalTitleBar = l->verticalTitleBar;
Execution Count:183
183
645}
executed: }
Execution Count:183
183
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:81
evaluated: customTitleBar
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:77
0-81
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:81
81
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:37
no
Evaluation Count:0
never evaluated: !state->dragging
never evaluated: !state->nca
never evaluated: !q->isWindow()
0-37
972 return;
executed: return;
Execution Count:37
37
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 -
1003static void setFrameStrutEventsEnabled(const QWidget *w, bool enabled) -
1004{ -
1005 if (const QWindow *window = w->windowHandle())
never evaluated: const QWindow *window = w->windowHandle()
0
1006 if (QPlatformWindow *platformWindow = window->handle())
never evaluated: QPlatformWindow *platformWindow = window->handle()
0
1007 if (platformWindow->frameStrutEventsEnabled() != enabled)
never evaluated: platformWindow->frameStrutEventsEnabled() != enabled
0
1008 platformWindow->setFrameStrutEventsEnabled(enabled);
never executed: platformWindow->setFrameStrutEventsEnabled(enabled);
0
1009}
never executed: }
0
1010 -
1011void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) -
1012{ -
1013 Q_Q(QDockWidget);
executed (the execution status of this line is deduced): QDockWidget * const q = q_func();
-
1014 -
1015 if (!floating && parent) {
evaluated: !floating
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:13
evaluated: parent
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-13
1016 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()));
-
1017 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
1018 return; // this dockwidget can't be redocked
executed: return;
Execution Count:1
1
1019 }
executed: }
Execution Count:8
8
1020 -
1021 bool wasFloating = q->isFloating();
executed (the execution status of this line is deduced): bool wasFloating = q->isFloating();
-
1022 bool hidden = q->isHidden();
executed (the execution status of this line is deduced): bool hidden = q->isHidden();
-
1023 -
1024 if (q->isVisible())
evaluated: q->isVisible()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
1025 q->hide();
executed: q->hide();
Execution Count:14
14
1026 -
1027 Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
evaluated: floating
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:9
9-13
1028 -
1029 QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
executed (the execution status of this line is deduced): QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
-
1030 const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
executed (the execution status of this line is deduced): const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
-
1031 -
1032 if (nativeDeco) {
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
1033 flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
never executed (the execution status of this line is deduced): flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
-
1034 if (hasFeature(this, QDockWidget::DockWidgetClosable))
never evaluated: hasFeature(this, QDockWidget::DockWidgetClosable)
0
1035 flags |= Qt::WindowCloseButtonHint;
never executed: flags |= Qt::WindowCloseButtonHint;
0
1036 } else {
never executed: }
0
1037 flags |= Qt::FramelessWindowHint;
executed (the execution status of this line is deduced): flags |= Qt::FramelessWindowHint;
-
1038 }
executed: }
Execution Count:22
22
1039 -
1040 if (unplug)
evaluated: unplug
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:19
3-19
1041 flags |= Qt::X11BypassWindowManagerHint;
executed: flags |= Qt::X11BypassWindowManagerHint;
Execution Count:3
3
1042 -
1043 q->setWindowFlags(flags);
executed (the execution status of this line is deduced): q->setWindowFlags(flags);
-
1044 -
1045 -
1046 if (!rect.isNull())
evaluated: !rect.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:21
1-21
1047 q->setGeometry(rect);
executed: q->setGeometry(rect);
Execution Count:1
1
1048 -
1049 updateButtons();
executed (the execution status of this line is deduced): updateButtons();
-
1050 -
1051 if (!hidden)
evaluated: !hidden
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:5
5-17
1052 q->show();
executed: q->show();
Execution Count:17
17
1053 -
1054 if (floating != wasFloating) {
evaluated: floating != wasFloating
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
1055 emit q->topLevelChanged(floating);
executed (the execution status of this line is deduced): q->topLevelChanged(floating);
-
1056 if (!floating && parent) {
evaluated: !floating
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
evaluated: parent
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-8
1057 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()));
-
1058 if (mwlayout)
partially evaluated: mwlayout
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1059 emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
executed: q->dockLocationChanged(mwlayout->dockWidgetArea(q));
Execution Count:5
5
1060 }
executed: }
Execution Count:5
5
1061 }
executed: }
Execution Count:14
14
1062 -
1063 if (floating && nativeDeco)
evaluated: floating
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:9
partially evaluated: nativeDeco
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
1064 setFrameStrutEventsEnabled(q, true);
never executed: setFrameStrutEventsEnabled(q, true);
0
1065 -
1066 resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
executed (the execution status of this line is deduced): resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
-
1067}
executed: }
Execution Count:22
22
1068 -
1069/*! -
1070 \class QDockWidget -
1071 -
1072 \brief The QDockWidget class provides a widget that can be docked -
1073 inside a QMainWindow or floated as a top-level window on the -
1074 desktop. -
1075 -
1076 \ingroup mainwindow-classes -
1077 \inmodule QtWidgets -
1078 -
1079 QDockWidget provides the concept of dock widgets, also know as -
1080 tool palettes or utility windows. Dock windows are secondary -
1081 windows placed in the \e {dock widget area} around the -
1082 \l{QMainWindow::centralWidget()}{central widget} in a -
1083 QMainWindow. -
1084 -
1085 \image mainwindow-docks.png -
1086 -
1087 Dock windows can be moved inside their current area, moved into -
1088 new areas and floated (e.g., undocked) by the end-user. The -
1089 QDockWidget API allows the programmer to restrict the dock widgets -
1090 ability to move, float and close, as well as the areas in which -
1091 they can be placed. -
1092 -
1093 \section1 Appearance -
1094 -
1095 A QDockWidget consists of a title bar and the content area. The -
1096 title bar displays the dock widgets -
1097 \l{QWidget::windowTitle()}{window title}, -
1098 a \e float button and a \e close button. -
1099 Depending on the state of the QDockWidget, the \e float and \e -
1100 close buttons may be either disabled or not shown at all. -
1101 -
1102 The visual appearance of the title bar and buttons is dependent -
1103 on the \l{QStyle}{style} in use. -
1104 -
1105 A QDockWidget acts as a wrapper for its child widget, set with setWidget(). -
1106 Custom size hints, minimum and maximum sizes and size policies should be -
1107 implemented in the child widget. QDockWidget will respect them, adjusting -
1108 its own constraints to include the frame and title. Size constraints -
1109 should not be set on the QDockWidget itself, because they change depending -
1110 on whether it is docked; a docked QDockWidget has no frame and a smaller title -
1111 bar. -
1112 -
1113 \sa QMainWindow, {Dock Widgets Example} -
1114*/ -
1115 -
1116/*! -
1117 \enum QDockWidget::DockWidgetFeature -
1118 -
1119 \value DockWidgetClosable The dock widget can be closed. On some systems the dock -
1120 widget always has a close button when it's floating -
1121 (for example on MacOS 10.5). -
1122 \value DockWidgetMovable The dock widget can be moved between docks -
1123 by the user. -
1124 \value DockWidgetFloatable The dock widget can be detached from the -
1125 main window, and floated as an independent -
1126 window. -
1127 \value DockWidgetVerticalTitleBar The dock widget displays a vertical title -
1128 bar on its left side. This can be used to -
1129 increase the amount of vertical space in -
1130 a QMainWindow. -
1131 \value AllDockWidgetFeatures (Deprecated) The dock widget can be closed, moved, -
1132 and floated. Since new features might be added in future -
1133 releases, the look and behavior of dock widgets might -
1134 change if you use this flag. Please specify individual -
1135 flags instead. -
1136 \value NoDockWidgetFeatures The dock widget cannot be closed, moved, -
1137 or floated. -
1138 -
1139 \omitvalue DockWidgetFeatureMask -
1140 \omitvalue Reserved -
1141*/ -
1142 -
1143/*! -
1144 \property QDockWidget::windowTitle -
1145 \brief the dock widget title (caption) -
1146 -
1147 By default, this property contains an empty string. -
1148*/ -
1149 -
1150/*! -
1151 Constructs a QDockWidget with parent \a parent and window flags \a -
1152 flags. The dock widget will be placed in the left dock widget -
1153 area. -
1154*/ -
1155QDockWidget::QDockWidget(QWidget *parent, Qt::WindowFlags flags) -
1156 : QWidget(*new QDockWidgetPrivate, parent, flags) -
1157{ -
1158 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1159 d->init();
executed (the execution status of this line is deduced): d->init();
-
1160}
executed: }
Execution Count:25
25
1161 -
1162/*! -
1163 Constructs a QDockWidget with parent \a parent and window flags \a -
1164 flags. The dock widget will be placed in the left dock widget -
1165 area. -
1166 -
1167 The window title is set to \a title. This title is used when the -
1168 QDockWidget is docked and undocked. It is also used in the context -
1169 menu provided by QMainWindow. -
1170 -
1171 \sa setWindowTitle() -
1172*/ -
1173QDockWidget::QDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) -
1174 : QWidget(*new QDockWidgetPrivate, parent, flags) -
1175{ -
1176 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1177 d->init();
executed (the execution status of this line is deduced): d->init();
-
1178 setWindowTitle(title);
executed (the execution status of this line is deduced): setWindowTitle(title);
-
1179}
executed: }
Execution Count:2
2
1180 -
1181/*! -
1182 Destroys the dock widget. -
1183*/ -
1184QDockWidget::~QDockWidget() -
1185{ } -
1186 -
1187/*! -
1188 Returns the widget for the dock widget. This function returns zero -
1189 if the widget has not been set. -
1190 -
1191 \sa setWidget() -
1192*/ -
1193QWidget *QDockWidget::widget() const -
1194{ -
1195 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1196 return layout->widgetForRole(QDockWidgetLayout::Content);
executed: return layout->widgetForRole(QDockWidgetLayout::Content);
Execution Count:33
33
1197} -
1198 -
1199/*! -
1200 Sets the widget for the dock widget to \a widget. -
1201 -
1202 If the dock widget is visible when \a widget is added, you must -
1203 \l{QWidget::}{show()} it explicitly. -
1204 -
1205 Note that you must add the layout of the \a widget before you call -
1206 this function; if not, the \a widget will not be visible. -
1207 -
1208 \sa widget() -
1209*/ -
1210void QDockWidget::setWidget(QWidget *widget) -
1211{ -
1212 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1213 layout->setWidgetForRole(QDockWidgetLayout::Content, widget);
executed (the execution status of this line is deduced): layout->setWidgetForRole(QDockWidgetLayout::Content, widget);
-
1214}
executed: }
Execution Count:19
19
1215 -
1216/*! -
1217 \property QDockWidget::features -
1218 \brief whether the dock widget is movable, closable, and floatable -
1219 -
1220 By default, this property is set to a combination of DockWidgetClosable, -
1221 DockWidgetMovable and DockWidgetFloatable. -
1222 -
1223 \sa DockWidgetFeature -
1224*/ -
1225 -
1226void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) -
1227{ -
1228 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1229 features &= DockWidgetFeatureMask;
executed (the execution status of this line is deduced): features &= DockWidgetFeatureMask;
-
1230 if (d->features == features)
evaluated: d->features == features
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:14
9-14
1231 return;
executed: return;
Execution Count:9
9
1232 const bool closableChanged = (d->features ^ features) & DockWidgetClosable;
executed (the execution status of this line is deduced): const bool closableChanged = (d->features ^ features) & DockWidgetClosable;
-
1233 d->features = features;
executed (the execution status of this line is deduced): d->features = features;
-
1234 QDockWidgetLayout *layout
executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1235 = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1236 layout->setVerticalTitleBar(features & DockWidgetVerticalTitleBar);
executed (the execution status of this line is deduced): layout->setVerticalTitleBar(features & DockWidgetVerticalTitleBar);
-
1237 d->updateButtons();
executed (the execution status of this line is deduced): d->updateButtons();
-
1238 d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable);
executed (the execution status of this line is deduced): d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable);
-
1239 emit featuresChanged(d->features);
executed (the execution status of this line is deduced): featuresChanged(d->features);
-
1240 update();
executed (the execution status of this line is deduced): update();
-
1241 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
1242 //this ensures the native decoration is drawn -
1243 d->setWindowState(true /*floating*/, true /*unplug*/);
never executed (the execution status of this line is deduced): d->setWindowState(true , true );
-
1244 }
never executed: }
0
1245}
executed: }
Execution Count:14
14
1246 -
1247QDockWidget::DockWidgetFeatures QDockWidget::features() const -
1248{ -
1249 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
1250 return d->features;
executed: return d->features;
Execution Count:2076
2076
1251} -
1252 -
1253/*! -
1254 \property QDockWidget::floating -
1255 \brief whether the dock widget is floating -
1256 -
1257 A floating dock widget is presented to the user as an independent -
1258 window "on top" of its parent QMainWindow, instead of being -
1259 docked in the QMainWindow. -
1260 -
1261 By default, this property is true. -
1262 -
1263 \sa isWindow() -
1264*/ -
1265void QDockWidget::setFloating(bool floating) -
1266{ -
1267 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1268 -
1269 // the initial click of a double-click may have started a drag... -
1270 if (d->state != 0)
partially evaluated: d->state != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
1271 d->endDrag(true);
never executed: d->endDrag(true);
0
1272 -
1273 QRect r = d->undockedGeometry;
executed (the execution status of this line is deduced): QRect r = d->undockedGeometry;
-
1274 -
1275 d->setWindowState(floating, false, floating ? r : QRect());
executed (the execution status of this line is deduced): d->setWindowState(floating, false, floating ? r : QRect());
-
1276 -
1277 if (floating && r.isNull()) {
evaluated: floating
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:10
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
1-10
1278 if (x() < 0 || y() < 0) //may happen if we have been hidden
evaluated: x() < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
partially evaluated: y() < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
1279 move(QPoint());
executed: move(QPoint());
Execution Count:1
1
1280 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);
-
1281 }
executed: }
Execution Count:9
9
1282}
executed: }
Execution Count:20
20
1283 -
1284/*! -
1285 \property QDockWidget::allowedAreas -
1286 \brief areas where the dock widget may be placed -
1287 -
1288 The default is Qt::AllDockWidgetAreas. -
1289 -
1290 \sa Qt::DockWidgetArea -
1291*/ -
1292 -
1293void QDockWidget::setAllowedAreas(Qt::DockWidgetAreas areas) -
1294{ -
1295 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1296 areas &= Qt::DockWidgetArea_Mask;
executed (the execution status of this line is deduced): areas &= Qt::DockWidgetArea_Mask;
-
1297 if (areas == d->allowedAreas)
evaluated: areas == d->allowedAreas
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:8
8
1298 return;
executed: return;
Execution Count:8
8
1299 d->allowedAreas = areas;
executed (the execution status of this line is deduced): d->allowedAreas = areas;
-
1300 emit allowedAreasChanged(d->allowedAreas);
executed (the execution status of this line is deduced): allowedAreasChanged(d->allowedAreas);
-
1301}
executed: }
Execution Count:8
8
1302 -
1303Qt::DockWidgetAreas QDockWidget::allowedAreas() const -
1304{ -
1305 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
1306 return d->allowedAreas;
executed: return d->allowedAreas;
Execution Count:61
61
1307} -
1308 -
1309/*! -
1310 \fn bool QDockWidget::isAreaAllowed(Qt::DockWidgetArea area) const -
1311 -
1312 Returns true if this dock widget can be placed in the given \a area; -
1313 otherwise returns false. -
1314*/ -
1315 -
1316/*! \reimp */ -
1317void QDockWidget::changeEvent(QEvent *event) -
1318{ -
1319 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1320 QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1321 -
1322 switch (event->type()) { -
1323 case QEvent::ModifiedChange: -
1324 case QEvent::WindowTitleChange: -
1325 update(layout->titleArea());
executed (the execution status of this line is deduced): update(layout->titleArea());
-
1326#ifndef QT_NO_ACTION -
1327 d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this);
executed (the execution status of this line is deduced): d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this);
-
1328 d->toggleViewAction->setText(d->fixedWindowTitle);
executed (the execution status of this line is deduced): d->toggleViewAction->setText(d->fixedWindowTitle);
-
1329#endif -
1330#ifndef QT_NO_TABBAR -
1331 { -
1332 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
-
1333 if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
evaluated: QMainWindowLayout *winLayout = qt_mainwindow_layout(win)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1334 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
1335 info->updateTabBar();
never executed: info->updateTabBar();
0
1336 }
executed: }
Execution Count:1
1
1337 } -
1338#endif // QT_NO_TABBAR -
1339 break;
executed: break;
Execution Count:2
2
1340 default: -
1341 break;
executed: break;
Execution Count:52
52
1342 } -
1343 QWidget::changeEvent(event);
executed (the execution status of this line is deduced): QWidget::changeEvent(event);
-
1344}
executed: }
Execution Count:54
54
1345 -
1346/*! \reimp */ -
1347void QDockWidget::closeEvent(QCloseEvent *event) -
1348{ -
1349 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1350 if (d->state)
partially evaluated: d->state
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1351 d->endDrag(true);
never executed: d->endDrag(true);
0
1352 QWidget::closeEvent(event);
executed (the execution status of this line is deduced): QWidget::closeEvent(event);
-
1353}
executed: }
Execution Count:2
2
1354 -
1355/*! \reimp */ -
1356void QDockWidget::paintEvent(QPaintEvent *event) -
1357{ -
1358 Q_UNUSED(event)
executed (the execution status of this line is deduced): (void)event;
-
1359 -
1360 QDockWidgetLayout *layout
executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1361 = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1362 bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
executed (the execution status of this line is deduced): bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
-
1363 bool nativeDeco = layout->nativeWindowDeco();
executed (the execution status of this line is deduced): bool nativeDeco = layout->nativeWindowDeco();
-
1364 -
1365 if (!nativeDeco && !customTitleBar) {
partially evaluated: !nativeDeco
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
partially evaluated: !customTitleBar
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
1366 QStylePainter p(this);
executed (the execution status of this line is deduced): QStylePainter p(this);
-
1367 // ### Add PixelMetric to change spacers, so style may show border -
1368 // when not floating. -
1369 if (isFloating()) {
evaluated: isFloating()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:18
12-18
1370 QStyleOptionFrame framOpt;
executed (the execution status of this line is deduced): QStyleOptionFrame framOpt;
-
1371 framOpt.init(this);
executed (the execution status of this line is deduced): framOpt.init(this);
-
1372 p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
executed (the execution status of this line is deduced): p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
-
1373 }
executed: }
Execution Count:12
12
1374 -
1375 // Title must be painted after the frame, since the areas overlap, and -
1376 // the title may wish to extend out to all sides (eg. XP style) -
1377 QStyleOptionDockWidgetV2 titleOpt;
executed (the execution status of this line is deduced): QStyleOptionDockWidgetV2 titleOpt;
-
1378 initStyleOption(&titleOpt);
executed (the execution status of this line is deduced): initStyleOption(&titleOpt);
-
1379 p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
executed (the execution status of this line is deduced): p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
-
1380 }
executed: }
Execution Count:30
30
1381}
executed: }
Execution Count:30
30
1382 -
1383/*! \reimp */ -
1384bool QDockWidget::event(QEvent *event) -
1385{ -
1386 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1387 -
1388 QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
executed (the execution status of this line is deduced): QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
-
1389 QMainWindowLayout *layout = qt_mainwindow_layout(win);
executed (the execution status of this line is deduced): QMainWindowLayout *layout = qt_mainwindow_layout(win);
-
1390 -
1391 switch (event->type()) { -
1392#ifndef QT_NO_ACTION -
1393 case QEvent::Hide: -
1394 if (layout != 0)
evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:4
4-15
1395 layout->keepSize(this);
executed: layout->keepSize(this);
Execution Count:15
15
1396 d->toggleViewAction->setChecked(false);
executed (the execution status of this line is deduced): d->toggleViewAction->setChecked(false);
-
1397 emit visibilityChanged(false);
executed (the execution status of this line is deduced): visibilityChanged(false);
-
1398 break;
executed: break;
Execution Count:19
19
1399 case QEvent::Show: -
1400 if (static_cast<QDockWidgetLayout *>(QDockWidget::layout())->nativeWindowDeco(isFloating()))
partially evaluated: static_cast<QDockWidgetLayout *>(QDockWidget::layout())->nativeWindowDeco(isFloating())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
1401 setFrameStrutEventsEnabled(this, true);
never executed: setFrameStrutEventsEnabled(this, true);
0
1402 d->toggleViewAction->setChecked(true);
executed (the execution status of this line is deduced): d->toggleViewAction->setChecked(true);
-
1403 emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
executed (the execution status of this line is deduced): visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
-
1404 break;
executed: break;
Execution Count:34
34
1405#endif -
1406 case QEvent::ApplicationLayoutDirectionChange: -
1407 case QEvent::LayoutDirectionChange: -
1408 case QEvent::StyleChange: -
1409 case QEvent::ParentChange: -
1410 d->updateButtons();
executed (the execution status of this line is deduced): d->updateButtons();
-
1411 break;
executed: break;
Execution Count:15
15
1412 case QEvent::ZOrderChange: { -
1413 bool onTop = false;
executed (the execution status of this line is deduced): bool onTop = false;
-
1414 if (win != 0) {
evaluated: win != 0
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:3
3-18
1415 const QObjectList &siblings = win->children();
executed (the execution status of this line is deduced): const QObjectList &siblings = win->children();
-
1416 onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
partially evaluated: siblings.count() > 0
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
evaluated: siblings.last() == (QObject*)this
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:7
0-18
1417 }
executed: }
Execution Count:18
18
1418 if (!isFloating() && layout != 0 && onTop)
evaluated: !isFloating()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:12
partially evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
evaluated: onTop
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
0-12
1419 layout->raise(this);
executed: layout->raise(this);
Execution Count:4
4
1420 break;
executed: break;
Execution Count:21
21
1421 } -
1422 case QEvent::WindowActivate: -
1423 case QEvent::WindowDeactivate: -
1424 update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
executed (the execution status of this line is deduced): update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
-
1425 break;
executed: break;
Execution Count:18
18
1426 case QEvent::ContextMenu: -
1427 if (d->state) {
never evaluated: d->state
0
1428 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
1429 return true;
never executed: return true;
0
1430 } -
1431 break;
never executed: break;
0
1432 // return true after calling the handler since we don't want -
1433 // them to be passed onto the default handlers -
1434 case QEvent::MouseButtonPress: -
1435 if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mousePressEvent(static_cast<QMouseEvent *>(event))
0
1436 return true;
never executed: return true;
0
1437 break;
never executed: break;
0
1438 case QEvent::MouseButtonDblClick: -
1439 if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event))
0
1440 return true;
never executed: return true;
0
1441 break;
never executed: break;
0
1442 case QEvent::MouseMove: -
1443 if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseMoveEvent(static_cast<QMouseEvent *>(event))
0
1444 return true;
never executed: return true;
0
1445 break;
never executed: break;
0
1446#ifdef Q_WS_WIN -
1447 case QEvent::Leave: -
1448 if (d->state != 0 && d->state->dragging && !d->state->nca) { -
1449 // This is a workaround for loosing the mouse on Vista. -
1450 QPoint pos = QCursor::pos(); -
1451 QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, -
1452 QApplication::mouseButtons(), QApplication::keyboardModifiers()); -
1453 d->mouseMoveEvent(&fake); -
1454 } -
1455 break; -
1456#endif -
1457 case QEvent::MouseButtonRelease: -
1458 if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
never evaluated: d->mouseReleaseEvent(static_cast<QMouseEvent *>(event))
0
1459 return true;
never executed: return true;
0
1460 break;
never executed: break;
0
1461 case QEvent::NonClientAreaMouseMove: -
1462 case QEvent::NonClientAreaMouseButtonPress: -
1463 case QEvent::NonClientAreaMouseButtonRelease: -
1464 case QEvent::NonClientAreaMouseButtonDblClick: -
1465 d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
executed (the execution status of this line is deduced): d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
-
1466 return true;
executed: return true;
Execution Count:2
2
1467 case QEvent::Move: -
1468 d->moveEvent(static_cast<QMoveEvent*>(event));
executed (the execution status of this line is deduced): d->moveEvent(static_cast<QMoveEvent*>(event));
-
1469 break;
executed: break;
Execution Count:37
37
1470 case QEvent::Resize: -
1471 // if the mainwindow is plugging us, we don't want to update undocked geometry -
1472 if (isFloating() && layout != 0 && layout->pluggingWidget != this)
evaluated: isFloating()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:20
evaluated: layout != 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
partially evaluated: layout->pluggingWidget != this
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-20
1473 d->undockedGeometry = geometry();
executed: d->undockedGeometry = geometry();
Execution Count:8
8
1474 break;
executed: break;
Execution Count:35
35
1475 default: -
1476 break;
executed: break;
Execution Count:671
671
1477 } -
1478 return QWidget::event(event);
executed: return QWidget::event(event);
Execution Count:850
850
1479} -
1480 -
1481#ifndef QT_NO_ACTION -
1482/*! -
1483 Returns a checkable action that can be used to show or close this -
1484 dock widget. -
1485 -
1486 The action's text is set to the dock widget's window title. -
1487 -
1488 \sa QAction::text, QWidget::windowTitle -
1489 */ -
1490QAction * QDockWidget::toggleViewAction() const -
1491{ -
1492 Q_D(const QDockWidget);
executed (the execution status of this line is deduced): const QDockWidgetPrivate * const d = d_func();
-
1493 return d->toggleViewAction;
executed: return d->toggleViewAction;
Execution Count:1
1
1494} -
1495#endif // QT_NO_ACTION -
1496 -
1497/*! -
1498 \fn void QDockWidget::featuresChanged(QDockWidget::DockWidgetFeatures features) -
1499 -
1500 This signal is emitted when the \l features property changes. The -
1501 \a features parameter gives the new value of the property. -
1502*/ -
1503 -
1504/*! -
1505 \fn void QDockWidget::topLevelChanged(bool topLevel) -
1506 -
1507 This signal is emitted when the \l floating property changes. -
1508 The \a topLevel parameter is true if the dock widget is now floating; -
1509 otherwise it is false. -
1510 -
1511 \sa isWindow() -
1512*/ -
1513 -
1514/*! -
1515 \fn void QDockWidget::allowedAreasChanged(Qt::DockWidgetAreas allowedAreas) -
1516 -
1517 This signal is emitted when the \l allowedAreas property changes. The -
1518 \a allowedAreas parameter gives the new value of the property. -
1519*/ -
1520 -
1521/*! -
1522 \fn void QDockWidget::visibilityChanged(bool visible) -
1523 \since 4.3 -
1524 -
1525 This signal is emitted when the dock widget becomes \a visible (or -
1526 invisible). This happens when the widget is hidden or shown, as -
1527 well as when it is docked in a tabbed dock area and its tab -
1528 becomes selected or unselected. -
1529*/ -
1530 -
1531/*! -
1532 \fn void QDockWidget::dockLocationChanged(Qt::DockWidgetArea area) -
1533 \since 4.3 -
1534 -
1535 This signal is emitted when the dock widget is moved to another -
1536 dock \a area, or is moved to a different location in its current -
1537 dock area. This happens when the dock widget is moved -
1538 programmatically or is dragged to a new location by the user. -
1539*/ -
1540 -
1541/*! -
1542 \since 4.3 -
1543 -
1544 Sets an arbitrary \a widget as the dock widget's title bar. If \a widget -
1545 is 0, any custom title bar widget previously set on the dock widget is -
1546 removed, but not deleted, and the default title bar will be used -
1547 instead. -
1548 -
1549 If a title bar widget is set, QDockWidget will not use native window -
1550 decorations when it is floated. -
1551 -
1552 Here are some tips for implementing custom title bars: -
1553 -
1554 \list -
1555 \li Mouse events that are not explicitly handled by the title bar widget -
1556 must be ignored by calling QMouseEvent::ignore(). These events then -
1557 propagate to the QDockWidget parent, which handles them in the usual -
1558 manner, moving when the title bar is dragged, docking and undocking -
1559 when it is double-clicked, etc. -
1560 -
1561 \li When DockWidgetVerticalTitleBar is set on QDockWidget, the title -
1562 bar widget is repositioned accordingly. In resizeEvent(), the title -
1563 bar should check what orientation it should assume: -
1564 \snippet code/src_gui_widgets_qdockwidget.cpp 0 -
1565 -
1566 \li The title bar widget must have a valid QWidget::sizeHint() and -
1567 QWidget::minimumSizeHint(). These functions should take into account -
1568 the current orientation of the title bar. -
1569 -
1570 \li It is not possible to remove a title bar from a dock widget. However, -
1571 a similar effect can be achieved by setting a default constructed -
1572 QWidget as the title bar widget. -
1573 \endlist -
1574 -
1575 Using qobject_cast() as shown above, the title bar widget has full access -
1576 to its parent QDockWidget. Hence it can perform such operations as docking -
1577 and hiding in response to user actions. -
1578 -
1579 \sa titleBarWidget(), DockWidgetVerticalTitleBar -
1580*/ -
1581 -
1582void QDockWidget::setTitleBarWidget(QWidget *widget) -
1583{ -
1584 Q_D(QDockWidget);
executed (the execution status of this line is deduced): QDockWidgetPrivate * const d = d_func();
-
1585 QDockWidgetLayout *layout
executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1586 = qobject_cast<QDockWidgetLayout*>(this->layout());
executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1587 layout->setWidgetForRole(QDockWidgetLayout::TitleBar, widget);
executed (the execution status of this line is deduced): layout->setWidgetForRole(QDockWidgetLayout::TitleBar, widget);
-
1588 d->updateButtons();
executed (the execution status of this line is deduced): d->updateButtons();
-
1589 if (isWindow()) {
partially evaluated: isWindow()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1590 //this ensures the native decoration is drawn -
1591 d->setWindowState(true /*floating*/, true /*unplug*/);
executed (the execution status of this line is deduced): d->setWindowState(true , true );
-
1592 }
executed: }
Execution Count:3
3
1593}
executed: }
Execution Count:3
3
1594 -
1595/*! -
1596 \since 4.3 -
1597 Returns the custom title bar widget set on the QDockWidget, or 0 if no -
1598 custom title bar has been set. -
1599 -
1600 \sa setTitleBarWidget() -
1601*/ -
1602 -
1603QWidget *QDockWidget::titleBarWidget() const -
1604{ -
1605 QDockWidgetLayout *layout
never executed (the execution status of this line is deduced): QDockWidgetLayout *layout
-
1606 = qobject_cast<QDockWidgetLayout*>(this->layout());
never executed (the execution status of this line is deduced): = qobject_cast<QDockWidgetLayout*>(this->layout());
-
1607 return layout->widgetForRole(QDockWidgetLayout::TitleBar);
never executed: return layout->widgetForRole(QDockWidgetLayout::TitleBar);
0
1608} -
1609 -
1610QT_END_NAMESPACE -
1611 -
1612#include "qdockwidget.moc" -
1613#include "moc_qdockwidget.cpp" -
1614 -
1615#endif // QT_NO_DOCKWIDGET -
1616 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial