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