kdiroperator.h
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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 KDIROPERATOR_H_
#define KDIROPERATOR_H_
#include <qwidget.h>
#include <qptrstack.h>
#include <kaction.h>
#include <kcompletion.h>
#include <kdirlister.h>
#include <kfileview.h>
#include <kfileitem.h>
#include <kfile.h>
class QPopupMenu;
class QTimer;
class KAction;
class KDirLister;
class KToggleAction;
class KActionSeparator;
class KActionMenu;
class QWidgetStack;
class KProgress;
namespace KIO {
class CopyJob;
class DeleteJob;
}
class KIO_EXPORT KDirOperator : public QWidget
{
Q_OBJECT
public:
enum ActionTypes { SortActions = 1,
ViewActions = 2,
NavActions = 4,
FileActions = 8,
AllActions = 15 };
KDirOperator(const KURL& urlName = KURL(),
QWidget *parent = 0, const char* name = 0);
virtual ~KDirOperator();
// ### KDE4: make virtual
void setShowHiddenFiles ( bool s ) { showHiddenAction->setChecked( s ); }
bool showHiddenFiles () const { return showHiddenAction->isChecked(); }
void close();
virtual bool close( bool alsoDelete ) { return QWidget::close( alsoDelete ); }
void setNameFilter(const QString& filter);
const QString& nameFilter() const { return dir->nameFilter(); }
void setMimeFilter( const QStringList& mimetypes );
QStringList mimeFilter() const { return dir->mimeFilters(); }
void clearFilter();
KURL url() const;
// ### KDE4: make virtual
void setURL(const KURL& url, bool clearforward);
void setCurrentItem( const QString& filename );
// ### KDE4: make virtual
void setView(KFileView *view);
KFileView * view() const { return m_fileView; }
QWidget * viewWidget() const { return m_fileView ? m_fileView->widget() : 0L; }
// ### KDE4: make virtual
void setView(KFile::FileView view);
void setSorting( QDir::SortSpec );
QDir::SortSpec sorting() const { return mySorting; }
bool isRoot() const { return url().path() == QChar('/'); }
KDirLister *dirLister() const { return dir; }
KProgress * progressBar() const;
// ### KDE4: make virtual
void setMode( KFile::Mode m );
KFile::Mode mode() const;
// ### KDE4: make virtual
void setPreviewWidget(const QWidget *w);
const KFileItemList * selectedItems() const {
return ( m_fileView ? m_fileView->selectedItems() : 0L );
}
inline bool isSelected( const KFileItem *item ) const {
return ( m_fileView ? m_fileView->isSelected( item ) : false );
}
int numDirs() const;
int numFiles() const;
KCompletion * completionObject() const {
return const_cast<KCompletion *>( &myCompletion );
}
KCompletion *dirCompletionObject() const {
return const_cast<KCompletion *>( &myDirCompletion );
}
KActionCollection * actionCollection() const { return myActionCollection; }
// ### KDE4: make virtual
void setViewConfig( KConfig *config, const QString& group );
KConfig *viewConfig();
QString viewConfigGroup() const;
virtual void readConfig( KConfig *, const QString& group = QString::null );
virtual void writeConfig( KConfig *, const QString& group = QString::null );
void setOnlyDoubleClickSelectsFiles( bool enable );
bool onlyDoubleClickSelectsFiles() const;
// ### KDE4: make virtual and turn QString into KURL
bool mkdir( const QString& directory, bool enterDirectory = true );
// ### KDE4: make virtual
KIO::DeleteJob * del( const KFileItemList& items,
bool ask = true, bool showProgress = true );
// ### KDE4: make virtual
KIO::DeleteJob * del( const KFileItemList& items, QWidget *parent,
bool ask = true, bool showProgress = true );
void clearHistory();
// ### KDE4: make virtual
void setEnableDirHighlighting( bool enable );
bool dirHighlighting() const;
bool dirOnlyMode() const { return dirOnlyMode( myMode ); }
static bool dirOnlyMode( uint mode ) {
return ( (mode & KFile::Directory) &&
(mode & (KFile::File | KFile::Files)) == 0 );
}
void setupMenu(int whichActions);
virtual void setAcceptDrops(bool b);
// ### KDE4: make virtual
void setDropOptions(int options);
// ### KDE4: make virtual
KIO::CopyJob * trash( const KFileItemList& items, QWidget *parent,
bool ask = true, bool showProgress = true );
protected:
virtual KFileView* createView( QWidget* parent, KFile::FileView view );
// ### KDE4: make virtual
void setDirLister( KDirLister *lister );
virtual void resizeEvent( QResizeEvent * );
void setupActions();
void updateSortActions();
void updateViewActions();
void setupMenu();
void prepareCompletionObjects();
bool checkPreviewSupport();
public slots:
// ### KDE4: make virtual
void back();
// ### KDE4: make virtual
void forward();
// ### KDE4: make virtual
void home();
// ### KDE4: make virtual
void cdUp();
void updateDir();
// ### KDE4: make virtual
void rereadDir();
// ### KDE4: make virtual
void mkdir();
// ### KDE4: make virtual
void deleteSelected();
void updateSelectionDependentActions();
QString makeCompletion(const QString&);
QString makeDirCompletion(const QString&);
// ### KDE4: make virtual
void trashSelected(KAction::ActivationReason, Qt::ButtonState);
protected slots:
void resetCursor();
void pathChanged();
void insertNewFiles(const KFileItemList &newone);
void itemDeleted(KFileItem *);
// ### KDE4: make virtual
void selectDir(const KFileItem *item );
void selectFile(const KFileItem *item);
void highlightFile(const KFileItem* i) { emit fileHighlighted( i ); }
virtual void activatedMenu( const KFileItem *, const QPoint& pos );
void sortByName() { byNameAction->setChecked( true ); }
void sortBySize() { bySizeAction->setChecked( true ); }
void sortByDate() { byDateAction->setChecked( true ); }
void sortReversed() { reverseAction->setChecked( !reverseAction->isChecked() ); }
void toggleDirsFirst() { dirsFirstAction->setChecked( !dirsFirstAction->isChecked() ); }
void toggleIgnoreCase() { caseInsensitiveAction->setChecked( !caseInsensitiveAction->isChecked() ); }
void slotCompletionMatch(const QString& match);
signals:
void urlEntered(const KURL& );
void updateInformation(int files, int dirs);
void completion(const QString&);
void finishedLoading();
void viewChanged( KFileView * newView );
void fileHighlighted( const KFileItem *item );
void dirActivated( const KFileItem *item );
void fileSelected( const KFileItem *item );
void dropped(const KFileItem *item, QDropEvent*event, const KURL::List&urls);
private:
QPtrStack<KURL> backStack;
QPtrStack<KURL> forwardStack;
KDirLister *dir;
KURL currUrl;
KCompletion myCompletion;
KCompletion myDirCompletion;
bool myCompleteListDirty;
QDir::SortSpec mySorting;
bool checkPreviewInternal() const;
void checkPath(const QString& txt, bool takeFiles = false);
void connectView(KFileView *);
bool openURL( const KURL& url, bool keep = false, bool reload = false );
KFileView *m_fileView;
KFileItemList pendingMimeTypes;
// the enum KFile::FileView as an int
int m_viewKind;
int defaultView;
KFile::Mode myMode;
KProgress *progress;
const QWidget *myPreview; // temporary pointer for the preview widget
// actions for the popupmenus
// ### clean up all those -- we have them all in the actionMenu!
KActionMenu *actionMenu;
KAction *backAction;
KAction *forwardAction;
KAction *homeAction;
KAction *upAction;
KAction *reloadAction;
KActionSeparator *actionSeparator;
KAction *mkdirAction;
KActionMenu *sortActionMenu;
KRadioAction *byNameAction;
KRadioAction *byDateAction;
KRadioAction *bySizeAction;
KToggleAction *reverseAction;
KToggleAction *dirsFirstAction;
KToggleAction *caseInsensitiveAction;
KActionMenu *viewActionMenu;
KRadioAction *shortAction;
KRadioAction *detailedAction;
KToggleAction *showHiddenAction;
KToggleAction *separateDirsAction;
KActionCollection *myActionCollection;
KActionCollection *viewActionCollection;
private slots:
void slotDetailedView();
void slotSimpleView();
void slotToggleHidden( bool );
void slotSeparateDirs();
void slotDefaultPreview();
void togglePreview( bool );
void slotSortByName();
void slotSortBySize();
void slotSortByDate();
void slotSortReversed();
void slotToggleDirsFirst();
void slotToggleIgnoreCase();
void slotStarted();
void slotProgress( int );
void slotShowProgress();
void slotIOFinished();
void slotCanceled();
void slotRedirected( const KURL& );
void slotViewActionAdded( KAction * );
void slotViewActionRemoved( KAction * );
void slotViewSortingChanged( QDir::SortSpec );
void slotClearView();
void slotRefreshItems( const KFileItemList& items );
void slotProperties();
void insertViewDependentActions();
private:
static bool isReadable( const KURL& url );
protected:
virtual void virtual_hook( int id, void* data );
private:
class KDirOperatorPrivate;
KDirOperatorPrivate *d;
};
#endif
KDirOperator::dirLister
KDirLister * dirLister() const
Definition: kdiroperator.h:260
KDirOperator::ActionTypes
ActionTypes
The various action types.
Definition: kdiroperator.h:106
KDirOperator::sorting
QDir::SortSpec sorting() const
Definition: kdiroperator.h:250
KDirOperator::selectedItems
const KFileItemList * selectedItems() const
Definition: kdiroperator.h:298
KDirOperator::view
KFileView * view() const
Definition: kdiroperator.h:227
KDirOperator::sortBySize
void sortBySize()
Changes sorting to sort by size.
Definition: kdiroperator.h:769
KDirOperator::sortByName
void sortByName()
Changes sorting to sort by name.
Definition: kdiroperator.h:764
KDirOperator::nameFilter
const QString & nameFilter() const
Definition: kdiroperator.h:156
KFileView
This class defines an interface to all file views.
Definition: kfileview.h:98
KFile::Mode
Mode
Modes of operation for the dialog.
Definition: kfile.h:42
KDirOperator::showHiddenFiles
bool showHiddenFiles() const
Definition: kdiroperator.h:134
KDirOperator::toggleIgnoreCase
void toggleIgnoreCase()
Toggles case sensitive / case insensitive sorting.
Definition: kdiroperator.h:789
KDirOperator
This widget works as a network transparent filebrowser.
Definition: kdiroperator.h:97
KDirOperator::viewWidget
QWidget * viewWidget() const
Returns the widget of the current view.
Definition: kdiroperator.h:233
KDirOperator::actionCollection
KActionCollection * actionCollection() const
an accessor to a collection of all available Actions.
Definition: kdiroperator.h:390
KDirOperator::dirCompletionObject
KCompletion * dirCompletionObject() const
Definition: kdiroperator.h:341
KDirOperator::sortByDate
void sortByDate()
Changes sorting to sort by date.
Definition: kdiroperator.h:774
KDirOperator::isSelected
bool isSelected(const KFileItem *item) const
Definition: kdiroperator.h:305
KDirOperator::setShowHiddenFiles
void setShowHiddenFiles(bool s)
Enables/disables showing hidden files.
Definition: kdiroperator.h:129
KDirOperator::mimeFilter
QStringList mimeFilter() const
Definition: kdiroperator.h:180
KDirOperator::isRoot
bool isRoot() const
Definition: kdiroperator.h:255
KDirOperator::sortReversed
void sortReversed()
Changes sorting to reverse sorting.
Definition: kdiroperator.h:779
KDirOperator::dirOnlyMode
bool dirOnlyMode() const
Definition: kdiroperator.h:538
KDirOperator::close
virtual bool close(bool alsoDelete)
Reimplemented to avoid "hidden virtual" warnings.
Definition: kdiroperator.h:141
KDirOperator::highlightFile
void highlightFile(const KFileItem *i)
Emits fileHighlighted( i )
Definition: kdiroperator.h:754
KDirOperator::completionObject
KCompletion * completionObject() const
Definition: kdiroperator.h:329
KDirOperator::toggleDirsFirst
void toggleDirsFirst()
Toggles showing directories first / having them sorted like files.
Definition: kdiroperator.h:784

KDE Home | KDE Accessibility Home | Description of Access Keys