KDevelop API Documentation

fileselector_widget.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
00003    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00004    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00005    Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef FILESELECTOR_WIDGET_H
00023 #define FILESELECTOR_WIDGET_H
00024 
00025 #include <qwidget.h>
00026 #include <kfile.h>
00027 #include <kurl.h>
00028 #include <ktoolbar.h>
00029 #include <qframe.h>
00030 #include <kdiroperator.h>
00031 
00032 class KDevMainWindow;
00033 class KDevPartController;
00034 class FileSelectorPart;
00035 class KActionCollection;
00036 class KActionSelector;
00037 class KDirOperator;
00038 class KURLComboBox;
00039 class KHistoryCombo;
00040 
00041 namespace KParts
00042 {
00043     class Part;
00044 }
00045 
00046 namespace KTextEditor
00047 {
00048     class Document;
00049 }
00050 
00051 /*
00052     The KDev file selector presents a directory view, in which the default action is
00053     to open the activated file.
00054     Additinally, a toolbar for managing the kdiroperator widget + sync that to
00055     the directory of the current file is available, as well as a filter widget
00056     allowing to filter the displayed files using a name filter.
00057 */
00058 
00059 /* I think this fix for not moving toolbars is better */
00060 class KDevFileSelectorToolBar: public KToolBar
00061 {
00062     Q_OBJECT
00063 public:
00064     KDevFileSelectorToolBar(QWidget *parent);
00065     virtual ~KDevFileSelectorToolBar();
00066 
00067     virtual void setMovingEnabled( bool b );
00068 };
00069 
00070 class KDevFileSelectorToolBarParent: public QFrame
00071 {
00072     Q_OBJECT
00073 public:
00074     KDevFileSelectorToolBarParent(QWidget *parent);
00075     ~KDevFileSelectorToolBarParent();
00076     void setToolBar(KDevFileSelectorToolBar *tb);
00077 
00078 private:
00079     KDevFileSelectorToolBar *m_tb;
00080 
00081 protected:
00082     virtual void resizeEvent ( QResizeEvent * );
00083 };
00084 
00085 class KDevDirOperator: public KDirOperator
00086 {
00087     Q_OBJECT
00088 public:
00089     KDevDirOperator(FileSelectorPart *part, const KURL &urlName=KURL(), QWidget *parent=0, const char *name=0)
00090         :KDirOperator(urlName, parent, name), m_part(part)
00091     {
00092     }
00093 
00094 protected slots:
00095     virtual void activatedMenu (const KFileItem *fi, const QPoint &pos);
00096 
00097 private:
00098     FileSelectorPart *m_part;
00099 };
00100 
00101 class KDevFileSelector : public QWidget
00102 {
00103     Q_OBJECT
00104 
00105     friend class KFSConfigPage;
00106 
00107 public:
00108     /* When to sync to current document directory */
00109     enum AutoSyncEvent { DocumentChanged=1, DocumentOpened=2, GotVisible=4 };
00110 
00111     KDevFileSelector( FileSelectorPart *part, KDevMainWindow *mainWindow=0, KDevPartController *partController=0,
00112                       QWidget * parent = 0, const char * name = 0 );
00113     ~KDevFileSelector();
00114 
00115     void readConfig( KConfig *, const QString & );
00116     void writeConfig( KConfig *, const QString & );
00117     void setupToolbar( KConfig * );
00118     void setView( KFile::FileView );
00119     KDevDirOperator *dirOperator(){ return dir; }
00120     KActionCollection *actionCollection() { return mActionCollection; };
00121 
00122 public slots:
00123     void slotFilterChange(const QString&);
00124     void setDir(KURL);
00125     void setDir( const QString& url ) { setDir( KURL( url ) ); };
00126 
00127 private slots:
00128     void cmbPathActivated( const KURL& u );
00129     void cmbPathReturnPressed( const QString& u );
00130     void dirUrlEntered( const KURL& u );
00131     void dirFinishedLoading();
00132     void setActiveDocumentDir();
00133     void viewChanged();
00134     void btnFilterClick();
00135     void autoSync();
00136     void autoSync( KParts::Part * );
00137     void initialDirChangeHack();
00138 protected:
00139     void focusInEvent( QFocusEvent * );
00140     void showEvent( QShowEvent * );
00141     bool eventFilter( QObject *, QEvent * );
00142     KURL activeDocumentUrl();
00143 
00144 private:
00145     class KDevFileSelectorToolBar *toolbar;
00146     KActionCollection *mActionCollection;
00147     class KBookmarkHandler *bookmarkHandler;
00148     KURLComboBox *cmbPath;
00149     KDevDirOperator * dir;
00150     class KAction *acSyncDir;
00151     KHistoryCombo * filter;
00152     class QToolButton *btnFilter;
00153 
00154     FileSelectorPart *m_part;
00155     KDevMainWindow *mainwin;
00156     KDevPartController *partController;
00157 
00158     QString lastFilter;
00159     int autoSyncEvents; // enabled autosync events
00160     QString waitingUrl; // maybe display when we gets visible
00161     QString waitingDir;
00162 };
00163 
00164 /*  @todo anders
00165     KFSFilterHelper
00166     A popup widget presenting a listbox with checkable items
00167     representing the mime types available in the current directory, and
00168     providing a name filter based on those.
00169 */
00170 
00171 /*
00172     Config page for file selector.
00173     Allows for configuring the toolbar, the history length
00174     of the path and file filter combos, and how to handle
00175     user closed session.
00176 */
00177 class KFSConfigPage : public QWidget
00178 {
00179     Q_OBJECT
00180 public:
00181     KFSConfigPage( QWidget* parent=0, const char *name=0, KDevFileSelector *kfs=0);
00182     virtual ~KFSConfigPage() {};
00183 
00184 public slots:
00185     virtual void apply();
00186     virtual void reload();
00187     virtual void slotChanged();
00188 
00189 private:
00190     void init();
00191 
00192     KDevFileSelector *fileSelector;
00193     bool bDirty;
00194     //class QListBox *lbAvailableActions, *lbUsedActions;
00195     KActionSelector *acSel;
00196     class QSpinBox *sbPathHistLength, *sbFilterHistLength;
00197     class QCheckBox *cbSyncOpen, *cbSyncActive, *cbSyncShow;
00198     class QCheckBox *cbSesLocation, *cbSesFilter;
00199 };
00200 
00201 
00202 #endif
00203 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:40 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003