OpenCoverage

qdialogbuttonbox.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdialogbuttonbox.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets 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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <QtCore/qhash.h>-
41#include <QtWidgets/qpushbutton.h>-
42#include <QtWidgets/qstyle.h>-
43#include <QtWidgets/qlayout.h>-
44#include <QtWidgets/qdialog.h>-
45#include <QtWidgets/qapplication.h>-
46#include <private/qwidget_p.h>-
47#include <private/qguiapplication_p.h>-
48#include <QtGui/qpa/qplatformdialoghelper.h>-
49#include <QtGui/qpa/qplatformtheme.h>-
50#include <QtWidgets/qaction.h>-
51-
52#include "qdialogbuttonbox.h"-
53-
54QT_BEGIN_NAMESPACE-
55-
56/*!-
57 \class QDialogButtonBox-
58 \since 4.2-
59 \brief The QDialogButtonBox class is a widget that presents buttons in a-
60 layout that is appropriate to the current widget style.-
61-
62 \ingroup dialog-classes-
63 \inmodule QtWidgets-
64-
65 Dialogs and message boxes typically present buttons in a layout that-
66 conforms to the interface guidelines for that platform. Invariably,-
67 different platforms have different layouts for their dialogs.-
68 QDialogButtonBox allows a developer to add buttons to it and will-
69 automatically use the appropriate layout for the user's desktop-
70 environment.-
71-
72 Most buttons for a dialog follow certain roles. Such roles include:-
73-
74 \list-
75 \li Accepting or rejecting the dialog.-
76 \li Asking for help.-
77 \li Performing actions on the dialog itself (such as resetting fields or-
78 applying changes).-
79 \endlist-
80-
81 There can also be alternate ways of dismissing the dialog which may cause-
82 destructive results.-
83-
84 Most dialogs have buttons that can almost be considered standard (e.g.-
85 \uicontrol OK and \uicontrol Cancel buttons). It is sometimes convenient to create these-
86 buttons in a standard way.-
87-
88 There are a couple ways of using QDialogButtonBox. One ways is to create-
89 the buttons (or button texts) yourself and add them to the button box,-
90 specifying their role.-
91-
92 \snippet dialogs/extension/finddialog.cpp 1-
93-
94 Alternatively, QDialogButtonBox provides several standard buttons (e.g. OK, Cancel, Save)-
95 that you can use. They exist as flags so you can OR them together in the constructor.-
96-
97 \snippet dialogs/tabdialog/tabdialog.cpp 2-
98-
99 You can mix and match normal buttons and standard buttons.-
100-
101 Currently the buttons are laid out in the following way if the button box is horizontal:-
102 \table-
103 \row \li \inlineimage buttonbox-gnomelayout-horizontal.png GnomeLayout Horizontal-
104 \li Button box laid out in horizontal GnomeLayout-
105 \row \li \inlineimage buttonbox-kdelayout-horizontal.png KdeLayout Horizontal-
106 \li Button box laid out in horizontal KdeLayout-
107 \row \li \inlineimage buttonbox-maclayout-horizontal.png MacLayout Horizontal-
108 \li Button box laid out in horizontal MacLayout-
109 \row \li \inlineimage buttonbox-winlayout-horizontal.png WinLayout Horizontal-
110 \li Button box laid out in horizontal WinLayout-
111 \endtable-
112-
113 The buttons are laid out the following way if the button box is vertical:-
114-
115 \table-
116 \row \li GnomeLayout-
117 \li KdeLayout-
118 \li MacLayout-
119 \li WinLayout-
120 \row \li \inlineimage buttonbox-gnomelayout-vertical.png GnomeLayout Vertical-
121 \li \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical-
122 \li \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical-
123 \li \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical-
124 \endtable-
125-
126 Additionally, button boxes that contain only buttons with ActionRole or-
127 HelpRole can be considered modeless and have an alternate look on \macos:-
128-
129 \table-
130 \row \li modeless horizontal MacLayout-
131 \li \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout-
132 \row \li modeless vertical MacLayout-
133 \li \inlineimage buttonbox-mac-modeless-vertical.png Screenshot of modeless vertical MacLayout-
134 \endtable-
135-
136 When a button is clicked in the button box, the clicked() signal is emitted-
137 for the actual button is that is pressed. For convenience, if the button-
138 has an AcceptRole, RejectRole, or HelpRole, the accepted(), rejected(), or-
139 helpRequested() signals are emitted respectively.-
140-
141 If you want a specific button to be default you need to call-
142 QPushButton::setDefault() on it yourself. However, if there is no default-
143 button set and to preserve which button is the default button across-
144 platforms when using the QPushButton::autoDefault property, the first push-
145 button with the accept role is made the default button when the-
146 QDialogButtonBox is shown,-
147-
148 \sa QMessageBox, QPushButton, QDialog-
149*/-
150-
151class QDialogButtonBoxPrivate : public QWidgetPrivate-
152{-
153 Q_DECLARE_PUBLIC(QDialogButtonBox)-
154-
155public:-
156 QDialogButtonBoxPrivate(Qt::Orientation orient);-
157-
158 QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles];-
159 QHash<QPushButton *, QDialogButtonBox::StandardButton> standardButtonHash;-
160-
161 Qt::Orientation orientation;-
162 QDialogButtonBox::ButtonLayout layoutPolicy;-
163 QBoxLayout *buttonLayout;-
164 bool internalRemove;-
165 bool center;-
166-
167 void createStandardButtons(QDialogButtonBox::StandardButtons buttons);-
168-
169 void layoutButtons();-
170 void initLayout();-
171 void resetLayout();-
172 QPushButton *createButton(QDialogButtonBox::StandardButton button, bool doLayout = true);-
173 void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout = true);-
174 void _q_handleButtonDestroyed();-
175 void _q_handleButtonClicked();-
176 void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse);-
177 void retranslateStrings();-
178};-
179-
180QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient)-
181 : orientation(orient), buttonLayout(0), internalRemove(false), center(false)-
182{-
183}
never executed: end of block
0
184-
185void QDialogButtonBoxPrivate::initLayout()-
186{-
187 Q_Q(QDialogButtonBox);-
188 layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q));-
189 bool createNewLayout = buttonLayout == 0
buttonLayout == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
190 || (orientation == Qt::Horizontal && qobject_cast<QVBoxLayout *>(buttonLayout) != 0)
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...onLayout) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
191 || (orientation == Qt::Vertical && qobject_cast<QHBoxLayout *>(buttonLayout) != 0);
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
qobject_cast<Q...onLayout) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
192 if (createNewLayout) {
createNewLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
193 delete buttonLayout;-
194 if (orientation == Qt::Horizontal)
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
0
195 buttonLayout = new QHBoxLayout(q);
never executed: buttonLayout = new QHBoxLayout(q);
0
196 else-
197 buttonLayout = new QVBoxLayout(q);
never executed: buttonLayout = new QVBoxLayout(q);
0
198 }-
199-
200 int left, top, right, bottom;-
201 setLayoutItemMargins(QStyle::SE_PushButtonLayoutItem);-
202 getLayoutItemMargins(&left, &top, &right, &bottom);-
203 buttonLayout->setContentsMargins(-left, -top, -right, -bottom);-
204-
205 if (!q->testAttribute(Qt::WA_WState_OwnSizePolicy)) {
!q->testAttrib...OwnSizePolicy)Description
TRUEnever evaluated
FALSEnever evaluated
0
206 QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::ButtonBox);-
207 if (orientation == Qt::Vertical)
orientation == Qt::VerticalDescription
TRUEnever evaluated
FALSEnever evaluated
0
208 sp.transpose();
never executed: sp.transpose();
0
209 q->setSizePolicy(sp);-
210 q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
211 }
never executed: end of block
0
212}
never executed: end of block
0
213-
214void QDialogButtonBoxPrivate::resetLayout()-
215{-
216 //delete buttonLayout;-
217 initLayout();-
218 layoutButtons();-
219}
never executed: end of block
0
220-
221void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList,-
222 bool reverse)-
223{-
224 int start = reverse ? buttonList.count() - 1 : 0;
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
0
225 int end = reverse ? -1 : buttonList.count();
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
0
226 int step = reverse ? -1 : 1;
reverseDescription
TRUEnever evaluated
FALSEnever evaluated
0
227-
228 for (int i = start; i != end; i += step) {
i != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
229 QAbstractButton *button = buttonList.at(i);-
230 buttonLayout->addWidget(button);-
231 button->show();-
232 }
never executed: end of block
0
233}
never executed: end of block
0
234-
235void QDialogButtonBoxPrivate::layoutButtons()-
236{-
237 Q_Q(QDialogButtonBox);-
238 const int MacGap = 36 - 8; // 8 is the default gap between a widget and a spacer item-
239-
240 for (int i = buttonLayout->count() - 1; i >= 0; --i) {
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
241 QLayoutItem *item = buttonLayout->takeAt(i);-
242 if (QWidget *widget = item->widget())
QWidget *widge...item->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
243 widget->hide();
never executed: widget->hide();
0
244 delete item;-
245 }
never executed: end of block
0
246-
247 int tmpPolicy = layoutPolicy;-
248-
249 static const int M = 5;-
250 static const int ModalRoles[M] = { QPlatformDialogHelper::AcceptRole, QPlatformDialogHelper::RejectRole,-
251 QPlatformDialogHelper::DestructiveRole, QPlatformDialogHelper::YesRole, QPlatformDialogHelper::NoRole };-
252 if (tmpPolicy == QDialogButtonBox::MacLayout) {
tmpPolicy == Q...Box::MacLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
253 bool hasModalButton = false;-
254 for (int i = 0; i < M; ++i) {
i < MDescription
TRUEnever evaluated
FALSEnever evaluated
0
255 if (!buttonLists[ModalRoles[i]].isEmpty()) {
!buttonLists[M...[i]].isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
256 hasModalButton = true;-
257 break;
never executed: break;
0
258 }-
259 }
never executed: end of block
0
260 if (!hasModalButton)
!hasModalButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
261 tmpPolicy = 4; // Mac modeless
never executed: tmpPolicy = 4;
0
262 }
never executed: end of block
0
263-
264 const int *currentLayout = QPlatformDialogHelper::buttonLayout(-
265 orientation, static_cast<QPlatformDialogHelper::ButtonLayout>(tmpPolicy));-
266-
267 if (center)
centerDescription
TRUEnever evaluated
FALSEnever evaluated
0
268 buttonLayout->addStretch();
never executed: buttonLayout->addStretch();
0
269-
270 const QList<QAbstractButton *> &acceptRoleList = buttonLists[QPlatformDialogHelper::AcceptRole];-
271-
272 while (*currentLayout != QPlatformDialogHelper::EOL) {
*currentLayout...logHelper::EOLDescription
TRUEnever evaluated
FALSEnever evaluated
0
273 int role = (*currentLayout & ~QPlatformDialogHelper::Reverse);-
274 bool reverse = (*currentLayout & QPlatformDialogHelper::Reverse);-
275-
276 switch (role) {-
277 case QPlatformDialogHelper::Stretch:
never executed: case QPlatformDialogHelper::Stretch:
0
278 if (!center)
!centerDescription
TRUEnever evaluated
FALSEnever evaluated
0
279 buttonLayout->addStretch();
never executed: buttonLayout->addStretch();
0
280 break;
never executed: break;
0
281 case QPlatformDialogHelper::AcceptRole: {
never executed: case QPlatformDialogHelper::AcceptRole:
0
282 if (acceptRoleList.isEmpty())
acceptRoleList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
283 break;
never executed: break;
0
284 // Only the first one-
285 QAbstractButton *button = acceptRoleList.first();-
286 buttonLayout->addWidget(button);-
287 button->show();-
288 }-
289 break;
never executed: break;
0
290 case QPlatformDialogHelper::AlternateRole:
never executed: case QPlatformDialogHelper::AlternateRole:
0
291 if (acceptRoleList.size() > 1)
acceptRoleList.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
292 addButtonsToLayout(acceptRoleList.mid(1), reverse);
never executed: addButtonsToLayout(acceptRoleList.mid(1), reverse);
0
293 break;
never executed: break;
0
294 case QPlatformDialogHelper::DestructiveRole:
never executed: case QPlatformDialogHelper::DestructiveRole:
0
295 {-
296 const QList<QAbstractButton *> &list = buttonLists[role];-
297-
298 /*-
299 Mac: Insert a gap on the left of the destructive-
300 buttons to ensure that they don't get too close to-
301 the help and action buttons (but only if there are-
302 some buttons to the left of the destructive buttons-
303 (and the stretch, whence buttonLayout->count() > 1-
304 and not 0)).-
305 */-
306 if (tmpPolicy == QDialogButtonBox::MacLayout
tmpPolicy == Q...Box::MacLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
307 && !list.isEmpty() && buttonLayout->count() > 1)
!list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
buttonLayout->count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
308 buttonLayout->addSpacing(MacGap);
never executed: buttonLayout->addSpacing(MacGap);
0
309-
310 addButtonsToLayout(list, reverse);-
311-
312 /*-
313 Insert a gap between the destructive buttons and the-
314 accept and reject buttons.-
315 */-
316 if (tmpPolicy == QDialogButtonBox::MacLayout && !list.isEmpty())
tmpPolicy == Q...Box::MacLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
!list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
317 buttonLayout->addSpacing(MacGap);
never executed: buttonLayout->addSpacing(MacGap);
0
318 }-
319 break;
never executed: break;
0
320 case QPlatformDialogHelper::RejectRole:
never executed: case QPlatformDialogHelper::RejectRole:
0
321 case QPlatformDialogHelper::ActionRole:
never executed: case QPlatformDialogHelper::ActionRole:
0
322 case QPlatformDialogHelper::HelpRole:
never executed: case QPlatformDialogHelper::HelpRole:
0
323 case QPlatformDialogHelper::YesRole:
never executed: case QPlatformDialogHelper::YesRole:
0
324 case QPlatformDialogHelper::NoRole:
never executed: case QPlatformDialogHelper::NoRole:
0
325 case QPlatformDialogHelper::ApplyRole:
never executed: case QPlatformDialogHelper::ApplyRole:
0
326 case QPlatformDialogHelper::ResetRole:
never executed: case QPlatformDialogHelper::ResetRole:
0
327 addButtonsToLayout(buttonLists[role], reverse);-
328 }
never executed: end of block
0
329 ++currentLayout;-
330 }
never executed: end of block
0
331-
332 QWidget *lastWidget = 0;-
333 q->setFocusProxy(0);-
334 for (int i = 0; i < buttonLayout->count(); ++i) {
i < buttonLayout->count()Description
TRUEnever evaluated
FALSEnever evaluated
0
335 QLayoutItem *item = buttonLayout->itemAt(i);-
336 if (QWidget *widget = item->widget()) {
QWidget *widge...item->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
337 if (lastWidget)
lastWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
338 QWidget::setTabOrder(lastWidget, widget);
never executed: QWidget::setTabOrder(lastWidget, widget);
0
339 else-
340 q->setFocusProxy(widget);
never executed: q->setFocusProxy(widget);
0
341 lastWidget = widget;-
342 }
never executed: end of block
0
343 }
never executed: end of block
0
344-
345 if (center)
centerDescription
TRUEnever evaluated
FALSEnever evaluated
0
346 buttonLayout->addStretch();
never executed: buttonLayout->addStretch();
0
347}
never executed: end of block
0
348-
349QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardButton sbutton,-
350 bool doLayout)-
351{-
352 Q_Q(QDialogButtonBox);-
353 int icon = 0;-
354-
355 switch (sbutton) {-
356 case QDialogButtonBox::Ok:
never executed: case QDialogButtonBox::Ok:
0
357 icon = QStyle::SP_DialogOkButton;-
358 break;
never executed: break;
0
359 case QDialogButtonBox::Save:
never executed: case QDialogButtonBox::Save:
0
360 icon = QStyle::SP_DialogSaveButton;-
361 break;
never executed: break;
0
362 case QDialogButtonBox::Open:
never executed: case QDialogButtonBox::Open:
0
363 icon = QStyle::SP_DialogOpenButton;-
364 break;
never executed: break;
0
365 case QDialogButtonBox::Cancel:
never executed: case QDialogButtonBox::Cancel:
0
366 icon = QStyle::SP_DialogCancelButton;-
367 break;
never executed: break;
0
368 case QDialogButtonBox::Close:
never executed: case QDialogButtonBox::Close:
0
369 icon = QStyle::SP_DialogCloseButton;-
370 break;
never executed: break;
0
371 case QDialogButtonBox::Apply:
never executed: case QDialogButtonBox::Apply:
0
372 icon = QStyle::SP_DialogApplyButton;-
373 break;
never executed: break;
0
374 case QDialogButtonBox::Reset:
never executed: case QDialogButtonBox::Reset:
0
375 icon = QStyle::SP_DialogResetButton;-
376 break;
never executed: break;
0
377 case QDialogButtonBox::Help:
never executed: case QDialogButtonBox::Help:
0
378 icon = QStyle::SP_DialogHelpButton;-
379 break;
never executed: break;
0
380 case QDialogButtonBox::Discard:
never executed: case QDialogButtonBox::Discard:
0
381 icon = QStyle::SP_DialogDiscardButton;-
382 break;
never executed: break;
0
383 case QDialogButtonBox::Yes:
never executed: case QDialogButtonBox::Yes:
0
384 icon = QStyle::SP_DialogYesButton;-
385 break;
never executed: break;
0
386 case QDialogButtonBox::No:
never executed: case QDialogButtonBox::No:
0
387 icon = QStyle::SP_DialogNoButton;-
388 break;
never executed: break;
0
389 case QDialogButtonBox::YesToAll:
never executed: case QDialogButtonBox::YesToAll:
0
390 case QDialogButtonBox::NoToAll:
never executed: case QDialogButtonBox::NoToAll:
0
391 case QDialogButtonBox::SaveAll:
never executed: case QDialogButtonBox::SaveAll:
0
392 case QDialogButtonBox::Abort:
never executed: case QDialogButtonBox::Abort:
0
393 case QDialogButtonBox::Retry:
never executed: case QDialogButtonBox::Retry:
0
394 case QDialogButtonBox::Ignore:
never executed: case QDialogButtonBox::Ignore:
0
395 case QDialogButtonBox::RestoreDefaults:
never executed: case QDialogButtonBox::RestoreDefaults:
0
396 break;
never executed: break;
0
397 case QDialogButtonBox::NoButton:
never executed: case QDialogButtonBox::NoButton:
0
398 return 0;
never executed: return 0;
0
399 ;-
400 }-
401 QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q);-
402 QStyle *style = q->style();-
403 if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0)
style->styleHi...veIcons, 0, q)Description
TRUEnever evaluated
FALSEnever evaluated
icon != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
404 button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
never executed: button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
0
405 if (style != QApplication::style()) // Propagate style
style != QApplication::style()Description
TRUEnever evaluated
FALSEnever evaluated
0
406 button->setStyle(style);
never executed: button->setStyle(style);
0
407 standardButtonHash.insert(button, sbutton);-
408 QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(static_cast<QPlatformDialogHelper::StandardButton>(sbutton));-
409 if (Q_UNLIKELY(role == QPlatformDialogHelper::InvalidRole))
__builtin_expe...dRole), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
410 qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
never executed: QMessageLogger(__FILE__, 410, __PRETTY_FUNCTION__).warning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
0
411 else-
412 addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout);
never executed: addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout);
0
413-
414#ifdef Q_DEAD_CODE_FROM_QT4_MAC-
415 // Since mnemonics is off by default on Mac, we add a Cmd-D-
416 // shortcut here to e.g. make the "Don't Save" button work nativly:-
417 if (sbutton == QDialogButtonBox::Discard)-
418 button->setShortcut(QKeySequence(QLatin1String("Ctrl+D")));-
419#endif-
420-
421 return button;
never executed: return button;
0
422}-
423-
424void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role,-
425 bool doLayout)-
426{-
427 Q_Q(QDialogButtonBox);-
428 QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_handleButtonClicked()));-
429 QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed()));-
430 buttonLists[role].append(button);-
431 if (doLayout)
doLayoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
432 layoutButtons();
never executed: layoutButtons();
0
433}
never executed: end of block
0
434-
435void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardButtons buttons)-
436{-
437 uint i = QDialogButtonBox::FirstButton;-
438 while (i <= QDialogButtonBox::LastButton) {
i <= QDialogBu...ox::LastButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
439 if (i & buttons) {
i & buttonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
440 createButton(QDialogButtonBox::StandardButton(i), false);-
441 }
never executed: end of block
0
442 i = i << 1;-
443 }
never executed: end of block
0
444 layoutButtons();-
445}
never executed: end of block
0
446-
447void QDialogButtonBoxPrivate::retranslateStrings()-
448{-
449 typedef QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator Iterator;-
450-
451 const Iterator end = standardButtonHash.end();-
452 for (Iterator it = standardButtonHash.begin(); it != end; ++it) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
453 const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(it.value());-
454 if (!text.isEmpty())
!text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
455 it.key()->setText(text);
never executed: it.key()->setText(text);
0
456 }
never executed: end of block
0
457}
never executed: end of block
0
458-
459/*!-
460 Constructs an empty, horizontal button box with the given \a parent.-
461-
462 \sa orientation, addButton()-
463*/-
464QDialogButtonBox::QDialogButtonBox(QWidget *parent)-
465 : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)-
466{-
467 d_func()->initLayout();-
468}
never executed: end of block
0
469-
470/*!-
471 Constructs an empty button box with the given \a orientation and \a parent.-
472-
473 \sa orientation, addButton()-
474*/-
475QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)-
476 : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)-
477{-
478 d_func()->initLayout();-
479}
never executed: end of block
0
480-
481/*!-
482 \since 5.2-
483-
484 Constructs a horizontal button box with the given \a parent, containing-
485 the standard buttons specified by \a buttons.-
486-
487 \sa orientation, addButton()-
488*/-
489QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent)-
490 : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)-
491{-
492 d_func()->initLayout();-
493 d_func()->createStandardButtons(buttons);-
494}
never executed: end of block
0
495-
496/*!-
497 Constructs a button box with the given \a orientation and \a parent, containing-
498 the standard buttons specified by \a buttons.-
499-
500 \sa orientation, addButton()-
501*/-
502QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,-
503 QWidget *parent)-
504 : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)-
505{-
506 d_func()->initLayout();-
507 d_func()->createStandardButtons(buttons);-
508}
never executed: end of block
0
509-
510/*!-
511 Destroys the button box.-
512*/-
513QDialogButtonBox::~QDialogButtonBox()-
514{-
515}-
516-
517/*!-
518 \enum QDialogButtonBox::ButtonRole-
519 \enum QMessageBox::ButtonRole-
520-
521 This enum describes the roles that can be used to describe buttons in-
522 the button box. Combinations of these roles are as flags used to-
523 describe different aspects of their behavior.-
524-
525 \value InvalidRole The button is invalid.-
526 \value AcceptRole Clicking the button causes the dialog to be accepted-
527 (e.g. OK).-
528 \value RejectRole Clicking the button causes the dialog to be rejected-
529 (e.g. Cancel).-
530 \value DestructiveRole Clicking the button causes a destructive change-
531 (e.g. for Discarding Changes) and closes the dialog.-
532 \value ActionRole Clicking the button causes changes to the elements within-
533 the dialog.-
534 \value HelpRole The button can be clicked to request help.-
535 \value YesRole The button is a "Yes"-like button.-
536 \value NoRole The button is a "No"-like button.-
537 \value ApplyRole The button applies current changes.-
538 \value ResetRole The button resets the dialog's fields to default values.-
539-
540 \omitvalue NRoles-
541-
542 \sa StandardButton-
543*/-
544-
545/*!-
546 \enum QDialogButtonBox::StandardButton-
547-
548 These enums describe flags for standard buttons. Each button has a-
549 defined \l ButtonRole.-
550-
551 \value Ok An "OK" button defined with the \l AcceptRole.-
552 \value Open An "Open" button defined with the \l AcceptRole.-
553 \value Save A "Save" button defined with the \l AcceptRole.-
554 \value Cancel A "Cancel" button defined with the \l RejectRole.-
555 \value Close A "Close" button defined with the \l RejectRole.-
556 \value Discard A "Discard" or "Don't Save" button, depending on the platform,-
557 defined with the \l DestructiveRole.-
558 \value Apply An "Apply" button defined with the \l ApplyRole.-
559 \value Reset A "Reset" button defined with the \l ResetRole.-
560 \value RestoreDefaults A "Restore Defaults" button defined with the \l ResetRole.-
561 \value Help A "Help" button defined with the \l HelpRole.-
562 \value SaveAll A "Save All" button defined with the \l AcceptRole.-
563 \value Yes A "Yes" button defined with the \l YesRole.-
564 \value YesToAll A "Yes to All" button defined with the \l YesRole.-
565 \value No A "No" button defined with the \l NoRole.-
566 \value NoToAll A "No to All" button defined with the \l NoRole.-
567 \value Abort An "Abort" button defined with the \l RejectRole.-
568 \value Retry A "Retry" button defined with the \l AcceptRole.-
569 \value Ignore An "Ignore" button defined with the \l AcceptRole.-
570-
571 \value NoButton An invalid button.-
572-
573 \omitvalue FirstButton-
574 \omitvalue LastButton-
575-
576 \sa ButtonRole, standardButtons-
577*/-
578-
579/*!-
580 \enum QDialogButtonBox::ButtonLayout-
581-
582 This enum describes the layout policy to be used when arranging the buttons-
583 contained in the button box.-
584-
585 \value WinLayout Use a policy appropriate for applications on Windows.-
586 \value MacLayout Use a policy appropriate for applications on \macos.-
587 \value KdeLayout Use a policy appropriate for applications on KDE.-
588 \value GnomeLayout Use a policy appropriate for applications on GNOME.-
589-
590 The button layout is specified by the \l{style()}{current style}. However,-
591 on the X11 platform, it may be influenced by the desktop environment.-
592*/-
593-
594/*!-
595 \fn void QDialogButtonBox::clicked(QAbstractButton *button)-
596-
597 This signal is emitted when a button inside the button box is clicked. The-
598 specific button that was pressed is specified by \a button.-
599-
600 \sa accepted(), rejected(), helpRequested()-
601*/-
602-
603/*!-
604 \fn void QDialogButtonBox::accepted()-
605-
606 This signal is emitted when a button inside the button box is clicked, as long-
607 as it was defined with the \l AcceptRole or \l YesRole.-
608-
609 \sa rejected(), clicked(), helpRequested()-
610*/-
611-
612/*!-
613 \fn void QDialogButtonBox::rejected()-
614-
615 This signal is emitted when a button inside the button box is clicked, as long-
616 as it was defined with the \l RejectRole or \l NoRole.-
617-
618 \sa accepted(), helpRequested(), clicked()-
619*/-
620-
621/*!-
622 \fn void QDialogButtonBox::helpRequested()-
623-
624 This signal is emitted when a button inside the button box is clicked, as long-
625 as it was defined with the \l HelpRole.-
626-
627 \sa accepted(), rejected(), clicked()-
628*/-
629-
630/*!-
631 \property QDialogButtonBox::orientation-
632 \brief the orientation of the button box-
633-
634 By default, the orientation is horizontal (i.e. the buttons are laid out-
635 side by side). The possible orientations are Qt::Horizontal and-
636 Qt::Vertical.-
637*/-
638Qt::Orientation QDialogButtonBox::orientation() const-
639{-
640 return d_func()->orientation;
never executed: return d_func()->orientation;
0
641}-
642-
643void QDialogButtonBox::setOrientation(Qt::Orientation orientation)-
644{-
645 Q_D(QDialogButtonBox);-
646 if (orientation == d->orientation)
orientation == d->orientationDescription
TRUEnever evaluated
FALSEnever evaluated
0
647 return;
never executed: return;
0
648-
649 d->orientation = orientation;-
650 d->resetLayout();-
651}
never executed: end of block
0
652-
653/*!-
654 Clears the button box, deleting all buttons within it.-
655-
656 \sa removeButton(), addButton()-
657*/-
658void QDialogButtonBox::clear()-
659{-
660 Q_D(QDialogButtonBox);-
661 // Remove the created standard buttons, they should be in the other lists, which will-
662 // do the deletion-
663 d->standardButtonHash.clear();-
664 for (int i = 0; i < NRoles; ++i) {
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
0
665 QList<QAbstractButton *> &list = d->buttonLists[i];-
666 while (list.count()) {
list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
667 QAbstractButton *button = list.takeAt(0);-
668 QObject::disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));-
669 delete button;-
670 }
never executed: end of block
0
671 }
never executed: end of block
0
672}
never executed: end of block
0
673-
674/*!-
675 Returns a list of all the buttons that have been added to the button box.-
676-
677 \sa buttonRole(), addButton(), removeButton()-
678*/-
679QList<QAbstractButton *> QDialogButtonBox::buttons() const-
680{-
681 Q_D(const QDialogButtonBox);-
682 QList<QAbstractButton *> finalList;-
683 for (int i = 0; i < NRoles; ++i) {
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
0
684 const QList<QAbstractButton *> &list = d->buttonLists[i];-
685 for (int j = 0; j < list.count(); ++j)
j < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
686 finalList.append(list.at(j));
never executed: finalList.append(list.at(j));
0
687 }
never executed: end of block
0
688 return finalList;
never executed: return finalList;
0
689}-
690-
691/*!-
692 Returns the button role for the specified \a button. This function returns-
693 \l InvalidRole if \a button is 0 or has not been added to the button box.-
694-
695 \sa buttons(), addButton()-
696*/-
697QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *button) const-
698{-
699 Q_D(const QDialogButtonBox);-
700 for (int i = 0; i < NRoles; ++i) {
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
0
701 const QList<QAbstractButton *> &list = d->buttonLists[i];-
702 for (int j = 0; j < list.count(); ++j) {
j < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
703 if (list.at(j) == button)
list.at(j) == buttonDescription
TRUEnever evaluated
FALSEnever evaluated
0
704 return ButtonRole(i);
never executed: return ButtonRole(i);
0
705 }
never executed: end of block
0
706 }
never executed: end of block
0
707 return InvalidRole;
never executed: return InvalidRole;
0
708}-
709-
710/*!-
711 Removes \a button from the button box without deleting it and sets its parent to zero.-
712-
713 \sa clear(), buttons(), addButton()-
714*/-
715void QDialogButtonBox::removeButton(QAbstractButton *button)-
716{-
717 Q_D(QDialogButtonBox);-
718-
719 if (!button)
!buttonDescription
TRUEnever evaluated
FALSEnever evaluated
0
720 return;
never executed: return;
0
721-
722 // Remove it from the standard button hash first and then from the roles-
723 if (QPushButton *pushButton = qobject_cast<QPushButton *>(button))
QPushButton *p...ton *>(button)Description
TRUEnever evaluated
FALSEnever evaluated
0
724 d->standardButtonHash.remove(pushButton);
never executed: d->standardButtonHash.remove(pushButton);
0
725 for (int i = 0; i < NRoles; ++i) {
i < NRolesDescription
TRUEnever evaluated
FALSEnever evaluated
0
726 QList<QAbstractButton *> &list = d->buttonLists[i];-
727 for (int j = 0; j < list.count(); ++j) {
j < list.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
728 if (list.at(j) == button) {
list.at(j) == buttonDescription
TRUEnever evaluated
FALSEnever evaluated
0
729 list.takeAt(j);-
730 if (!d->internalRemove) {
!d->internalRemoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
731 disconnect(button, SIGNAL(clicked()), this, SLOT(_q_handleButtonClicked()));-
732 disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));-
733 }
never executed: end of block
0
734 break;
never executed: break;
0
735 }-
736 }
never executed: end of block
0
737 }
never executed: end of block
0
738 if (!d->internalRemove)
!d->internalRemoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
739 button->setParent(0);
never executed: button->setParent(0);
0
740}
never executed: end of block
0
741-
742/*!-
743 Adds the given \a button to the button box with the specified \a role.-
744 If the role is invalid, the button is not added.-
745-
746 If the button has already been added, it is removed and added again with the-
747 new role.-
748-
749 \note The button box takes ownership of the button.-
750-
751 \sa removeButton(), clear()-
752*/-
753void QDialogButtonBox::addButton(QAbstractButton *button, ButtonRole role)-
754{-
755 Q_D(QDialogButtonBox);-
756 if (Q_UNLIKELY(role <= InvalidRole || role >= NRoles)) {
__builtin_expe...Roles), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
757 qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");-
758 return;
never executed: return;
0
759 }-
760 removeButton(button);-
761 button->setParent(this);-
762 d->addButton(button, role);-
763}
never executed: end of block
0
764-
765/*!-
766 Creates a push button with the given \a text, adds it to the button box for the-
767 specified \a role, and returns the corresponding push button. If \a role is-
768 invalid, no button is created, and zero is returned.-
769-
770 \sa removeButton(), clear()-
771*/-
772QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role)-
773{-
774 Q_D(QDialogButtonBox);-
775 if (Q_UNLIKELY(role <= InvalidRole || role >= NRoles)) {
__builtin_expe...Roles), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
776 qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");-
777 return 0;
never executed: return 0;
0
778 }-
779 QPushButton *button = new QPushButton(text, this);-
780 d->addButton(button, role);-
781 return button;
never executed: return button;
0
782}-
783-
784/*!-
785 Adds a standard \a button to the button box if it is valid to do so, and returns-
786 a push button. If \a button is invalid, it is not added to the button box, and-
787 zero is returned.-
788-
789 \sa removeButton(), clear()-
790*/-
791QPushButton *QDialogButtonBox::addButton(StandardButton button)-
792{-
793 Q_D(QDialogButtonBox);-
794 return d->createButton(button);
never executed: return d->createButton(button);
0
795}-
796-
797/*!-
798 \property QDialogButtonBox::standardButtons-
799 \brief collection of standard buttons in the button box-
800-
801 This property controls which standard buttons are used by the button box.-
802-
803 \sa addButton()-
804*/-
805void QDialogButtonBox::setStandardButtons(StandardButtons buttons)-
806{-
807 Q_D(QDialogButtonBox);-
808 // Clear out all the old standard buttons, then recreate them.-
809 qDeleteAll(d->standardButtonHash.keys());-
810 d->standardButtonHash.clear();-
811-
812 d->createStandardButtons(buttons);-
813}
never executed: end of block
0
814-
815QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons() const-
816{-
817 Q_D(const QDialogButtonBox);-
818 StandardButtons standardButtons = NoButton;-
819 QHash<QPushButton *, StandardButton>::const_iterator it = d->standardButtonHash.constBegin();-
820 while (it != d->standardButtonHash.constEnd()) {
it != d->stand...ash.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
821 standardButtons |= it.value();-
822 ++it;-
823 }
never executed: end of block
0
824 return standardButtons;
never executed: return standardButtons;
0
825}-
826-
827/*!-
828 Returns the QPushButton corresponding to the standard button \a which,-
829 or 0 if the standard button doesn't exist in this button box.-
830-
831 \sa standardButton(), standardButtons(), buttons()-
832*/-
833QPushButton *QDialogButtonBox::button(StandardButton which) const-
834{-
835 Q_D(const QDialogButtonBox);-
836 return d->standardButtonHash.key(which);
never executed: return d->standardButtonHash.key(which);
0
837}-
838-
839/*!-
840 Returns the standard button enum value corresponding to the given \a button,-
841 or NoButton if the given \a button isn't a standard button.-
842-
843 \sa button(), buttons(), standardButtons()-
844*/-
845QDialogButtonBox::StandardButton QDialogButtonBox::standardButton(QAbstractButton *button) const-
846{-
847 Q_D(const QDialogButtonBox);-
848 return d->standardButtonHash.value(static_cast<QPushButton *>(button));
never executed: return d->standardButtonHash.value(static_cast<QPushButton *>(button));
0
849}-
850-
851void QDialogButtonBoxPrivate::_q_handleButtonClicked()-
852{-
853 Q_Q(QDialogButtonBox);-
854 if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
QAbstractButto...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
0
855 // Can't fetch this *after* emitting clicked, as clicked may destroy the button-
856 // or change its role. Now changing the role is not possible yet, but arguably-
857 // both clicked and accepted/rejected/etc. should be emitted "atomically"-
858 // depending on whatever role the button had at the time of the click.-
859 const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button);-
860 QPointer<QDialogButtonBox> guard(q);-
861-
862 emit q->clicked(button);-
863-
864 if (!guard)
!guardDescription
TRUEnever evaluated
FALSEnever evaluated
0
865 return;
never executed: return;
0
866-
867 switch (buttonRole) {-
868 case QPlatformDialogHelper::AcceptRole:
never executed: case QPlatformDialogHelper::AcceptRole:
0
869 case QPlatformDialogHelper::YesRole:
never executed: case QPlatformDialogHelper::YesRole:
0
870 emit q->accepted();-
871 break;
never executed: break;
0
872 case QPlatformDialogHelper::RejectRole:
never executed: case QPlatformDialogHelper::RejectRole:
0
873 case QPlatformDialogHelper::NoRole:
never executed: case QPlatformDialogHelper::NoRole:
0
874 emit q->rejected();-
875 break;
never executed: break;
0
876 case QPlatformDialogHelper::HelpRole:
never executed: case QPlatformDialogHelper::HelpRole:
0
877 emit q->helpRequested();-
878 break;
never executed: break;
0
879 default:
never executed: default:
0
880 break;
never executed: break;
0
881 }-
882 }-
883}
never executed: end of block
0
884-
885void QDialogButtonBoxPrivate::_q_handleButtonDestroyed()-
886{-
887 Q_Q(QDialogButtonBox);-
888 if (QObject *object = q->sender()) {
QObject *object = q->sender()Description
TRUEnever evaluated
FALSEnever evaluated
0
889 QBoolBlocker skippy(internalRemove);-
890 q->removeButton(static_cast<QAbstractButton *>(object));-
891 }
never executed: end of block
0
892}
never executed: end of block
0
893-
894/*!-
895 \property QDialogButtonBox::centerButtons-
896 \brief whether the buttons in the button box are centered-
897-
898 By default, this property is \c false. This behavior is appopriate-
899 for most types of dialogs. A notable exception is message boxes-
900 on most platforms (e.g. Windows), where the button box is-
901 centered horizontally.-
902-
903 \sa QMessageBox-
904*/-
905void QDialogButtonBox::setCenterButtons(bool center)-
906{-
907 Q_D(QDialogButtonBox);-
908 if (d->center != center) {
d->center != centerDescription
TRUEnever evaluated
FALSEnever evaluated
0
909 d->center = center;-
910 d->resetLayout();-
911 }
never executed: end of block
0
912}
never executed: end of block
0
913-
914bool QDialogButtonBox::centerButtons() const-
915{-
916 Q_D(const QDialogButtonBox);-
917 return d->center;
never executed: return d->center;
0
918}-
919-
920/*!-
921 \reimp-
922*/-
923void QDialogButtonBox::changeEvent(QEvent *event)-
924{-
925 typedef QHash<QPushButton *, QDialogButtonBox::StandardButton> StandardButtonHash;-
926-
927 Q_D(QDialogButtonBox);-
928 switch (event->type()) {-
929 case QEvent::StyleChange: // Propagate style
never executed: case QEvent::StyleChange:
0
930 if (!d->standardButtonHash.empty()) {
!d->standardButtonHash.empty()Description
TRUEnever evaluated
FALSEnever evaluated
0
931 QStyle *newStyle = style();-
932 const StandardButtonHash::iterator end = d->standardButtonHash.end();-
933 for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end; ++it)
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
934 it.key()->setStyle(newStyle);
never executed: it.key()->setStyle(newStyle);
0
935 }
never executed: end of block
0
936 // fallthrough intended-
937#ifdef Q_OS_MAC-
938 case QEvent::MacSizeChange:-
939#endif-
940 d->resetLayout();-
941 QWidget::changeEvent(event);-
942 break;
never executed: break;
0
943 default:
never executed: default:
0
944 QWidget::changeEvent(event);-
945 break;
never executed: break;
0
946 }-
947}-
948-
949/*!-
950 \reimp-
951*/-
952bool QDialogButtonBox::event(QEvent *event)-
953{-
954 Q_D(QDialogButtonBox);-
955 if (event->type() == QEvent::Show) {
event->type() == QEvent::ShowDescription
TRUEnever evaluated
FALSEnever evaluated
0
956 QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole];-
957 QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
acceptRoleList.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
958 bool hasDefault = false;-
959 QWidget *dialog = 0;-
960 QWidget *p = this;-
961 while (p && !p->isWindow()) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
!p->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
962 p = p->parentWidget();-
963 if ((dialog = qobject_cast<QDialog *>(p)))
(dialog = qobj...QDialog *>(p))Description
TRUEnever evaluated
FALSEnever evaluated
0
964 break;
never executed: break;
0
965 }
never executed: end of block
0
966-
967 const auto pbs = (dialog ? dialog : this)->findChildren<QPushButton *>();
dialogDescription
TRUEnever evaluated
FALSEnever evaluated
0
968 for (QPushButton *pb : pbs) {-
969 if (pb->isDefault() && pb != firstAcceptButton) {
pb->isDefault()Description
TRUEnever evaluated
FALSEnever evaluated
pb != firstAcceptButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
970 hasDefault = true;-
971 break;
never executed: break;
0
972 }-
973 }
never executed: end of block
0
974 if (!hasDefault && firstAcceptButton)
!hasDefaultDescription
TRUEnever evaluated
FALSEnever evaluated
firstAcceptButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
975 firstAcceptButton->setDefault(true);
never executed: firstAcceptButton->setDefault(true);
0
976 }else if (event->type() == QEvent::LanguageChange) {
never executed: end of block
event->type() ...LanguageChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
977 d->retranslateStrings();-
978 }
never executed: end of block
0
979 return QWidget::event(event);
never executed: return QWidget::event(event);
0
980}-
981-
982QT_END_NAMESPACE-
983-
984#include "moc_qdialogbuttonbox.cpp"-
Source codeSwitch to Preprocessed file

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