00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __TDEFILEDIALOG_H__
00026 #define __TDEFILEDIALOG_H__
00027
00028 #include <tqstring.h>
00029
00030 #include <kdialogbase.h>
00031 #include <tdefile.h>
00032 #include <kurl.h>
00033 #include <kmimetype.h>
00034 #include <tdeio/jobclasses.h>
00035
00036 class TQCheckBox;
00037 class TQHBoxLayout;
00038 class TQGridLayout;
00039 class TQLabel;
00040 class TQPopupMenu;
00041 class TQVBoxLayout;
00042
00043 class TDEActionCollection;
00044 class KDirOperator;
00045 class KURLBar;
00046 class KURLComboBox;
00047 class KFileFilterCombo;
00048 class KFileView;
00049 class KFileItem;
00050 class KPushButton;
00051 class TDEToolBar;
00052 class KPreviewWidgetBase;
00053
00054 struct KFileDialogPrivate;
00055
00077 class TDEIO_EXPORT KFileDialog : public KDialogBase
00078 {
00079 Q_OBJECT
00080
00081 public:
00082
00094 enum OperationMode { Other = 0, Opening, Saving };
00095
00119 KFileDialog(const TQString& startDir, const TQString& filter,
00120 TQWidget *parent, const char *name,
00121 bool modal);
00122
00159 KFileDialog(const TQString& startDir, const TQString& filter,
00160 TQWidget *parent, const char *name,
00161 bool modal, TQWidget* widget);
00162
00163
00167 ~KFileDialog();
00168
00172 KURL selectedURL() const;
00173
00177 KURL::List selectedURLs() const;
00178
00182 KURL baseURL() const;
00183
00188 TQString selectedFile() const;
00189
00193 TQStringList selectedFiles() const;
00194
00202 void setURL(const KURL &url, bool clearforward = true);
00203
00209 void setSelection(const TQString& name);
00210
00228 void setOperationMode( KFileDialog::OperationMode );
00229
00237 OperationMode operationMode() const;
00238
00250 void setKeepLocation( bool keep );
00251
00256 bool keepsLocation() const;
00257
00292 void setFilter(const TQString& filter);
00293
00301 TQString currentFilter() const;
00302
00313 void setFilterMimeType(const TQString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType) KDE_DEPRECATED;
00314
00323 KMimeType::Ptr currentFilterMimeType();
00324
00336 void setMimeFilter( const TQStringList& types,
00337 const TQString& defaultType = TQString::null );
00338
00347 TQString currentMimeFilter() const;
00348
00352 void clearFilter();
00353
00368 void setPreviewWidget(const TQWidget *w) KDE_DEPRECATED;
00369
00381 void setPreviewWidget(const KPreviewWidgetBase *w);
00382
00408 static TQString getOpenFileName(const TQString& startDir= TQString::null,
00409 const TQString& filter= TQString::null,
00410 TQWidget *parent= 0,
00411 const TQString& caption = TQString::null);
00412
00413
00422 static TQString getOpenFileNameWId(const TQString& startDir,
00423 const TQString& filter,
00424 WId parent_id, const TQString& caption);
00425
00451 static TQStringList getOpenFileNames(const TQString& startDir= TQString::null,
00452 const TQString& filter= TQString::null,
00453 TQWidget *parent = 0,
00454 const TQString& caption= TQString::null);
00455
00456
00457
00483 static KURL getOpenURL(const TQString& startDir = TQString::null,
00484 const TQString& filter= TQString::null,
00485 TQWidget *parent= 0,
00486 const TQString& caption = TQString::null);
00487
00488
00489
00515 static KURL::List getOpenURLs(const TQString& startDir= TQString::null,
00516 const TQString& filter= TQString::null,
00517 TQWidget *parent = 0,
00518 const TQString& caption= TQString::null);
00519
00520
00521
00549 static TQString getSaveFileName(const TQString& startDir= TQString::null,
00550 const TQString& filter= TQString::null,
00551 TQWidget *parent= 0,
00552 const TQString& caption = TQString::null);
00553
00554
00560 static TQString getSaveFileNameWId(const TQString& dir, const TQString& filter,
00561 WId parent_id,
00562 const TQString& caption);
00563
00591 static KURL getSaveURL(const TQString& startDir= TQString::null,
00592 const TQString& filter= TQString::null,
00593 TQWidget *parent= 0,
00594 const TQString& caption = TQString::null);
00595
00596
00615 static TQString getExistingDirectory(const TQString & startDir = TQString::null,
00616 TQWidget * parent = 0,
00617 const TQString& caption= TQString::null);
00618
00641 static KURL getExistingURL(const TQString & startDir = TQString::null,
00642 TQWidget * parent = 0,
00643 const TQString& caption= TQString::null);
00662 static KURL getImageOpenURL( const TQString& startDir = TQString::null,
00663 TQWidget *parent = 0,
00664 const TQString& caption = TQString::null );
00665 virtual void show();
00666
00670 void setMode( KFile::Mode m );
00671
00693 void setMode( unsigned int m );
00694
00699 KFile::Mode mode() const;
00700
00708 void setLocationLabel(const TQString& text);
00709
00722 TDEToolBar *toolBar() const { return toolbar; }
00723
00728 KPushButton *okButton() const;
00729
00734 KPushButton *cancelButton() const;
00735
00751 KURLBar *speedBar();
00752
00757 TDEActionCollection *actionCollection() const;
00758
00763 int pathComboIndex();
00764
00777 static KURL getStartURL( const TQString& startDir, TQString& recentDirClass );
00778
00783 static void setStartDir( const KURL& directory );
00784
00785 signals:
00793 void fileSelected(const TQString&);
00794
00798 void fileHighlighted(const TQString&);
00799
00808 void selectionChanged();
00809
00820 void filterChanged( const TQString& filter );
00821
00822 protected:
00823 TDEToolBar *toolbar;
00824
00825 static KURL *lastDirectory;
00826
00827 KURLComboBox *locationEdit;
00828
00829 KFileFilterCombo *filterWidget;
00830
00834 virtual void keyPressEvent( TQKeyEvent *e );
00835
00840 void init(const TQString& startDir, const TQString& filter, TQWidget* widget);
00841
00846 virtual void initGUI();
00847
00852 void multiSelectionChanged();
00853
00857 virtual void readConfig( TDEConfig *, const TQString& group = TQString::null );
00858
00862 virtual void writeConfig( TDEConfig *, const TQString& group = TQString::null );
00863
00867 virtual void readRecentFiles( TDEConfig * );
00868
00872 virtual void saveRecentFiles( TDEConfig * );
00873
00880 KURL::List tokenize(const TQString& line) const;
00881
00886 KURL getCompleteURL(const TQString&);
00887
00894 TQString currentFilterExtension();
00895
00904 void updateAutoSelectExtension();
00905
00906
00907 protected slots:
00908 void urlEntered( const KURL& );
00909 void enterURL( const KURL& url );
00910 void enterURL( const TQString& url );
00911 void locationActivated( const TQString& url );
00912
00916
00917 void toolbarCallback(int);
00921
00922 void pathComboChanged( const TQString& );
00926
00927 void dirCompletion( const TQString& );
00928
00929 void slotFilterChanged();
00930 void fileHighlighted(const KFileItem *i);
00931 void fileSelected(const KFileItem *i);
00932 void slotStatResult(TDEIO::Job* job);
00933 void slotLoadingFinished();
00934
00935 void fileCompletion( const TQString& );
00939 void toggleSpeedbar( bool );
00940
00944 void toggleBookmarks(bool show);
00945
00949 virtual void updateStatusLine(int dirs, int files);
00950
00951 virtual void slotOk();
00952 virtual void accept();
00953 virtual void slotCancel();
00954
00955 void slotAutoSelectExtClicked();
00956 void addToRecentDocuments();
00957 void initSpeedbar();
00958
00959 private slots:
00960 void slotLocationChanged( const TQString& text );
00961
00962 private:
00963 KFileDialog(const KFileDialog&);
00964 KFileDialog operator=(const KFileDialog&);
00965
00966 void setLocationText( const TQString& text );
00967 void updateLocationWhatsThis();
00968
00969 void appendExtension(KURL &url);
00970 void updateLocationEditExtension(const TQString &);
00971 void updateFilter();
00972
00973 static void initStatic();
00974
00975 void setNonExtSelection();
00976
00977 protected:
00978 KDirOperator *ops;
00979 bool autoDirectoryFollowing;
00980
00981 KURL::List& parseSelectedURLs() const;
00982
00983 protected:
00984 virtual void virtual_hook( int id, void* data );
00985 private:
00986 KFileDialogPrivate *d;
00987 };
00988
00989 #endif