1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
/*
Copyright (C) 2003 Nadeem Hasan <nhasan@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KINPUTDIALOG_H
#define KINPUTDIALOG_H
// #include <tqt.h>
#include <kdialogbase.h>
class TQValidator;
class KLineEdit;
class KIntSpinBox;
class KDoubleSpinBox;
class KComboBox;
class KTextEdit;
class KInputDialogPrivate;
/**
* The KInputDialog class provides a simple dialog to get a single value
* from the user. The value can be a string, a number (either an integer or
* a float) or an item from a list. This class is designed to be source
* compatible with QInputDialog.
*
* Five static convenience functions are provided: getText(), getInteger().
* getDouble(), getItem() and getItemList().
*
* @since 3.2
* @author Nadeem Hasan <nhasan@kde.org>
*/
class KDEUI_EXPORT KInputDialog : public KDialogBase
{
Q_OBJECT
private:
/**
* Constructor. This class is not designed to be instantiated except
* from the static member functions.
*/
KInputDialog( const TQString &caption, const TQString &label,
const TQString &value, TQWidget *parent, const char *name,
TQValidator *validator, const TQString &mask );
KInputDialog( const TQString &caption, const TQString &label,
const TQString &value, TQWidget *parent, const char *name );
KInputDialog( const TQString &caption, const TQString &label, int value,
int minValue, int maxValue, int step, int base, TQWidget *parent,
const char *name );
KInputDialog( const TQString &caption, const TQString &label, double value,
double minValue, double maxValue, double step, int decimals,
TQWidget *parent, const char *name );
KInputDialog( const TQString &caption, const TQString &label,
const TQStringList &list, int current, bool editable, TQWidget *parent,
const char *name );
KInputDialog( const TQString &caption, const TQString &label,
const TQStringList &list, const TQStringList &select, bool editable,
TQWidget *parent, const char *name );
~KInputDialog();
KLineEdit *lineEdit() const;
KIntSpinBox *intSpinBox() const;
KDoubleSpinBox *doubleSpinBox() const;
KComboBox *comboBox() const;
KListBox *listBox() const;
KTextEdit *textEdit() const;
private slots:
void slotEditTextChanged( const TQString& );
void slotUpdateButtons( const TQString& );
public:
/**
* Static convenience function to get a string from the user.
*
* caption is the text that is displayed in the title bar. label is the
* text that appears as a label for the line edit. value is the initial
* value of the line edit. ok will be set to true if user pressed Ok
* and false if user pressed Cancel.
*
* If you provide a validator, the Ok button is disabled as long as
* the validator doesn't return Acceptable. If there is no validator,
* the Ok button is enabled whenever the line edit isn't empty. If you
* want to accept empty input, create a trivial TQValidator that
* always returns acceptable, e.g. TQRegExpValidator with a regexp
* of ".*".
*
* @param caption Caption of the dialog
* @param label Text of the label for the line edit
* @param value Initial value of the line edit
* @param ok This bool would be set to true if user pressed Ok
* @param parent Parent of the dialog widget
* @param name Name of the dialog widget
* @param validator A @ref TQValidator to be associated with the line edit
* @param mask Mask associated with the line edit. See the
* documentation for @ref TQLineEdit about masks.
*
* @return String user entered if Ok was pressed, else a null string
*/
static TQString getText( const TQString &caption, const TQString &label,
const TQString &value=TQString::null, bool *ok=0, TQWidget *parent=0,
const char *name=0, TQValidator *validator=0,
const TQString &mask=TQString::null );
/**
* Same as @ref getText except it provides an extra parameter to specify
* a TQWhatsThis text for the input widget.
*
* ### KDE4: Merge with getText.
*
* @since KDE 3.3
**/
static TQString text( const TQString &caption, const TQString &label,
const TQString &value=TQString::null, bool *ok=0, TQWidget *parent=0,
const char *name=0, TQValidator *validator=0,
const TQString &mask=TQString::null,
const TQString& whatsThis=TQString::null );
/**
* Static convenience function to get a multiline string from the user.
*
* caption is the text that is displayed in the title bar. label is the
* text that appears as a label for the line edit. value is the initial
* value of the line edit. ok will be set to true if user pressed Ok
* and false if user pressed Cancel.
*
* @param caption Caption of the dialog
* @param label Text of the label for the line edit
* @param value Initial value of the line edit
* @param ok This bool would be set to true if user pressed Ok
* @param parent Parent of the dialog widget
* @param name Name of the dialog widget
*
* @return String user entered if Ok was pressed, else a null string
* @since 3.3
*/
static TQString getMultiLineText( const TQString &caption,
const TQString &label, const TQString &value=TQString::null,
bool *ok=0, TQWidget *parent=0, const char *name=0 );
/**
* Static convenience function to get an integer from the user.
*
* caption is the text that is displayed in the title bar. label is the
* text that appears as the label for the spin box. value is the initial
* value for the spin box. minValue and maxValue are the minimum and
* maximum allowable values the user may choose. step is the amount by
* which the value will change as the user presses the increment and
* decrement buttons of the spin box. Base is the base of the number.
*
* @param caption Caption of the dialog
* @param label Text of the label for the spin box
* @param value Initial value of the spin box
* @param minValue Minimum value user can input
* @param maxValue Maximum value user can input
* @param step Amount by which value is incremented or decremented
* @param base Base of the number
* @param ok This bool would be set to true if user pressed Ok
* @param parent Parent of the dialog widget
* @param name Name of the dialog widget
*
* @return Number user entered if Ok was pressed, else 0
*/
static int getInteger( const TQString &caption, const TQString &label,
int value=0, int minValue=-2147483647, int maxValue=2147483647,
int step=1, int base=10, bool *ok=0, TQWidget *parent=0,
const char *name=0 );
/**
* This is an overloaded convenience function. It behaves exactly same as
* above except it assumes base to be 10, i.e. accepts decimal numbers.
*/
static int getInteger( const TQString &caption, const TQString &label,
int value=0, int minValue=-2147483647, int maxValue=2147483647,
int step=1, bool *ok=0, TQWidget *parent=0, const char *name=0 );
/**
* Static convenience function to get a floating point number from the user.
*
* caption is the text that is displayed in the title bar. label is the
* text that appears as the label for the spin box. value is the initial
* value for the spin box. minValue and maxValue are the minimum and
* maximum allowable values the user may choose. step is the amount by
* which the value will change as the user presses the increment and
* decrement buttons of the spin box.
*
* @param caption Caption of the dialog
* @param label Text of the label for the spin box
* @param value Initial value of the spin box
* @param minValue Minimum value user can input
* @param maxValue Maximum value user can input
* @param step Amount by which value is incremented or decremented
* @param decimals Number of digits after the decimal point
* @param ok This bool would be set to true if user pressed Ok
* @param parent Parent of the dialog widget
* @param name Name of the dialog widget
*
* @return Number user entered if Ok was pressed, else 0
*/
static double getDouble( const TQString &caption, const TQString &label,
double value=0, double minValue=-2147483647,
double maxValue=2147483647, double step=0.1, int decimals=1,
bool *ok=0, TQWidget *parent=0, const char *name=0 );
/**
* This is an overloaded convenience function. It behaves exctly like
* the above function.
*/
static double getDouble( const TQString &caption, const TQString &label,
double value=0, double minValue=-2147483647,
double maxValue=2147483647, int decimals=1, bool *ok=0,
TQWidget *parent=0, const char *name=0 );
/**
* Static convenience function to let the user select an item from a
* list. caption is the text that is displayed in the title bar.
* label is the text that appears as the label for the list. list
* is the string list which is inserted into the list, and current
* is the number of the item which should be the selected item. If
* editable is true, the user can enter their own text.
*
* @param caption Caption of the dialog
* @param label Text of the label for the spin box
* @param list List of item for user to choose from
* @param current Index of the selected item
* @param editable If true, user can enter own text
* @param ok This bool would be set to true if user pressed Ok
* @param parent Parent of the dialog widget
* @param name Name of the dialog widget
*
* @return Text of the selected item. If @p editable is true this can be
* a text entered by the user.
*/
static TQString getItem( const TQString &caption, const TQString &label,
const TQStringList &list, int current=0, bool editable=false,
bool *ok=0, TQWidget *parent=0, const char *name=0 );
/**
* Static convenience function to let the user select one or more
* items from a listbox. caption is the text that is displayed in the
* title bar. label is the text that appears as the label for the listbox.
* list is the string list which is inserted into the listbox, select
* is the list of item(s) that should be the selected. If multiple is
* true, the user can select multiple items.
*
* @param caption Caption of the dialog
* @param label Text of the label for the spin box
* @param list List of item for user to choose from
* @param select List of item(s) that should be selected
* @param multiple If true, user can select multiple items
* @param ok This bool would be set to true if user pressed Ok
* @param parent Parent of the dialog widget
* @param name Name of the dialog widget
*
* @return List of selected items if multiple is true, else currently
* selected item as a QStringList
*/
static TQStringList getItemList( const TQString &caption,
const TQString &label, const TQStringList &list=TQStringList(),
const TQStringList &select=TQStringList(), bool multiple=false,
bool *ok=0, TQWidget *parent=0, const char *name=0 );
private:
KInputDialogPrivate* const d;
friend class KInputDialogPrivate;
};
#endif // KINPUTDIALOG_H
/* vim: set ai et sw=2 ts=2
*/
|