You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdevelop/parts/fileselector/fileselector_widget.h

209 lines
5.7 KiB

/* This file is part of the KDE project
Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef FILESELECTOR_WIDGET_H
#define FILESELECTOR_WIDGET_H
#include <tqwidget.h>
#include <tdefile.h>
#include <kurl.h>
#include <tdetoolbar.h>
#include <tqframe.h>
#include <tdediroperator.h>
class TDevMainWindow;
class TDevPartController;
class FileSelectorPart;
class TDEActionCollection;
class TDEActionSelector;
class KDirOperator;
class KURLComboBox;
class KHistoryCombo;
namespace KParts
{
class Part;
}
namespace KTextEditor
{
class Document;
}
/*
The KDev file selector presents a directory view, in which the default action is
to open the activated file.
Additinally, a toolbar for managing the kdiroperator widget + sync that to
the directory of the current file is available, as well as a filter widget
allowing to filter the displayed files using a name filter.
*/
/* I think this fix for not moving toolbars is better */
class TDevFileSelectorToolBar: public TDEToolBar
{
Q_OBJECT
public:
TDevFileSelectorToolBar(TQWidget *parent);
virtual ~TDevFileSelectorToolBar();
virtual void setMovingEnabled( bool b );
};
class TDevFileSelectorToolBarParent: public TQFrame
{
Q_OBJECT
public:
TDevFileSelectorToolBarParent(TQWidget *parent);
~TDevFileSelectorToolBarParent();
void setToolBar(TDevFileSelectorToolBar *tb);
private:
TDevFileSelectorToolBar *m_tb;
protected:
virtual void resizeEvent ( TQResizeEvent * );
};
class TDevDirOperator: public KDirOperator
{
Q_OBJECT
public:
TDevDirOperator(FileSelectorPart *part, const KURL &urlName=KURL(), TQWidget *parent=0, const char *name=0)
:KDirOperator(urlName, parent, name), m_part(part)
{
}
protected slots:
virtual void activatedMenu (const KFileItem *fi, const TQPoint &pos);
private:
FileSelectorPart *m_part;
};
class TDevFileSelector : public TQWidget
{
Q_OBJECT
friend class KFSConfigPage;
public:
/* When to sync to current document directory */
enum AutoSyncEvent { DocumentChanged=1, DocumentOpened=2, GotVisible=4 };
TDevFileSelector( FileSelectorPart *part, TDevMainWindow *mainWindow=0, TDevPartController *partController=0,
TQWidget * parent = 0, const char * name = 0 );
~TDevFileSelector();
void readConfig( TDEConfig *, const TQString & );
void writeConfig( TDEConfig *, const TQString & );
void setupToolbar( TDEConfig * );
void setView( KFile::FileView );
TDevDirOperator *dirOperator(){ return dir; }
TDEActionCollection *actionCollection() { return mActionCollection; };
public slots:
void slotFilterChange(const TQString&);
void setDir(KURL);
void setDir( const TQString& url ) { setDir( KURL( url ) ); };
private slots:
void cmbPathActivated( const KURL& u );
void cmbPathReturnPressed( const TQString& u );
void dirUrlEntered( const KURL& u );
void dirFinishedLoading();
void setActiveDocumentDir();
void viewChanged();
void btnFilterClick();
void autoSync();
void autoSync( KParts::Part * );
void initialDirChangeHack();
protected:
void focusInEvent( TQFocusEvent * );
void showEvent( TQShowEvent * );
bool eventFilter( TQObject *, TQEvent * );
KURL activeDocumentUrl();
private:
class TDevFileSelectorToolBar *toolbar;
TDEActionCollection *mActionCollection;
class KBookmarkHandler *bookmarkHandler;
KURLComboBox *cmbPath;
TDevDirOperator * dir;
class TDEAction *acSyncDir;
KHistoryCombo * filter;
class TQToolButton *btnFilter;
FileSelectorPart *m_part;
TDevMainWindow *mainwin;
TDevPartController *partController;
TQString lastFilter;
int autoSyncEvents; // enabled autosync events
TQString waitingUrl; // maybe display when we gets visible
TQString waitingDir;
};
/* @todo anders
KFSFilterHelper
A popup widget presenting a listbox with checkable items
representing the mime types available in the current directory, and
providing a name filter based on those.
*/
/*
Config page for file selector.
Allows for configuring the toolbar, the history length
of the path and file filter combos, and how to handle
user closed session.
*/
class KFSConfigPage : public TQWidget
{
Q_OBJECT
public:
KFSConfigPage( TQWidget* parent=0, const char *name=0, TDevFileSelector *kfs=0);
virtual ~KFSConfigPage() {};
public slots:
virtual void apply();
virtual void reload();
virtual void slotChanged();
private:
void init();
TDevFileSelector *fileSelector;
bool bDirty;
//class TQListBox *lbAvailableActions, *lbUsedActions;
TDEActionSelector *acSel;
class TQSpinBox *sbPathHistLength, *sbFilterHistLength;
class TQCheckBox *cbSyncOpen, *cbSyncActive, *cbSyncShow;
class TQCheckBox *cbSesLocation, *cbSesFilter;
};
#endif