1/****************************************************************************
2**
3** Copyright (C) 2014 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#ifndef QINPUTDIALOG_H
43#define QINPUTDIALOG_H
44
45#include <QtGui/qdialog.h>
46#include <QtCore/qstring.h>
47#include <QtGui/qlineedit.h>
48
49QT_BEGIN_HEADER
50
51QT_BEGIN_NAMESPACE
52
53QT_MODULE(Gui)
54
55#ifndef QT_NO_INPUTDIALOG
56
57class QInputDialogPrivate;
58
59class Q_GUI_EXPORT QInputDialog : public QDialog
60{
61 Q_OBJECT
62 Q_DECLARE_PRIVATE(QInputDialog)
63// Q_ENUMS(InputMode InputDialogOption)
64 QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
65 QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
66 QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
67 QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
68 QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
69 QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
70 QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
71 QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
72 QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
73 QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
74 QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
75 QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
76 QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
77 QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
78 QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
79 QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
80 QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
81
82public:
83 enum InputDialogOption {
84 NoButtons = 0x00000001,
85 UseListViewForComboBoxItems = 0x00000002
86 };
87
88 Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
89
90 enum InputMode {
91 TextInput,
92 IntInput,
93 DoubleInput
94 };
95
96 QInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
97 ~QInputDialog();
98
99 void setInputMode(InputMode mode);
100 InputMode inputMode() const;
101
102 void setLabelText(const QString &text);
103 QString labelText() const;
104
105 void setOption(InputDialogOption option, bool on = true);
106 bool testOption(InputDialogOption option) const;
107 void setOptions(InputDialogOptions options);
108 InputDialogOptions options() const;
109
110 void setTextValue(const QString &text);
111 QString textValue() const;
112
113 void setTextEchoMode(QLineEdit::EchoMode mode);
114 QLineEdit::EchoMode textEchoMode() const;
115
116 void setComboBoxEditable(bool editable);
117 bool isComboBoxEditable() const;
118
119 void setComboBoxItems(const QStringList &items);
120 QStringList comboBoxItems() const;
121
122 void setIntValue(int value);
123 int intValue() const;
124
125 void setIntMinimum(int min);
126 int intMinimum() const;
127
128 void setIntMaximum(int max);
129 int intMaximum() const;
130
131 void setIntRange(int min, int max);
132
133 void setIntStep(int step);
134 int intStep() const;
135
136 void setDoubleValue(double value);
137 double doubleValue() const;
138
139 void setDoubleMinimum(double min);
140 double doubleMinimum() const;
141
142 void setDoubleMaximum(double max);
143 double doubleMaximum() const;
144
145 void setDoubleRange(double min, double max);
146
147 void setDoubleDecimals(int decimals);
148 int doubleDecimals() const;
149
150 void setOkButtonText(const QString &text);
151 QString okButtonText() const;
152
153 void setCancelButtonText(const QString &text);
154 QString cancelButtonText() const;
155
156#ifdef Q_NO_USING_KEYWORD
157#ifndef Q_QDOC
158 void open() { QDialog::open(); }
159#endif
160#else
161 using QDialog::open;
162#endif
163 void open(QObject *receiver, const char *member);
164
165 QSize minimumSizeHint() const;
166 QSize sizeHint() const;
167
168 void setVisible(bool visible);
169
170#ifdef Q_QDOC
171 static QString getText(QWidget *parent, const QString &title, const QString &label,
172 QLineEdit::EchoMode echo = QLineEdit::Normal,
173 const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
174 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
175 static QString getItem(QWidget *parent, const QString &title, const QString &label,
176 const QStringList &items, int current = 0, bool editable = true,
177 bool *ok = 0, Qt::WindowFlags flags = 0,
178 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
179#else
180 static QString getText(QWidget *parent, const QString &title, const QString &label,
181 QLineEdit::EchoMode echo = QLineEdit::Normal,
182 const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0);
183 static QString getItem(QWidget *parent, const QString &title, const QString &label,
184 const QStringList &items, int current = 0, bool editable = true,
185 bool *ok = 0, Qt::WindowFlags flags = 0);
186 static QString getText(QWidget *parent, const QString &title, const QString &label,
187 QLineEdit::EchoMode echo,
188 const QString &text, bool *ok, Qt::WindowFlags flags,
189 Qt::InputMethodHints inputMethodHints);
190 static QString getItem(QWidget *parent, const QString &title, const QString &label,
191 const QStringList &items, int current, bool editable,
192 bool *ok, Qt::WindowFlags flags,
193 Qt::InputMethodHints inputMethodHints);
194#endif
195 static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
196 int minValue = -2147483647, int maxValue = 2147483647,
197 int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
198 static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
199 double minValue = -2147483647, double maxValue = 2147483647,
200 int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
201
202 // obsolete
203 static int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
204 int minValue = -2147483647, int maxValue = 2147483647,
205 int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
206
207#ifdef QT3_SUPPORT
208 inline static QT3_SUPPORT QString getText(const QString &title, const QString &label,
209 QLineEdit::EchoMode echo = QLineEdit::Normal,
210 const QString &text = QString(), bool *ok = 0,
211 QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
212 { return getText(parent, title, label, echo, text, ok, flags); }
213 inline static QT3_SUPPORT int getInteger(const QString &title, const QString &label, int value = 0,
214 int minValue = -2147483647, int maxValue = 2147483647,
215 int step = 1, bool *ok = 0,
216 QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
217 { return getInteger(parent, title, label, value, minValue, maxValue, step, ok, flags); }
218 inline static QT3_SUPPORT double getDouble(const QString &title, const QString &label, double value = 0,
219 double minValue = -2147483647, double maxValue = 2147483647,
220 int decimals = 1, bool *ok = 0,
221 QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
222 { return getDouble(parent, title, label, value, minValue, maxValue, decimals, ok, flags); }
223 inline static QT3_SUPPORT QString getItem(const QString &title, const QString &label, const QStringList &list,
224 int current = 0, bool editable = true, bool *ok = 0,
225 QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
226 { return getItem(parent, title, label, list, current, editable, ok, flags); }
227#endif
228
229Q_SIGNALS:
230 // ### emit signals!
231 void textValueChanged(const QString &text);
232 void textValueSelected(const QString &text);
233 void intValueChanged(int value);
234 void intValueSelected(int value);
235 void doubleValueChanged(double value);
236 void doubleValueSelected(double value);
237
238
239public:
240 void done(int result); // ### Qt 5: Make protected.
241
242private:
243 Q_DISABLE_COPY(QInputDialog)
244 Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
245 Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&))
246};
247
248Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
249
250#endif // QT_NO_INPUTDIALOG
251
252QT_END_NAMESPACE
253
254QT_END_HEADER
255
256#endif // QINPUTDIALOG_H
257