dialogs/qinputdialog.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7static const char *signalForMember(const char *member) -
8{ -
9 static const int NumCandidates = 4; -
10 static const char * const candidateSignals[NumCandidates] = { -
11 "2""textValueSelected(QString)", -
12 "2""intValueSelected(int)", -
13 "2""doubleValueSelected(double)", -
14 "2""accepted()" -
15 }; -
16 -
17 QByteArray normalizedMember(QMetaObject::normalizedSignature(member)); -
18 -
19 int i = 0; -
20 while (i < NumCandidates - 1) {
never evaluated: i < NumCandidates - 1
0
21 if (QMetaObject::checkConnectArgs(candidateSignals[i], normalizedMember))
never evaluated: QMetaObject::checkConnectArgs(candidateSignals[i], normalizedMember)
0
22 break;
never executed: break;
0
23 ++i; -
24 }
never executed: }
0
25 return candidateSignals[i];
never executed: return candidateSignals[i];
0
26} -
27 -
28 -
29 -
30 -
31 -
32 -
33 -
34 -
35 -
36class QInputDialogSpinBox : public QSpinBox -
37{ -
38 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
39 -
40public: -
41 QInputDialogSpinBox(QWidget *parent) -
42 : QSpinBox(parent) { -
43 connect(lineEdit(), "2""textChanged(QString)", this, "1""notifyTextChanged()"); -
44 connect(this, "2""editingFinished()", this, "1""notifyTextChanged()"); -
45 }
executed: }
Execution Count:5
5
46 -
47public: -
48 void textChanged(bool); -
49 -
50private : -
51 void notifyTextChanged() { textChanged(hasAcceptableInput()); }
executed: }
Execution Count:173
173
52 -
53private: -
54 void keyPressEvent(QKeyEvent *event) { -
55 if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
evaluated: event->key() == Qt::Key_Return
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:104
partially evaluated: event->key() == Qt::Key_Enter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
partially evaluated: !hasAcceptableInput()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-104
56 -
57 setProperty("value", property("value")); -
58 -
59 } else {
executed: }
Execution Count:5
5
60 QSpinBox::keyPressEvent(event); -
61 }
executed: }
Execution Count:104
104
62 notifyTextChanged(); -
63 }
executed: }
Execution Count:109
109
64 -
65 void mousePressEvent(QMouseEvent *event) { -
66 QSpinBox::mousePressEvent(event); -
67 notifyTextChanged(); -
68 }
never executed: }
0
69}; -
70 -
71class QInputDialogDoubleSpinBox : public QDoubleSpinBox -
72{ -
73 public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; -
74 -
75public: -
76 QInputDialogDoubleSpinBox(QWidget *parent = 0) -
77 : QDoubleSpinBox(parent) { -
78 connect(lineEdit(), "2""textChanged(QString)", this, "1""notifyTextChanged()"); -
79 connect(this, "2""editingFinished()", this, "1""notifyTextChanged()"); -
80 }
executed: }
Execution Count:16
16
81 -
82public: -
83 void textChanged(bool); -
84 -
85private : -
86 void notifyTextChanged() { textChanged(hasAcceptableInput()); }
executed: }
Execution Count:723
723
87 -
88private: -
89 void keyPressEvent(QKeyEvent *event) { -
90 if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
evaluated: event->key() == Qt::Key_Return
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:413
partially evaluated: event->key() == Qt::Key_Enter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:413
partially evaluated: !hasAcceptableInput()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-413
91 -
92 setProperty("value", property("value")); -
93 -
94 } else {
executed: }
Execution Count:16
16
95 QDoubleSpinBox::keyPressEvent(event); -
96 }
executed: }
Execution Count:413
413
97 notifyTextChanged(); -
98 }
executed: }
Execution Count:429
429
99 -
100 void mousePressEvent(QMouseEvent *event) { -
101 QDoubleSpinBox::mousePressEvent(event); -
102 notifyTextChanged(); -
103 }
never executed: }
0
104}; -
105 -
106class QInputDialogPrivate : public QDialogPrivate -
107{ -
108 inline QInputDialog* q_func() { return static_cast<QInputDialog *>(q_ptr); } inline const QInputDialog* q_func() const { return static_cast<const QInputDialog *>(q_ptr); } friend class QInputDialog; -
109 -
110public: -
111 QInputDialogPrivate(); -
112 -
113 void ensureLayout(); -
114 void ensureLineEdit(); -
115 void ensureComboBox(); -
116 void ensureListView(); -
117 void ensureIntSpinBox(); -
118 void ensureDoubleSpinBox(); -
119 void ensureEnabledConnection(QAbstractSpinBox *spinBox); -
120 void setInputWidget(QWidget *widget); -
121 void chooseRightTextInputWidget(); -
122 void setComboBoxText(const QString &text); -
123 void setListViewText(const QString &text); -
124 QString listViewText() const; -
125 void ensureLayout() const { const_cast<QInputDialogPrivate *>(this)->ensureLayout(); }
executed: }
Execution Count:62
62
126 bool useComboBoxOrListView() const { return comboBox && comboBox->count() > 0; }
executed: return comboBox && comboBox->count() > 0;
Execution Count:19
19
127 void _q_textChanged(const QString &text); -
128 void _q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex); -
129 -
130 mutable QLabel *label; -
131 mutable QDialogButtonBox *buttonBox; -
132 mutable QLineEdit *lineEdit; -
133 mutable QSpinBox *intSpinBox; -
134 mutable QDoubleSpinBox *doubleSpinBox; -
135 mutable QComboBox *comboBox; -
136 mutable QListView *listView; -
137 mutable QWidget *inputWidget; -
138 mutable QVBoxLayout *mainLayout; -
139 QInputDialog::InputDialogOptions opts; -
140 QString textValue; -
141 QPointer<QObject> receiverToDisconnectOnClose; -
142 QByteArray memberToDisconnectOnClose; -
143}; -
144 -
145QInputDialogPrivate::QInputDialogPrivate() -
146 : label(0), buttonBox(0), lineEdit(0), intSpinBox(0), doubleSpinBox(0), comboBox(0), listView(0), -
147 inputWidget(0), mainLayout(0) -
148{ -
149}
executed: }
Execution Count:32
32
150 -
151void QInputDialogPrivate::ensureLayout() -
152{ -
153 QInputDialog * const q = q_func(); -
154 -
155 if (mainLayout)
evaluated: mainLayout
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:31
31
156 return;
executed: return;
Execution Count:31
31
157 -
158 if (!inputWidget) {
partially evaluated: !inputWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
159 ensureLineEdit(); -
160 inputWidget = lineEdit; -
161 }
never executed: }
0
162 -
163 if (!label)
partially evaluated: !label
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
164 label = new QLabel(QInputDialog::tr("Enter a value:"), q);
never executed: label = new QLabel(QInputDialog::tr("Enter a value:"), q);
0
165 -
166 label->setBuddy(inputWidget); -
167 -
168 label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); -
169 -
170 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q); -
171 QObject::connect(buttonBox, "2""accepted()", q, "1""accept()"); -
172 QObject::connect(buttonBox, "2""rejected()", q, "1""reject()"); -
173 -
174 mainLayout = new QVBoxLayout(q); -
175 -
176 mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); -
177 mainLayout->addWidget(label); -
178 mainLayout->addWidget(inputWidget); -
179 mainLayout->addWidget(buttonBox); -
180 ensureEnabledConnection(qobject_cast<QAbstractSpinBox *>(inputWidget)); -
181 inputWidget->show(); -
182}
executed: }
Execution Count:31
31
183 -
184void QInputDialogPrivate::ensureLineEdit() -
185{ -
186 QInputDialog * const q = q_func(); -
187 if (!lineEdit) {
evaluated: !lineEdit
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
188 lineEdit = new QLineEdit(q); -
189 -
190 qt_widget_private(lineEdit)->inheritsInputMethodHints = 1; -
191 -
192 lineEdit->hide(); -
193 QObject::connect(lineEdit, "2""textChanged(QString)", -
194 q, "1""_q_textChanged(QString)"); -
195 }
executed: }
Execution Count:7
7
196}
executed: }
Execution Count:13
13
197 -
198void QInputDialogPrivate::ensureComboBox() -
199{ -
200 QInputDialog * const q = q_func(); -
201 if (!comboBox) {
evaluated: !comboBox
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
202 comboBox = new QComboBox(q); -
203 -
204 qt_widget_private(comboBox)->inheritsInputMethodHints = 1; -
205 -
206 comboBox->hide(); -
207 QObject::connect(comboBox, "2""editTextChanged(QString)", -
208 q, "1""_q_textChanged(QString)"); -
209 QObject::connect(comboBox, "2""currentIndexChanged(QString)", -
210 q, "1""_q_textChanged(QString)"); -
211 }
executed: }
Execution Count:4
4
212}
executed: }
Execution Count:8
8
213 -
214void QInputDialogPrivate::ensureListView() -
215{ -
216 QInputDialog * const q = q_func(); -
217 if (!listView) {
never evaluated: !listView
0
218 ensureComboBox(); -
219 -
220 listView = new QListView(q); -
221 listView->hide(); -
222 listView->setEditTriggers(QAbstractItemView::NoEditTriggers); -
223 listView->setSelectionMode(QAbstractItemView::SingleSelection); -
224 listView->setModel(comboBox->model()); -
225 listView->setCurrentIndex(QModelIndex()); -
226 QObject::connect(listView->selectionModel(), -
227 "2""currentRowChanged(QModelIndex,QModelIndex)", -
228 q, "1""_q_currentRowChanged(QModelIndex,QModelIndex)"); -
229 }
never executed: }
0
230}
never executed: }
0
231 -
232void QInputDialogPrivate::ensureIntSpinBox() -
233{ -
234 QInputDialog * const q = q_func(); -
235 if (!intSpinBox) {
evaluated: !intSpinBox
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:10
5-10
236 intSpinBox = new QInputDialogSpinBox(q); -
237 intSpinBox->hide(); -
238 QObject::connect(intSpinBox, "2""valueChanged(int)", -
239 q, "2""intValueChanged(int)"); -
240 }
executed: }
Execution Count:5
5
241}
executed: }
Execution Count:15
15
242 -
243void QInputDialogPrivate::ensureDoubleSpinBox() -
244{ -
245 QInputDialog * const q = q_func(); -
246 if (!doubleSpinBox) {
evaluated: !doubleSpinBox
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:32
16-32
247 doubleSpinBox = new QInputDialogDoubleSpinBox(q); -
248 doubleSpinBox->hide(); -
249 QObject::connect(doubleSpinBox, "2""valueChanged(double)", -
250 q, "2""doubleValueChanged(double)"); -
251 }
executed: }
Execution Count:16
16
252}
executed: }
Execution Count:48
48
253 -
254void QInputDialogPrivate::ensureEnabledConnection(QAbstractSpinBox *spinBox) -
255{ -
256 if (spinBox) {
evaluated: spinBox
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:10
10-21
257 QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok); -
258 QObject::connect(spinBox, "2""textChanged(bool)", okButton, "1""setEnabled(bool)", Qt::UniqueConnection); -
259 }
executed: }
Execution Count:21
21
260}
executed: }
Execution Count:31
31
261 -
262void QInputDialogPrivate::setInputWidget(QWidget *widget) -
263{ -
264 qt_noop(); -
265 if (inputWidget == widget)
evaluated: inputWidget == widget
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:32
8-32
266 return;
executed: return;
Execution Count:8
8
267 -
268 if (mainLayout) {
partially evaluated: mainLayout
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
269 qt_noop(); -
270 mainLayout->removeWidget(inputWidget); -
271 inputWidget->hide(); -
272 mainLayout->insertWidget(1, widget); -
273 widget->show(); -
274 -
275 -
276 QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok); -
277 if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(inputWidget))
never evaluated: QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(inputWidget)
0
278 QObject::disconnect(spinBox, "2""textChanged(bool)", okButton, "1""setEnabled(bool)");
never executed: QObject::disconnect(spinBox, "2""textChanged(bool)", okButton, "1""setEnabled(bool)");
0
279 -
280 -
281 QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(widget); -
282 ensureEnabledConnection(spinBox); -
283 okButton->setEnabled(!spinBox || spinBox->hasAcceptableInput()); -
284 }
never executed: }
0
285 -
286 inputWidget = widget; -
287 -
288 -
289 -
290 if (widget == lineEdit) {
evaluated: widget == lineEdit
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:25
7-25
291 lineEdit->setText(textValue); -
292 } else if (widget == comboBox) {
evaluated: widget == comboBox
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:21
executed: }
Execution Count:7
4-21
293 setComboBoxText(textValue); -
294 } else if (widget == listView) {
partially evaluated: widget == listView
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
executed: }
Execution Count:4
0-21
295 setListViewText(textValue); -
296 ensureLayout(); -
297 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(listView->selectionModel()->hasSelection()); -
298 }
never executed: }
0
299} -
300 -
301void QInputDialogPrivate::chooseRightTextInputWidget() -
302{ -
303 QWidget *widget; -
304 -
305 if (useComboBoxOrListView()) {
evaluated: useComboBoxOrListView()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
7-12
306 if ((opts & QInputDialog::UseListViewForComboBoxItems) && !comboBox->isEditable()) {
partially evaluated: (opts & QInputDialog::UseListViewForComboBoxItems)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
never evaluated: !comboBox->isEditable()
0-12
307 ensureListView(); -
308 widget = listView; -
309 } else {
never executed: }
0
310 widget = comboBox; -
311 }
executed: }
Execution Count:12
12
312 } else { -
313 ensureLineEdit(); -
314 widget = lineEdit; -
315 }
executed: }
Execution Count:7
7
316 -
317 setInputWidget(widget); -
318 -
319 if (inputWidget == comboBox) {
evaluated: inputWidget == comboBox
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
7-12
320 _q_textChanged(comboBox->currentText()); -
321 } else if (inputWidget == listView) {
partially evaluated: inputWidget == listView
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
executed: }
Execution Count:12
0-12
322 _q_textChanged(listViewText()); -
323 }
never executed: }
0
324} -
325 -
326void QInputDialogPrivate::setComboBoxText(const QString &text) -
327{ -
328 int index = comboBox->findText(text); -
329 if (index != -1) {
evaluated: index != -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
330 comboBox->setCurrentIndex(index); -
331 } else if (comboBox->isEditable()) {
partially evaluated: comboBox->isEditable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
executed: }
Execution Count:6
0-6
332 comboBox->setEditText(text); -
333 }
never executed: }
0
334} -
335 -
336void QInputDialogPrivate::setListViewText(const QString &text) -
337{ -
338 int row = comboBox->findText(text); -
339 if (row != -1) {
never evaluated: row != -1
0
340 QModelIndex index(comboBox->model()->index(row, 0)); -
341 listView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear -
342 | QItemSelectionModel::SelectCurrent); -
343 }
never executed: }
0
344}
never executed: }
0
345 -
346QString QInputDialogPrivate::listViewText() const -
347{ -
348 if (listView->selectionModel()->hasSelection()) {
never evaluated: listView->selectionModel()->hasSelection()
0
349 int row = listView->selectionModel()->selectedRows().value(0).row(); -
350 return comboBox->itemText(row);
never executed: return comboBox->itemText(row);
0
351 } else { -
352 return QString();
never executed: return QString();
0
353 } -
354} -
355 -
356void QInputDialogPrivate::_q_textChanged(const QString &text) -
357{ -
358 QInputDialog * const q = q_func(); -
359 if (textValue != text) {
evaluated: textValue != text
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:16
16-81
360 textValue = text; -
361 q->textValueChanged(text); -
362 }
executed: }
Execution Count:81
81
363}
executed: }
Execution Count:97
97
364 -
365void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex, -
366 const QModelIndex & ) -
367{ -
368 _q_textChanged(comboBox->model()->data(newIndex).toString()); -
369 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); -
370}
never executed: }
0
371QInputDialog::QInputDialog(QWidget *parent, Qt::WindowFlags flags) -
372 : QDialog(*new QInputDialogPrivate, parent, flags) -
373{ -
374}
executed: }
Execution Count:32
32
375 -
376 -
377 -
378 -
379 -
380 -
381QInputDialog::~QInputDialog() -
382{ -
383} -
384void QInputDialog::setInputMode(InputMode mode) -
385{ -
386 QInputDialogPrivate * const d = d_func(); -
387 -
388 QWidget *widget; -
389 -
390 -
391 -
392 -
393 -
394 -
395 -
396 switch (mode) { -
397 case IntInput: -
398 d->ensureIntSpinBox(); -
399 widget = d->intSpinBox; -
400 break;
executed: break;
Execution Count:5
5
401 case DoubleInput: -
402 d->ensureDoubleSpinBox(); -
403 widget = d->doubleSpinBox; -
404 break;
executed: break;
Execution Count:16
16
405 default: -
406 qt_noop(); -
407 d->chooseRightTextInputWidget(); -
408 return;
executed: return;
Execution Count:11
11
409 } -
410 -
411 d->setInputWidget(widget); -
412}
executed: }
Execution Count:21
21
413 -
414QInputDialog::InputMode QInputDialog::inputMode() const -
415{ -
416 const QInputDialogPrivate * const d = d_func(); -
417 -
418 if (d->inputWidget) {
evaluated: d->inputWidget
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:4
4-34
419 if (d->inputWidget == d->intSpinBox) {
evaluated: d->inputWidget == d->intSpinBox
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:29
5-29
420 return IntInput;
executed: return IntInput;
Execution Count:5
5
421 } else if (d->inputWidget == d->doubleSpinBox) {
evaluated: d->inputWidget == d->doubleSpinBox
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:13
13-16
422 return DoubleInput;
executed: return DoubleInput;
Execution Count:16
16
423 } -
424 } -
425 -
426 return TextInput;
executed: return TextInput;
Execution Count:17
17
427} -
428void QInputDialog::setLabelText(const QString &text) -
429{ -
430 QInputDialogPrivate * const d = d_func(); -
431 if (!d->label) {
partially evaluated: !d->label
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-31
432 d->label = new QLabel(text, this); -
433 } else {
executed: }
Execution Count:31
31
434 d->label->setText(text); -
435 }
never executed: }
0
436} -
437 -
438QString QInputDialog::labelText() const -
439{ -
440 const QInputDialogPrivate * const d = d_func(); -
441 d->ensureLayout(); -
442 return d->label->text();
never executed: return d->label->text();
0
443} -
444void QInputDialog::setOption(InputDialogOption option, bool on) -
445{ -
446 QInputDialogPrivate * const d = d_func(); -
447 if (!(d->opts & option) != !on)
never evaluated: !(d->opts & option) != !on
0
448 setOptions(d->opts ^ option);
never executed: setOptions(d->opts ^ option);
0
449}
never executed: }
0
450 -
451 -
452 -
453 -
454 -
455 -
456 -
457bool QInputDialog::testOption(InputDialogOption option) const -
458{ -
459 const QInputDialogPrivate * const d = d_func(); -
460 return (d->opts & option) != 0;
never executed: return (d->opts & option) != 0;
0
461} -
462void QInputDialog::setOptions(InputDialogOptions options) -
463{ -
464 QInputDialogPrivate * const d = d_func(); -
465 -
466 InputDialogOptions changed = (options ^ d->opts); -
467 if (!changed)
never evaluated: !changed
0
468 return;
never executed: return;
0
469 -
470 d->opts = options; -
471 d->ensureLayout(); -
472 -
473 if (changed & NoButtons)
never evaluated: changed & NoButtons
0
474 d->buttonBox->setVisible(!(options & NoButtons));
never executed: d->buttonBox->setVisible(!(options & NoButtons));
0
475 if ((changed & UseListViewForComboBoxItems) && inputMode() == TextInput)
never evaluated: (changed & UseListViewForComboBoxItems)
never evaluated: inputMode() == TextInput
0
476 d->chooseRightTextInputWidget();
never executed: d->chooseRightTextInputWidget();
0
477}
never executed: }
0
478 -
479QInputDialog::InputDialogOptions QInputDialog::options() const -
480{ -
481 const QInputDialogPrivate * const d = d_func(); -
482 return d->opts;
never executed: return d->opts;
0
483} -
484void QInputDialog::setTextValue(const QString &text) -
485{ -
486 QInputDialogPrivate * const d = d_func(); -
487 -
488 setInputMode(TextInput); -
489 if (d->inputWidget == d->lineEdit) {
evaluated: d->inputWidget == d->lineEdit
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
490 d->lineEdit->setText(text); -
491 } else if (d->inputWidget == d->comboBox) {
partially evaluated: d->inputWidget == d->comboBox
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
executed: }
Execution Count:6
0-6
492 d->setComboBoxText(text); -
493 } else {
executed: }
Execution Count:4
4
494 d->setListViewText(text); -
495 }
never executed: }
0
496} -
497 -
498QString QInputDialog::textValue() const -
499{ -
500 const QInputDialogPrivate * const d = d_func(); -
501 return d->textValue;
executed: return d->textValue;
Execution Count:18
18
502} -
503void QInputDialog::setTextEchoMode(QLineEdit::EchoMode mode) -
504{ -
505 QInputDialogPrivate * const d = d_func(); -
506 d->ensureLineEdit(); -
507 d->lineEdit->setEchoMode(mode); -
508}
executed: }
Execution Count:6
6
509 -
510QLineEdit::EchoMode QInputDialog::textEchoMode() const -
511{ -
512 const QInputDialogPrivate * const d = d_func(); -
513 if (d->lineEdit) {
never evaluated: d->lineEdit
0
514 return d->lineEdit->echoMode();
never executed: return d->lineEdit->echoMode();
0
515 } else { -
516 return QLineEdit::Normal;
never executed: return QLineEdit::Normal;
0
517 } -
518} -
519void QInputDialog::setComboBoxEditable(bool editable) -
520{ -
521 QInputDialogPrivate * const d = d_func(); -
522 d->ensureComboBox(); -
523 d->comboBox->setEditable(editable); -
524 if (inputMode() == TextInput)
partially evaluated: inputMode() == TextInput
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
525 d->chooseRightTextInputWidget();
executed: d->chooseRightTextInputWidget();
Execution Count:4
4
526}
executed: }
Execution Count:4
4
527 -
528bool QInputDialog::isComboBoxEditable() const -
529{ -
530 const QInputDialogPrivate * const d = d_func(); -
531 if (d->comboBox) {
never evaluated: d->comboBox
0
532 return d->comboBox->isEditable();
never executed: return d->comboBox->isEditable();
0
533 } else { -
534 return false;
never executed: return false;
0
535 } -
536} -
537void QInputDialog::setComboBoxItems(const QStringList &items) -
538{ -
539 QInputDialogPrivate * const d = d_func(); -
540 -
541 d->ensureComboBox(); -
542 d->comboBox->blockSignals(true); -
543 d->comboBox->clear(); -
544 d->comboBox->addItems(items); -
545 d->comboBox->blockSignals(false); -
546 -
547 if (inputMode() == TextInput)
partially evaluated: inputMode() == TextInput
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
548 d->chooseRightTextInputWidget();
executed: d->chooseRightTextInputWidget();
Execution Count:4
4
549}
executed: }
Execution Count:4
4
550 -
551QStringList QInputDialog::comboBoxItems() const -
552{ -
553 const QInputDialogPrivate * const d = d_func(); -
554 QStringList result; -
555 if (d->comboBox) {
never evaluated: d->comboBox
0
556 const int count = d->comboBox->count(); -
557 for (int i = 0; i < count; ++i)
never evaluated: i < count
0
558 result.append(d->comboBox->itemText(i));
never executed: result.append(d->comboBox->itemText(i));
0
559 }
never executed: }
0
560 return result;
never executed: return result;
0
561} -
562void QInputDialog::setIntValue(int value) -
563{ -
564 QInputDialogPrivate * const d = d_func(); -
565 setInputMode(IntInput); -
566 d->intSpinBox->setValue(value); -
567}
executed: }
Execution Count:5
5
568 -
569int QInputDialog::intValue() const -
570{ -
571 const QInputDialogPrivate * const d = d_func(); -
572 if (d->intSpinBox) {
partially evaluated: d->intSpinBox
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
573 return d->intSpinBox->value();
executed: return d->intSpinBox->value();
Execution Count:10
10
574 } else { -
575 return 0;
never executed: return 0;
0
576 } -
577} -
578void QInputDialog::setIntMinimum(int min) -
579{ -
580 QInputDialogPrivate * const d = d_func(); -
581 d->ensureIntSpinBox(); -
582 d->intSpinBox->setMinimum(min); -
583}
never executed: }
0
584 -
585int QInputDialog::intMinimum() const -
586{ -
587 const QInputDialogPrivate * const d = d_func(); -
588 if (d->intSpinBox) {
never evaluated: d->intSpinBox
0
589 return d->intSpinBox->minimum();
never executed: return d->intSpinBox->minimum();
0
590 } else { -
591 return 0;
never executed: return 0;
0
592 } -
593} -
594void QInputDialog::setIntMaximum(int max) -
595{ -
596 QInputDialogPrivate * const d = d_func(); -
597 d->ensureIntSpinBox(); -
598 d->intSpinBox->setMaximum(max); -
599}
never executed: }
0
600 -
601int QInputDialog::intMaximum() const -
602{ -
603 const QInputDialogPrivate * const d = d_func(); -
604 if (d->intSpinBox) {
never evaluated: d->intSpinBox
0
605 return d->intSpinBox->maximum();
never executed: return d->intSpinBox->maximum();
0
606 } else { -
607 return 99;
never executed: return 99;
0
608 } -
609} -
610 -
611 -
612 -
613 -
614 -
615 -
616void QInputDialog::setIntRange(int min, int max) -
617{ -
618 QInputDialogPrivate * const d = d_func(); -
619 d->ensureIntSpinBox(); -
620 d->intSpinBox->setRange(min, max); -
621}
executed: }
Execution Count:5
5
622void QInputDialog::setIntStep(int step) -
623{ -
624 QInputDialogPrivate * const d = d_func(); -
625 d->ensureIntSpinBox(); -
626 d->intSpinBox->setSingleStep(step); -
627}
executed: }
Execution Count:5
5
628 -
629int QInputDialog::intStep() const -
630{ -
631 const QInputDialogPrivate * const d = d_func(); -
632 if (d->intSpinBox) {
never evaluated: d->intSpinBox
0
633 return d->intSpinBox->singleStep();
never executed: return d->intSpinBox->singleStep();
0
634 } else { -
635 return 1;
never executed: return 1;
0
636 } -
637} -
638void QInputDialog::setDoubleValue(double value) -
639{ -
640 QInputDialogPrivate * const d = d_func(); -
641 setInputMode(DoubleInput); -
642 d->doubleSpinBox->setValue(value); -
643}
executed: }
Execution Count:16
16
644 -
645double QInputDialog::doubleValue() const -
646{ -
647 const QInputDialogPrivate * const d = d_func(); -
648 if (d->doubleSpinBox) {
partially evaluated: d->doubleSpinBox
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
649 return d->doubleSpinBox->value();
executed: return d->doubleSpinBox->value();
Execution Count:32
32
650 } else { -
651 return 0.0;
never executed: return 0.0;
0
652 } -
653} -
654void QInputDialog::setDoubleMinimum(double min) -
655{ -
656 QInputDialogPrivate * const d = d_func(); -
657 d->ensureDoubleSpinBox(); -
658 d->doubleSpinBox->setMinimum(min); -
659}
never executed: }
0
660 -
661double QInputDialog::doubleMinimum() const -
662{ -
663 const QInputDialogPrivate * const d = d_func(); -
664 if (d->doubleSpinBox) {
never evaluated: d->doubleSpinBox
0
665 return d->doubleSpinBox->minimum();
never executed: return d->doubleSpinBox->minimum();
0
666 } else { -
667 return 0.0;
never executed: return 0.0;
0
668 } -
669} -
670void QInputDialog::setDoubleMaximum(double max) -
671{ -
672 QInputDialogPrivate * const d = d_func(); -
673 d->ensureDoubleSpinBox(); -
674 d->doubleSpinBox->setMaximum(max); -
675}
never executed: }
0
676 -
677double QInputDialog::doubleMaximum() const -
678{ -
679 const QInputDialogPrivate * const d = d_func(); -
680 if (d->doubleSpinBox) {
never evaluated: d->doubleSpinBox
0
681 return d->doubleSpinBox->maximum();
never executed: return d->doubleSpinBox->maximum();
0
682 } else { -
683 return 99.99;
never executed: return 99.99;
0
684 } -
685} -
686 -
687 -
688 -
689 -
690 -
691 -
692void QInputDialog::setDoubleRange(double min, double max) -
693{ -
694 QInputDialogPrivate * const d = d_func(); -
695 d->ensureDoubleSpinBox(); -
696 d->doubleSpinBox->setRange(min, max); -
697}
executed: }
Execution Count:16
16
698void QInputDialog::setDoubleDecimals(int decimals) -
699{ -
700 QInputDialogPrivate * const d = d_func(); -
701 d->ensureDoubleSpinBox(); -
702 d->doubleSpinBox->setDecimals(decimals); -
703}
executed: }
Execution Count:16
16
704 -
705int QInputDialog::doubleDecimals() const -
706{ -
707 const QInputDialogPrivate * const d = d_func(); -
708 if (d->doubleSpinBox) {
never evaluated: d->doubleSpinBox
0
709 return d->doubleSpinBox->decimals();
never executed: return d->doubleSpinBox->decimals();
0
710 } else { -
711 return 2;
never executed: return 2;
0
712 } -
713} -
714void QInputDialog::setOkButtonText(const QString &text) -
715{ -
716 const QInputDialogPrivate * const d = d_func(); -
717 d->ensureLayout(); -
718 d->buttonBox->button(QDialogButtonBox::Ok)->setText(text); -
719}
never executed: }
0
720 -
721QString QInputDialog::okButtonText() const -
722{ -
723 const QInputDialogPrivate * const d = d_func(); -
724 d->ensureLayout(); -
725 return d->buttonBox->button(QDialogButtonBox::Ok)->text();
never executed: return d->buttonBox->button(QDialogButtonBox::Ok)->text();
0
726} -
727 -
728 -
729 -
730 -
731 -
732 -
733 -
734void QInputDialog::setCancelButtonText(const QString &text) -
735{ -
736 const QInputDialogPrivate * const d = d_func(); -
737 d->ensureLayout(); -
738 d->buttonBox->button(QDialogButtonBox::Cancel)->setText(text); -
739}
never executed: }
0
740 -
741QString QInputDialog::cancelButtonText() const -
742{ -
743 const QInputDialogPrivate * const d = d_func(); -
744 d->ensureLayout(); -
745 return d->buttonBox->button(QDialogButtonBox::Cancel)->text();
never executed: return d->buttonBox->button(QDialogButtonBox::Cancel)->text();
0
746} -
747void QInputDialog::open(QObject *receiver, const char *member) -
748{ -
749 QInputDialogPrivate * const d = d_func(); -
750 connect(this, signalForMember(member), receiver, member); -
751 d->receiverToDisconnectOnClose = receiver; -
752 d->memberToDisconnectOnClose = member; -
753 QDialog::open(); -
754}
never executed: }
0
755 -
756 -
757 -
758 -
759QSize QInputDialog::minimumSizeHint() const -
760{ -
761 const QInputDialogPrivate * const d = d_func(); -
762 d->ensureLayout(); -
763 return QDialog::minimumSizeHint();
never executed: return QDialog::minimumSizeHint();
0
764} -
765 -
766 -
767 -
768 -
769QSize QInputDialog::sizeHint() const -
770{ -
771 const QInputDialogPrivate * const d = d_func(); -
772 d->ensureLayout(); -
773 return QDialog::sizeHint();
executed: return QDialog::sizeHint();
Execution Count:31
31
774} -
775 -
776 -
777 -
778 -
779void QInputDialog::setVisible(bool visible) -
780{ -
781 const QInputDialogPrivate * const d = d_func(); -
782 if (visible) {
evaluated: visible
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:31
31
783 d->ensureLayout(); -
784 d->inputWidget->setFocus(); -
785 if (d->inputWidget == d->lineEdit) {
evaluated: d->inputWidget == d->lineEdit
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:25
6-25
786 d->lineEdit->selectAll(); -
787 } else if (d->inputWidget == d->intSpinBox) {
executed: }
Execution Count:6
evaluated: d->inputWidget == d->intSpinBox
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:20
5-20
788 d->intSpinBox->selectAll(); -
789 } else if (d->inputWidget == d->doubleSpinBox) {
executed: }
Execution Count:5
evaluated: d->inputWidget == d->doubleSpinBox
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
4-16
790 d->doubleSpinBox->selectAll(); -
791 }
executed: }
Execution Count:16
16
792 } -
793 QDialog::setVisible(visible); -
794}
executed: }
Execution Count:62
62
795void QInputDialog::done(int result) -
796{ -
797 QInputDialogPrivate * const d = d_func(); -
798 QDialog::done(result); -
799 if (result) {
evaluated: result
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:1
1-30
800 InputMode mode = inputMode(); -
801 switch (mode) { -
802 case DoubleInput: -
803 doubleValueSelected(doubleValue()); -
804 break;
executed: break;
Execution Count:16
16
805 case IntInput: -
806 intValueSelected(intValue()); -
807 break;
executed: break;
Execution Count:5
5
808 default: -
809 qt_noop(); -
810 textValueSelected(textValue()); -
811 }
executed: }
Execution Count:9
9
812 }
executed: }
Execution Count:30
30
813 if (d->receiverToDisconnectOnClose) {
partially evaluated: d->receiverToDisconnectOnClose
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
814 disconnect(this, signalForMember(d->memberToDisconnectOnClose), -
815 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); -
816 d->receiverToDisconnectOnClose = 0; -
817 }
never executed: }
0
818 d->memberToDisconnectOnClose.clear(); -
819}
executed: }
Execution Count:31
31
820QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label, -
821 QLineEdit::EchoMode mode, const QString &text, bool *ok, -
822 Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) -
823{ -
824 QInputDialog dialog(parent, flags); -
825 dialog.setWindowTitle(title); -
826 dialog.setLabelText(label); -
827 dialog.setTextValue(text); -
828 dialog.setTextEchoMode(mode); -
829 dialog.setInputMethodHints(inputMethodHints); -
830 -
831 int ret = dialog.exec(); -
832 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
833 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:6
6
834 if (ret) {
evaluated: ret
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
835 return dialog.textValue();
executed: return dialog.textValue();
Execution Count:5
5
836 } else { -
837 return QString();
executed: return QString();
Execution Count:1
1
838 } -
839} -
840int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &label, int value, -
841 int min, int max, int step, bool *ok, Qt::WindowFlags flags) -
842{ -
843 QInputDialog dialog(parent, flags); -
844 dialog.setWindowTitle(title); -
845 dialog.setLabelText(label); -
846 dialog.setIntRange(min, max); -
847 dialog.setIntValue(value); -
848 dialog.setIntStep(step); -
849 -
850 int ret = dialog.exec(); -
851 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
852 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:5
5
853 if (ret) {
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
854 return dialog.intValue();
executed: return dialog.intValue();
Execution Count:5
5
855 } else { -
856 return value;
never executed: return value;
0
857 } -
858} -
859double QInputDialog::getDouble(QWidget *parent, const QString &title, const QString &label, -
860 double value, double min, double max, int decimals, bool *ok, -
861 Qt::WindowFlags flags) -
862{ -
863 QInputDialog dialog(parent, flags); -
864 dialog.setWindowTitle(title); -
865 dialog.setLabelText(label); -
866 dialog.setDoubleDecimals(decimals); -
867 dialog.setDoubleRange(min, max); -
868 dialog.setDoubleValue(value); -
869 -
870 int ret = dialog.exec(); -
871 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
872 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:16
16
873 if (ret) {
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
874 return dialog.doubleValue();
executed: return dialog.doubleValue();
Execution Count:16
16
875 } else { -
876 return value;
never executed: return value;
0
877 } -
878} -
879QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label, -
880 const QStringList &items, int current, bool editable, bool *ok, -
881 Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) -
882{ -
883 QString text(items.value(current)); -
884 -
885 QInputDialog dialog(parent, flags); -
886 dialog.setWindowTitle(title); -
887 dialog.setLabelText(label); -
888 dialog.setComboBoxItems(items); -
889 dialog.setTextValue(text); -
890 dialog.setComboBoxEditable(editable); -
891 dialog.setInputMethodHints(inputMethodHints); -
892 -
893 int ret = dialog.exec(); -
894 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
895 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:4
4
896 if (ret) {
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
897 return dialog.textValue();
executed: return dialog.textValue();
Execution Count:4
4
898 } else { -
899 return text;
never executed: return text;
0
900 } -
901} -
902 -
903 -
904 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial