1 | // Copyright (C) 2002 Jason Katz-Brown <jason@katzbrown.com> |
2 | // Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com> |
3 | // |
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
5 | // of this software and associated documentation files (the "Software"), to deal |
6 | // in the Software without restriction, including without limitation the rights |
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
8 | // copies of the Software, and to permit persons to whom the Software is |
9 | // furnished to do so, subject to the following conditions: |
10 | // |
11 | // The above copyright notice and this permission notice shall be included in |
12 | // all copies or substantial portions of the Software. |
13 | // |
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17 | // THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
18 | // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
20 | // |
21 | // Except as contained in this notice, the name(s) of the author(s) shall not be |
22 | // used in advertising or otherwise to promote the sale, use or other dealings |
23 | // in this Software without prior written authorization from the author(s). |
24 | |
25 | #ifndef KCOMBOBOX_DIALOG_H |
26 | #define KCOMBOBOX_DIALOG_H |
27 | |
28 | #include <KConfig> |
29 | #include <KDialog> |
30 | #include <KGlobal> |
31 | |
32 | class QCheckBox; |
33 | class KHistoryComboBox; |
34 | |
35 | ///Dialog for user to choose an item from a QStringList. |
36 | class KComboBoxDialog : public KDialog |
37 | { |
38 | Q_OBJECT |
39 | |
40 | public: |
41 | /** |
42 | * Create a dialog that asks for a single line of text. _value is |
43 | * the initial value of the line. _text appears as the current text |
44 | * of the combobox. |
45 | * |
46 | * @param _items Items in the combobox |
47 | * @param _text Text of the label |
48 | * @param _value Initial value of the combobox |
49 | */ |
50 | KComboBoxDialog( const QString &_text, const QStringList& _items, const QString& _value = QString(), bool showDontAskAgain = false, QWidget *parent = 0 ); |
51 | virtual ~KComboBoxDialog(); |
52 | |
53 | ///@return the value the user chose |
54 | QString text() const; |
55 | |
56 | ///@return the line edit widget |
57 | KHistoryComboBox *comboBox() const { return combo; } |
58 | |
59 | /** |
60 | * Static convenience function to get input from the user. |
61 | * |
62 | * @param _text Text of the label |
63 | * @param _items Items in the combobox |
64 | * @param _value Initial value of the inputline |
65 | * @param dontAskAgainName Name for saving whether the user doesn't want to be asked again; use QString() to disable |
66 | */ |
67 | static QString getItem( const QString &_text, const QStringList &_items, const QString& _value = QString(), const QString &dontAskAgainName = QString(), QWidget *parent = 0 ); |
68 | |
69 | /** |
70 | * Static convenience function to get input from the user. |
71 | * This method includes a caption. |
72 | * |
73 | * @param _caption Caption of the dialog |
74 | * @param _text Text of the label |
75 | * @param _items Items in the combobox |
76 | * @param _value Initial value of the inputline |
77 | * @param dontAskAgainName Name for saving whether the user doesn't want to be asked again; use QString() to disable |
78 | */ |
79 | static QString getItem( const QString &_text, const QString &_caption, const QStringList &_items, const QString& _value = QString(), const QString &dontAskAgainName = QString(), QWidget *parent = 0 ); |
80 | |
81 | /** |
82 | * Static convenience method. |
83 | * This method is meant as a replacement for KLineEditDlg::getText() for cases |
84 | * when a history and autocompletion are desired. |
85 | * |
86 | * @param _caption Caption of the dialog |
87 | * @param _text Text of the label |
88 | * @param _value Initial value of the inputline |
89 | * @param ok Variable to store whether the user hit OK |
90 | * @param parent Parent widget for the dialog |
91 | * @param configName Name of the dialog for saving the completion and history |
92 | * @parma config KConfig for saving the completion and history |
93 | */ |
94 | static QString getText(const QString &_caption, const QString &_text, |
95 | const QString &_value = QString(), |
96 | bool *ok = 0, QWidget *parent = 0, |
97 | const QString &configName = QString(), |
98 | KSharedConfigPtr config = KGlobal::config()); |
99 | |
100 | protected: |
101 | KHistoryComboBox *combo; |
102 | QCheckBox *dontAskAgainCheckBox; |
103 | bool dontAskAgainChecked(); |
104 | }; |
105 | |
106 | #endif |
107 | |