summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kfiledialog.cpp11
-rw-r--r--microkde/kfiledialog.h2
-rw-r--r--microkde/kio/kfile/kurlrequester.cpp7
-rw-r--r--microkde/kio/kfile/kurlrequester.h2
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
@@ -1,79 +1,88 @@
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 if ( cap.isEmpty() ) 29 if ( cap.isEmpty() )
30 dia.setCaption( file ); 30 dia.setCaption( file );
31 else 31 else
32 dia.setCaption( cap ); 32 dia.setCaption( cap );
33 int res = dia.exec(); 33 int res = dia.exec();
34 if ( res ) 34 if ( res )
35 retfile = o.selectedName(); 35 retfile = o.selectedName();
36 return retfile; 36 return retfile;
37} 37}
38 38
39QString KFileDialog::getOpenFileName( const QString & fn, 39QString 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 62QString 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
67QString KFileDialog::getSaveFileName( const QString & fn, 71QString 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}
72QString KFileDialog::getOpenFileName( const QString & fn, 76QString 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}
82QString 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
7class KFileDialog 7class 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
@@ -1,406 +1,409 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 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 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, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#include <sys/stat.h> 20#include <sys/stat.h>
21#ifdef _WIN32_ 21#ifdef _WIN32_
22 22
23#else 23#else
24#include <unistd.h> 24#include <unistd.h>
25#endif 25#endif
26#include <qstring.h> 26#include <qstring.h>
27//US #include <qtooltip.h> 27//US #include <qtooltip.h>
28 28
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30 30
31//US #include <kaccel.h> 31//US #include <kaccel.h>
32//US #include <kcombobox.h> 32//US #include <kcombobox.h>
33#include <kdebug.h> 33#include <kdebug.h>
34#include <kdialog.h> 34#include <kdialog.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klineedit.h> 38#include <klineedit.h>
39#include <klocale.h> 39#include <klocale.h>
40//US #include <kurlcompletion.h> 40//US #include <kurlcompletion.h>
41//US #include <kurldrag.h> 41//US #include <kurldrag.h>
42//US #include <kprotocolinfo.h> 42//US #include <kprotocolinfo.h>
43 43
44 44
45#include "kurlrequester.h" 45#include "kurlrequester.h"
46 46
47 47
48class KURLDragPushButton : public QPushButton 48class KURLDragPushButton : public QPushButton
49{ 49{
50public: 50public:
51 KURLDragPushButton( QWidget *parent, const char *name=0 ) 51 KURLDragPushButton( QWidget *parent, const char *name=0 )
52 : QPushButton( parent, name ) { 52 : QPushButton( parent, name ) {
53 //US setDragEnabled( true ); 53 //US setDragEnabled( true );
54 } 54 }
55 ~KURLDragPushButton() {} 55 ~KURLDragPushButton() {}
56 56
57 void setURL( const KURL& url ) { 57 void setURL( const KURL& url ) {
58 m_urls.clear(); 58 m_urls.clear();
59 m_urls.append( url ); 59 m_urls.append( url );
60 } 60 }
61 61
62 /* not needed so far 62 /* not needed so far
63 void setURLs( const KURL::List& urls ) { 63 void setURLs( const KURL::List& urls ) {
64 m_urls = urls; 64 m_urls = urls;
65 } 65 }
66 const KURL::List& urls() const { return m_urls; } 66 const KURL::List& urls() const { return m_urls; }
67 */ 67 */
68 68
69protected: 69protected:
70/*US 70/*US
71 virtual QDragObject *dragObject() { 71 virtual QDragObject *dragObject() {
72 if ( m_urls.isEmpty() ) 72 if ( m_urls.isEmpty() )
73 return 0L; 73 return 0L;
74 74
75 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" ); 75 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" );
76 return drag; 76 return drag;
77 } 77 }
78*/ 78*/
79private: 79private:
80 KURL::List m_urls; 80 KURL::List m_urls;
81 81
82}; 82};
83 83
84 84
85/* 85/*
86************************************************************************* 86*************************************************************************
87*/ 87*/
88 88
89class KURLRequester::KURLRequesterPrivate 89class KURLRequester::KURLRequesterPrivate
90{ 90{
91public: 91public:
92 KURLRequesterPrivate() { 92 KURLRequesterPrivate() {
93 edit = 0L; 93 edit = 0L;
94 //UScombo = 0L; 94 //UScombo = 0L;
95//US fileDialogMode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly; 95//US fileDialogMode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly;
96 } 96 }
97 97
98 void setText( const QString& text ) { 98 void setText( const QString& text ) {
99/*US 99/*US
100 if ( combo ) 100 if ( combo )
101 { 101 {
102 if (combo->editable()) 102 if (combo->editable())
103 { 103 {
104 combo->setEditText( text ); 104 combo->setEditText( text );
105 } 105 }
106 else 106 else
107 { 107 {
108 combo->insertItem( text ); 108 combo->insertItem( text );
109 combo->setCurrentItem( combo->count()-1 ); 109 combo->setCurrentItem( combo->count()-1 );
110 } 110 }
111 } 111 }
112 else 112 else
113*/ 113*/
114 { 114 {
115 edit->setText( text ); 115 edit->setText( text );
116 } 116 }
117 } 117 }
118 118
119 void connectSignals( QObject *receiver ) { 119 void connectSignals( QObject *receiver ) {
120 QObject *sender; 120 QObject *sender;
121 /*USif ( combo ) 121 /*USif ( combo )
122 sender = combo; 122 sender = combo;
123 else 123 else
124*/ 124*/
125 sender = edit; 125 sender = edit;
126 126
127 connect( sender, SIGNAL( textChanged( const QString& )), 127 connect( sender, SIGNAL( textChanged( const QString& )),
128 receiver, SIGNAL( textChanged( const QString& ))); 128 receiver, SIGNAL( textChanged( const QString& )));
129 connect( sender, SIGNAL( returnPressed() ), 129 connect( sender, SIGNAL( returnPressed() ),
130 receiver, SIGNAL( returnPressed() )); 130 receiver, SIGNAL( returnPressed() ));
131 //USconnect( sender, SIGNAL( returnPressed( const QString& ) ), 131 //USconnect( sender, SIGNAL( returnPressed( const QString& ) ),
132 //US receiver, SIGNAL( returnPressed( const QString& ) )); 132 //US receiver, SIGNAL( returnPressed( const QString& ) ));
133 } 133 }
134/*US 134/*US
135 void setCompletionObject( KCompletion *comp ) { 135 void setCompletionObject( KCompletion *comp ) {
136 if ( combo ) 136 if ( combo )
137 combo->setCompletionObject( comp ); 137 combo->setCompletionObject( comp );
138 else 138 else
139 edit->setCompletionObject( comp ); 139 edit->setCompletionObject( comp );
140 } 140 }
141 */ 141 */
142 /** 142 /**
143 * replaces ~user or $FOO, if necessary 143 * replaces ~user or $FOO, if necessary
144 */ 144 */
145 QString url() { 145 QString url() {
146 QString txt = /*US combo ? combo->currentText() : */ edit->text(); 146 QString txt = /*US combo ? combo->currentText() : */ edit->text();
147/*US KURLCompletion *comp; 147/*US KURLCompletion *comp;
148 if ( combo ) 148 if ( combo )
149 comp = dynamic_cast<KURLCompletion*>(combo->completionObject()); 149 comp = dynamic_cast<KURLCompletion*>(combo->completionObject());
150 else 150 else
151 comp = dynamic_cast<KURLCompletion*>(edit->completionObject()); 151 comp = dynamic_cast<KURLCompletion*>(edit->completionObject());
152 152
153 if ( comp ) 153 if ( comp )
154 return comp->replacedPath( txt ); 154 return comp->replacedPath( txt );
155 else 155 else
156*/ 156*/
157 return txt; 157 return txt;
158 } 158 }
159 159
160 KLineEdit *edit; 160 KLineEdit *edit;
161//US KComboBox *combo; 161//US KComboBox *combo;
162 int fileDialogMode; 162 int fileDialogMode;
163 QString fileDialogFilter; 163 QString fileDialogFilter;
164}; 164};
165 165
166 166
167/*US 167/*US
168KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent, 168KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent,
169 const char *name ) 169 const char *name )
170 : QHBox( parent, name ) 170 : QHBox( parent, name )
171{ 171{
172 d = new KURLRequesterPrivate; 172 d = new KURLRequesterPrivate;
173 173
174 // must have this as parent 174 // must have this as parent
175 editWidget->reparent( this, 0, QPoint(0,0) ); 175 editWidget->reparent( this, 0, QPoint(0,0) );
176//US d->edit = dynamic_cast<KLineEdit*>( editWidget ); 176//US d->edit = dynamic_cast<KLineEdit*>( editWidget );
177 d->edit = (KLineEdit*)( editWidget ); 177 d->edit = (KLineEdit*)( editWidget );
178//US d->combo = dynamic_cast<KComboBox*>( editWidget ); 178//US d->combo = dynamic_cast<KComboBox*>( editWidget );
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 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 );
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, "", 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
300void KURLRequester::setMode(unsigned int mode) 303void KURLRequester::setMode(unsigned int mode)
301{ 304{
302/*US 305/*US
303 Q_ASSERT( (mode & KFile::Files) == 0 ); 306 Q_ASSERT( (mode & KFile::Files) == 0 );
304 d->fileDialogMode = mode; 307 d->fileDialogMode = mode;
305 if ( (mode & KFile::Directory) && !(mode & KFile::File) ) 308 if ( (mode & KFile::Directory) && !(mode & KFile::File) )
306 myCompletion->setMode( KURLCompletion::DirCompletion ); 309 myCompletion->setMode( KURLCompletion::DirCompletion );
307 310
308 if (myFileDialog) 311 if (myFileDialog)
309 myFileDialog->setMode( d->fileDialogMode ); 312 myFileDialog->setMode( d->fileDialogMode );
310*/ 313*/
311} 314}
312 315
313void KURLRequester::setFilter(const QString &filter) 316void KURLRequester::setFilter(const QString &filter)
314{ 317{
315/*US 318/*US
316 d->fileDialogFilter = filter; 319 d->fileDialogFilter = filter;
317 if (myFileDialog) 320 if (myFileDialog)
318 myFileDialog->setFilter( d->fileDialogFilter ); 321 myFileDialog->setFilter( d->fileDialogFilter );
319*/ 322*/
320} 323}
321 324
322KFileDialog * KURLRequester::fileDialog() const 325KFileDialog * KURLRequester::fileDialog() const
323{ 326{
324/*US 327/*US
325 if ( !myFileDialog ) { 328 if ( !myFileDialog ) {
326 QWidget *p = parentWidget(); 329 QWidget *p = parentWidget();
327 myFileDialog = new KFileDialog( QString::null, QString::null, p, 330 myFileDialog = new KFileDialog( QString::null, QString::null, p,
328 "file dialog", true ); 331 "file dialog", true );
329 332
330 myFileDialog->setMode( d->fileDialogMode ); 333 myFileDialog->setMode( d->fileDialogMode );
331 myFileDialog->setFilter( d->fileDialogFilter ); 334 myFileDialog->setFilter( d->fileDialogFilter );
332 } 335 }
333 336
334 return myFileDialog; 337 return myFileDialog;
335*/ 338*/
336 return 0; 339 return 0;
337} 340}
338 341
339 342
340void KURLRequester::setShowLocalProtocol( bool b ) 343void KURLRequester::setShowLocalProtocol( bool b )
341{ 344{
342 if ( myShowLocalProt == b ) 345 if ( myShowLocalProt == b )
343 return; 346 return;
344 347
345 myShowLocalProt = b; 348 myShowLocalProt = b;
346 setURL( url() ); 349 setURL( url() );
347} 350}
348 351
349void KURLRequester::clear() 352void KURLRequester::clear()
350{ 353{
351 d->setText( QString::null ); 354 d->setText( QString::null );
352} 355}
353 356
354KLineEdit * KURLRequester::lineEdit() const 357KLineEdit * KURLRequester::lineEdit() const
355{ 358{
356 return d->edit; 359 return d->edit;
357} 360}
358/*US 361/*US
359KComboBox * KURLRequester::comboBox() const 362KComboBox * KURLRequester::comboBox() const
360{ 363{
361 return d->combo; 364 return d->combo;
362} 365}
363*/ 366*/
364void KURLRequester::slotUpdateURL() 367void KURLRequester::slotUpdateURL()
365{ 368{
366 // bin compat, myButton is declared as QPushButton 369 // bin compat, myButton is declared as QPushButton
367//US KURL u( QDir::currentDirPath() + '/', url() ); 370//US KURL u( QDir::currentDirPath() + '/', url() );
368 KURL u( url() ); 371 KURL u( url() );
369 (static_cast<KURLDragPushButton *>( myButton))->setURL( u ); 372 (static_cast<KURLDragPushButton *>( myButton))->setURL( u );
370} 373}
371 374
372QPushButton * KURLRequester::button() const 375QPushButton * KURLRequester::button() const
373{ 376{
374 return myButton; 377 return myButton;
375} 378}
376/*US 379/*US
377KEditListBox::CustomEditor KURLRequester::customEditor() 380KEditListBox::CustomEditor KURLRequester::customEditor()
378{ 381{
379 setSizePolicy(QSizePolicy( QSizePolicy::Preferred, 382 setSizePolicy(QSizePolicy( QSizePolicy::Preferred,
380 QSizePolicy::Fixed)); 383 QSizePolicy::Fixed));
381 384
382 KLineEdit *edit = d->edit; 385 KLineEdit *edit = d->edit;
383 if ( !edit && d->combo ) 386 if ( !edit && d->combo )
384 edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() ); 387 edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() );
385 388
386#ifndef NDEBUG 389#ifndef NDEBUG
387 if ( !edit ) 390 if ( !edit )
388 kdWarning() << "KURLRequester's lineedit is not a KLineEdit!??\n"; 391 kdWarning() << "KURLRequester's lineedit is not a KLineEdit!??\n";
389#endif 392#endif
390 393
391 KEditListBox::CustomEditor editor( this, edit ); 394 KEditListBox::CustomEditor editor( this, edit );
392 return editor; 395 return editor;
393} 396}
394*/ 397*/
395void KURLRequester::virtual_hook( int, void* ) 398void KURLRequester::virtual_hook( int, void* )
396{ /*BASE::virtual_hook( id, data );*/ } 399{ /*BASE::virtual_hook( id, data );*/ }
397 400
398/*US 401/*US
399KURLComboRequester::KURLComboRequester( QWidget *parent, 402KURLComboRequester::KURLComboRequester( QWidget *parent,
400 const char *name ) 403 const char *name )
401 : KURLRequester( new KComboBox(false), parent, name) 404 : KURLRequester( new KComboBox(false), parent, name)
402{ 405{
403} 406}
404*/ 407*/
405 408
406//US #include "kurlrequester.moc" 409//US #include "kurlrequester.moc"
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
@@ -1,269 +1,271 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 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 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, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#ifndef KURLREQUESTER_H 20#ifndef KURLREQUESTER_H
21#define KURLREQUESTER_H 21#define KURLREQUESTER_H
22 22
23#include <qhbox.h> 23#include <qhbox.h>
24 24
25#include <keditlistbox.h> 25#include <keditlistbox.h>
26//US #include <kfile.h> 26//US #include <kfile.h>
27//US #include <kpushbutton.h> 27//US #include <kpushbutton.h>
28#include <kurl.h> 28#include <kurl.h>
29 29
30//US class KComboBox; 30//US class KComboBox;
31 31
32class KFileDialog; 32class KFileDialog;
33class KLineEdit; 33class KLineEdit;
34//US class KURLCompletion; 34//US class KURLCompletion;
35class KURLDragPushButton; 35class KURLDragPushButton;
36 36
37class QPushButton; 37class QPushButton;
38class QString; 38class QString;
39class QTimer; 39class QTimer;
40 40
41/** 41/**
42 * This class is a widget showing a lineedit and a button, which invokes a 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. 43 * filedialog. File name completion is available in the lineedit.
44 * 44 *
45 * The defaults for the filedialog are to ask for one existing local file, i.e. 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 ) 46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly )
47 * The default filter is "*", i.e. show all files, and the start directory is 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 48 * the current working directory, or the last directory where a file has been
49 * selected. 49 * selected.
50 * 50 *
51 * You can change this behavior by using @ref setMode() or @ref setFilter(). 51 * You can change this behavior by using @ref setMode() or @ref setFilter().
52 * 52 *
53 * @short A widget to request a filename/url from the user 53 * @short A widget to request a filename/url from the user
54 * @author Carsten Pfeiffer <pfeiffer@kde.org> 54 * @author Carsten Pfeiffer <pfeiffer@kde.org>
55 */ 55 */
56class KURLRequester : public QHBox 56class KURLRequester : public QHBox
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 Q_PROPERTY( QString url READ url WRITE setURL ) 59 Q_PROPERTY( QString url READ url WRITE setURL )
60 60
61public: 61public:
62 /** 62 /**
63 * Constructs a KURLRequester widget. 63 * Constructs a KURLRequester widget.
64 */ 64 */
65 KURLRequester( QWidget *parent=0, const char *name=0 ); 65 KURLRequester( QWidget *parent=0, const char *name=0 );
66 66
67 /** 67 /**
68 * Constructs a KURLRequester widget with the initial URL @p url. 68 * Constructs a KURLRequester widget with the initial URL @p url.
69 */ 69 */
70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 ); 70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 );
71 71
72 /** 72 /**
73 * Special constructor, which creates a KURLRequester widget with a custom 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 74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit
75 * (or inherited thereof). Note: for geometry management reasons, the 75 * (or inherited thereof). Note: for geometry management reasons, the
76 * edit-widget is reparented to have the KURLRequester as parent. 76 * edit-widget is reparented to have the KURLRequester as parent.
77 * @param modal specifies whether the filedialog should be opened as modal 77 * @param modal specifies whether the filedialog should be opened as modal
78 * or not. 78 * or not.
79 */ 79 */
80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 ); 80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 );
81 /** 81 /**
82 * Destructs the KURLRequester. 82 * Destructs the KURLRequester.
83 */ 83 */
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.
132 * 133 *
133 * It is provided so that you can e.g. set an own completion object 134 * It is provided so that you can e.g. set an own completion object
134 * (e.g. @ref KShellCompletion) into it. 135 * (e.g. @ref KShellCompletion) into it.
135 */ 136 */
136 KLineEdit * lineEdit() const; 137 KLineEdit * lineEdit() const;
137 138
138 /** 139 /**
139 * @returns a pointer to the combobox, in case you have set one using the 140 * @returns a pointer to the combobox, in case you have set one using the
140 * special constructor. Returns 0L otherwise. 141 * special constructor. Returns 0L otherwise.
141 */ 142 */
142//US KComboBox * comboBox() const; 143//US KComboBox * comboBox() const;
143 144
144 /** 145 /**
145 * @returns a pointer to the pushbutton. It is provided so that you can 146 * @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 * specify an own pixmap or a text, if you really need to.
147 */ 148 */
148 QPushButton * button() const; 149 QPushButton * button() const;
149 150
150 /** 151 /**
151 * @returns the KURLCompletion object used in the lineedit/combobox. 152 * @returns the KURLCompletion object used in the lineedit/combobox.
152 */ 153 */
153//US KURLCompletion *completionObject() const { return myCompletion; } 154//US KURLCompletion *completionObject() const { return myCompletion; }
154 155
155 /** 156 /**
156 * @returns an object, suitable for use with KEditListBox. It allows you 157 * @returns an object, suitable for use with KEditListBox. It allows you
157 * to put this KURLRequester into a KEditListBox. 158 * to put this KURLRequester into a KEditListBox.
158 * Basically, do it like this: 159 * Basically, do it like this:
159 * <pre> 160 * <pre>
160 * KURLRequester *req = new KURLRequester( someWidget ); 161 * KURLRequester *req = new KURLRequester( someWidget );
161 * [...] 162 * [...]
162 * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget ); 163 * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget );
163 * </pre> 164 * </pre>
164 * @since 3.1 165 * @since 3.1
165 */ 166 */
166//US KEditListBox::CustomEditor customEditor(); 167//US KEditListBox::CustomEditor customEditor();
167 168
168public slots: 169public slots:
169 /** 170 /**
170 * Sets the url in the lineedit to @p url. Depending on the state of 171 * 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 * @ref showLocalProtocol(), file:/ on local files will be shown or not.
172 * @since 3.1 173 * @since 3.1
173 */ 174 */
174 void setURL( const QString& url ); 175 void setURL( const QString& url );
175 176
176 /** 177 /**
177 * @reimp 178 * @reimp
178 * Sets the caption of the file dialog. 179 * Sets the caption of the file dialog.
179 * @since 3.1 180 * @since 3.1
180 */ 181 */
181 virtual void setCaption( const QString& caption ); 182 virtual void setCaption( const QString& caption );
182 183
183 /** 184 /**
184 * Clears the lineedit/combobox. 185 * Clears the lineedit/combobox.
185 */ 186 */
186 void clear(); 187 void clear();
187 188
188signals: 189signals:
189 // forwards from LineEdit 190 // forwards from LineEdit
190 /** 191 /**
191 * Emitted when the text in the lineedit changes. 192 * Emitted when the text in the lineedit changes.
192 * The parameter contains the contents of the lineedit. 193 * The parameter contains the contents of the lineedit.
193 * @since 3.1 194 * @since 3.1
194 */ 195 */
195 void textChanged( const QString& ); 196 void textChanged( const QString& );
196 197
197 /** 198 /**
198 * Emitted when return or enter was pressed in the lineedit. 199 * Emitted when return or enter was pressed in the lineedit.
199 */ 200 */
200 void returnPressed(); 201 void returnPressed();
201 202
202 /** 203 /**
203 * Emitted when return or enter was pressed in the lineedit. 204 * Emitted when return or enter was pressed in the lineedit.
204 * The parameter contains the contents of the lineedit. 205 * The parameter contains the contents of the lineedit.
205 */ 206 */
206 void returnPressed( const QString& ); 207 void returnPressed( const QString& );
207 208
208 /** 209 /**
209 * Emitted before the filedialog is going to open. Connect 210 * Emitted before the filedialog is going to open. Connect
210 * to this signal to "configure" the filedialog, e.g. set the 211 * to this signal to "configure" the filedialog, e.g. set the
211 * filefilter, the mode, a preview-widget, etc. It's usually 212 * filefilter, the mode, a preview-widget, etc. It's usually
212 * not necessary to set a URL for the filedialog, as it will 213 * not necessary to set a URL for the filedialog, as it will
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
227protected: 228protected:
228 void init(); 229 void init();
229 230
230//US KURLCompletion * myCompletion; 231//US KURLCompletion * myCompletion;
231 232
232 233
233private: 234private:
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
239protected slots: 241protected 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
246private slots: 248private slots:
247 void slotUpdateURL(); 249 void slotUpdateURL();
248 250
249protected: 251protected:
250 virtual void virtual_hook( int id, void* data ); 252 virtual void virtual_hook( int id, void* data );
251private: 253private:
252 class KURLRequesterPrivate; 254 class KURLRequesterPrivate;
253 KURLRequesterPrivate *d; 255 KURLRequesterPrivate *d;
254}; 256};
255/*US 257/*US
256class KURLComboRequester : public KURLRequester // For use in Qt Designer 258class KURLComboRequester : public KURLRequester // For use in Qt Designer
257{ 259{
258 Q_OBJECT 260 Q_OBJECT
259public: 261public:
260*/ 262*/
261 /** 263 /**
262 * Constructs a KURLRequester widget with a combobox. 264 * Constructs a KURLRequester widget with a combobox.
263 */ 265 */
264/*US 266/*US
265 KURLComboRequester( QWidget *parent=0, const char *name=0 ); 267 KURLComboRequester( QWidget *parent=0, const char *name=0 );
266}; 268};
267*/ 269*/
268 270
269#endif // KURLREQUESTER_H 271#endif // KURLREQUESTER_H