-rw-r--r-- | microkde/kfiledialog.cpp | 11 | ||||
-rw-r--r-- | microkde/kfiledialog.h | 2 | ||||
-rw-r--r-- | microkde/kio/kfile/kurlrequester.cpp | 5 | ||||
-rw-r--r-- | microkde/kio/kfile/kurlrequester.h | 2 |
4 files changed, 18 insertions, 2 deletions
diff --git a/microkde/kfiledialog.cpp b/microkde/kfiledialog.cpp index 6be1580..c64f325 100644 --- a/microkde/kfiledialog.cpp +++ b/microkde/kfiledialog.cpp @@ -54,26 +54,35 @@ QString KFileDialog::getOpenFileName( const QString & fn, lay.addWidget( &o); dia.showMaximized(); dia.setCaption( cap ); int res = dia.exec(); if ( res ) retfile = o.selectedName(); return retfile; } - +QString KFileDialog::getExistingDirectory( const QString & fn, + const QString & cap, QWidget * par ) +{ + return KFileDialog::getSaveFileName( fn, cap, pr ); +} #else #include <qfiledialog.h> QString KFileDialog::getSaveFileName( const QString & fn, const QString & cap , QWidget * par ) { return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); } QString KFileDialog::getOpenFileName( const QString & fn, const QString & cap, QWidget * par ) { return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); } +QString KFileDialog::getExistingDirectory( const QString & fn, + const QString & cap, QWidget * par ) +{ + return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap ); +} #endif diff --git a/microkde/kfiledialog.h b/microkde/kfiledialog.h index 0825872..90709cd 100644 --- a/microkde/kfiledialog.h +++ b/microkde/kfiledialog.h @@ -10,11 +10,13 @@ class KFileDialog static QString getSaveFileName( const QString &, const QString &, QWidget * ); static QString getOpenFileName( const QString &, const QString &, QWidget * ); + static QString getExistingDirectory( const QString &, + const QString &, QWidget * ); }; #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 @@ -206,17 +206,17 @@ KURLRequester::~KURLRequester() delete d; } void KURLRequester::init() { myFileDialog = 0L; myShowLocalProt = false; - + mPathIsDir = false; if (/*US !d->combo && */ !d->edit ) d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" ); myButton = new KURLDragPushButton( this, "kfile button"); QIconSet iconSet = SmallIconSet("fileopen"); QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal ); myButton->setIconSet( iconSet ); myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); @@ -267,16 +267,19 @@ QString KURLRequester::url() const void KURLRequester::slotOpenDialog() { emit openFileDialog( this ); //US use our special KFIleDialog instead KURL u( url() ); //QString fn = u.url(); QString fn = d->edit->text(); + if ( mPathIsDir ) + fn = KFileDialog::getExistingDirectory ( fn, "", this ); + else fn = KFileDialog::getSaveFileName( fn, "", this ); if ( fn == "" ) return; setURL( fn ); emit urlSelected( d->url() ); /*US 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 @@ -100,16 +100,17 @@ public: /** * Sets the mode of the file dialog. * Note: you can only select one file with the filedialog, * so KFile::Files doesn't make much sense. * @see KFileDialog::setMode() */ void setMode( unsigned int m ); + void setPathIsDir( ) {mPathIsDir = true;} /** * Sets the filter for the file dialog. * @see KFileDialog::setFilter() */ void setFilter( const QString& filter ); /** @@ -229,16 +230,17 @@ protected: //US KURLCompletion * myCompletion; private: KURLDragPushButton * myButton; bool myShowLocalProt; mutable KFileDialog * myFileDialog; + bool mPathIsDir; protected slots: /** * Called when the button is pressed to open the filedialog. * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed. */ void slotOpenDialog(); |