qradiobutton.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qradiobutton.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5class QRadioButtonPrivate : public QAbstractButtonPrivate-
6{-
7 inline QRadioButton* q_func() { return static_cast<QRadioButton *>(q_ptr); } inline const QRadioButton* q_func() const { return static_cast<const QRadioButton *>(q_ptr); } friend class QRadioButton;-
8-
9public:-
10 QRadioButtonPrivate() : QAbstractButtonPrivate(QSizePolicy::RadioButton), hovering(true) {}
never executed: end of block
0
11 void init();-
12 uint hovering : 1;-
13};-
14-
15-
16-
17-
18void QRadioButtonPrivate::init()-
19{-
20 QRadioButton * const q = q_func();-
21 q->setCheckable(true);-
22 q->setAutoExclusive(true);-
23 q->setMouseTracking(true);-
24 q->setForegroundRole(QPalette::WindowText);-
25 setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem);-
26}
never executed: end of block
0
27QRadioButton::QRadioButton(QWidget *parent)-
28 : QAbstractButton(*new QRadioButtonPrivate, parent)-
29{-
30 QRadioButtonPrivate * const d = d_func();-
31 d->init();-
32}
never executed: end of block
0
33-
34-
35-
36-
37QRadioButton::~QRadioButton()-
38{-
39}-
40-
41-
42-
43-
44-
45-
46-
47QRadioButton::QRadioButton(const QString &text, QWidget *parent)-
48 : QAbstractButton(*new QRadioButtonPrivate, parent)-
49{-
50 QRadioButtonPrivate * const d = d_func();-
51 d->init();-
52 setText(text);-
53}
never executed: end of block
0
54void QRadioButton::initStyleOption(QStyleOptionButton *option) const-
55{-
56 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
57 return;
never executed: return;
0
58 const QRadioButtonPrivate * const d = d_func();-
59 option->initFrom(this);-
60 option->text = d->text;-
61 option->icon = d->icon;-
62 option->iconSize = iconSize();-
63 if (d->down
d->downDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
64 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
65 option->state |= (
(d->checked)Description
TRUEnever evaluated
FALSEnever evaluated
d->checked)
(d->checked)Description
TRUEnever evaluated
FALSEnever evaluated
? QStyle::State_On : QStyle::State_Off;
0
66 if (testAttribute(Qt::WA_Hover)
testAttribute(Qt::WA_Hover)Description
TRUEnever evaluated
FALSEnever evaluated
&& underMouse()
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
67 option->state.setFlag(QStyle::State_MouseOver, d->hovering);-
68 }
never executed: end of block
0
69}
never executed: end of block
0
70-
71-
72-
73-
74QSize QRadioButton::sizeHint() const-
75{-
76 const QRadioButtonPrivate * const d = d_func();-
77 if (d->sizeHint.isValid()
d->sizeHint.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
78 return
never executed: return d->sizeHint;
d->sizeHint;
never executed: return d->sizeHint;
0
79 ensurePolished();-
80 QStyleOptionButton opt;-
81 initStyleOption(&opt);-
82 QSize sz = style()->itemTextRect(fontMetrics(), QRect(), Qt::TextShowMnemonic,-
83 false, text()).size();-
84 if (!opt.icon.isNull()
!opt.icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
85 sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height()));
never executed: sz = QSize(sz.width() + opt.iconSize.width() + 4, qMax(sz.height(), opt.iconSize.height()));
0
86 d->sizeHint = (style()->sizeFromContents(QStyle::CT_RadioButton, &opt, sz, this).-
87 expandedTo(QApplication::globalStrut()));-
88 return
never executed: return d->sizeHint;
d->sizeHint;
never executed: return d->sizeHint;
0
89}-
90-
91-
92-
93-
94QSize QRadioButton::minimumSizeHint() const-
95{-
96 return
never executed: return sizeHint();
sizeHint();
never executed: return sizeHint();
0
97}-
98-
99-
100-
101-
102bool QRadioButton::hitButton(const QPoint &pos) const-
103{-
104 QStyleOptionButton opt;-
105 initStyleOption(&opt);-
106 return
never executed: return style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos);
style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos);
never executed: return style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos);
0
107}-
108-
109-
110-
111-
112void QRadioButton::mouseMoveEvent(QMouseEvent *e)-
113{-
114 QRadioButtonPrivate * const d = d_func();-
115 if (testAttribute(Qt::WA_Hover)
testAttribute(Qt::WA_Hover)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
116 bool hit = false;-
117 if (underMouse()
underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
118 hit = hitButton(e->pos());
never executed: hit = hitButton(e->pos());
0
119-
120 if (hit != d->hovering
hit != d->hoveringDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
121 update();-
122 d->hovering = hit;-
123 }
never executed: end of block
0
124 }
never executed: end of block
0
125-
126 QAbstractButton::mouseMoveEvent(e);-
127}
never executed: end of block
0
128-
129-
130-
131void QRadioButton::paintEvent(QPaintEvent *)-
132{-
133 QStylePainter p(this);-
134 QStyleOptionButton opt;-
135 initStyleOption(&opt);-
136 p.drawControl(QStyle::CE_RadioButton, opt);-
137}
never executed: end of block
0
138-
139-
140bool QRadioButton::event(QEvent *e)-
141{-
142 QRadioButtonPrivate * const d = d_func();-
143 if (e->type() == QEvent::StyleChange
e->type() == Q...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
144-
145-
146-
147 )-
148 d->setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem);
never executed: d->setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem);
0
149 return
never executed: return QAbstractButton::event(e);
QAbstractButton::event(e);
never executed: return QAbstractButton::event(e);
0
150}-
151-
152-
153-
154-
Switch to Source codePreprocessed file

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