author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kio/kfile/kurlrequester.h | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'microkde/kio/kfile/kurlrequester.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kio/kfile/kurlrequester.h | 269 |
1 files changed, 269 insertions, 0 deletions
diff --git a/microkde/kio/kfile/kurlrequester.h b/microkde/kio/kfile/kurlrequester.h new file mode 100644 index 0000000..3253dd5 --- a/dev/null +++ b/microkde/kio/kfile/kurlrequester.h | |||
@@ -0,0 +1,269 @@ | |||
1 | /* This file is part of the KDE libraries | ||
2 | Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> | ||
3 | |||
4 | library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | ||
6 | License version 2, as published by the Free Software Foundation. | ||
7 | |||
8 | This library is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | Library General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU Library General Public License | ||
14 | along with this library; see the file COPYING.LIB. If not, write to | ||
15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
16 | Boston, MA 02111-1307, USA. | ||
17 | */ | ||
18 | |||
19 | |||
20 | #ifndef KURLREQUESTER_H | ||
21 | #define KURLREQUESTER_H | ||
22 | |||
23 | #include <qhbox.h> | ||
24 | |||
25 | #include <keditlistbox.h> | ||
26 | //US #include <kfile.h> | ||
27 | //US #include <kpushbutton.h> | ||
28 | #include <kurl.h> | ||
29 | |||
30 | //US class KComboBox; | ||
31 | |||
32 | class KFileDialog; | ||
33 | class KLineEdit; | ||
34 | //US class KURLCompletion; | ||
35 | class KURLDragPushButton; | ||
36 | |||
37 | class QPushButton; | ||
38 | class QString; | ||
39 | class QTimer; | ||
40 | |||
41 | /** | ||
42 | * This class is a widget showing a lineedit and a button, which invokes a | ||
43 | * filedialog. File name completion is available in the lineedit. | ||
44 | * | ||
45 | * The defaults for the filedialog are to ask for one existing local file, i.e. | ||
46 | * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ) | ||
47 | * The default filter is "*", i.e. show all files, and the start directory is | ||
48 | * the current working directory, or the last directory where a file has been | ||
49 | * selected. | ||
50 | * | ||
51 | * You can change this behavior by using @ref setMode() or @ref setFilter(). | ||
52 | * | ||
53 | * @short A widget to request a filename/url from the user | ||
54 | * @author Carsten Pfeiffer <pfeiffer@kde.org> | ||
55 | */ | ||
56 | class KURLRequester : public QHBox | ||
57 | { | ||
58 | Q_OBJECT | ||
59 | Q_PROPERTY( QString url READ url WRITE setURL ) | ||
60 | |||
61 | public: | ||
62 | /** | ||
63 | * Constructs a KURLRequester widget. | ||
64 | */ | ||
65 | KURLRequester( QWidget *parent=0, const char *name=0 ); | ||
66 | |||
67 | /** | ||
68 | * Constructs a KURLRequester widget with the initial URL @p url. | ||
69 | */ | ||
70 | KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 ); | ||
71 | |||
72 | /** | ||
73 | * Special constructor, which creates a KURLRequester widget with a custom | ||
74 | * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit | ||
75 | * (or inherited thereof). Note: for geometry management reasons, the | ||
76 | * edit-widget is reparented to have the KURLRequester as parent. | ||
77 | * @param modal specifies whether the filedialog should be opened as modal | ||
78 | * or not. | ||
79 | */ | ||
80 | //US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 ); | ||
81 | /** | ||
82 | * Destructs the KURLRequester. | ||
83 | */ | ||
84 | ~KURLRequester(); | ||
85 | |||
86 | /** | ||
87 | * @returns the current url in the lineedit. May be malformed, if the user | ||
88 | * entered something weird. ~user or environment variables are substituted | ||
89 | * for local files. | ||
90 | */ | ||
91 | QString url() const; | ||
92 | |||
93 | /** | ||
94 | * Enables/disables showing file:/ in the lineedit, when a local file has | ||
95 | * been selected in the filedialog or was set via @ref setURL(). | ||
96 | * Default is false, not showing file:/ | ||
97 | * @see #showLocalProtocol | ||
98 | */ | ||
99 | void setShowLocalProtocol( bool b ); | ||
100 | |||
101 | /** | ||
102 | * Sets the mode of the file dialog. | ||
103 | * Note: you can only select one file with the filedialog, | ||
104 | * so KFile::Files doesn't make much sense. | ||
105 | * @see KFileDialog::setMode() | ||
106 | */ | ||
107 | void setMode( unsigned int m ); | ||
108 | |||
109 | /** | ||
110 | * Sets the filter for the file dialog. | ||
111 | * @see KFileDialog::setFilter() | ||
112 | */ | ||
113 | void setFilter( const QString& filter ); | ||
114 | |||
115 | /** | ||
116 | * @returns whether local files will be prefixed with file:/ in the | ||
117 | * lineedit | ||
118 | * @see #setShowLocalProtocol | ||
119 | */ | ||
120 | bool showLocalProtocol() const { return myShowLocalProt; } | ||
121 | |||
122 | /** | ||
123 | * @returns a pointer to the filedialog | ||
124 | * You can use this to customize the dialog, e.g. to specify a filter. | ||
125 | * Never returns 0L. | ||
126 | */ | ||
127 | virtual KFileDialog * fileDialog() const; | ||
128 | |||
129 | /** | ||
130 | * @returns a pointer to the lineedit, either the default one, or the | ||
131 | * special one, if you used the special constructor. | ||
132 | * | ||
133 | * It is provided so that you can e.g. set an own completion object | ||
134 | * (e.g. @ref KShellCompletion) into it. | ||
135 | */ | ||
136 | KLineEdit * lineEdit() const; | ||
137 | |||
138 | /** | ||
139 | * @returns a pointer to the combobox, in case you have set one using the | ||
140 | * special constructor. Returns 0L otherwise. | ||
141 | */ | ||
142 | //US KComboBox * comboBox() const; | ||
143 | |||
144 | /** | ||
145 | * @returns a pointer to the pushbutton. It is provided so that you can | ||
146 | * specify an own pixmap or a text, if you really need to. | ||
147 | */ | ||
148 | QPushButton * button() const; | ||
149 | |||
150 | /** | ||
151 | * @returns the KURLCompletion object used in the lineedit/combobox. | ||
152 | */ | ||
153 | //US KURLCompletion *completionObject() const { return myCompletion; } | ||
154 | |||
155 | /** | ||
156 | * @returns an object, suitable for use with KEditListBox. It allows you | ||
157 | * to put this KURLRequester into a KEditListBox. | ||
158 | * Basically, do it like this: | ||
159 | * <pre> | ||
160 | * KURLRequester *req = new KURLRequester( someWidget ); | ||
161 | * [...] | ||
162 | * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget ); | ||
163 | * </pre> | ||
164 | * @since 3.1 | ||
165 | */ | ||
166 | //US KEditListBox::CustomEditor customEditor(); | ||
167 | |||
168 | public slots: | ||
169 | /** | ||
170 | * Sets the url in the lineedit to @p url. Depending on the state of | ||
171 | * @ref showLocalProtocol(), file:/ on local files will be shown or not. | ||
172 | * @since 3.1 | ||
173 | */ | ||
174 | void setURL( const QString& url ); | ||
175 | |||
176 | /** | ||
177 | * @reimp | ||
178 | * Sets the caption of the file dialog. | ||
179 | * @since 3.1 | ||
180 | */ | ||
181 | virtual void setCaption( const QString& caption ); | ||
182 | |||
183 | /** | ||
184 | * Clears the lineedit/combobox. | ||
185 | */ | ||
186 | void clear(); | ||
187 | |||
188 | signals: | ||
189 | // forwards from LineEdit | ||
190 | /** | ||
191 | * Emitted when the text in the lineedit changes. | ||
192 | * The parameter contains the contents of the lineedit. | ||
193 | * @since 3.1 | ||
194 | */ | ||
195 | void textChanged( const QString& ); | ||
196 | |||
197 | /** | ||
198 | * Emitted when return or enter was pressed in the lineedit. | ||
199 | */ | ||
200 | void returnPressed(); | ||
201 | |||
202 | /** | ||
203 | * Emitted when return or enter was pressed in the lineedit. | ||
204 | * The parameter contains the contents of the lineedit. | ||
205 | */ | ||
206 | void returnPressed( const QString& ); | ||
207 | |||
208 | /** | ||
209 | * Emitted before the filedialog is going to open. Connect | ||
210 | * to this signal to "configure" the filedialog, e.g. set the | ||
211 | * filefilter, the mode, a preview-widget, etc. It's usually | ||
212 | * not necessary to set a URL for the filedialog, as it will | ||
213 | * get set properly from the editfield contents. | ||
214 | * | ||
215 | * If you use multiple KURLRequesters, you can connect all of them | ||
216 | * to the same slot and use the given KURLRequester pointer to know | ||
217 | * which one is going to open. | ||
218 | */ | ||
219 | void openFileDialog( KURLRequester * ); | ||
220 | |||
221 | /** | ||
222 | * Emitted when the user changed the URL via the file dialog. | ||
223 | * The parameter contains the contents of the lineedit. | ||
224 | */ | ||
225 | void urlSelected( const QString& ); | ||
226 | |||
227 | protected: | ||
228 | void init(); | ||
229 | |||
230 | //US KURLCompletion * myCompletion; | ||
231 | |||
232 | |||
233 | private: | ||
234 | KURLDragPushButton * myButton; | ||
235 | bool myShowLocalProt; | ||
236 | mutable KFileDialog * myFileDialog; | ||
237 | |||
238 | |||
239 | protected slots: | ||
240 | /** | ||
241 | * Called when the button is pressed to open the filedialog. | ||
242 | * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed. | ||
243 | */ | ||
244 | void slotOpenDialog(); | ||
245 | |||
246 | private slots: | ||
247 | void slotUpdateURL(); | ||
248 | |||
249 | protected: | ||
250 | virtual void virtual_hook( int id, void* data ); | ||
251 | private: | ||
252 | class KURLRequesterPrivate; | ||
253 | KURLRequesterPrivate *d; | ||
254 | }; | ||
255 | /*US | ||
256 | class KURLComboRequester : public KURLRequester // For use in Qt Designer | ||
257 | { | ||
258 | Q_OBJECT | ||
259 | public: | ||
260 | */ | ||
261 | /** | ||
262 | * Constructs a KURLRequester widget with a combobox. | ||
263 | */ | ||
264 | /*US | ||
265 | KURLComboRequester( QWidget *parent=0, const char *name=0 ); | ||
266 | }; | ||
267 | */ | ||
268 | |||
269 | #endif // KURLREQUESTER_H | ||