katefileselector.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> 00004 Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __KATE_FILESELECTOR_H__ 00022 #define __KATE_FILESELECTOR_H__ 00023 00024 #include "katemain.h" 00025 #include "katedocmanager.h" 00026 #include <kate/document.h> 00027 00028 #include <tqvbox.h> 00029 #include <kfile.h> 00030 #include <kurl.h> 00031 #include <ktoolbar.h> 00032 #include <tqframe.h> 00033 00034 class KateMainWindow; 00035 class KateViewManager; 00036 class KActionCollection; 00037 class KActionSelector; 00038 class KFileView; 00039 00040 /* 00041 The kate file selector presents a directory view, in which the default action is 00042 to open the activated file. 00043 Additinally, a toolbar for managing the kdiroperator widget + sync that to 00044 the directory of the current file is available, as well as a filter widget 00045 allowing to filter the displayed files using a name filter. 00046 */ 00047 00048 /* I think this fix for not moving toolbars is better */ 00049 class KateFileSelectorToolBar: public KToolBar 00050 { 00051 Q_OBJECT 00052 public: 00053 KateFileSelectorToolBar(TQWidget *parent); 00054 virtual ~KateFileSelectorToolBar(); 00055 00056 virtual void setMovingEnabled( bool b ); 00057 }; 00058 00059 class KateFileSelectorToolBarParent: public TQFrame 00060 { 00061 Q_OBJECT 00062 public: 00063 KateFileSelectorToolBarParent(TQWidget *parent); 00064 ~KateFileSelectorToolBarParent(); 00065 void setToolBar(KateFileSelectorToolBar *tb); 00066 private: 00067 KateFileSelectorToolBar *m_tb; 00068 protected: 00069 virtual void resizeEvent ( TQResizeEvent * ); 00070 }; 00071 00072 class KateFileSelector : public TQVBox 00073 { 00074 Q_OBJECT 00075 00076 friend class KFSConfigPage; 00077 00078 public: 00079 /* When to sync to current document directory */ 00080 enum AutoSyncEvent { DocumentChanged=1, GotVisible=2 }; 00081 00082 KateFileSelector( KateMainWindow *mainWindow=0, KateViewManager *viewManager=0, 00083 TQWidget * parent = 0, const char * name = 0 ); 00084 ~KateFileSelector(); 00085 00086 void readConfig( KConfig *, const TQString & ); 00087 void writeConfig( KConfig *, const TQString & ); 00088 void setupToolbar( KConfig * ); 00089 void setView( KFile::FileView ); 00090 KDirOperator *dirOperator(){ return dir; } 00091 KActionCollection *actionCollection() { return mActionCollection; }; 00092 00093 public slots: 00094 void slotFilterChange(const TQString&); 00095 void setDir(KURL); 00096 void setDir( const TQString& url ) { setDir( KURL( url ) ); }; 00097 void kateViewChanged(); 00098 void selectorViewChanged( KFileView * ); 00099 00100 private slots: 00101 void cmbPathActivated( const KURL& u ); 00102 void cmbPathReturnPressed( const TQString& u ); 00103 void dirUrlEntered( const KURL& u ); 00104 void dirFinishedLoading(); 00105 void setActiveDocumentDir(); 00106 void btnFilterClick(); 00107 00108 protected: 00109 void focusInEvent( TQFocusEvent * ); 00110 void showEvent( TQShowEvent * ); 00111 bool eventFilter( TQObject *, TQEvent * ); 00112 void initialDirChangeHack(); 00113 00114 private: 00115 class KateFileSelectorToolBar *toolbar; 00116 KActionCollection *mActionCollection; 00117 class KBookmarkHandler *bookmarkHandler; 00118 KURLComboBox *cmbPath; 00119 KDirOperator * dir; 00120 class KAction *acSyncDir; 00121 KHistoryCombo * filter; 00122 class TQToolButton *btnFilter; 00123 00124 KateMainWindow *mainwin; 00125 KateViewManager *viewmanager; 00126 00127 TQString lastFilter; 00128 int autoSyncEvents; // enabled autosync events 00129 TQString waitingUrl; // maybe display when we gets visible 00130 TQString waitingDir; 00131 }; 00132 00133 /* TODO anders 00134 KFSFilterHelper 00135 A popup widget presenting a listbox with checkable items 00136 representing the mime types available in the current directory, and 00137 providing a name filter based on those. 00138 */ 00139 00140 /* 00141 Config page for file selector. 00142 Allows for configuring the toolbar, the history length 00143 of the path and file filter combos, and how to handle 00144 user closed session. 00145 */ 00146 class KFSConfigPage : public Kate::ConfigPage { 00147 Q_OBJECT 00148 public: 00149 KFSConfigPage( TQWidget* parent=0, const char *name=0, KateFileSelector *kfs=0); 00150 virtual ~KFSConfigPage() {}; 00151 00152 virtual void apply(); 00153 virtual void reload(); 00154 00155 private slots: 00156 void slotMyChanged(); 00157 00158 private: 00159 void init(); 00160 00161 KateFileSelector *fileSelector; 00162 KActionSelector *acSel; 00163 class TQSpinBox *sbPathHistLength, *sbFilterHistLength; 00164 class TQCheckBox *cbSyncActive, *cbSyncShow; 00165 class TQCheckBox *cbSesLocation, *cbSesFilter; 00166 00167 bool m_changed; 00168 }; 00169 00170 00171 #endif //__KATE_FILESELECTOR_H__ 00172 // kate: space-indent on; indent-width 2; replace-tabs on;