Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qlayoutpolicy.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:trivial-parsing-only
4
5
#
include
"qlayoutpolicy_p.h"
6
#
include
<
QtCore
/
qdebug
.
h
>
7
#
include
<
QtCore
/
qdatastream
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
/*!
12
\class QLayoutPolicy
13
\inmodule QtGui
14
\internal
15
*/
16
void
QLayoutPolicy
::
setControlType
(
ControlType
type)
17
{
18
/*
19
The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
20
etc. In memory, we pack it onto the available bits (CTSize) in
21
setControlType(), and unpack it here.
22
23
Example:
24
25
0x00000001 maps to 0
26
0x00000002 maps to 1
27
0x00000004 maps to 2
28
0x00000008 maps to 3
29
etc.
30
*/
31
bits.ctype = qCountTrailingZeroBits(quint32(type));
32
}
33
34
QLayoutPolicy
::
ControlType
QLayoutPolicy
::controlType()
const
35
{
36
return
QLayoutPolicy::ControlType(1 << bits.ctype);
37
}
38
39
#
ifndef
QT_NO_DATASTREAM
40
41
/*!
42
\relates QLayoutPolicy
43
44
Writes the size \a policy to the data stream \a stream.
45
46
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
47
*/
48
QDataStream
&
operator
<<(QDataStream &stream,
const
QLayoutPolicy
&policy)
49
{
50
// The order here is for historical reasons. (compatibility with Qt4)
51
quint32 data = (policy.bits.horPolicy |
// [0, 3]
52
policy.bits.verPolicy << 4 |
// [4, 7]
53
policy.bits.hfw << 8 |
// [8]
54
policy.bits.ctype << 9 |
// [9, 13]
55
policy.bits.wfh << 14 |
// [14]
56
//policy.bits.padding << 15 | // [15]
57
policy.bits.verStretch << 16 |
// [16, 23]
58
policy.bits.horStretch << 24);
// [24, 31]
59
return
stream << data;
60
}
61
62
#
define
VALUE_OF_BITS
(
data
,
bitstart
,
bitcount
)
(
(
data
>>
bitstart
)
&
(
(
1
<<
bitcount
)
-
1
)
)
63
64
/*!
65
\relates QLayoutPolicy
66
67
Reads the size \a policy from the data stream \a stream.
68
69
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
70
*/
71
QDataStream
&
operator
>>(QDataStream &stream,
QLayoutPolicy
&policy)
72
{
73
quint32 data;
74
stream >> data;
75
policy.bits.horPolicy =
VALUE_OF_BITS
(data, 0, 4);
76
policy.bits.verPolicy =
VALUE_OF_BITS
(data, 4, 4);
77
policy.bits.hfw =
VALUE_OF_BITS
(data, 8, 1);
78
policy.bits.ctype =
VALUE_OF_BITS
(data, 9, 5);
79
policy.bits.wfh =
VALUE_OF_BITS
(data, 14, 1);
80
policy.bits.padding = 0;
81
policy.bits.verStretch =
VALUE_OF_BITS
(data, 16, 8);
82
policy.bits.horStretch =
VALUE_OF_BITS
(data, 24, 8);
83
return
stream;
84
}
85
#
endif
// QT_NO_DATASTREAM
86
87
#
ifndef
QT_NO_DEBUG_STREAM
88
QDebug
operator
<<(QDebug dbg,
const
QLayoutPolicy
&p)
89
{
90
QDebugStateSaver saver(dbg);
91
dbg.nospace() <<
"QLayoutPolicy(horizontalPolicy = "
<< p.horizontalPolicy()
92
<<
", verticalPolicy = "
<< p.verticalPolicy() <<
')'
;
93
return
dbg;
94
}
95
#
endif
96
97
QT_END_NAMESPACE
98
99
#
include
"moc_qlayoutpolicy_p.cpp"
QLayoutPolicy
\inmodule QtGui
Definition
qlayoutpolicy_p.h:33
QLayoutPolicy::operator>>
friend QDataStream & operator>>(QDataStream &, QLayoutPolicy &)
Reads the size policy from the data stream stream.
Definition
qlayoutpolicy.cpp:71
QLayoutPolicy::operator<<
friend QDataStream & operator<<(QDataStream &, const QLayoutPolicy &)
Writes the size policy to the data stream stream.
Definition
qlayoutpolicy.cpp:48
QLayoutPolicy::ControlType
ControlType
Definition
qlayoutpolicy_p.h:54
QLayoutPolicy::setControlType
Q_GUI_EXPORT void setControlType(ControlType type)
Definition
qlayoutpolicy.cpp:16
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
operator<<
QDebug operator<<(QDebug dbg, const QLayoutPolicy &p)
Definition
qlayoutpolicy.cpp:88
VALUE_OF_BITS
#define VALUE_OF_BITS(data, bitstart, bitcount)
Definition
qlayoutpolicy.cpp:62
qtbase
src
gui
util
qlayoutpolicy.cpp
Generated on
for Qt by
1.18.0