author | zautrix <zautrix> | 2005-06-11 17:03:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-11 17:03:59 (UTC) |
commit | 81370a5f955c2710b6e9336b6c412c8d630ef72a (patch) (unidiff) | |
tree | 6252851fbafcbc3ff777e1af0171990124beb23e /microkde | |
parent | 0cfaf22fc5d8f511320813171be84ce3436990c6 (diff) | |
download | kdepimpi-81370a5f955c2710b6e9336b6c412c8d630ef72a.zip kdepimpi-81370a5f955c2710b6e9336b6c412c8d630ef72a.tar.gz kdepimpi-81370a5f955c2710b6e9336b6c412c8d630ef72a.tar.bz2 |
fixes
-rw-r--r-- | microkde/kfiledialog.cpp | 11 | ||||
-rw-r--r-- | microkde/kfiledialog.h | 2 | ||||
-rw-r--r-- | microkde/kio/kfile/kurlrequester.cpp | 7 | ||||
-rw-r--r-- | microkde/kio/kfile/kurlrequester.h | 2 |
4 files changed, 19 insertions, 3 deletions
diff --git a/microkde/kfiledialog.cpp b/microkde/kfiledialog.cpp index 6be1580..c64f325 100644 --- a/microkde/kfiledialog.cpp +++ b/microkde/kfiledialog.cpp | |||
@@ -38,42 +38,51 @@ QString KFileDialog::getSaveFileName( const QString & fn, | |||
38 | 38 | ||
39 | QString KFileDialog::getOpenFileName( const QString & fn, | 39 | QString KFileDialog::getOpenFileName( const QString & fn, |
40 | const QString & cap, QWidget * par ) | 40 | const QString & cap, QWidget * par ) |
41 | { | 41 | { |
42 | QString retfile = ""; | 42 | QString retfile = ""; |
43 | QDialog dia ( par, "input-dialog", true ); | 43 | QDialog dia ( par, "input-dialog", true ); |
44 | // QLineEdit lab ( &dia ); | 44 | // QLineEdit lab ( &dia ); |
45 | QVBoxLayout lay( &dia ); | 45 | QVBoxLayout lay( &dia ); |
46 | lay.setMargin(7); | 46 | lay.setMargin(7); |
47 | lay.setSpacing(7); | 47 | lay.setSpacing(7); |
48 | QString file = fn; | 48 | QString file = fn; |
49 | if ( file.isEmpty() ) | 49 | if ( file.isEmpty() ) |
50 | file = QDir::homeDirPath()+"/*";; | 50 | file = QDir::homeDirPath()+"/*";; |
51 | QFileInfo fi ( file ); | 51 | QFileInfo fi ( file ); |
52 | OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() ); | 52 | OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() ); |
53 | QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); | 53 | QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); |
54 | lay.addWidget( &o); | 54 | lay.addWidget( &o); |
55 | dia.showMaximized(); | 55 | dia.showMaximized(); |
56 | dia.setCaption( cap ); | 56 | dia.setCaption( cap ); |
57 | int res = dia.exec(); | 57 | int res = dia.exec(); |
58 | if ( res ) | 58 | if ( res ) |
59 | retfile = o.selectedName(); | 59 | retfile = o.selectedName(); |
60 | return retfile; | 60 | return retfile; |
61 | } | 61 | } |
62 | 62 | QString KFileDialog::getExistingDirectory( const QString & fn, | |
63 | const QString & cap, QWidget * par ) | ||
64 | { | ||
65 | return KFileDialog::getSaveFileName( fn, cap, pr ); | ||
66 | } | ||
63 | #else | 67 | #else |
64 | 68 | ||
65 | #include <qfiledialog.h> | 69 | #include <qfiledialog.h> |
66 | 70 | ||
67 | QString KFileDialog::getSaveFileName( const QString & fn, | 71 | QString KFileDialog::getSaveFileName( const QString & fn, |
68 | const QString & cap , QWidget * par ) | 72 | const QString & cap , QWidget * par ) |
69 | { | 73 | { |
70 | return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); | 74 | return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); |
71 | } | 75 | } |
72 | QString KFileDialog::getOpenFileName( const QString & fn, | 76 | QString KFileDialog::getOpenFileName( const QString & fn, |
73 | const QString & cap, QWidget * par ) | 77 | const QString & cap, QWidget * par ) |
74 | { | 78 | { |
75 | 79 | ||
76 | return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); | 80 | return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); |
77 | } | 81 | } |
82 | QString KFileDialog::getExistingDirectory( const QString & fn, | ||
83 | const QString & cap, QWidget * par ) | ||
84 | { | ||
85 | return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap ); | ||
86 | } | ||
78 | #endif | 87 | #endif |
79 | 88 | ||
diff --git a/microkde/kfiledialog.h b/microkde/kfiledialog.h index 0825872..90709cd 100644 --- a/microkde/kfiledialog.h +++ b/microkde/kfiledialog.h | |||
@@ -1,20 +1,22 @@ | |||
1 | #ifndef MICROKDE_KFILEDIALOG_H | 1 | #ifndef MICROKDE_KFILEDIALOG_H |
2 | #define MICROKDE_KFILEDIALOG_H | 2 | #define MICROKDE_KFILEDIALOG_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | 6 | ||
7 | class KFileDialog | 7 | class KFileDialog |
8 | { | 8 | { |
9 | public: | 9 | public: |
10 | 10 | ||
11 | static QString getSaveFileName( const QString &, | 11 | static QString getSaveFileName( const QString &, |
12 | const QString &, QWidget * ); | 12 | const QString &, QWidget * ); |
13 | 13 | ||
14 | 14 | ||
15 | static QString getOpenFileName( const QString &, | 15 | static QString getOpenFileName( const QString &, |
16 | const QString &, QWidget * ); | 16 | const QString &, QWidget * ); |
17 | 17 | ||
18 | static QString getExistingDirectory( const QString &, | ||
19 | const QString &, QWidget * ); | ||
18 | }; | 20 | }; |
19 | 21 | ||
20 | #endif | 22 | #endif |
diff --git a/microkde/kio/kfile/kurlrequester.cpp b/microkde/kio/kfile/kurlrequester.cpp index 991c8be..ca94570 100644 --- a/microkde/kio/kfile/kurlrequester.cpp +++ b/microkde/kio/kfile/kurlrequester.cpp | |||
@@ -190,49 +190,49 @@ KURLRequester::KURLRequester( QWidget *parent, const char *name ) | |||
190 | 190 | ||
191 | 191 | ||
192 | KURLRequester::KURLRequester( const QString& url, QWidget *parent, | 192 | KURLRequester::KURLRequester( const QString& url, QWidget *parent, |
193 | const char *name ) | 193 | const char *name ) |
194 | : QHBox( parent, name ) | 194 | : QHBox( parent, name ) |
195 | { | 195 | { |
196 | d = new KURLRequesterPrivate; | 196 | d = new KURLRequesterPrivate; |
197 | init(); | 197 | init(); |
198 | setURL( url ); | 198 | setURL( url ); |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | KURLRequester::~KURLRequester() | 202 | KURLRequester::~KURLRequester() |
203 | { | 203 | { |
204 | //US delete myCompletion; | 204 | //US delete myCompletion; |
205 | delete myFileDialog; | 205 | delete myFileDialog; |
206 | delete d; | 206 | delete d; |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void KURLRequester::init() | 210 | void KURLRequester::init() |
211 | { | 211 | { |
212 | myFileDialog = 0L; | 212 | myFileDialog = 0L; |
213 | myShowLocalProt = false; | 213 | myShowLocalProt = false; |
214 | 214 | mPathIsDir = false; | |
215 | if (/*US !d->combo && */ !d->edit ) | 215 | if (/*US !d->combo && */ !d->edit ) |
216 | d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" ); | 216 | d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" ); |
217 | 217 | ||
218 | myButton = new KURLDragPushButton( this, "kfile button"); | 218 | myButton = new KURLDragPushButton( this, "kfile button"); |
219 | QIconSet iconSet = SmallIconSet("fileopen"); | 219 | QIconSet iconSet = SmallIconSet("fileopen"); |
220 | QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal ); | 220 | QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal ); |
221 | myButton->setIconSet( iconSet ); | 221 | myButton->setIconSet( iconSet ); |
222 | myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); | 222 | myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); |
223 | //US QToolTip::add(myButton, i18n("Open file dialog")); | 223 | //US QToolTip::add(myButton, i18n("Open file dialog")); |
224 | 224 | ||
225 | connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() )); | 225 | connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() )); |
226 | 226 | ||
227 | setSpacing( KDialog::spacingHint() ); | 227 | setSpacing( KDialog::spacingHint() ); |
228 | 228 | ||
229 | QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit; | 229 | QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit; |
230 | setFocusProxy( widget ); | 230 | setFocusProxy( widget ); |
231 | 231 | ||
232 | d->connectSignals( this ); | 232 | d->connectSignals( this ); |
233 | connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() )); | 233 | connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() )); |
234 | /*US | 234 | /*US |
235 | myCompletion = new KURLCompletion(); | 235 | myCompletion = new KURLCompletion(); |
236 | d->setCompletionObject( myCompletion ); | 236 | d->setCompletionObject( myCompletion ); |
237 | 237 | ||
238 | KAccel *accel = new KAccel( this ); | 238 | KAccel *accel = new KAccel( this ); |
@@ -251,49 +251,52 @@ void KURLRequester::setURL( const QString& url ) | |||
251 | else | 251 | else |
252 | d->setText( url ); | 252 | d->setText( url ); |
253 | } | 253 | } |
254 | 254 | ||
255 | void KURLRequester::setCaption( const QString& caption ) | 255 | void KURLRequester::setCaption( const QString& caption ) |
256 | { | 256 | { |
257 | //USfileDialog()->setCaption( caption ); | 257 | //USfileDialog()->setCaption( caption ); |
258 | //USQWidget::setCaption( caption ); | 258 | //USQWidget::setCaption( caption ); |
259 | } | 259 | } |
260 | 260 | ||
261 | QString KURLRequester::url() const | 261 | QString KURLRequester::url() const |
262 | { | 262 | { |
263 | return d->url(); | 263 | return d->url(); |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void KURLRequester::slotOpenDialog() | 267 | void KURLRequester::slotOpenDialog() |
268 | { | 268 | { |
269 | emit openFileDialog( this ); | 269 | emit openFileDialog( this ); |
270 | 270 | ||
271 | //US use our special KFIleDialog instead | 271 | //US use our special KFIleDialog instead |
272 | KURL u( url() ); | 272 | KURL u( url() ); |
273 | //QString fn = u.url(); | 273 | //QString fn = u.url(); |
274 | QString fn = d->edit->text(); | 274 | QString fn = d->edit->text(); |
275 | fn = KFileDialog::getSaveFileName( fn, "", this ); | 275 | if ( mPathIsDir ) |
276 | fn = KFileDialog::getExistingDirectory ( fn, "", this ); | ||
277 | else | ||
278 | fn = KFileDialog::getSaveFileName( fn, "", this ); | ||
276 | 279 | ||
277 | if ( fn == "" ) | 280 | if ( fn == "" ) |
278 | return; | 281 | return; |
279 | 282 | ||
280 | setURL( fn ); | 283 | setURL( fn ); |
281 | emit urlSelected( d->url() ); | 284 | emit urlSelected( d->url() ); |
282 | /*US | 285 | /*US |
283 | KFileDialog *dlg = fileDialog(); | 286 | KFileDialog *dlg = fileDialog(); |
284 | if ( !d->url().isEmpty() ) { | 287 | if ( !d->url().isEmpty() ) { |
285 | KURL u( url() ); | 288 | KURL u( url() ); |
286 | // If we won't be able to list it (e.g. http), then don't try :) | 289 | // If we won't be able to list it (e.g. http), then don't try :) |
287 | if ( KProtocolInfo::supportsListing( u.protocol() ) ) | 290 | if ( KProtocolInfo::supportsListing( u.protocol() ) ) |
288 | dlg->setSelection( u.url() ); | 291 | dlg->setSelection( u.url() ); |
289 | } | 292 | } |
290 | 293 | ||
291 | if ( dlg->exec() == QDialog::Accepted ) | 294 | if ( dlg->exec() == QDialog::Accepted ) |
292 | { | 295 | { |
293 | setURL( dlg->selectedURL().prettyURL() ); | 296 | setURL( dlg->selectedURL().prettyURL() ); |
294 | emit urlSelected( d->url() ); | 297 | emit urlSelected( d->url() ); |
295 | } | 298 | } |
296 | */ | 299 | */ |
297 | 300 | ||
298 | } | 301 | } |
299 | 302 | ||
diff --git a/microkde/kio/kfile/kurlrequester.h b/microkde/kio/kfile/kurlrequester.h index 3253dd5..faa3326 100644 --- a/microkde/kio/kfile/kurlrequester.h +++ b/microkde/kio/kfile/kurlrequester.h | |||
@@ -84,48 +84,49 @@ public: | |||
84 | ~KURLRequester(); | 84 | ~KURLRequester(); |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * @returns the current url in the lineedit. May be malformed, if the user | 87 | * @returns the current url in the lineedit. May be malformed, if the user |
88 | * entered something weird. ~user or environment variables are substituted | 88 | * entered something weird. ~user or environment variables are substituted |
89 | * for local files. | 89 | * for local files. |
90 | */ | 90 | */ |
91 | QString url() const; | 91 | QString url() const; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Enables/disables showing file:/ in the lineedit, when a local file has | 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(). | 95 | * been selected in the filedialog or was set via @ref setURL(). |
96 | * Default is false, not showing file:/ | 96 | * Default is false, not showing file:/ |
97 | * @see #showLocalProtocol | 97 | * @see #showLocalProtocol |
98 | */ | 98 | */ |
99 | void setShowLocalProtocol( bool b ); | 99 | void setShowLocalProtocol( bool b ); |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Sets the mode of the file dialog. | 102 | * Sets the mode of the file dialog. |
103 | * Note: you can only select one file with the filedialog, | 103 | * Note: you can only select one file with the filedialog, |
104 | * so KFile::Files doesn't make much sense. | 104 | * so KFile::Files doesn't make much sense. |
105 | * @see KFileDialog::setMode() | 105 | * @see KFileDialog::setMode() |
106 | */ | 106 | */ |
107 | void setMode( unsigned int m ); | 107 | void setMode( unsigned int m ); |
108 | void setPathIsDir( ) {mPathIsDir = true;} | ||
108 | 109 | ||
109 | /** | 110 | /** |
110 | * Sets the filter for the file dialog. | 111 | * Sets the filter for the file dialog. |
111 | * @see KFileDialog::setFilter() | 112 | * @see KFileDialog::setFilter() |
112 | */ | 113 | */ |
113 | void setFilter( const QString& filter ); | 114 | void setFilter( const QString& filter ); |
114 | 115 | ||
115 | /** | 116 | /** |
116 | * @returns whether local files will be prefixed with file:/ in the | 117 | * @returns whether local files will be prefixed with file:/ in the |
117 | * lineedit | 118 | * lineedit |
118 | * @see #setShowLocalProtocol | 119 | * @see #setShowLocalProtocol |
119 | */ | 120 | */ |
120 | bool showLocalProtocol() const { return myShowLocalProt; } | 121 | bool showLocalProtocol() const { return myShowLocalProt; } |
121 | 122 | ||
122 | /** | 123 | /** |
123 | * @returns a pointer to the filedialog | 124 | * @returns a pointer to the filedialog |
124 | * You can use this to customize the dialog, e.g. to specify a filter. | 125 | * You can use this to customize the dialog, e.g. to specify a filter. |
125 | * Never returns 0L. | 126 | * Never returns 0L. |
126 | */ | 127 | */ |
127 | virtual KFileDialog * fileDialog() const; | 128 | virtual KFileDialog * fileDialog() const; |
128 | 129 | ||
129 | /** | 130 | /** |
130 | * @returns a pointer to the lineedit, either the default one, or the | 131 | * @returns a pointer to the lineedit, either the default one, or the |
131 | * special one, if you used the special constructor. | 132 | * special one, if you used the special constructor. |
@@ -213,48 +214,49 @@ signals: | |||
213 | * get set properly from the editfield contents. | 214 | * get set properly from the editfield contents. |
214 | * | 215 | * |
215 | * If you use multiple KURLRequesters, you can connect all of them | 216 | * 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 | * to the same slot and use the given KURLRequester pointer to know |
217 | * which one is going to open. | 218 | * which one is going to open. |
218 | */ | 219 | */ |
219 | void openFileDialog( KURLRequester * ); | 220 | void openFileDialog( KURLRequester * ); |
220 | 221 | ||
221 | /** | 222 | /** |
222 | * Emitted when the user changed the URL via the file dialog. | 223 | * Emitted when the user changed the URL via the file dialog. |
223 | * The parameter contains the contents of the lineedit. | 224 | * The parameter contains the contents of the lineedit. |
224 | */ | 225 | */ |
225 | void urlSelected( const QString& ); | 226 | void urlSelected( const QString& ); |
226 | 227 | ||
227 | protected: | 228 | protected: |
228 | void init(); | 229 | void init(); |
229 | 230 | ||
230 | //US KURLCompletion * myCompletion; | 231 | //US KURLCompletion * myCompletion; |
231 | 232 | ||
232 | 233 | ||
233 | private: | 234 | private: |
234 | KURLDragPushButton * myButton; | 235 | KURLDragPushButton * myButton; |
235 | bool myShowLocalProt; | 236 | bool myShowLocalProt; |
236 | mutable KFileDialog * myFileDialog; | 237 | mutable KFileDialog * myFileDialog; |
238 | bool mPathIsDir; | ||
237 | 239 | ||
238 | 240 | ||
239 | protected slots: | 241 | protected slots: |
240 | /** | 242 | /** |
241 | * Called when the button is pressed to open the filedialog. | 243 | * Called when the button is pressed to open the filedialog. |
242 | * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed. | 244 | * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed. |
243 | */ | 245 | */ |
244 | void slotOpenDialog(); | 246 | void slotOpenDialog(); |
245 | 247 | ||
246 | private slots: | 248 | private slots: |
247 | void slotUpdateURL(); | 249 | void slotUpdateURL(); |
248 | 250 | ||
249 | protected: | 251 | protected: |
250 | virtual void virtual_hook( int id, void* data ); | 252 | virtual void virtual_hook( int id, void* data ); |
251 | private: | 253 | private: |
252 | class KURLRequesterPrivate; | 254 | class KURLRequesterPrivate; |
253 | KURLRequesterPrivate *d; | 255 | KURLRequesterPrivate *d; |
254 | }; | 256 | }; |
255 | /*US | 257 | /*US |
256 | class KURLComboRequester : public KURLRequester // For use in Qt Designer | 258 | class KURLComboRequester : public KURLRequester // For use in Qt Designer |
257 | { | 259 | { |
258 | Q_OBJECT | 260 | Q_OBJECT |
259 | public: | 261 | public: |
260 | */ | 262 | */ |