Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qradiobutton.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | class 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 | - | |||||||||||||
9 | public: | - | ||||||||||||
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 | - | |||||||||||||
18 | void 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 | ||||||||||||
27 | QRadioButton::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 | - | |||||||||||||
37 | QRadioButton::~QRadioButton() | - | ||||||||||||
38 | { | - | ||||||||||||
39 | } | - | ||||||||||||
40 | - | |||||||||||||
41 | - | |||||||||||||
42 | - | |||||||||||||
43 | - | |||||||||||||
44 | - | |||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | QRadioButton::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 | ||||||||||||
54 | void QRadioButton::initStyleOption(QStyleOptionButton *option) const | - | ||||||||||||
55 | { | - | ||||||||||||
56 | if (!option
| 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
| 0 | ||||||||||||
64 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 | ||||||||||||
65 | option->state |= (
| 0 | ||||||||||||
66 | if (testAttribute(Qt::WA_Hover)
| 0 | ||||||||||||
67 | if (d->hovering
| 0 | ||||||||||||
68 | option->state |= QStyle::State_MouseOver; never executed: option->state |= QStyle::State_MouseOver; | 0 | ||||||||||||
69 | else | - | ||||||||||||
70 | option->state &= ~QStyle::State_MouseOver; never executed: option->state &= ~QStyle::State_MouseOver; | 0 | ||||||||||||
71 | } | - | ||||||||||||
72 | } never executed: end of block | 0 | ||||||||||||
73 | - | |||||||||||||
74 | - | |||||||||||||
75 | - | |||||||||||||
76 | - | |||||||||||||
77 | QSize QRadioButton::sizeHint() const | - | ||||||||||||
78 | { | - | ||||||||||||
79 | const QRadioButtonPrivate * const d = d_func(); | - | ||||||||||||
80 | if (d->sizeHint.isValid()
| 0 | ||||||||||||
81 | return never executed: d->sizeHint;return d->sizeHint; never executed: return d->sizeHint; | 0 | ||||||||||||
82 | ensurePolished(); | - | ||||||||||||
83 | QStyleOptionButton opt; | - | ||||||||||||
84 | initStyleOption(&opt); | - | ||||||||||||
85 | QSize sz = style()->itemTextRect(fontMetrics(), QRect(), Qt::TextShowMnemonic, | - | ||||||||||||
86 | false, text()).size(); | - | ||||||||||||
87 | if (!opt.icon.isNull()
| 0 | ||||||||||||
88 | 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 | ||||||||||||
89 | d->sizeHint = (style()->sizeFromContents(QStyle::CT_RadioButton, &opt, sz, this). | - | ||||||||||||
90 | expandedTo(QApplication::globalStrut())); | - | ||||||||||||
91 | return never executed: d->sizeHint;return d->sizeHint; never executed: return d->sizeHint; | 0 | ||||||||||||
92 | } | - | ||||||||||||
93 | - | |||||||||||||
94 | - | |||||||||||||
95 | - | |||||||||||||
96 | - | |||||||||||||
97 | QSize QRadioButton::minimumSizeHint() const | - | ||||||||||||
98 | { | - | ||||||||||||
99 | return never executed: sizeHint();return sizeHint(); never executed: return sizeHint(); | 0 | ||||||||||||
100 | } | - | ||||||||||||
101 | - | |||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | - | |||||||||||||
105 | bool QRadioButton::hitButton(const QPoint &pos) const | - | ||||||||||||
106 | { | - | ||||||||||||
107 | QStyleOptionButton opt; | - | ||||||||||||
108 | initStyleOption(&opt); | - | ||||||||||||
109 | return never executed: style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos);return style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos); never executed: return style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, this).contains(pos); | 0 | ||||||||||||
110 | } | - | ||||||||||||
111 | - | |||||||||||||
112 | - | |||||||||||||
113 | - | |||||||||||||
114 | - | |||||||||||||
115 | void QRadioButton::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||
116 | { | - | ||||||||||||
117 | QRadioButtonPrivate * const d = d_func(); | - | ||||||||||||
118 | if (testAttribute(Qt::WA_Hover)
| 0 | ||||||||||||
119 | bool hit = false; | - | ||||||||||||
120 | if (underMouse()
| 0 | ||||||||||||
121 | hit = hitButton(e->pos()); never executed: hit = hitButton(e->pos()); | 0 | ||||||||||||
122 | - | |||||||||||||
123 | if (hit != d->hovering
| 0 | ||||||||||||
124 | update(); | - | ||||||||||||
125 | d->hovering = hit; | - | ||||||||||||
126 | } never executed: end of block | 0 | ||||||||||||
127 | } never executed: end of block | 0 | ||||||||||||
128 | - | |||||||||||||
129 | QAbstractButton::mouseMoveEvent(e); | - | ||||||||||||
130 | } never executed: end of block | 0 | ||||||||||||
131 | - | |||||||||||||
132 | - | |||||||||||||
133 | - | |||||||||||||
134 | void QRadioButton::paintEvent(QPaintEvent *) | - | ||||||||||||
135 | { | - | ||||||||||||
136 | QStylePainter p(this); | - | ||||||||||||
137 | QStyleOptionButton opt; | - | ||||||||||||
138 | initStyleOption(&opt); | - | ||||||||||||
139 | p.drawControl(QStyle::CE_RadioButton, opt); | - | ||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||
141 | - | |||||||||||||
142 | - | |||||||||||||
143 | bool QRadioButton::event(QEvent *e) | - | ||||||||||||
144 | { | - | ||||||||||||
145 | QRadioButtonPrivate * const d = d_func(); | - | ||||||||||||
146 | if (e->type() == QEvent::StyleChange
| 0 | ||||||||||||
147 | - | |||||||||||||
148 | - | |||||||||||||
149 | - | |||||||||||||
150 | ) | - | ||||||||||||
151 | d->setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem); never executed: d->setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem); | 0 | ||||||||||||
152 | return never executed: QAbstractButton::event(e);return QAbstractButton::event(e); never executed: return QAbstractButton::event(e); | 0 | ||||||||||||
153 | } | - | ||||||||||||
154 | - | |||||||||||||
155 | - | |||||||||||||
156 | - | |||||||||||||
157 | - | |||||||||||||
Switch to Source code | Preprocessed file |