qdialogbuttonbox.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdialogbuttonbox.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4class QDialogButtonBoxPrivate : public QWidgetPrivate-
5{-
6 inline QDialogButtonBox* q_func() { return static_cast<QDialogButtonBox *>(q_ptr); } inline const QDialogButtonBox* q_func() const { return static_cast<const QDialogButtonBox *>(q_ptr); } friend class QDialogButtonBox;-
7-
8public:-
9 QDialogButtonBoxPrivate(Qt::Orientation orient);-
10-
11 QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles];-
12 QHash<QPushButton *, QDialogButtonBox::StandardButton> standardButtonHash;-
13-
14 Qt::Orientation orientation;-
15 QDialogButtonBox::ButtonLayout layoutPolicy;-
16 QBoxLayout *buttonLayout;-
17 bool internalRemove;-
18 bool center;-
19-
20 void createStandardButtons(QDialogButtonBox::StandardButtons buttons);-
21-
22 void layoutButtons();-
23 void initLayout();-
24 void resetLayout();-
25 QPushButton *createButton(QDialogButtonBox::StandardButton button, bool doLayout = true);-
26 void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout = true);-
27 void _q_handleButtonDestroyed();-
28 void _q_handleButtonClicked();-
29 void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse);-
30 void retranslateStrings();-
31};-
32-
33QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient)-
34 : orientation(orient), buttonLayout(0), internalRemove(false), center(false)-
35{-
36}
never executed: end of block
0
37-
38void QDialogButtonBoxPrivate::initLayout()-
39{-
40 QDialogButtonBox * const q = q_func();-
41 layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q));-
42 bool createNewLayout = buttonLayout == 0
buttonLayout == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
43 || (orientation == Qt::Horizontal
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
&& qobject_cast<QVBoxLayout *>(buttonLayout) != 0
qobject_cast<Q...onLayout) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
44 || (orientation == Qt::Vertical
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
&& qobject_cast<QHBoxLayout *>(buttonLayout) != 0
qobject_cast<Q...onLayout) != 0Description
TRUEnever evaluated
FALSEnever evaluated
);
0
45 if (createNewLayout
createNewLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
46 delete buttonLayout;-
47 if (orientation == Qt::Horizontal
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
48 buttonLayout = new QHBoxLayout(q);
never executed: buttonLayout = new QHBoxLayout(q);
0
49 else-
50 buttonLayout = new QVBoxLayout(q);
never executed: buttonLayout = new QVBoxLayout(q);
0
51 }-
52-
53 int left, top, right, bottom;-
54 setLayoutItemMargins(QStyle::SE_PushButtonLayoutItem);-
55 getLayoutItemMargins(&left, &top, &right, &bottom);-
56 buttonLayout->setContentsMargins(-left, -top, -right, -bottom);-
57-
58 if (!q->testAttribute(Qt::WA_WState_OwnSizePolicy)
!q->testAttrib...OwnSizePolicy)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
59 QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::ButtonBox);-
60 if (orientation == Qt::Vertical
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
61 sp.transpose();
never executed: sp.transpose();
0
62 q->setSizePolicy(sp);-
63 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
64 }
never executed: end of block
0
65}
never executed: end of block
0
66-
67void QDialogButtonBoxPrivate::resetLayout()-
68{-
69-
70 initLayout();-
71 layoutButtons();-
72}
never executed: end of block
0
73-
74void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList,-
75 bool reverse)-
76{-
77 int start = reverse
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
? buttonList.count() - 1 : 0;
0
78 int end = reverse
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
? -1 : buttonList.count();
0
79 int step = reverse
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
? -1 : 1;
0
80-
81 for (int i = start; i != end
i != endDescription
TRUEnever evaluated
FALSEnever evaluated
; i += step) {
0
82 QAbstractButton *button = buttonList.at(i);-
83 buttonLayout->addWidget(button);-
84 button->show();-
85 }
never executed: end of block
0
86}
never executed: end of block
0
87-
88void QDialogButtonBoxPrivate::layoutButtons()-
89{-
90 QDialogButtonBox * const q = q_func();-
91 const int MacGap = 36 - 8;-
92-
93 for (int i = buttonLayout->count() - 1; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --i) {
0
94 QLayoutItem *item = buttonLayout->takeAt(i);-
95 if (QWidget *widget = item->widget()
QWidget *widge...item->widget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
96 widget->hide();
never executed: widget->hide();
0
97 delete item;-
98 }
never executed: end of block
0
99-
100 int tmpPolicy = layoutPolicy;-
101-
102 static const int M = 5;-
103 static const int ModalRoles[M] = { QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole,-
104 QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole };-
105 if (tmpPolicy == QDialogButtonBox::MacLayout
tmpPolicy == Q...Box::MacLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
106 bool hasModalButton = false;-
107 for (int i = 0; i < M
i < MDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
108 if (!buttonLists[ModalRoles[i]].isEmpty()
!buttonLists[M...[i]].isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
109 hasModalButton = true;-
110 break;
never executed: break;
0
111 }-
112 }
never executed: end of block
0
113 if (!hasModalButton
!hasModalButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
114 tmpPolicy = 4;
never executed: tmpPolicy = 4;
0
115 }
never executed: end of block
0
116-
117 const int *currentLayout = QPlatformDialogHelper::buttonLayout(-
118 orientation, static_cast<QPlatformDialogHelper::ButtonLayout>(tmpPolicy));-
119-
120 if (center
centerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
121 buttonLayout->addStretch();
never executed: buttonLayout->addStretch();
0
122-
123 const QList<QAbstractButton *> &acceptRoleList = buttonLists[QPlatformDialogHelper::AcceptRole];-
124-
125 while (*
*currentLayout...logHelper::EOLDescription
TRUEnever evaluated
FALSEnever evaluated
currentLayout != QPlatformDialogHelper::EOL
*currentLayout...logHelper::EOLDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
126 int role = (*currentLayout & ~QPlatformDialogHelper::Reverse);-
127 bool reverse = (*currentLayout & QPlatformDialogHelper::Reverse);-
128-
129 switch (role) {-
130 case
never executed: case QPlatformDialogHelper::Stretch:
QPlatformDialogHelper::Stretch:
never executed: case QPlatformDialogHelper::Stretch:
0
131 if (!center
!centerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
132 buttonLayout->addStretch();
never executed: buttonLayout->addStretch();
0
133 break;
never executed: break;
0
134 case
never executed: case QPlatformDialogHelper::AcceptRole:
QPlatformDialogHelper::AcceptRole:
never executed: case QPlatformDialogHelper::AcceptRole:
{
0
135 if (acceptRoleList.isEmpty()
acceptRoleList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
136 break;
never executed: break;
0
137-
138 QAbstractButton *button = acceptRoleList.first();-
139 buttonLayout->addWidget(button);-
140 button->show();-
141 }-
142 break;
never executed: break;
0
143 case
never executed: case QPlatformDialogHelper::AlternateRole:
QPlatformDialogHelper::AlternateRole:
never executed: case QPlatformDialogHelper::AlternateRole:
0
144 if (acceptRoleList.size() > 1
acceptRoleList.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
145 addButtonsToLayout(acceptRoleList.mid(1), reverse);
never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse);
0
146 break;
never executed: break;
0
147 case
never executed: case QPlatformDialogHelper::DestructiveRole:
QPlatformDialogHelper::DestructiveRole:
never executed: case QPlatformDialogHelper::DestructiveRole:
0
148 {-
149 const QList<QAbstractButton *> &list = buttonLists[role];-
150 if (tmpPolicy == QDialogButtonBox::MacLayout
tmpPolicy == Q...Box::MacLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 && !list.isEmpty()
!list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& buttonLayout->count() > 1
buttonLayout->count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
152 buttonLayout->addSpacing(MacGap);
never executed: buttonLayout->addSpacing(MacGap);
0
153-
154 addButtonsToLayout(list, reverse);-
155-
156-
157-
158-
159-
160 if (tmpPolicy == QDialogButtonBox::MacLayout
tmpPolicy == Q...Box::MacLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
&& !list.isEmpty()
!list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
161 buttonLayout->addSpacing(MacGap);
never executed: buttonLayout->addSpacing(MacGap);
0
162 }-
163 break;
never executed: break;
0
164 case
never executed: case QPlatformDialogHelper::RejectRole:
QPlatformDialogHelper::RejectRole:
never executed: case QPlatformDialogHelper::RejectRole:
0
165 case
never executed: case QPlatformDialogHelper::ActionRole:
QPlatformDialogHelper::ActionRole:
never executed: case QPlatformDialogHelper::ActionRole:
0
166 case
never executed: case QPlatformDialogHelper::HelpRole:
QPlatformDialogHelper::HelpRole:
never executed: case QPlatformDialogHelper::HelpRole:
0
167 case
never executed: case QPlatformDialogHelper::YesRole:
QPlatformDialogHelper::YesRole:
never executed: case QPlatformDialogHelper::YesRole:
0
168 case
never executed: case QPlatformDialogHelper::NoRole:
QPlatformDialogHelper::NoRole:
never executed: case QPlatformDialogHelper::NoRole:
0
169 case
never executed: case QPlatformDialogHelper::ApplyRole:
QPlatformDialogHelper::ApplyRole:
never executed: case QPlatformDialogHelper::ApplyRole:
0
170 case
never executed: case QPlatformDialogHelper::ResetRole:
QPlatformDialogHelper::ResetRole:
never executed: case QPlatformDialogHelper::ResetRole:
0
171 addButtonsToLayout(buttonLists[role], reverse);-
172 }
never executed: end of block
0
173 ++currentLayout;-
174 }
never executed: end of block
0
175-
176 QWidget *lastWidget = 0;-
177 q->setFocusProxy(0);-
178 for (int i = 0; i < buttonLayout->count()
i < buttonLayout->count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
179 QLayoutItem *item = buttonLayout->itemAt(i);-
180 if (QWidget *widget = item->widget()
QWidget *widge...item->widget()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
181 if (lastWidget
lastWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
182 QWidget::setTabOrder(lastWidget, widget);
never executed: QWidget::setTabOrder(lastWidget, widget);
0
183 else-
184 q->setFocusProxy(widget);
never executed: q->setFocusProxy(widget);
0
185 lastWidget = widget;-
186 }
never executed: end of block
0
187 }
never executed: end of block
0
188-
189 if (center
centerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
190 buttonLayout->addStretch();
never executed: buttonLayout->addStretch();
0
191}
never executed: end of block
0
192-
193QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardButton sbutton,-
194 bool doLayout)-
195{-
196 QDialogButtonBox * const q = q_func();-
197 int icon = 0;-
198-
199 switch (sbutton) {-
200 case
never executed: case QDialogButtonBox::Ok:
QDialogButtonBox::Ok:
never executed: case QDialogButtonBox::Ok:
0
201 icon = QStyle::SP_DialogOkButton;-
202 break;
never executed: break;
0
203 case
never executed: case QDialogButtonBox::Save:
QDialogButtonBox::Save:
never executed: case QDialogButtonBox::Save:
0
204 icon = QStyle::SP_DialogSaveButton;-
205 break;
never executed: break;
0
206 case
never executed: case QDialogButtonBox::Open:
QDialogButtonBox::Open:
never executed: case QDialogButtonBox::Open:
0
207 icon = QStyle::SP_DialogOpenButton;-
208 break;
never executed: break;
0
209 case
never executed: case QDialogButtonBox::Cancel:
QDialogButtonBox::Cancel:
never executed: case QDialogButtonBox::Cancel:
0
210 icon = QStyle::SP_DialogCancelButton;-
211 break;
never executed: break;
0
212 case
never executed: case QDialogButtonBox::Close:
QDialogButtonBox::Close:
never executed: case QDialogButtonBox::Close:
0
213 icon = QStyle::SP_DialogCloseButton;-
214 break;
never executed: break;
0
215 case
never executed: case QDialogButtonBox::Apply:
QDialogButtonBox::Apply:
never executed: case QDialogButtonBox::Apply:
0
216 icon = QStyle::SP_DialogApplyButton;-
217 break;
never executed: break;
0
218 case
never executed: case QDialogButtonBox::Reset:
QDialogButtonBox::Reset:
never executed: case QDialogButtonBox::Reset:
0
219 icon = QStyle::SP_DialogResetButton;-
220 break;
never executed: break;
0
221 case
never executed: case QDialogButtonBox::Help:
QDialogButtonBox::Help:
never executed: case QDialogButtonBox::Help:
0
222 icon = QStyle::SP_DialogHelpButton;-
223 break;
never executed: break;
0
224 case
never executed: case QDialogButtonBox::Discard:
QDialogButtonBox::Discard:
never executed: case QDialogButtonBox::Discard:
0
225 icon = QStyle::SP_DialogDiscardButton;-
226 break;
never executed: break;
0
227 case
never executed: case QDialogButtonBox::Yes:
QDialogButtonBox::Yes:
never executed: case QDialogButtonBox::Yes:
0
228 icon = QStyle::SP_DialogYesButton;-
229 break;
never executed: break;
0
230 case
never executed: case QDialogButtonBox::No:
QDialogButtonBox::No:
never executed: case QDialogButtonBox::No:
0
231 icon = QStyle::SP_DialogNoButton;-
232 break;
never executed: break;
0
233 case
never executed: case QDialogButtonBox::YesToAll:
QDialogButtonBox::YesToAll:
never executed: case QDialogButtonBox::YesToAll:
0
234 case
never executed: case QDialogButtonBox::NoToAll:
QDialogButtonBox::NoToAll:
never executed: case QDialogButtonBox::NoToAll:
0
235 case
never executed: case QDialogButtonBox::SaveAll:
QDialogButtonBox::SaveAll:
never executed: case QDialogButtonBox::SaveAll:
0
236 case
never executed: case QDialogButtonBox::Abort:
QDialogButtonBox::Abort:
never executed: case QDialogButtonBox::Abort:
0
237 case
never executed: case QDialogButtonBox::Retry:
QDialogButtonBox::Retry:
never executed: case QDialogButtonBox::Retry:
0
238 case
never executed: case QDialogButtonBox::Ignore:
QDialogButtonBox::Ignore:
never executed: case QDialogButtonBox::Ignore:
0
239 case
never executed: case QDialogButtonBox::RestoreDefaults:
QDialogButtonBox::RestoreDefaults:
never executed: case QDialogButtonBox::RestoreDefaults:
0
240 break;
never executed: break;
0
241 case
never executed: case QDialogButtonBox::NoButton:
QDialogButtonBox::NoButton:
never executed: case QDialogButtonBox::NoButton:
0
242 return
never executed: return 0;
0;
never executed: return 0;
0
243 ;-
244 }-
245 QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q);-
246 QStyle *style = q->style();-
247 if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q)
style->styleHi...veIcons, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
&& icon != 0
icon != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
248 button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
never executed: button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
0
249 if (style != QApplication::style()
style != QApplication::style()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
250 button->setStyle(style);
never executed: button->setStyle(style);
0
251 standardButtonHash.insert(button, sbutton);-
252 QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(static_cast<QPlatformDialogHelper::StandardButton>(sbutton));-
253 if (__builtin_expect(!!(role == QPlatformDialogHelper::InvalidRole), false)
__builtin_expe...dRole), false)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
254 QMessageLogger(__FILE__, 410, __PRETTY_FUNCTION__).warning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
never executed: QMessageLogger(__FILE__, 410, __PRETTY_FUNCTION__).warning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
0
255 else-
256 addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout);
never executed: addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout);
0
257 return
never executed: return button;
button;
never executed: return button;
0
258}-
259-
260void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role,-
261 bool doLayout)-
262{-
263 QDialogButtonBox * const q = q_func();-
264 QObject::connect(button, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "428"), q, qFlagLocation("1""_q_handleButtonClicked()" "\0" __FILE__ ":" "428"));-
265 QObject::connect(button, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "429"), q, qFlagLocation("1""_q_handleButtonDestroyed()" "\0" __FILE__ ":" "429"));-
266 buttonLists[role].append(button);-
267 if (doLayout
doLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
268 layoutButtons();
never executed: layoutButtons();
0
269}
never executed: end of block
0
270-
271void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardButtons buttons)-
272{-
273 uint i = QDialogButtonBox::FirstButton;-
274 while (i <= QDialogButtonBox::LastButton
i <= QDialogBu...ox::LastButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
275 if (i & buttons
i & buttonsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
276 createButton(QDialogButtonBox::StandardButton(i), false);-
277 }
never executed: end of block
0
278 i = i << 1;-
279 }
never executed: end of block
0
280 layoutButtons();-
281}
never executed: end of block
0
282-
283void QDialogButtonBoxPrivate::retranslateStrings()-
284{-
285 typedef QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator Iterator;-
286-
287 const Iterator end = standardButtonHash.end();-
288 for (Iterator it = standardButtonHash.begin(); it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
289 const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(it.value());-
290 if (!text.isEmpty()
!text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
291 it.key()->setText(text);
never executed: it.key()->setText(text);
0
292 }
never executed: end of block
0
293}
never executed: end of block
0
294-
295-
296-
297-
298-
299-
300QDialogButtonBox::QDialogButtonBox(QWidget *parent)-
301 : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)-
302{-
303 d_func()->initLayout();-
304}
never executed: end of block
0
305-
306-
307-
308-
309-
310-
311QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)-
312 : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)-
313{-
314 d_func()->initLayout();-
315}
never executed: end of block
0
316QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent)-
317 : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)-
318{-
319 d_func()->initLayout();-
320 d_func()->createStandardButtons(buttons);-
321}
never executed: end of block
0
322-
323-
324-
325-
326-
327-
328-
329QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,-
330 QWidget *parent)-
331 : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)-
332{-
333 d_func()->initLayout();-
334 d_func()->createStandardButtons(buttons);-
335}
never executed: end of block
0
336-
337-
338-
339-
340QDialogButtonBox::~QDialogButtonBox()-
341{-
342}-
343Qt::Orientation QDialogButtonBox::orientation() const-
344{-
345 return
never executed: return d_func()->orientation;
d_func()->orientation;
never executed: return d_func()->orientation;
0
346}-
347-
348void QDialogButtonBox::setOrientation(Qt::Orientation orientation)-
349{-
350 QDialogButtonBoxPrivate * const d = d_func();-
351 if (orientation == d->orientation
orientation == d->orientationDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
352 return;
never executed: return;
0
353-
354 d->orientation = orientation;-
355 d->resetLayout();-
356}
never executed: end of block
0
357-
358-
359-
360-
361-
362-
363void QDialogButtonBox::clear()-
364{-
365 QDialogButtonBoxPrivate * const d = d_func();-
366-
367-
368 d->standardButtonHash.clear();-
369 for (int i = 0; i < NRoles
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
370 QList<QAbstractButton *> &list = d->buttonLists[i];-
371 while (list.count()
list.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
372 QAbstractButton *button = list.takeAt(0);-
373 QObject::disconnect(button, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "668"), this, qFlagLocation("1""_q_handleButtonDestroyed()" "\0" __FILE__ ":" "668"));-
374 delete button;-
375 }
never executed: end of block
0
376 }
never executed: end of block
0
377}
never executed: end of block
0
378-
379-
380-
381-
382-
383-
384QList<QAbstractButton *> QDialogButtonBox::buttons() const-
385{-
386 const QDialogButtonBoxPrivate * const d = d_func();-
387 QList<QAbstractButton *> finalList;-
388 for (int i = 0; i < NRoles
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
389 const QList<QAbstractButton *> &list = d->buttonLists[i];-
390 for (int j = 0; j < list.count()
j < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j)
0
391 finalList.append(list.at(j));
never executed: finalList.append(list.at(j));
0
392 }
never executed: end of block
0
393 return
never executed: return finalList;
finalList;
never executed: return finalList;
0
394}-
395-
396-
397-
398-
399-
400-
401-
402QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *button) const-
403{-
404 const QDialogButtonBoxPrivate * const d = d_func();-
405 for (int i = 0; i < NRoles
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
406 const QList<QAbstractButton *> &list = d->buttonLists[i];-
407 for (int j = 0; j < list.count()
j < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
408 if (list.at(j) == button
list.at(j) == buttonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
409 return
never executed: return ButtonRole(i);
ButtonRole(i);
never executed: return ButtonRole(i);
0
410 }
never executed: end of block
0
411 }
never executed: end of block
0
412 return
never executed: return InvalidRole;
InvalidRole;
never executed: return InvalidRole;
0
413}-
414-
415-
416-
417-
418-
419-
420void QDialogButtonBox::removeButton(QAbstractButton *button)-
421{-
422 QDialogButtonBoxPrivate * const d = d_func();-
423-
424 if (!button
!buttonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
425 return;
never executed: return;
0
426-
427-
428 if (QPushButton *pushButton = qobject_cast<QPushButton *>(button)
QPushButton *p...ton *>(button)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
429 d->standardButtonHash.remove(pushButton);
never executed: d->standardButtonHash.remove(pushButton);
0
430 for (int i = 0; i < NRoles
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
431 QList<QAbstractButton *> &list = d->buttonLists[i];-
432 for (int j = 0; j < list.count()
j < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
433 if (list.at(j) == button
list.at(j) == buttonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
434 list.takeAt(j);-
435 if (!d->internalRemove
!d->internalRemoveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
436 disconnect(button, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "731"), this, qFlagLocation("1""_q_handleButtonClicked()" "\0" __FILE__ ":" "731"));-
437 disconnect(button, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "732"), this, qFlagLocation("1""_q_handleButtonDestroyed()" "\0" __FILE__ ":" "732"));-
438 }
never executed: end of block
0
439 break;
never executed: break;
0
440 }-
441 }
never executed: end of block
0
442 }
never executed: end of block
0
443 if (!d->internalRemove
!d->internalRemoveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
444 button->setParent(0);
never executed: button->setParent(0);
0
445}
never executed: end of block
0
446void QDialogButtonBox::addButton(QAbstractButton *button, ButtonRole role)-
447{-
448 QDialogButtonBoxPrivate * const d = d_func();-
449 if (__builtin_expect(!!(role <= InvalidRole || role >= NRoles), false)
__builtin_expe...Roles), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
450 QMessageLogger(__FILE__, 757, __PRETTY_FUNCTION__).warning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");-
451 return;
never executed: return;
0
452 }-
453 removeButton(button);-
454 button->setParent(this);-
455 d->addButton(button, role);-
456}
never executed: end of block
0
457QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role)-
458{-
459 QDialogButtonBoxPrivate * const d = d_func();-
460 if (__builtin_expect(!!(role <= InvalidRole || role >= NRoles), false)
__builtin_expe...Roles), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
461 QMessageLogger(__FILE__, 776, __PRETTY_FUNCTION__).warning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");-
462 return
never executed: return 0;
0;
never executed: return 0;
0
463 }-
464 QPushButton *button = new QPushButton(text, this);-
465 d->addButton(button, role);-
466 return
never executed: return button;
button;
never executed: return button;
0
467}-
468QPushButton *QDialogButtonBox::addButton(StandardButton button)-
469{-
470 QDialogButtonBoxPrivate * const d = d_func();-
471 return
never executed: return d->createButton(button);
d->createButton(button);
never executed: return d->createButton(button);
0
472}-
473void QDialogButtonBox::setStandardButtons(StandardButtons buttons)-
474{-
475 QDialogButtonBoxPrivate * const d = d_func();-
476-
477 qDeleteAll(d->standardButtonHash.keys());-
478 d->standardButtonHash.clear();-
479-
480 d->createStandardButtons(buttons);-
481}
never executed: end of block
0
482-
483QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons() const-
484{-
485 const QDialogButtonBoxPrivate * const d = d_func();-
486 StandardButtons standardButtons = NoButton;-
487 QHash<QPushButton *, StandardButton>::const_iterator it = d->standardButtonHash.constBegin();-
488 while (it != d->standardButtonHash.constEnd()
it != d->stand...ash.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
489 standardButtons |= it.value();-
490 ++it;-
491 }
never executed: end of block
0
492 return
never executed: return standardButtons;
standardButtons;
never executed: return standardButtons;
0
493}-
494-
495-
496-
497-
498-
499-
500-
501QPushButton *QDialogButtonBox::button(StandardButton which) const-
502{-
503 const QDialogButtonBoxPrivate * const d = d_func();-
504 return
never executed: return d->standardButtonHash.key(which);
d->standardButtonHash.key(which);
never executed: return d->standardButtonHash.key(which);
0
505}-
506-
507-
508-
509-
510-
511-
512-
513QDialogButtonBox::StandardButton QDialogButtonBox::standardButton(QAbstractButton *button) const-
514{-
515 const QDialogButtonBoxPrivate * const d = d_func();-
516 return
never executed: return d->standardButtonHash.value(static_cast<QPushButton *>(button));
d->standardButtonHash.value(static_cast<QPushButton *>(button));
never executed: return d->standardButtonHash.value(static_cast<QPushButton *>(button));
0
517}-
518-
519void QDialogButtonBoxPrivate::_q_handleButtonClicked()-
520{-
521 QDialogButtonBox * const q = q_func();-
522 if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())
QAbstractButto...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
523-
524-
525-
526-
527 const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button);-
528 QPointer<QDialogButtonBox> guard(q);-
529-
530 q->clicked(button);-
531-
532 if (!guard
!guardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
533 return;
never executed: return;
0
534-
535 switch (buttonRole) {-
536 case
never executed: case QPlatformDialogHelper::AcceptRole:
QPlatformDialogHelper::AcceptRole:
never executed: case QPlatformDialogHelper::AcceptRole:
0
537 case
never executed: case QPlatformDialogHelper::YesRole:
QPlatformDialogHelper::YesRole:
never executed: case QPlatformDialogHelper::YesRole:
0
538 q->accepted();-
539 break;
never executed: break;
0
540 case
never executed: case QPlatformDialogHelper::RejectRole:
QPlatformDialogHelper::RejectRole:
never executed: case QPlatformDialogHelper::RejectRole:
0
541 case
never executed: case QPlatformDialogHelper::NoRole:
QPlatformDialogHelper::NoRole:
never executed: case QPlatformDialogHelper::NoRole:
0
542 q->rejected();-
543 break;
never executed: break;
0
544 case
never executed: case QPlatformDialogHelper::HelpRole:
QPlatformDialogHelper::HelpRole:
never executed: case QPlatformDialogHelper::HelpRole:
0
545 q->helpRequested();-
546 break;
never executed: break;
0
547 default
never executed: default:
:
never executed: default:
0
548 break;
never executed: break;
0
549 }-
550 }-
551}
never executed: end of block
0
552-
553void QDialogButtonBoxPrivate::_q_handleButtonDestroyed()-
554{-
555 QDialogButtonBox * const q = q_func();-
556 if (QObject *object = q->sender()
QObject *object = q->sender()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
557 QBoolBlocker skippy(internalRemove);-
558 q->removeButton(static_cast<QAbstractButton *>(object));-
559 }
never executed: end of block
0
560}
never executed: end of block
0
561void QDialogButtonBox::setCenterButtons(bool center)-
562{-
563 QDialogButtonBoxPrivate * const d = d_func();-
564 if (d->center != center
d->center != centerDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
565 d->center = center;-
566 d->resetLayout();-
567 }
never executed: end of block
0
568}
never executed: end of block
0
569-
570bool QDialogButtonBox::centerButtons() const-
571{-
572 const QDialogButtonBoxPrivate * const d = d_func();-
573 return
never executed: return d->center;
d->center;
never executed: return d->center;
0
574}-
575-
576-
577-
578-
579void QDialogButtonBox::changeEvent(QEvent *event)-
580{-
581 typedef QHash<QPushButton *, QDialogButtonBox::StandardButton> StandardButtonHash;-
582-
583 QDialogButtonBoxPrivate * const d = d_func();-
584 switch (event->type()) {-
585 case
never executed: case QEvent::StyleChange:
QEvent::StyleChange:
never executed: case QEvent::StyleChange:
0
586 if (!d->standardButtonHash.empty()
!d->standardButtonHash.empty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
587 QStyle *newStyle = style();-
588 const StandardButtonHash::iterator end = d->standardButtonHash.end();-
589 for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
590 it.key()->setStyle(newStyle);
never executed: it.key()->setStyle(newStyle);
0
591 }
never executed: end of block
0
592-
593-
594-
595-
596 d->resetLayout();-
597 QWidget::changeEvent(event);-
598 break;
never executed: break;
0
599 default
never executed: default:
:
never executed: default:
0
600 QWidget::changeEvent(event);-
601 break;
never executed: break;
0
602 }-
603}-
604-
605-
606-
607-
608bool QDialogButtonBox::event(QEvent *event)-
609{-
610 QDialogButtonBoxPrivate * const d = d_func();-
611 if (event->type() == QEvent::Show
event->type() == QEvent::ShowDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
612 QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole];-
613 QPushButton *firstAcceptButton = acceptRoleList.isEmpty()
acceptRoleList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
0
614 bool hasDefault = false;-
615 QWidget *dialog = 0;-
616 QWidget *p = this;-
617 while (p
pDescription
TRUEnever evaluated
FALSEnever evaluated
&& !p->isWindow()
!p->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
618 p = p->parentWidget();-
619 if ((
(dialog = qobj...QDialog *>(p))Description
TRUEnever evaluated
FALSEnever evaluated
dialog = qobject_cast<QDialog *>(p))
(dialog = qobj...QDialog *>(p))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
620 break;
never executed: break;
0
621 }
never executed: end of block
0
622-
623 const auto pbs = (dialog
dialogDescription
TRUEnever evaluated
FALSEnever evaluated
? dialog : this)->findChildren<QPushButton *>();
0
624 for (QPushButton *pb : pbs) {-
625 if (pb->isDefault()
pb->isDefault()Description
TRUEnever evaluated
FALSEnever evaluated
&& pb != firstAcceptButton
pb != firstAcceptButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
626 hasDefault = true;-
627 break;
never executed: break;
0
628 }-
629 }
never executed: end of block
0
630 if (!hasDefault
!hasDefaultDescription
TRUEnever evaluated
FALSEnever evaluated
&& firstAcceptButton
firstAcceptButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
631 firstAcceptButton->setDefault(true);
never executed: firstAcceptButton->setDefault(true);
0
632 }
never executed: end of block
else if (event->type() == QEvent::LanguageChange
event->type() ...LanguageChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
633 d->retranslateStrings();-
634 }
never executed: end of block
0
635 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
636}-
637-
638-
639-
Switch to Source codePreprocessed file

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