summaryrefslogtreecommitdiffstats
path: root/kolf/kcomboboxdialog.h
blob: 8db7912272574d8dbabe365ec3eb5b81d318369a (plain)
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
// Copyright (C) 2002 Jason Katz-Brown <jason@katzbrown.com>
// Copyright (C) 2002 Neil Stevens <neil@qualityassistant.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// 
// Except as contained in this notice, the name(s) of the author(s) shall not be
// used in advertising or otherwise to promote the sale, use or other dealings
// in this Software without prior written authorization from the author(s).

#ifndef KCOMBOBOX_DIALOG_H
#define KCOMBOBOX_DIALOG_H

#include <tqstringlist.h>

#include <kdialogbase.h>
#include <kglobal.h>

class TQCheckBox;
class KHistoryCombo;

/**
 * Dialog for user to choose an item from a TQStringList.
 */

class KComboBoxDialog : public KDialogBase
{
Q_OBJECT
  TQ_OBJECT

public:
	/**
	 * Create a dialog that asks for a single line of text. _value is
	 * the initial value of the line. _text appears as the current text
	 * of the combobox.
	 *
	 * @param _items     Items in the combobox
	 * @param _text      Text of the label
	 * @param _value     Initial value of the combobox
	 */
	KComboBoxDialog( const TQString &_text, const TQStringList& _items, const TQString& _value = TQString(), bool showDontAskAgain = false, TQWidget *parent = 0 );
	virtual ~KComboBoxDialog();

	/**
	 * @return the value the user chose
	 */
	TQString text() const;

	/**
	 * @return the line edit widget
	 */
	KHistoryCombo *comboBox() const { return combo; }

	/**
	 * Static convenience function to get input from the user.
	 *
	 * @param _text            Text of the label
	 * @param _items           Items in the combobox
	 * @param _value           Initial value of the inputline
	 * @param dontAskAgainName Name for saving whether the user doesn't want to be asked again; use TQString() to disable
	 */
	static TQString getItem( const TQString &_text, const TQStringList &_items, const TQString& _value = TQString(), const TQString &dontAskAgainName = TQString(), TQWidget *parent = 0 );

	/**
	 * Static convenience function to get input from the user.
	 * This method includes a caption.
	 *
	 * @param _caption         Caption of the dialog
	 * @param _text            Text of the label
	 * @param _items           Items in the combobox
	 * @param _value           Initial value of the inputline
	 * @param dontAskAgainName Name for saving whether the user doesn't want to be asked again; use TQString() to disable
	 */
	static TQString getItem( const TQString &_text, const TQString &_caption, const TQStringList &_items, const TQString& _value = TQString(), const TQString &dontAskAgainName = TQString(), TQWidget *parent = 0 );

	/**
	 * Static convenience method.
	 * This method is meant as a replacement for KLineEditDlg::getText() for cases
	 * when a history and autocompletion are desired.
	 *
	 * @param _caption         Caption of the dialog
	 * @param _text            Text of the label
	 * @param _value           Initial value of the inputline
	 * @param ok               Variable to store whether the user hit OK
	 * @param parent           Parent widget for the dialog
	 * @param configName       Name of the dialog for saving the completion and history
	 * @parma config           KConfig for saving the completion and history
	 */
	static TQString getText(const TQString &_caption, const TQString &_text,
	                       const TQString &_value = TQString(),
	                       bool *ok = 0, TQWidget *parent = 0,
	                       const TQString &configName = TQString(),
	                       KConfig *config = KGlobal::config());

protected:
	KHistoryCombo *combo;
	TQCheckBox *dontAskAgainCheckBox;
	bool dontAskAgainChecked();
};

#endif