widgets/qdialogbuttonbox.cpp

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

Generated by Squish Coco Non-Commercial