summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kfiledialog.cpp5
-rw-r--r--microkde/kio/kfile/kurlrequester.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/microkde/kfiledialog.cpp b/microkde/kfiledialog.cpp
index 3f47425..6be1580 100644
--- a/microkde/kfiledialog.cpp
+++ b/microkde/kfiledialog.cpp
@@ -1,76 +1,79 @@
1#include <kfiledialog.h> 1#include <kfiledialog.h>
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qapplication.h> 6#include <qapplication.h>
7 7
8#ifndef DESKTOP_VERSION 8#ifndef DESKTOP_VERSION
9//US orig#include <ofileselector.h> 9//US orig#include <ofileselector.h>
10#include <ofileselector_p.h> 10#include <ofileselector_p.h>
11QString KFileDialog::getSaveFileName( const QString & fn, 11QString KFileDialog::getSaveFileName( const QString & fn,
12 const QString & cap , QWidget * par ) 12 const QString & cap , QWidget * par )
13{ 13{
14 QString retfile = ""; 14 QString retfile = "";
15 QDialog dia ( par, "input-dialog", true ); 15 QDialog dia ( par, "input-dialog", true );
16 QVBoxLayout lay( &dia ); 16 QVBoxLayout lay( &dia );
17 lay.setMargin(7); 17 lay.setMargin(7);
18 lay.setSpacing(7); 18 lay.setSpacing(7);
19 QString file = fn; 19 QString file = fn;
20 if ( file.isEmpty() ) 20 if ( file.isEmpty() )
21 file = QDir::homeDirPath()+"/*"; 21 file = QDir::homeDirPath()+"/*";
22 QFileInfo fi ( file ); 22 QFileInfo fi ( file );
23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() ); 23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() );
24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
25 lay.addWidget( &o); 25 lay.addWidget( &o);
26 // o.setNewVisible( true ); 26 // o.setNewVisible( true );
27 // o.setNameVisible( true ); 27 // o.setNameVisible( true );
28 dia.showMaximized(); 28 dia.showMaximized();
29 dia.setCaption( cap ); 29 if ( cap.isEmpty() )
30 dia.setCaption( file );
31 else
32 dia.setCaption( cap );
30 int res = dia.exec(); 33 int res = dia.exec();
31 if ( res ) 34 if ( res )
32 retfile = o.selectedName(); 35 retfile = o.selectedName();
33 return retfile; 36 return retfile;
34} 37}
35 38
36QString KFileDialog::getOpenFileName( const QString & fn, 39QString KFileDialog::getOpenFileName( const QString & fn,
37 const QString & cap, QWidget * par ) 40 const QString & cap, QWidget * par )
38{ 41{
39 QString retfile = ""; 42 QString retfile = "";
40 QDialog dia ( par, "input-dialog", true ); 43 QDialog dia ( par, "input-dialog", true );
41 // QLineEdit lab ( &dia ); 44 // QLineEdit lab ( &dia );
42 QVBoxLayout lay( &dia ); 45 QVBoxLayout lay( &dia );
43 lay.setMargin(7); 46 lay.setMargin(7);
44 lay.setSpacing(7); 47 lay.setSpacing(7);
45 QString file = fn; 48 QString file = fn;
46 if ( file.isEmpty() ) 49 if ( file.isEmpty() )
47 file = QDir::homeDirPath()+"/*";; 50 file = QDir::homeDirPath()+"/*";;
48 QFileInfo fi ( file ); 51 QFileInfo fi ( file );
49 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() );
50 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 53 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
51 lay.addWidget( &o); 54 lay.addWidget( &o);
52 dia.showMaximized(); 55 dia.showMaximized();
53 dia.setCaption( cap ); 56 dia.setCaption( cap );
54 int res = dia.exec(); 57 int res = dia.exec();
55 if ( res ) 58 if ( res )
56 retfile = o.selectedName(); 59 retfile = o.selectedName();
57 return retfile; 60 return retfile;
58} 61}
59 62
60#else 63#else
61 64
62#include <qfiledialog.h> 65#include <qfiledialog.h>
63 66
64QString KFileDialog::getSaveFileName( const QString & fn, 67QString KFileDialog::getSaveFileName( const QString & fn,
65 const QString & cap , QWidget * par ) 68 const QString & cap , QWidget * par )
66{ 69{
67 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); 70 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap );
68} 71}
69QString KFileDialog::getOpenFileName( const QString & fn, 72QString KFileDialog::getOpenFileName( const QString & fn,
70 const QString & cap, QWidget * par ) 73 const QString & cap, QWidget * par )
71{ 74{
72 75
73 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); 76 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap );
74} 77}
75#endif 78#endif
76 79
diff --git a/microkde/kio/kfile/kurlrequester.cpp b/microkde/kio/kfile/kurlrequester.cpp
index 6d39308..991c8be 100644
--- a/microkde/kio/kfile/kurlrequester.cpp
+++ b/microkde/kio/kfile/kurlrequester.cpp
@@ -179,193 +179,193 @@ KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent,
179 179
180 init(); 180 init();
181} 181}
182*/ 182*/
183 183
184KURLRequester::KURLRequester( QWidget *parent, const char *name ) 184KURLRequester::KURLRequester( QWidget *parent, const char *name )
185 : QHBox( parent, name ) 185 : QHBox( parent, name )
186{ 186{
187 d = new KURLRequesterPrivate; 187 d = new KURLRequesterPrivate;
188 init(); 188 init();
189} 189}
190 190
191 191
192KURLRequester::KURLRequester( const QString& url, QWidget *parent, 192KURLRequester::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
202KURLRequester::~KURLRequester() 202KURLRequester::~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
210void KURLRequester::init() 210void KURLRequester::init()
211{ 211{
212 myFileDialog = 0L; 212 myFileDialog = 0L;
213 myShowLocalProt = false; 213 myShowLocalProt = false;
214 214
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 );
239 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() )); 239 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() ));
240 accel->readSettings(); 240 accel->readSettings();
241*/ 241*/
242} 242}
243 243
244 244
245void KURLRequester::setURL( const QString& url ) 245void KURLRequester::setURL( const QString& url )
246{ 246{
247 bool hasLocalPrefix = (url.startsWith("file:")); 247 bool hasLocalPrefix = (url.startsWith("file:"));
248 248
249 if ( !myShowLocalProt && hasLocalPrefix ) 249 if ( !myShowLocalProt && hasLocalPrefix )
250 d->setText( url.mid( 5, url.length()-5 )); 250 d->setText( url.mid( 5, url.length()-5 ));
251 else 251 else
252 d->setText( url ); 252 d->setText( url );
253} 253}
254 254
255void KURLRequester::setCaption( const QString& caption ) 255void 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
261QString KURLRequester::url() const 261QString KURLRequester::url() const
262{ 262{
263 return d->url(); 263 return d->url();
264} 264}
265 265
266 266
267void KURLRequester::slotOpenDialog() 267void 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, "Save backup filename", this ); 275 fn = KFileDialog::getSaveFileName( fn, "", this );
276 276
277 if ( fn == "" ) 277 if ( fn == "" )
278 return; 278 return;
279 279
280 setURL( fn ); 280 setURL( fn );
281 emit urlSelected( d->url() ); 281 emit urlSelected( d->url() );
282/*US 282/*US
283 KFileDialog *dlg = fileDialog(); 283 KFileDialog *dlg = fileDialog();
284 if ( !d->url().isEmpty() ) { 284 if ( !d->url().isEmpty() ) {
285 KURL u( url() ); 285 KURL u( url() );
286 // If we won't be able to list it (e.g. http), then don't try :) 286 // If we won't be able to list it (e.g. http), then don't try :)
287 if ( KProtocolInfo::supportsListing( u.protocol() ) ) 287 if ( KProtocolInfo::supportsListing( u.protocol() ) )
288 dlg->setSelection( u.url() ); 288 dlg->setSelection( u.url() );
289 } 289 }
290 290
291 if ( dlg->exec() == QDialog::Accepted ) 291 if ( dlg->exec() == QDialog::Accepted )
292 { 292 {
293 setURL( dlg->selectedURL().prettyURL() ); 293 setURL( dlg->selectedURL().prettyURL() );
294 emit urlSelected( d->url() ); 294 emit urlSelected( d->url() );
295 } 295 }
296*/ 296*/
297 297
298} 298}
299 299
300void KURLRequester::setMode(unsigned int mode) 300void KURLRequester::setMode(unsigned int mode)
301{ 301{
302/*US 302/*US
303 Q_ASSERT( (mode & KFile::Files) == 0 ); 303 Q_ASSERT( (mode & KFile::Files) == 0 );
304 d->fileDialogMode = mode; 304 d->fileDialogMode = mode;
305 if ( (mode & KFile::Directory) && !(mode & KFile::File) ) 305 if ( (mode & KFile::Directory) && !(mode & KFile::File) )
306 myCompletion->setMode( KURLCompletion::DirCompletion ); 306 myCompletion->setMode( KURLCompletion::DirCompletion );
307 307
308 if (myFileDialog) 308 if (myFileDialog)
309 myFileDialog->setMode( d->fileDialogMode ); 309 myFileDialog->setMode( d->fileDialogMode );
310*/ 310*/
311} 311}
312 312
313void KURLRequester::setFilter(const QString &filter) 313void KURLRequester::setFilter(const QString &filter)
314{ 314{
315/*US 315/*US
316 d->fileDialogFilter = filter; 316 d->fileDialogFilter = filter;
317 if (myFileDialog) 317 if (myFileDialog)
318 myFileDialog->setFilter( d->fileDialogFilter ); 318 myFileDialog->setFilter( d->fileDialogFilter );
319*/ 319*/
320} 320}
321 321
322KFileDialog * KURLRequester::fileDialog() const 322KFileDialog * KURLRequester::fileDialog() const
323{ 323{
324/*US 324/*US
325 if ( !myFileDialog ) { 325 if ( !myFileDialog ) {
326 QWidget *p = parentWidget(); 326 QWidget *p = parentWidget();
327 myFileDialog = new KFileDialog( QString::null, QString::null, p, 327 myFileDialog = new KFileDialog( QString::null, QString::null, p,
328 "file dialog", true ); 328 "file dialog", true );
329 329
330 myFileDialog->setMode( d->fileDialogMode ); 330 myFileDialog->setMode( d->fileDialogMode );
331 myFileDialog->setFilter( d->fileDialogFilter ); 331 myFileDialog->setFilter( d->fileDialogFilter );
332 } 332 }
333 333
334 return myFileDialog; 334 return myFileDialog;
335*/ 335*/
336 return 0; 336 return 0;
337} 337}
338 338
339 339
340void KURLRequester::setShowLocalProtocol( bool b ) 340void KURLRequester::setShowLocalProtocol( bool b )
341{ 341{
342 if ( myShowLocalProt == b ) 342 if ( myShowLocalProt == b )
343 return; 343 return;
344 344
345 myShowLocalProt = b; 345 myShowLocalProt = b;
346 setURL( url() ); 346 setURL( url() );
347} 347}
348 348
349void KURLRequester::clear() 349void KURLRequester::clear()
350{ 350{
351 d->setText( QString::null ); 351 d->setText( QString::null );
352} 352}
353 353
354KLineEdit * KURLRequester::lineEdit() const 354KLineEdit * KURLRequester::lineEdit() const
355{ 355{
356 return d->edit; 356 return d->edit;
357} 357}
358/*US 358/*US
359KComboBox * KURLRequester::comboBox() const 359KComboBox * KURLRequester::comboBox() const
360{ 360{
361 return d->combo; 361 return d->combo;
362} 362}
363*/ 363*/
364void KURLRequester::slotUpdateURL() 364void KURLRequester::slotUpdateURL()
365{ 365{
366 // bin compat, myButton is declared as QPushButton 366 // bin compat, myButton is declared as QPushButton
367//US KURL u( QDir::currentDirPath() + '/', url() ); 367//US KURL u( QDir::currentDirPath() + '/', url() );
368 KURL u( url() ); 368 KURL u( url() );
369 (static_cast<KURLDragPushButton *>( myButton))->setURL( u ); 369 (static_cast<KURLDragPushButton *>( myButton))->setURL( u );
370} 370}
371 371