dialogs/qinputdialog.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 "qinputdialog.h" -
43 -
44#ifndef QT_NO_INPUTDIALOG -
45 -
46#include "qapplication.h" -
47#include "qcombobox.h" -
48#include "qdialogbuttonbox.h" -
49#include "qlabel.h" -
50#include "qlayout.h" -
51#include "qlineedit.h" -
52#include "qlistwidget.h" -
53#include "qpushbutton.h" -
54#include "qspinbox.h" -
55#include "qstackedlayout.h" -
56#include "qvalidator.h" -
57#include "qevent.h" -
58#include "qdialog_p.h" -
59 -
60QT_USE_NAMESPACE -
61 -
62static const char *signalForMember(const char *member) -
63{ -
64 static const int NumCandidates = 4; -
65 static const char * const candidateSignals[NumCandidates] = { -
66 SIGNAL(textValueSelected(QString)), -
67 SIGNAL(intValueSelected(int)), -
68 SIGNAL(doubleValueSelected(double)), -
69 SIGNAL(accepted()) -
70 }; -
71 -
72 QByteArray normalizedMember(QMetaObject::normalizedSignature(member));
never executed (the execution status of this line is deduced): QByteArray normalizedMember(QMetaObject::normalizedSignature(member));
-
73 -
74 int i = 0;
never executed (the execution status of this line is deduced): int i = 0;
-
75 while (i < NumCandidates - 1) { // sic
never evaluated: i < NumCandidates - 1
0
76 if (QMetaObject::checkConnectArgs(candidateSignals[i], normalizedMember))
never evaluated: QMetaObject::checkConnectArgs(candidateSignals[i], normalizedMember)
0
77 break;
never executed: break;
0
78 ++i;
never executed (the execution status of this line is deduced): ++i;
-
79 }
never executed: }
0
80 return candidateSignals[i];
never executed: return candidateSignals[i];
0
81} -
82 -
83QT_BEGIN_NAMESPACE -
84 -
85/* -
86 These internal classes add extra validation to QSpinBox and QDoubleSpinBox by emitting -
87 textChanged(bool) after events that may potentially change the visible text. Return or -
88 Enter key presses are not propagated if the visible text is invalid. Instead, the visible -
89 text is modified to the last valid value. -
90*/ -
91class QInputDialogSpinBox : public QSpinBox -
92{ -
93 Q_OBJECT -
94 -
95public: -
96 QInputDialogSpinBox(QWidget *parent) -
97 : QSpinBox(parent) { -
98 connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
executed (the execution status of this line is deduced): connect(lineEdit(), "2""textChanged(QString)", this, "1""notifyTextChanged()");
-
99 connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
executed (the execution status of this line is deduced): connect(this, "2""editingFinished()", this, "1""notifyTextChanged()");
-
100 }
executed: }
Execution Count:5
5
101 -
102signals: -
103 void textChanged(bool); -
104 -
105private slots: -
106 void notifyTextChanged() { emit textChanged(hasAcceptableInput()); }
executed: }
Execution Count:173
173
107 -
108private: -
109 void keyPressEvent(QKeyEvent *event) { -
110 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
111#ifndef QT_NO_PROPERTIES -
112 setProperty("value", property("value"));
executed (the execution status of this line is deduced): setProperty("value", property("value"));
-
113#endif -
114 } else {
executed: }
Execution Count:5
5
115 QSpinBox::keyPressEvent(event);
executed (the execution status of this line is deduced): QSpinBox::keyPressEvent(event);
-
116 }
executed: }
Execution Count:104
104
117 notifyTextChanged();
executed (the execution status of this line is deduced): notifyTextChanged();
-
118 }
executed: }
Execution Count:109
109
119 -
120 void mousePressEvent(QMouseEvent *event) { -
121 QSpinBox::mousePressEvent(event);
never executed (the execution status of this line is deduced): QSpinBox::mousePressEvent(event);
-
122 notifyTextChanged();
never executed (the execution status of this line is deduced): notifyTextChanged();
-
123 }
never executed: }
0
124}; -
125 -
126class QInputDialogDoubleSpinBox : public QDoubleSpinBox -
127{ -
128 Q_OBJECT -
129 -
130public: -
131 QInputDialogDoubleSpinBox(QWidget *parent = 0) -
132 : QDoubleSpinBox(parent) { -
133 connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
executed (the execution status of this line is deduced): connect(lineEdit(), "2""textChanged(QString)", this, "1""notifyTextChanged()");
-
134 connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
executed (the execution status of this line is deduced): connect(this, "2""editingFinished()", this, "1""notifyTextChanged()");
-
135 }
executed: }
Execution Count:16
16
136 -
137signals: -
138 void textChanged(bool); -
139 -
140private slots: -
141 void notifyTextChanged() { emit textChanged(hasAcceptableInput()); }
executed: }
Execution Count:723
723
142 -
143private: -
144 void keyPressEvent(QKeyEvent *event) { -
145 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
146#ifndef QT_NO_PROPERTIES -
147 setProperty("value", property("value"));
executed (the execution status of this line is deduced): setProperty("value", property("value"));
-
148#endif -
149 } else {
executed: }
Execution Count:16
16
150 QDoubleSpinBox::keyPressEvent(event);
executed (the execution status of this line is deduced): QDoubleSpinBox::keyPressEvent(event);
-
151 }
executed: }
Execution Count:413
413
152 notifyTextChanged();
executed (the execution status of this line is deduced): notifyTextChanged();
-
153 }
executed: }
Execution Count:429
429
154 -
155 void mousePressEvent(QMouseEvent *event) { -
156 QDoubleSpinBox::mousePressEvent(event);
never executed (the execution status of this line is deduced): QDoubleSpinBox::mousePressEvent(event);
-
157 notifyTextChanged();
never executed (the execution status of this line is deduced): notifyTextChanged();
-
158 }
never executed: }
0
159}; -
160 -
161class QInputDialogPrivate : public QDialogPrivate -
162{ -
163 Q_DECLARE_PUBLIC(QInputDialog) -
164 -
165public: -
166 QInputDialogPrivate(); -
167 -
168 void ensureLayout(); -
169 void ensureLineEdit(); -
170 void ensureComboBox(); -
171 void ensureListView(); -
172 void ensureIntSpinBox(); -
173 void ensureDoubleSpinBox(); -
174 void ensureEnabledConnection(QAbstractSpinBox *spinBox); -
175 void setInputWidget(QWidget *widget); -
176 void chooseRightTextInputWidget(); -
177 void setComboBoxText(const QString &text); -
178 void setListViewText(const QString &text); -
179 QString listViewText() const; -
180 void ensureLayout() const { const_cast<QInputDialogPrivate *>(this)->ensureLayout(); }
executed: }
Execution Count:62
62
181 bool useComboBoxOrListView() const { return comboBox && comboBox->count() > 0; }
executed: return comboBox && comboBox->count() > 0;
Execution Count:19
19
182 void _q_textChanged(const QString &text); -
183 void _q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex); -
184 -
185 mutable QLabel *label; -
186 mutable QDialogButtonBox *buttonBox; -
187 mutable QLineEdit *lineEdit; -
188 mutable QSpinBox *intSpinBox; -
189 mutable QDoubleSpinBox *doubleSpinBox; -
190 mutable QComboBox *comboBox; -
191 mutable QListView *listView; -
192 mutable QWidget *inputWidget; -
193 mutable QVBoxLayout *mainLayout; -
194 QInputDialog::InputDialogOptions opts; -
195 QString textValue; -
196 QPointer<QObject> receiverToDisconnectOnClose; -
197 QByteArray memberToDisconnectOnClose; -
198}; -
199 -
200QInputDialogPrivate::QInputDialogPrivate() -
201 : label(0), buttonBox(0), lineEdit(0), intSpinBox(0), doubleSpinBox(0), comboBox(0), listView(0), -
202 inputWidget(0), mainLayout(0) -
203{ -
204}
executed: }
Execution Count:32
32
205 -
206void QInputDialogPrivate::ensureLayout() -
207{ -
208 Q_Q(QInputDialog);
executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
209 -
210 if (mainLayout)
evaluated: mainLayout
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:31
31
211 return;
executed: return;
Execution Count:31
31
212 -
213 if (!inputWidget) {
partially evaluated: !inputWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
214 ensureLineEdit();
never executed (the execution status of this line is deduced): ensureLineEdit();
-
215 inputWidget = lineEdit;
never executed (the execution status of this line is deduced): inputWidget = lineEdit;
-
216 }
never executed: }
0
217 -
218 if (!label)
partially evaluated: !label
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
219 label = new QLabel(QInputDialog::tr("Enter a value:"), q);
never executed: label = new QLabel(QInputDialog::tr("Enter a value:"), q);
0
220#ifndef QT_NO_SHORTCUT -
221 label->setBuddy(inputWidget);
executed (the execution status of this line is deduced): label->setBuddy(inputWidget);
-
222#endif -
223 label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
executed (the execution status of this line is deduced): label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
-
224 -
225 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q);
executed (the execution status of this line is deduced): buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q);
-
226 QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
executed (the execution status of this line is deduced): QObject::connect(buttonBox, "2""accepted()", q, "1""accept()");
-
227 QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
executed (the execution status of this line is deduced): QObject::connect(buttonBox, "2""rejected()", q, "1""reject()");
-
228 -
229 mainLayout = new QVBoxLayout(q);
executed (the execution status of this line is deduced): mainLayout = new QVBoxLayout(q);
-
230 //we want to let the input dialog grow to available size on Symbian. -
231 mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
executed (the execution status of this line is deduced): mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
-
232 mainLayout->addWidget(label);
executed (the execution status of this line is deduced): mainLayout->addWidget(label);
-
233 mainLayout->addWidget(inputWidget);
executed (the execution status of this line is deduced): mainLayout->addWidget(inputWidget);
-
234 mainLayout->addWidget(buttonBox);
executed (the execution status of this line is deduced): mainLayout->addWidget(buttonBox);
-
235 ensureEnabledConnection(qobject_cast<QAbstractSpinBox *>(inputWidget));
executed (the execution status of this line is deduced): ensureEnabledConnection(qobject_cast<QAbstractSpinBox *>(inputWidget));
-
236 inputWidget->show();
executed (the execution status of this line is deduced): inputWidget->show();
-
237}
executed: }
Execution Count:31
31
238 -
239void QInputDialogPrivate::ensureLineEdit() -
240{ -
241 Q_Q(QInputDialog);
executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
242 if (!lineEdit) {
evaluated: !lineEdit
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
243 lineEdit = new QLineEdit(q);
executed (the execution status of this line is deduced): lineEdit = new QLineEdit(q);
-
244#ifndef QT_NO_IM -
245 qt_widget_private(lineEdit)->inheritsInputMethodHints = 1;
executed (the execution status of this line is deduced): qt_widget_private(lineEdit)->inheritsInputMethodHints = 1;
-
246#endif -
247 lineEdit->hide();
executed (the execution status of this line is deduced): lineEdit->hide();
-
248 QObject::connect(lineEdit, SIGNAL(textChanged(QString)),
executed (the execution status of this line is deduced): QObject::connect(lineEdit, "2""textChanged(QString)",
-
249 q, SLOT(_q_textChanged(QString)));
executed (the execution status of this line is deduced): q, "1""_q_textChanged(QString)");
-
250 }
executed: }
Execution Count:7
7
251}
executed: }
Execution Count:13
13
252 -
253void QInputDialogPrivate::ensureComboBox() -
254{ -
255 Q_Q(QInputDialog);
executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
256 if (!comboBox) {
evaluated: !comboBox
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
257 comboBox = new QComboBox(q);
executed (the execution status of this line is deduced): comboBox = new QComboBox(q);
-
258#ifndef QT_NO_IM -
259 qt_widget_private(comboBox)->inheritsInputMethodHints = 1;
executed (the execution status of this line is deduced): qt_widget_private(comboBox)->inheritsInputMethodHints = 1;
-
260#endif -
261 comboBox->hide();
executed (the execution status of this line is deduced): comboBox->hide();
-
262 QObject::connect(comboBox, SIGNAL(editTextChanged(QString)),
executed (the execution status of this line is deduced): QObject::connect(comboBox, "2""editTextChanged(QString)",
-
263 q, SLOT(_q_textChanged(QString)));
executed (the execution status of this line is deduced): q, "1""_q_textChanged(QString)");
-
264 QObject::connect(comboBox, SIGNAL(currentIndexChanged(QString)),
executed (the execution status of this line is deduced): QObject::connect(comboBox, "2""currentIndexChanged(QString)",
-
265 q, SLOT(_q_textChanged(QString)));
executed (the execution status of this line is deduced): q, "1""_q_textChanged(QString)");
-
266 }
executed: }
Execution Count:4
4
267}
executed: }
Execution Count:8
8
268 -
269void QInputDialogPrivate::ensureListView() -
270{ -
271 Q_Q(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
272 if (!listView) {
never evaluated: !listView
0
273 ensureComboBox();
never executed (the execution status of this line is deduced): ensureComboBox();
-
274 -
275 listView = new QListView(q);
never executed (the execution status of this line is deduced): listView = new QListView(q);
-
276 listView->hide();
never executed (the execution status of this line is deduced): listView->hide();
-
277 listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
never executed (the execution status of this line is deduced): listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
-
278 listView->setSelectionMode(QAbstractItemView::SingleSelection);
never executed (the execution status of this line is deduced): listView->setSelectionMode(QAbstractItemView::SingleSelection);
-
279 listView->setModel(comboBox->model());
never executed (the execution status of this line is deduced): listView->setModel(comboBox->model());
-
280 listView->setCurrentIndex(QModelIndex()); // ###
never executed (the execution status of this line is deduced): listView->setCurrentIndex(QModelIndex());
-
281 QObject::connect(listView->selectionModel(),
never executed (the execution status of this line is deduced): QObject::connect(listView->selectionModel(),
-
282 SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
never executed (the execution status of this line is deduced): "2""currentRowChanged(QModelIndex,QModelIndex)",
-
283 q, SLOT(_q_currentRowChanged(QModelIndex,QModelIndex)));
never executed (the execution status of this line is deduced): q, "1""_q_currentRowChanged(QModelIndex,QModelIndex)");
-
284 }
never executed: }
0
285}
never executed: }
0
286 -
287void QInputDialogPrivate::ensureIntSpinBox() -
288{ -
289 Q_Q(QInputDialog);
executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
290 if (!intSpinBox) {
evaluated: !intSpinBox
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:10
5-10
291 intSpinBox = new QInputDialogSpinBox(q);
executed (the execution status of this line is deduced): intSpinBox = new QInputDialogSpinBox(q);
-
292 intSpinBox->hide();
executed (the execution status of this line is deduced): intSpinBox->hide();
-
293 QObject::connect(intSpinBox, SIGNAL(valueChanged(int)),
executed (the execution status of this line is deduced): QObject::connect(intSpinBox, "2""valueChanged(int)",
-
294 q, SIGNAL(intValueChanged(int)));
executed (the execution status of this line is deduced): q, "2""intValueChanged(int)");
-
295 }
executed: }
Execution Count:5
5
296}
executed: }
Execution Count:15
15
297 -
298void QInputDialogPrivate::ensureDoubleSpinBox() -
299{ -
300 Q_Q(QInputDialog);
executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
301 if (!doubleSpinBox) {
evaluated: !doubleSpinBox
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:32
16-32
302 doubleSpinBox = new QInputDialogDoubleSpinBox(q);
executed (the execution status of this line is deduced): doubleSpinBox = new QInputDialogDoubleSpinBox(q);
-
303 doubleSpinBox->hide();
executed (the execution status of this line is deduced): doubleSpinBox->hide();
-
304 QObject::connect(doubleSpinBox, SIGNAL(valueChanged(double)),
executed (the execution status of this line is deduced): QObject::connect(doubleSpinBox, "2""valueChanged(double)",
-
305 q, SIGNAL(doubleValueChanged(double)));
executed (the execution status of this line is deduced): q, "2""doubleValueChanged(double)");
-
306 }
executed: }
Execution Count:16
16
307}
executed: }
Execution Count:48
48
308 -
309void QInputDialogPrivate::ensureEnabledConnection(QAbstractSpinBox *spinBox) -
310{ -
311 if (spinBox) {
evaluated: spinBox
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:10
10-21
312 QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
executed (the execution status of this line is deduced): QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
-
313 QObject::connect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)), Qt::UniqueConnection);
executed (the execution status of this line is deduced): QObject::connect(spinBox, "2""textChanged(bool)", okButton, "1""setEnabled(bool)", Qt::UniqueConnection);
-
314 }
executed: }
Execution Count:21
21
315}
executed: }
Execution Count:31
31
316 -
317void QInputDialogPrivate::setInputWidget(QWidget *widget) -
318{ -
319 Q_ASSERT(widget);
executed (the execution status of this line is deduced): qt_noop();
-
320 if (inputWidget == widget)
evaluated: inputWidget == widget
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:32
8-32
321 return;
executed: return;
Execution Count:8
8
322 -
323 if (mainLayout) {
partially evaluated: mainLayout
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
324 Q_ASSERT(inputWidget);
never executed (the execution status of this line is deduced): qt_noop();
-
325 mainLayout->removeWidget(inputWidget);
never executed (the execution status of this line is deduced): mainLayout->removeWidget(inputWidget);
-
326 inputWidget->hide();
never executed (the execution status of this line is deduced): inputWidget->hide();
-
327 mainLayout->insertWidget(1, widget);
never executed (the execution status of this line is deduced): mainLayout->insertWidget(1, widget);
-
328 widget->show();
never executed (the execution status of this line is deduced): widget->show();
-
329 -
330 // disconnect old input widget -
331 QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
never executed (the execution status of this line is deduced): QAbstractButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
-
332 if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(inputWidget))
never evaluated: QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(inputWidget)
0
333 QObject::disconnect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)));
never executed: QObject::disconnect(spinBox, "2""textChanged(bool)", okButton, "1""setEnabled(bool)");
0
334 -
335 // connect new input widget and update enabled state of OK button -
336 QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(widget);
never executed (the execution status of this line is deduced): QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(widget);
-
337 ensureEnabledConnection(spinBox);
never executed (the execution status of this line is deduced): ensureEnabledConnection(spinBox);
-
338 okButton->setEnabled(!spinBox || spinBox->hasAcceptableInput());
never executed (the execution status of this line is deduced): okButton->setEnabled(!spinBox || spinBox->hasAcceptableInput());
-
339 }
never executed: }
0
340 -
341 inputWidget = widget;
executed (the execution status of this line is deduced): inputWidget = widget;
-
342 -
343 // synchronize the text shown in the new text editor with the current -
344 // textValue -
345 if (widget == lineEdit) {
evaluated: widget == lineEdit
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:25
7-25
346 lineEdit->setText(textValue);
executed (the execution status of this line is deduced): lineEdit->setText(textValue);
-
347 } else if (widget == comboBox) {
executed: }
Execution Count:7
evaluated: widget == comboBox
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:21
4-21
348 setComboBoxText(textValue);
executed (the execution status of this line is deduced): setComboBoxText(textValue);
-
349 } else if (widget == listView) {
executed: }
Execution Count:4
partially evaluated: widget == listView
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
350 setListViewText(textValue);
never executed (the execution status of this line is deduced): setListViewText(textValue);
-
351 ensureLayout();
never executed (the execution status of this line is deduced): ensureLayout();
-
352 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(listView->selectionModel()->hasSelection());
never executed (the execution status of this line is deduced): buttonBox->button(QDialogButtonBox::Ok)->setEnabled(listView->selectionModel()->hasSelection());
-
353 }
never executed: }
0
354} -
355 -
356void QInputDialogPrivate::chooseRightTextInputWidget() -
357{ -
358 QWidget *widget;
executed (the execution status of this line is deduced): QWidget *widget;
-
359 -
360 if (useComboBoxOrListView()) {
evaluated: useComboBoxOrListView()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
7-12
361 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
362 ensureListView();
never executed (the execution status of this line is deduced): ensureListView();
-
363 widget = listView;
never executed (the execution status of this line is deduced): widget = listView;
-
364 } else {
never executed: }
0
365 widget = comboBox;
executed (the execution status of this line is deduced): widget = comboBox;
-
366 }
executed: }
Execution Count:12
12
367 } else { -
368 ensureLineEdit();
executed (the execution status of this line is deduced): ensureLineEdit();
-
369 widget = lineEdit;
executed (the execution status of this line is deduced): widget = lineEdit;
-
370 }
executed: }
Execution Count:7
7
371 -
372 setInputWidget(widget);
executed (the execution status of this line is deduced): setInputWidget(widget);
-
373 -
374 if (inputWidget == comboBox) {
evaluated: inputWidget == comboBox
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:7
7-12
375 _q_textChanged(comboBox->currentText());
executed (the execution status of this line is deduced): _q_textChanged(comboBox->currentText());
-
376 } else if (inputWidget == listView) {
executed: }
Execution Count:12
partially evaluated: inputWidget == listView
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-12
377 _q_textChanged(listViewText());
never executed (the execution status of this line is deduced): _q_textChanged(listViewText());
-
378 }
never executed: }
0
379} -
380 -
381void QInputDialogPrivate::setComboBoxText(const QString &text) -
382{ -
383 int index = comboBox->findText(text);
executed (the execution status of this line is deduced): int index = comboBox->findText(text);
-
384 if (index != -1) {
evaluated: index != -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
385 comboBox->setCurrentIndex(index);
executed (the execution status of this line is deduced): comboBox->setCurrentIndex(index);
-
386 } else if (comboBox->isEditable()) {
executed: }
Execution Count:6
partially evaluated: comboBox->isEditable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-6
387 comboBox->setEditText(text);
never executed (the execution status of this line is deduced): comboBox->setEditText(text);
-
388 }
never executed: }
0
389} -
390 -
391void QInputDialogPrivate::setListViewText(const QString &text) -
392{ -
393 int row = comboBox->findText(text);
never executed (the execution status of this line is deduced): int row = comboBox->findText(text);
-
394 if (row != -1) {
never evaluated: row != -1
0
395 QModelIndex index(comboBox->model()->index(row, 0));
never executed (the execution status of this line is deduced): QModelIndex index(comboBox->model()->index(row, 0));
-
396 listView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear
never executed (the execution status of this line is deduced): listView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear
-
397 | QItemSelectionModel::SelectCurrent);
never executed (the execution status of this line is deduced): | QItemSelectionModel::SelectCurrent);
-
398 }
never executed: }
0
399}
never executed: }
0
400 -
401QString QInputDialogPrivate::listViewText() const -
402{ -
403 if (listView->selectionModel()->hasSelection()) {
never evaluated: listView->selectionModel()->hasSelection()
0
404 int row = listView->selectionModel()->selectedRows().value(0).row();
never executed (the execution status of this line is deduced): int row = listView->selectionModel()->selectedRows().value(0).row();
-
405 return comboBox->itemText(row);
never executed: return comboBox->itemText(row);
0
406 } else { -
407 return QString();
never executed: return QString();
0
408 } -
409} -
410 -
411void QInputDialogPrivate::_q_textChanged(const QString &text) -
412{ -
413 Q_Q(QInputDialog);
executed (the execution status of this line is deduced): QInputDialog * const q = q_func();
-
414 if (textValue != text) {
evaluated: textValue != text
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:16
16-81
415 textValue = text;
executed (the execution status of this line is deduced): textValue = text;
-
416 emit q->textValueChanged(text);
executed (the execution status of this line is deduced): q->textValueChanged(text);
-
417 }
executed: }
Execution Count:81
81
418}
executed: }
Execution Count:97
97
419 -
420void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex, -
421 const QModelIndex & /* oldIndex */) -
422{ -
423 _q_textChanged(comboBox->model()->data(newIndex).toString());
never executed (the execution status of this line is deduced): _q_textChanged(comboBox->model()->data(newIndex).toString());
-
424 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
never executed (the execution status of this line is deduced): buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
-
425}
never executed: }
0
426 -
427/*! -
428 \class QInputDialog -
429 \brief The QInputDialog class provides a simple convenience dialog to get a -
430 single value from the user. -
431 \ingroup standard-dialogs -
432 \inmodule QtWidgets -
433 -
434 The input value can be a string, a number or an item from a list. A label -
435 must be set to tell the user what they should enter. -
436 -
437 Four static convenience functions are provided: getText(), getInt(), -
438 getDouble(), and getItem(). All the functions can be used in a similar way, -
439 for example: -
440 -
441 \snippet dialogs/standarddialogs/dialog.cpp 3 -
442 -
443 The \c ok variable is set to true if the user clicks \uicontrol OK; otherwise it -
444 is set to false. -
445 -
446 \image inputdialogs.png Input Dialogs -
447 -
448 The \l{dialogs/standarddialogs}{Standard Dialogs} example shows how to use -
449 QInputDialog as well as other built-in Qt dialogs. -
450 -
451 \sa QMessageBox, {Standard Dialogs Example} -
452*/ -
453 -
454/*! -
455 \enum QInputDialog::InputMode -
456 \since 4.5 -
457 -
458 This enum describes the different modes of input that can be selected for -
459 the dialog. -
460 -
461 \value TextInput Used to input text strings. -
462 \value IntInput Used to input integers. -
463 \value DoubleInput Used to input floating point numbers with double -
464 precision accuracy. -
465 -
466 \sa inputMode -
467*/ -
468 -
469/*! -
470 \since 4.5 -
471 -
472 Constructs a new input dialog with the given \a parent and window \a flags. -
473*/ -
474QInputDialog::QInputDialog(QWidget *parent, Qt::WindowFlags flags) -
475 : QDialog(*new QInputDialogPrivate, parent, flags) -
476{ -
477}
executed: }
Execution Count:32
32
478 -
479/*! -
480 \since 4.5 -
481 -
482 Destroys the input dialog. -
483*/ -
484QInputDialog::~QInputDialog() -
485{ -
486} -
487 -
488/*! -
489 \since 4.5 -
490 -
491 \property QInputDialog::inputMode -
492 -
493 \brief the mode used for input -
494 -
495 This property help determines which widget is used for entering input into -
496 the dialog. -
497*/ -
498void QInputDialog::setInputMode(InputMode mode) -
499{ -
500 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
501 -
502 QWidget *widget;
executed (the execution status of this line is deduced): QWidget *widget;
-
503 -
504 /* -
505 Warning: Some functions in QInputDialog rely on implementation details -
506 of the code below. Look for the comments that accompany the calls to -
507 setInputMode() throughout this file before you change the code below. -
508 */ -
509 -
510 switch (mode) { -
511 case IntInput: -
512 d->ensureIntSpinBox();
executed (the execution status of this line is deduced): d->ensureIntSpinBox();
-
513 widget = d->intSpinBox;
executed (the execution status of this line is deduced): widget = d->intSpinBox;
-
514 break;
executed: break;
Execution Count:5
5
515 case DoubleInput: -
516 d->ensureDoubleSpinBox();
executed (the execution status of this line is deduced): d->ensureDoubleSpinBox();
-
517 widget = d->doubleSpinBox;
executed (the execution status of this line is deduced): widget = d->doubleSpinBox;
-
518 break;
executed: break;
Execution Count:16
16
519 default: -
520 Q_ASSERT(mode == TextInput);
executed (the execution status of this line is deduced): qt_noop();
-
521 d->chooseRightTextInputWidget();
executed (the execution status of this line is deduced): d->chooseRightTextInputWidget();
-
522 return;
executed: return;
Execution Count:11
11
523 } -
524 -
525 d->setInputWidget(widget);
executed (the execution status of this line is deduced): d->setInputWidget(widget);
-
526}
executed: }
Execution Count:21
21
527 -
528QInputDialog::InputMode QInputDialog::inputMode() const -
529{ -
530 Q_D(const QInputDialog);
executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
531 -
532 if (d->inputWidget) {
evaluated: d->inputWidget
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:4
4-34
533 if (d->inputWidget == d->intSpinBox) {
evaluated: d->inputWidget == d->intSpinBox
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:29
5-29
534 return IntInput;
executed: return IntInput;
Execution Count:5
5
535 } else if (d->inputWidget == d->doubleSpinBox) {
evaluated: d->inputWidget == d->doubleSpinBox
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:13
13-16
536 return DoubleInput;
executed: return DoubleInput;
Execution Count:16
16
537 } -
538 } -
539 -
540 return TextInput;
executed: return TextInput;
Execution Count:17
17
541} -
542 -
543/*! -
544 \since 4.5 -
545 -
546 \property QInputDialog::labelText -
547 -
548 \brief the text to for the label to describe what needs to be input -
549*/ -
550void QInputDialog::setLabelText(const QString &text) -
551{ -
552 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
553 if (!d->label) {
partially evaluated: !d->label
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-31
554 d->label = new QLabel(text, this);
executed (the execution status of this line is deduced): d->label = new QLabel(text, this);
-
555 } else {
executed: }
Execution Count:31
31
556 d->label->setText(text);
never executed (the execution status of this line is deduced): d->label->setText(text);
-
557 }
never executed: }
0
558} -
559 -
560QString QInputDialog::labelText() const -
561{ -
562 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
563 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
564 return d->label->text();
never executed: return d->label->text();
0
565} -
566 -
567/*! -
568 \enum QInputDialog::InputDialogOption -
569 -
570 \since 4.5 -
571 -
572 This enum specifies various options that affect the look and feel -
573 of an input dialog. -
574 -
575 \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".) -
576 \value UseListViewForComboBoxItems Use a QListView rather than a non-editable QComboBox for -
577 displaying the items set with setComboBoxItems(). -
578 -
579 \sa options, setOption(), testOption() -
580*/ -
581 -
582/*! -
583 Sets the given \a option to be enabled if \a on is true; -
584 otherwise, clears the given \a option. -
585 -
586 \sa options, testOption() -
587*/ -
588void QInputDialog::setOption(InputDialogOption option, bool on) -
589{ -
590 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
591 if (!(d->opts & option) != !on)
never evaluated: !(d->opts & option) != !on
0
592 setOptions(d->opts ^ option);
never executed: setOptions(d->opts ^ option);
0
593}
never executed: }
0
594 -
595/*! -
596 Returns true if the given \a option is enabled; otherwise, returns -
597 false. -
598 -
599 \sa options, setOption() -
600*/ -
601bool QInputDialog::testOption(InputDialogOption option) const -
602{ -
603 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
604 return (d->opts & option) != 0;
never executed: return (d->opts & option) != 0;
0
605} -
606 -
607/*! -
608 \property QInputDialog::options -
609 \brief the various options that affect the look and feel of the dialog -
610 \since 4.5 -
611 -
612 By default, all options are disabled. -
613 -
614 \sa setOption(), testOption() -
615*/ -
616void QInputDialog::setOptions(InputDialogOptions options) -
617{ -
618 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
619 -
620 InputDialogOptions changed = (options ^ d->opts);
never executed (the execution status of this line is deduced): InputDialogOptions changed = (options ^ d->opts);
-
621 if (!changed)
never evaluated: !changed
0
622 return;
never executed: return;
0
623 -
624 d->opts = options;
never executed (the execution status of this line is deduced): d->opts = options;
-
625 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
626 -
627 if (changed & NoButtons)
never evaluated: changed & NoButtons
0
628 d->buttonBox->setVisible(!(options & NoButtons));
never executed: d->buttonBox->setVisible(!(options & NoButtons));
0
629 if ((changed & UseListViewForComboBoxItems) && inputMode() == TextInput)
never evaluated: (changed & UseListViewForComboBoxItems)
never evaluated: inputMode() == TextInput
0
630 d->chooseRightTextInputWidget();
never executed: d->chooseRightTextInputWidget();
0
631}
never executed: }
0
632 -
633QInputDialog::InputDialogOptions QInputDialog::options() const -
634{ -
635 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
636 return d->opts;
never executed: return d->opts;
0
637} -
638 -
639/*! -
640 \since 4.5 -
641 -
642 \property QInputDialog::textValue -
643 -
644 \brief the text value for the input dialog -
645 -
646 This property is only relevant when the input dialog is used in -
647 TextInput mode. -
648*/ -
649void QInputDialog::setTextValue(const QString &text) -
650{ -
651 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
652 -
653 setInputMode(TextInput);
executed (the execution status of this line is deduced): setInputMode(TextInput);
-
654 if (d->inputWidget == d->lineEdit) {
evaluated: d->inputWidget == d->lineEdit
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
655 d->lineEdit->setText(text);
executed (the execution status of this line is deduced): d->lineEdit->setText(text);
-
656 } else if (d->inputWidget == d->comboBox) {
executed: }
Execution Count:6
partially evaluated: d->inputWidget == d->comboBox
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-6
657 d->setComboBoxText(text);
executed (the execution status of this line is deduced): d->setComboBoxText(text);
-
658 } else {
executed: }
Execution Count:4
4
659 d->setListViewText(text);
never executed (the execution status of this line is deduced): d->setListViewText(text);
-
660 }
never executed: }
0
661} -
662 -
663QString QInputDialog::textValue() const -
664{ -
665 Q_D(const QInputDialog);
executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
666 return d->textValue;
executed: return d->textValue;
Execution Count:18
18
667} -
668 -
669/*! -
670 \since 4.5 -
671 -
672 \property QInputDialog::textEchoMode -
673 -
674 \brief the echo mode for the text value -
675 -
676 This property is only relevant when the input dialog is used in -
677 TextInput mode. -
678*/ -
679void QInputDialog::setTextEchoMode(QLineEdit::EchoMode mode) -
680{ -
681 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
682 d->ensureLineEdit();
executed (the execution status of this line is deduced): d->ensureLineEdit();
-
683 d->lineEdit->setEchoMode(mode);
executed (the execution status of this line is deduced): d->lineEdit->setEchoMode(mode);
-
684}
executed: }
Execution Count:6
6
685 -
686QLineEdit::EchoMode QInputDialog::textEchoMode() const -
687{ -
688 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
689 if (d->lineEdit) {
never evaluated: d->lineEdit
0
690 return d->lineEdit->echoMode();
never executed: return d->lineEdit->echoMode();
0
691 } else { -
692 return QLineEdit::Normal;
never executed: return QLineEdit::Normal;
0
693 } -
694} -
695 -
696/*! -
697 \since 4.5 -
698 -
699 \property QInputDialog::comboBoxEditable -
700 -
701 \brief whether or not the combo box is used in the input dialog is editable -
702*/ -
703void QInputDialog::setComboBoxEditable(bool editable) -
704{ -
705 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
706 d->ensureComboBox();
executed (the execution status of this line is deduced): d->ensureComboBox();
-
707 d->comboBox->setEditable(editable);
executed (the execution status of this line is deduced): d->comboBox->setEditable(editable);
-
708 if (inputMode() == TextInput)
partially evaluated: inputMode() == TextInput
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
709 d->chooseRightTextInputWidget();
executed: d->chooseRightTextInputWidget();
Execution Count:4
4
710}
executed: }
Execution Count:4
4
711 -
712bool QInputDialog::isComboBoxEditable() const -
713{ -
714 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
715 if (d->comboBox) {
never evaluated: d->comboBox
0
716 return d->comboBox->isEditable();
never executed: return d->comboBox->isEditable();
0
717 } else { -
718 return false;
never executed: return false;
0
719 } -
720} -
721 -
722/*! -
723 \since 4.5 -
724 -
725 \property QInputDialog::comboBoxItems -
726 -
727 \brief the items used in the combobox for the input dialog -
728*/ -
729void QInputDialog::setComboBoxItems(const QStringList &items) -
730{ -
731 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
732 -
733 d->ensureComboBox();
executed (the execution status of this line is deduced): d->ensureComboBox();
-
734 d->comboBox->blockSignals(true);
executed (the execution status of this line is deduced): d->comboBox->blockSignals(true);
-
735 d->comboBox->clear();
executed (the execution status of this line is deduced): d->comboBox->clear();
-
736 d->comboBox->addItems(items);
executed (the execution status of this line is deduced): d->comboBox->addItems(items);
-
737 d->comboBox->blockSignals(false);
executed (the execution status of this line is deduced): d->comboBox->blockSignals(false);
-
738 -
739 if (inputMode() == TextInput)
partially evaluated: inputMode() == TextInput
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
740 d->chooseRightTextInputWidget();
executed: d->chooseRightTextInputWidget();
Execution Count:4
4
741}
executed: }
Execution Count:4
4
742 -
743QStringList QInputDialog::comboBoxItems() const -
744{ -
745 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
746 QStringList result;
never executed (the execution status of this line is deduced): QStringList result;
-
747 if (d->comboBox) {
never evaluated: d->comboBox
0
748 const int count = d->comboBox->count();
never executed (the execution status of this line is deduced): const int count = d->comboBox->count();
-
749 for (int i = 0; i < count; ++i)
never evaluated: i < count
0
750 result.append(d->comboBox->itemText(i));
never executed: result.append(d->comboBox->itemText(i));
0
751 }
never executed: }
0
752 return result;
never executed: return result;
0
753} -
754 -
755/*! -
756 \property QInputDialog::intValue -
757 \since 4.5 -
758 \brief the current integer value accepted as input -
759 -
760 This property is only relevant when the input dialog is used in -
761 IntInput mode. -
762*/ -
763void QInputDialog::setIntValue(int value) -
764{ -
765 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
766 setInputMode(IntInput);
executed (the execution status of this line is deduced): setInputMode(IntInput);
-
767 d->intSpinBox->setValue(value);
executed (the execution status of this line is deduced): d->intSpinBox->setValue(value);
-
768}
executed: }
Execution Count:5
5
769 -
770int QInputDialog::intValue() const -
771{ -
772 Q_D(const QInputDialog);
executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
773 if (d->intSpinBox) {
partially evaluated: d->intSpinBox
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
774 return d->intSpinBox->value();
executed: return d->intSpinBox->value();
Execution Count:10
10
775 } else { -
776 return 0;
never executed: return 0;
0
777 } -
778} -
779 -
780/*! -
781 \property QInputDialog::intMinimum -
782 \since 4.5 -
783 \brief the minimum integer value accepted as input -
784 -
785 This property is only relevant when the input dialog is used in -
786 IntInput mode. -
787*/ -
788void QInputDialog::setIntMinimum(int min) -
789{ -
790 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
791 d->ensureIntSpinBox();
never executed (the execution status of this line is deduced): d->ensureIntSpinBox();
-
792 d->intSpinBox->setMinimum(min);
never executed (the execution status of this line is deduced): d->intSpinBox->setMinimum(min);
-
793}
never executed: }
0
794 -
795int QInputDialog::intMinimum() const -
796{ -
797 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
798 if (d->intSpinBox) {
never evaluated: d->intSpinBox
0
799 return d->intSpinBox->minimum();
never executed: return d->intSpinBox->minimum();
0
800 } else { -
801 return 0;
never executed: return 0;
0
802 } -
803} -
804 -
805/*! -
806 \property QInputDialog::intMaximum -
807 \since 4.5 -
808 \brief the maximum integer value accepted as input -
809 -
810 This property is only relevant when the input dialog is used in -
811 IntInput mode. -
812*/ -
813void QInputDialog::setIntMaximum(int max) -
814{ -
815 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
816 d->ensureIntSpinBox();
never executed (the execution status of this line is deduced): d->ensureIntSpinBox();
-
817 d->intSpinBox->setMaximum(max);
never executed (the execution status of this line is deduced): d->intSpinBox->setMaximum(max);
-
818}
never executed: }
0
819 -
820int QInputDialog::intMaximum() const -
821{ -
822 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
823 if (d->intSpinBox) {
never evaluated: d->intSpinBox
0
824 return d->intSpinBox->maximum();
never executed: return d->intSpinBox->maximum();
0
825 } else { -
826 return 99;
never executed: return 99;
0
827 } -
828} -
829 -
830/*! -
831 Sets the range of integer values accepted by the dialog when used in -
832 IntInput mode, with minimum and maximum values specified by \a min and -
833 \a max respectively. -
834*/ -
835void QInputDialog::setIntRange(int min, int max) -
836{ -
837 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
838 d->ensureIntSpinBox();
executed (the execution status of this line is deduced): d->ensureIntSpinBox();
-
839 d->intSpinBox->setRange(min, max);
executed (the execution status of this line is deduced): d->intSpinBox->setRange(min, max);
-
840}
executed: }
Execution Count:5
5
841 -
842/*! -
843 \property QInputDialog::intStep -
844 \since 4.5 -
845 \brief the step by which the integer value is increased and decreased -
846 -
847 This property is only relevant when the input dialog is used in -
848 IntInput mode. -
849*/ -
850void QInputDialog::setIntStep(int step) -
851{ -
852 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
853 d->ensureIntSpinBox();
executed (the execution status of this line is deduced): d->ensureIntSpinBox();
-
854 d->intSpinBox->setSingleStep(step);
executed (the execution status of this line is deduced): d->intSpinBox->setSingleStep(step);
-
855}
executed: }
Execution Count:5
5
856 -
857int QInputDialog::intStep() const -
858{ -
859 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
860 if (d->intSpinBox) {
never evaluated: d->intSpinBox
0
861 return d->intSpinBox->singleStep();
never executed: return d->intSpinBox->singleStep();
0
862 } else { -
863 return 1;
never executed: return 1;
0
864 } -
865} -
866 -
867/*! -
868 \property QInputDialog::doubleValue -
869 \since 4.5 -
870 \brief the current double precision floating point value accepted as input -
871 -
872 This property is only relevant when the input dialog is used in -
873 DoubleInput mode. -
874*/ -
875void QInputDialog::setDoubleValue(double value) -
876{ -
877 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
878 setInputMode(DoubleInput);
executed (the execution status of this line is deduced): setInputMode(DoubleInput);
-
879 d->doubleSpinBox->setValue(value);
executed (the execution status of this line is deduced): d->doubleSpinBox->setValue(value);
-
880}
executed: }
Execution Count:16
16
881 -
882double QInputDialog::doubleValue() const -
883{ -
884 Q_D(const QInputDialog);
executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
885 if (d->doubleSpinBox) {
partially evaluated: d->doubleSpinBox
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
886 return d->doubleSpinBox->value();
executed: return d->doubleSpinBox->value();
Execution Count:32
32
887 } else { -
888 return 0.0;
never executed: return 0.0;
0
889 } -
890} -
891 -
892/*! -
893 \property QInputDialog::doubleMinimum -
894 \since 4.5 -
895 \brief the minimum double precision floating point value accepted as input -
896 -
897 This property is only relevant when the input dialog is used in -
898 DoubleInput mode. -
899*/ -
900void QInputDialog::setDoubleMinimum(double min) -
901{ -
902 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
903 d->ensureDoubleSpinBox();
never executed (the execution status of this line is deduced): d->ensureDoubleSpinBox();
-
904 d->doubleSpinBox->setMinimum(min);
never executed (the execution status of this line is deduced): d->doubleSpinBox->setMinimum(min);
-
905}
never executed: }
0
906 -
907double QInputDialog::doubleMinimum() const -
908{ -
909 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
910 if (d->doubleSpinBox) {
never evaluated: d->doubleSpinBox
0
911 return d->doubleSpinBox->minimum();
never executed: return d->doubleSpinBox->minimum();
0
912 } else { -
913 return 0.0;
never executed: return 0.0;
0
914 } -
915} -
916 -
917/*! -
918 \property QInputDialog::doubleMaximum -
919 \since 4.5 -
920 \brief the maximum double precision floating point value accepted as input -
921 -
922 This property is only relevant when the input dialog is used in -
923 DoubleInput mode. -
924*/ -
925void QInputDialog::setDoubleMaximum(double max) -
926{ -
927 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
928 d->ensureDoubleSpinBox();
never executed (the execution status of this line is deduced): d->ensureDoubleSpinBox();
-
929 d->doubleSpinBox->setMaximum(max);
never executed (the execution status of this line is deduced): d->doubleSpinBox->setMaximum(max);
-
930}
never executed: }
0
931 -
932double QInputDialog::doubleMaximum() const -
933{ -
934 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
935 if (d->doubleSpinBox) {
never evaluated: d->doubleSpinBox
0
936 return d->doubleSpinBox->maximum();
never executed: return d->doubleSpinBox->maximum();
0
937 } else { -
938 return 99.99;
never executed: return 99.99;
0
939 } -
940} -
941 -
942/*! -
943 Sets the range of double precision floating point values accepted by the -
944 dialog when used in DoubleInput mode, with minimum and maximum values -
945 specified by \a min and \a max respectively. -
946*/ -
947void QInputDialog::setDoubleRange(double min, double max) -
948{ -
949 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
950 d->ensureDoubleSpinBox();
executed (the execution status of this line is deduced): d->ensureDoubleSpinBox();
-
951 d->doubleSpinBox->setRange(min, max);
executed (the execution status of this line is deduced): d->doubleSpinBox->setRange(min, max);
-
952}
executed: }
Execution Count:16
16
953 -
954/*! -
955 \since 4.5 -
956 -
957 \property QInputDialog::doubleDecimals -
958 -
959 \brief sets the percision of the double spinbox in decimals -
960 -
961 \sa QDoubleSpinBox::setDecimals() -
962*/ -
963void QInputDialog::setDoubleDecimals(int decimals) -
964{ -
965 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
966 d->ensureDoubleSpinBox();
executed (the execution status of this line is deduced): d->ensureDoubleSpinBox();
-
967 d->doubleSpinBox->setDecimals(decimals);
executed (the execution status of this line is deduced): d->doubleSpinBox->setDecimals(decimals);
-
968}
executed: }
Execution Count:16
16
969 -
970int QInputDialog::doubleDecimals() const -
971{ -
972 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
973 if (d->doubleSpinBox) {
never evaluated: d->doubleSpinBox
0
974 return d->doubleSpinBox->decimals();
never executed: return d->doubleSpinBox->decimals();
0
975 } else { -
976 return 2;
never executed: return 2;
0
977 } -
978} -
979 -
980/*! -
981 \since 4.5 -
982 -
983 \property QInputDialog::okButtonText -
984 -
985 \brief the text for the button used to accept the entry in the dialog -
986*/ -
987void QInputDialog::setOkButtonText(const QString &text) -
988{ -
989 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
990 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
991 d->buttonBox->button(QDialogButtonBox::Ok)->setText(text);
never executed (the execution status of this line is deduced): d->buttonBox->button(QDialogButtonBox::Ok)->setText(text);
-
992}
never executed: }
0
993 -
994QString QInputDialog::okButtonText() const -
995{ -
996 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
997 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
998 return d->buttonBox->button(QDialogButtonBox::Ok)->text();
never executed: return d->buttonBox->button(QDialogButtonBox::Ok)->text();
0
999} -
1000 -
1001/*! -
1002 \since 4.5 -
1003 -
1004 \property QInputDialog::cancelButtonText -
1005 \brief the text for the button used to cancel the dialog -
1006*/ -
1007void QInputDialog::setCancelButtonText(const QString &text) -
1008{ -
1009 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
1010 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
1011 d->buttonBox->button(QDialogButtonBox::Cancel)->setText(text);
never executed (the execution status of this line is deduced): d->buttonBox->button(QDialogButtonBox::Cancel)->setText(text);
-
1012}
never executed: }
0
1013 -
1014QString QInputDialog::cancelButtonText() const -
1015{ -
1016 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
1017 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
1018 return d->buttonBox->button(QDialogButtonBox::Cancel)->text();
never executed: return d->buttonBox->button(QDialogButtonBox::Cancel)->text();
0
1019} -
1020 -
1021/*! -
1022 \since 4.5 -
1023 \overload -
1024 -
1025 This function connects one of its signals to the slot specified by \a receiver -
1026 and \a member. The specific signal depends on the arguments that are specified -
1027 in \a member. These are: -
1028 -
1029 \list -
1030 \li textValueSelected() if \a member has a QString for its first argument. -
1031 \li intValueSelected() if \a member has an int for its first argument. -
1032 \li doubleValueSelected() if \a member has a double for its first argument. -
1033 \li accepted() if \a member has NO arguments. -
1034 \endlist -
1035 -
1036 The signal will be disconnected from the slot when the dialog is closed. -
1037*/ -
1038void QInputDialog::open(QObject *receiver, const char *member) -
1039{ -
1040 Q_D(QInputDialog);
never executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
1041 connect(this, signalForMember(member), receiver, member);
never executed (the execution status of this line is deduced): connect(this, signalForMember(member), receiver, member);
-
1042 d->receiverToDisconnectOnClose = receiver;
never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose = receiver;
-
1043 d->memberToDisconnectOnClose = member;
never executed (the execution status of this line is deduced): d->memberToDisconnectOnClose = member;
-
1044 QDialog::open();
never executed (the execution status of this line is deduced): QDialog::open();
-
1045}
never executed: }
0
1046 -
1047/*! -
1048 \reimp -
1049*/ -
1050QSize QInputDialog::minimumSizeHint() const -
1051{ -
1052 Q_D(const QInputDialog);
never executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
1053 d->ensureLayout();
never executed (the execution status of this line is deduced): d->ensureLayout();
-
1054 return QDialog::minimumSizeHint();
never executed: return QDialog::minimumSizeHint();
0
1055} -
1056 -
1057/*! -
1058 \reimp -
1059*/ -
1060QSize QInputDialog::sizeHint() const -
1061{ -
1062 Q_D(const QInputDialog);
executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
1063 d->ensureLayout();
executed (the execution status of this line is deduced): d->ensureLayout();
-
1064 return QDialog::sizeHint();
executed: return QDialog::sizeHint();
Execution Count:31
31
1065} -
1066 -
1067/*! -
1068 \reimp -
1069*/ -
1070void QInputDialog::setVisible(bool visible) -
1071{ -
1072 Q_D(const QInputDialog);
executed (the execution status of this line is deduced): const QInputDialogPrivate * const d = d_func();
-
1073 if (visible) {
evaluated: visible
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:31
31
1074 d->ensureLayout();
executed (the execution status of this line is deduced): d->ensureLayout();
-
1075 d->inputWidget->setFocus();
executed (the execution status of this line is deduced): d->inputWidget->setFocus();
-
1076 if (d->inputWidget == d->lineEdit) {
evaluated: d->inputWidget == d->lineEdit
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:25
6-25
1077 d->lineEdit->selectAll();
executed (the execution status of this line is deduced): d->lineEdit->selectAll();
-
1078 } 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
1079 d->intSpinBox->selectAll();
executed (the execution status of this line is deduced): d->intSpinBox->selectAll();
-
1080 } 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
1081 d->doubleSpinBox->selectAll();
executed (the execution status of this line is deduced): d->doubleSpinBox->selectAll();
-
1082 }
executed: }
Execution Count:16
16
1083 } -
1084 QDialog::setVisible(visible);
executed (the execution status of this line is deduced): QDialog::setVisible(visible);
-
1085}
executed: }
Execution Count:62
62
1086 -
1087/*! -
1088 Closes the dialog and sets its result code to \a result. If this dialog -
1089 is shown with exec(), done() causes the local event loop to finish, -
1090 and exec() to return \a result. -
1091 -
1092 \sa QDialog::done() -
1093*/ -
1094void QInputDialog::done(int result) -
1095{ -
1096 Q_D(QInputDialog);
executed (the execution status of this line is deduced): QInputDialogPrivate * const d = d_func();
-
1097 QDialog::done(result);
executed (the execution status of this line is deduced): QDialog::done(result);
-
1098 if (result) {
evaluated: result
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:1
1-30
1099 InputMode mode = inputMode();
executed (the execution status of this line is deduced): InputMode mode = inputMode();
-
1100 switch (mode) { -
1101 case DoubleInput: -
1102 emit doubleValueSelected(doubleValue());
executed (the execution status of this line is deduced): doubleValueSelected(doubleValue());
-
1103 break;
executed: break;
Execution Count:16
16
1104 case IntInput: -
1105 emit intValueSelected(intValue());
executed (the execution status of this line is deduced): intValueSelected(intValue());
-
1106 break;
executed: break;
Execution Count:5
5
1107 default: -
1108 Q_ASSERT(mode == TextInput);
executed (the execution status of this line is deduced): qt_noop();
-
1109 emit textValueSelected(textValue());
executed (the execution status of this line is deduced): textValueSelected(textValue());
-
1110 }
executed: }
Execution Count:9
9
1111 }
executed: }
Execution Count:30
30
1112 if (d->receiverToDisconnectOnClose) {
partially evaluated: d->receiverToDisconnectOnClose
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
1113 disconnect(this, signalForMember(d->memberToDisconnectOnClose),
never executed (the execution status of this line is deduced): disconnect(this, signalForMember(d->memberToDisconnectOnClose),
-
1114 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
-
1115 d->receiverToDisconnectOnClose = 0;
never executed (the execution status of this line is deduced): d->receiverToDisconnectOnClose = 0;
-
1116 }
never executed: }
0
1117 d->memberToDisconnectOnClose.clear();
executed (the execution status of this line is deduced): d->memberToDisconnectOnClose.clear();
-
1118}
executed: }
Execution Count:31
31
1119 -
1120/*! -
1121 Static convenience function to get a string from the user. -
1122 -
1123 \a title is the text which is displayed in the title bar of the dialog. -
1124 \a label is the text which is shown to the user (it should say what should -
1125 be entered). -
1126 \a text is the default text which is placed in the line edit. -
1127 \a mode is the echo mode the line edit will use. -
1128 \a inputMethodHints is the input method hints that will be used in the -
1129 edit widget if an input method is active. -
1130 -
1131 If \a ok is nonnull \e *\a ok will be set to true if the user pressed -
1132 \uicontrol OK and to false if the user pressed \uicontrol Cancel. The dialog's parent -
1133 is \a parent. The dialog will be modal and uses the specified widget -
1134 \a flags. -
1135 -
1136 If the dialog is accepted, this function returns the text in the dialog's -
1137 line edit. If the dialog is rejected, a null QString is returned. -
1138 -
1139 Use this static function like this: -
1140 -
1141 \snippet dialogs/standarddialogs/dialog.cpp 3 -
1142 -
1143 \warning Do not delete \a parent during the execution of the dialog. If you -
1144 want to do this, you should create the dialog yourself using one of the -
1145 QInputDialog constructors. -
1146 -
1147 \sa getInt(), getDouble(), getItem() -
1148*/ -
1149 -
1150QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label, -
1151 QLineEdit::EchoMode mode, const QString &text, bool *ok, -
1152 Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) -
1153{ -
1154 QInputDialog dialog(parent, flags);
executed (the execution status of this line is deduced): QInputDialog dialog(parent, flags);
-
1155 dialog.setWindowTitle(title);
executed (the execution status of this line is deduced): dialog.setWindowTitle(title);
-
1156 dialog.setLabelText(label);
executed (the execution status of this line is deduced): dialog.setLabelText(label);
-
1157 dialog.setTextValue(text);
executed (the execution status of this line is deduced): dialog.setTextValue(text);
-
1158 dialog.setTextEchoMode(mode);
executed (the execution status of this line is deduced): dialog.setTextEchoMode(mode);
-
1159 dialog.setInputMethodHints(inputMethodHints);
executed (the execution status of this line is deduced): dialog.setInputMethodHints(inputMethodHints);
-
1160 -
1161 int ret = dialog.exec();
executed (the execution status of this line is deduced): int ret = dialog.exec();
-
1162 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1163 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:6
6
1164 if (ret) {
evaluated: ret
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
1165 return dialog.textValue();
executed: return dialog.textValue();
Execution Count:5
5
1166 } else { -
1167 return QString();
executed: return QString();
Execution Count:1
1
1168 } -
1169} -
1170 -
1171/*! -
1172 \since 4.5 -
1173 -
1174 Static convenience function to get an integer input from the user. -
1175 -
1176 \a title is the text which is displayed in the title bar of the dialog. -
1177 \a label is the text which is shown to the user (it should say what should -
1178 be entered). -
1179 \a value is the default integer which the spinbox will be set to. -
1180 \a min and \a max are the minimum and maximum values the user may choose. -
1181 \a step is the amount by which the values change as the user presses the -
1182 arrow buttons to increment or decrement the value. -
1183 -
1184 If \a ok is nonnull *\a ok will be set to true if the user pressed \uicontrol OK -
1185 and to false if the user pressed \uicontrol Cancel. The dialog's parent is -
1186 \a parent. The dialog will be modal and uses the widget \a flags. -
1187 -
1188 On success, this function returns the integer which has been entered by the -
1189 user; on failure, it returns the initial \a value. -
1190 -
1191 Use this static function like this: -
1192 -
1193 \snippet dialogs/standarddialogs/dialog.cpp 0 -
1194 -
1195 \warning Do not delete \a parent during the execution of the dialog. If you -
1196 want to do this, you should create the dialog yourself using one of the -
1197 QInputDialog constructors. -
1198 -
1199 \sa getText(), getDouble(), getItem() -
1200*/ -
1201 -
1202int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &label, int value, -
1203 int min, int max, int step, bool *ok, Qt::WindowFlags flags) -
1204{ -
1205 QInputDialog dialog(parent, flags);
executed (the execution status of this line is deduced): QInputDialog dialog(parent, flags);
-
1206 dialog.setWindowTitle(title);
executed (the execution status of this line is deduced): dialog.setWindowTitle(title);
-
1207 dialog.setLabelText(label);
executed (the execution status of this line is deduced): dialog.setLabelText(label);
-
1208 dialog.setIntRange(min, max);
executed (the execution status of this line is deduced): dialog.setIntRange(min, max);
-
1209 dialog.setIntValue(value);
executed (the execution status of this line is deduced): dialog.setIntValue(value);
-
1210 dialog.setIntStep(step);
executed (the execution status of this line is deduced): dialog.setIntStep(step);
-
1211 -
1212 int ret = dialog.exec();
executed (the execution status of this line is deduced): int ret = dialog.exec();
-
1213 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1214 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:5
5
1215 if (ret) {
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
1216 return dialog.intValue();
executed: return dialog.intValue();
Execution Count:5
5
1217 } else { -
1218 return value;
never executed: return value;
0
1219 } -
1220} -
1221 -
1222/*! -
1223 \fn QInputDialog::getInteger(QWidget *parent, const QString &title, const QString &label, int value, int min, int max, int step, bool *ok, Qt::WindowFlags flags) -
1224 \deprecated use getInt() -
1225 -
1226 Static convenience function to get an integer input from the user. -
1227 -
1228 \a title is the text which is displayed in the title bar of the dialog. -
1229 \a label is the text which is shown to the user (it should say what should -
1230 be entered). -
1231 \a value is the default integer which the spinbox will be set to. -
1232 \a min and \a max are the minimum and maximum values the user may choose. -
1233 \a step is the amount by which the values change as the user presses the -
1234 arrow buttons to increment or decrement the value. -
1235 -
1236 If \a ok is nonnull *\a ok will be set to true if the user pressed \uicontrol OK -
1237 and to false if the user pressed \uicontrol Cancel. The dialog's parent is -
1238 \a parent. The dialog will be modal and uses the widget \a flags. -
1239 -
1240 On success, this function returns the integer which has been entered by the -
1241 user; on failure, it returns the initial \a value. -
1242 -
1243 Use this static function like this: -
1244 -
1245 \snippet dialogs/standarddialogs/dialog.cpp 0 -
1246 -
1247 \warning Do not delete \a parent during the execution of the dialog. If you -
1248 want to do this, you should create the dialog yourself using one of the -
1249 QInputDialog constructors. -
1250 -
1251 \sa getText(), getDouble(), getItem() -
1252*/ -
1253 -
1254/*! -
1255 Static convenience function to get a floating point number from the user. -
1256 -
1257 \a title is the text which is displayed in the title bar of the dialog. -
1258 \a label is the text which is shown to the user (it should say what should -
1259 be entered). -
1260 \a value is the default floating point number that the line edit will be -
1261 set to. -
1262 \a min and \a max are the minimum and maximum values the user may choose. -
1263 \a decimals is the maximum number of decimal places the number may have. -
1264 -
1265 If \a ok is nonnull, *\a ok will be set to true if the user pressed \uicontrol OK -
1266 and to false if the user pressed \uicontrol Cancel. The dialog's parent is -
1267 \a parent. The dialog will be modal and uses the widget \a flags. -
1268 -
1269 This function returns the floating point number which has been entered by -
1270 the user. -
1271 -
1272 Use this static function like this: -
1273 -
1274 \snippet dialogs/standarddialogs/dialog.cpp 1 -
1275 -
1276 \warning Do not delete \a parent during the execution of the dialog. If you -
1277 want to do this, you should create the dialog yourself using one of the -
1278 QInputDialog constructors. -
1279 -
1280 \sa getText(), getInt(), getItem() -
1281*/ -
1282 -
1283double QInputDialog::getDouble(QWidget *parent, const QString &title, const QString &label, -
1284 double value, double min, double max, int decimals, bool *ok, -
1285 Qt::WindowFlags flags) -
1286{ -
1287 QInputDialog dialog(parent, flags);
executed (the execution status of this line is deduced): QInputDialog dialog(parent, flags);
-
1288 dialog.setWindowTitle(title);
executed (the execution status of this line is deduced): dialog.setWindowTitle(title);
-
1289 dialog.setLabelText(label);
executed (the execution status of this line is deduced): dialog.setLabelText(label);
-
1290 dialog.setDoubleDecimals(decimals);
executed (the execution status of this line is deduced): dialog.setDoubleDecimals(decimals);
-
1291 dialog.setDoubleRange(min, max);
executed (the execution status of this line is deduced): dialog.setDoubleRange(min, max);
-
1292 dialog.setDoubleValue(value);
executed (the execution status of this line is deduced): dialog.setDoubleValue(value);
-
1293 -
1294 int ret = dialog.exec();
executed (the execution status of this line is deduced): int ret = dialog.exec();
-
1295 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
1296 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:16
16
1297 if (ret) {
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
1298 return dialog.doubleValue();
executed: return dialog.doubleValue();
Execution Count:16
16
1299 } else { -
1300 return value;
never executed: return value;
0
1301 } -
1302} -
1303 -
1304/*! -
1305 Static convenience function to let the user select an item from a string -
1306 list. -
1307 -
1308 \a title is the text which is displayed in the title bar of the dialog. -
1309 \a label is the text which is shown to the user (it should say what should -
1310 be entered). -
1311 \a items is the string list which is inserted into the combobox. -
1312 \a current is the number of the item which should be the current item. -
1313 \a inputMethodHints is the input method hints that will be used if the -
1314 combobox is editable and an input method is active. -
1315 -
1316 If \a editable is true the user can enter their own text; otherwise the -
1317 user may only select one of the existing items. -
1318 -
1319 If \a ok is nonnull \e *\a ok will be set to true if the user pressed -
1320 \uicontrol OK and to false if the user pressed \uicontrol Cancel. The dialog's parent -
1321 is \a parent. The dialog will be modal and uses the widget \a flags. -
1322 -
1323 This function returns the text of the current item, or if \a editable is -
1324 true, the current text of the combobox. -
1325 -
1326 Use this static function like this: -
1327 -
1328 \snippet dialogs/standarddialogs/dialog.cpp 2 -
1329 -
1330 \warning Do not delete \a parent during the execution of the dialog. If you -
1331 want to do this, you should create the dialog yourself using one of the -
1332 QInputDialog constructors. -
1333 -
1334 \sa getText(), getInt(), getDouble() -
1335*/ -
1336 -
1337QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label, -
1338 const QStringList &items, int current, bool editable, bool *ok, -
1339 Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) -
1340{ -
1341 QString text(items.value(current));
executed (the execution status of this line is deduced): QString text(items.value(current));
-
1342 -
1343 QInputDialog dialog(parent, flags);
executed (the execution status of this line is deduced): QInputDialog dialog(parent, flags);
-
1344 dialog.setWindowTitle(title);
executed (the execution status of this line is deduced): dialog.setWindowTitle(title);
-
1345 dialog.setLabelText(label);
executed (the execution status of this line is deduced): dialog.setLabelText(label);
-
1346 dialog.setComboBoxItems(items);
executed (the execution status of this line is deduced): dialog.setComboBoxItems(items);
-
1347 dialog.setTextValue(text);
executed (the execution status of this line is deduced): dialog.setTextValue(text);
-
1348 dialog.setComboBoxEditable(editable);
executed (the execution status of this line is deduced): dialog.setComboBoxEditable(editable);
-
1349 dialog.setInputMethodHints(inputMethodHints);
executed (the execution status of this line is deduced): dialog.setInputMethodHints(inputMethodHints);
-
1350 -
1351 int ret = dialog.exec();
executed (the execution status of this line is deduced): int ret = dialog.exec();
-
1352 if (ok)
partially evaluated: ok
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1353 *ok = !!ret;
executed: *ok = !!ret;
Execution Count:4
4
1354 if (ret) {
partially evaluated: ret
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1355 return dialog.textValue();
executed: return dialog.textValue();
Execution Count:4
4
1356 } else { -
1357 return text;
never executed: return text;
0
1358 } -
1359} -
1360 -
1361/*! -
1362 \fn void QInputDialog::doubleValueChanged(double value) -
1363 -
1364 This signal is emitted whenever the double value changes in the dialog. -
1365 The current value is specified by \a value. -
1366 -
1367 This signal is only relevant when the input dialog is used in -
1368 DoubleInput mode. -
1369*/ -
1370 -
1371/*! -
1372 \fn void QInputDialog::doubleValueSelected(double value) -
1373 -
1374 This signal is emitted whenever the user selects a double value by -
1375 accepting the dialog; for example, by clicking the \uicontrol{OK} button. -
1376 The selected value is specified by \a value. -
1377 -
1378 This signal is only relevant when the input dialog is used in -
1379 DoubleInput mode. -
1380*/ -
1381 -
1382/*! -
1383 \fn void QInputDialog::intValueChanged(int value) -
1384 -
1385 This signal is emitted whenever the integer value changes in the dialog. -
1386 The current value is specified by \a value. -
1387 -
1388 This signal is only relevant when the input dialog is used in -
1389 IntInput mode. -
1390*/ -
1391 -
1392/*! -
1393 \fn void QInputDialog::intValueSelected(int value) -
1394 -
1395 This signal is emitted whenever the user selects a integer value by -
1396 accepting the dialog; for example, by clicking the \uicontrol{OK} button. -
1397 The selected value is specified by \a value. -
1398 -
1399 This signal is only relevant when the input dialog is used in -
1400 IntInput mode. -
1401*/ -
1402 -
1403/*! -
1404 \fn void QInputDialog::textValueChanged(const QString &text) -
1405 -
1406 This signal is emitted whenever the text string changes in the dialog. -
1407 The current string is specified by \a text. -
1408 -
1409 This signal is only relevant when the input dialog is used in -
1410 TextInput mode. -
1411*/ -
1412 -
1413/*! -
1414 \fn void QInputDialog::textValueSelected(const QString &text) -
1415 -
1416 This signal is emitted whenever the user selects a text string by -
1417 accepting the dialog; for example, by clicking the \uicontrol{OK} button. -
1418 The selected string is specified by \a text. -
1419 -
1420 This signal is only relevant when the input dialog is used in -
1421 TextInput mode. -
1422*/ -
1423 -
1424QT_END_NAMESPACE -
1425 -
1426#include "qinputdialog.moc" -
1427#include "moc_qinputdialog.cpp" -
1428 -
1429#endif // QT_NO_INPUTDIALOG -
1430 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial