kdirlister.h
/* This file is part of the KDE project
Copyright (C) 1999 David Faure <faure@kde.org>
2001, 2002, 2004, 2005 Michael Brade <brade@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 kdirlister_h
#define kdirlister_h
#include "kfileitem.h"
#include "kdirnotify.h"
#include <qstring.h>
#include <qstringlist.h>
#include <kurl.h>
namespace KIO { class Job; class ListJob; }
class KIO_EXPORT KDirLister : public QObject
{
class KDirListerPrivate;
friend class KDirListerPrivate;
friend class KDirListerCache;
Q_OBJECT
Q_PROPERTY( bool autoUpdate READ autoUpdate WRITE setAutoUpdate )
Q_PROPERTY( bool showingDotFiles READ showingDotFiles WRITE setShowingDotFiles )
Q_PROPERTY( bool dirOnlyMode READ dirOnlyMode WRITE setDirOnlyMode )
Q_PROPERTY( bool autoErrorHandlingEnabled READ autoErrorHandlingEnabled )
Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
Q_PROPERTY( QStringList mimeFilter READ mimeFilters WRITE setMimeFilter RESET clearMimeFilter )
public:
KDirLister( bool _delayedMimeTypes = false );
virtual ~KDirLister();
virtual bool openURL( const KURL& _url, bool _keep = false, bool _reload = false );
virtual void stop();
virtual void stop( const KURL& _url );
bool autoUpdate() const;
virtual void setAutoUpdate( bool enable );
bool autoErrorHandlingEnabled() const;
void setAutoErrorHandlingEnabled( bool enable, QWidget *parent );
bool showingDotFiles() const;
virtual void setShowingDotFiles( bool _showDotFiles );
bool dirOnlyMode() const;
virtual void setDirOnlyMode( bool dirsOnly );
const KURL& url() const;
const KURL::List& directories() const;
virtual void emitChanges();
virtual void updateDirectory( const KURL& _dir );
bool isFinished() const;
KFileItem *rootItem() const;
virtual KFileItem *findByURL( const KURL& _url ) const;
#ifndef KDE_NO_COMPAT
KFileItem *find( const KURL& _url ) const;
#endif
virtual KFileItem *findByName( const QString& name ) const;
virtual void setNameFilter( const QString &filter );
const QString& nameFilter() const;
virtual void setMimeFilter( const QStringList &mimeList );
void setMimeExcludeFilter(const QStringList &mimeList );
virtual void clearMimeFilter();
const QStringList& mimeFilters() const;
bool matchesFilter( const QString& name ) const;
bool matchesMimeFilter( const QString& mime ) const;
void setMainWindow( QWidget *window );
QWidget *mainWindow();
enum WhichItems
{
AllItems = 0,
FilteredItems = 1
};
KFileItemList items( WhichItems which = FilteredItems ) const;
KFileItemList itemsForDir( const KURL& dir,
WhichItems which = FilteredItems ) const;
signals:
void started( const KURL& _url );
void completed();
void completed( const KURL& _url );
void canceled();
void canceled( const KURL& _url );
void redirection( const KURL& _url );
void redirection( const KURL& oldUrl, const KURL& newUrl );
void clear();
void clear( const KURL& _url );
void newItems( const KFileItemList& items );
void itemsFilteredByMime( const KFileItemList& items );
void deleteItem( KFileItem *_fileItem );
void refreshItems( const KFileItemList& items );
void infoMessage( const QString& msg );
void percent( int percent );
void totalSize( KIO::filesize_t size );
void processedSize( KIO::filesize_t size );
void speed( int bytes_per_second );
protected:
enum Changes {
NONE=0, NAME_FILTER=1, MIME_FILTER=2, DOT_FILES=4, DIR_ONLY_MODE=8
};
virtual bool matchesFilter( const KFileItem * ) const;
virtual bool matchesMimeFilter( const KFileItem * ) const;
virtual bool doNameFilter( const QString& name, const QPtrList<QRegExp>& filters ) const;
virtual bool doMimeFilter( const QString& mime, const QStringList& filters ) const;
bool doMimeExcludeFilter( const QString& mimeExclude, const QStringList& filters ) const;
virtual bool validURL( const KURL& ) const;
virtual void handleError( KIO::Job * );
protected:
virtual void virtual_hook( int id, void *data );
private slots:
void slotInfoMessage( KIO::Job *, const QString& );
void slotPercent( KIO::Job *, unsigned long );
void slotTotalSize( KIO::Job *, KIO::filesize_t );
void slotProcessedSize( KIO::Job *, KIO::filesize_t );
void slotSpeed( KIO::Job *, unsigned long );
private:
void jobStarted( KIO::ListJob * );
void connectJob( KIO::ListJob * );
void jobDone( KIO::ListJob * );
uint numJobs();
private:
virtual void addNewItem( const KFileItem *item );
virtual void addNewItems( const KFileItemList& items );
/*virtual*/ void aboutToRefreshItem( const KFileItem *item ); // TODO: KDE 4.0 make virtual
virtual void addRefreshItem( const KFileItem *item );
virtual void emitItems();
virtual void emitDeleteItem( KFileItem *item );
KDirListerPrivate *d;
};
#endif
KIO::ListJob
A ListJob is allows you to get the get the content of a directory.
Definition: jobclasses.h:1392
KIO::filesize_t
Q_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KDirLister::WhichItems
WhichItems
Used by items() and itemsForDir() to specify whether you want all items for a directory or just the f...
Definition: kdirlister.h:363
KIO::Job
The base class for all jobs.
Definition: jobclasses.h:68
KDirLister
The dir lister deals with the kiojob used to list and update a directory and has signals for the user...
Definition: kdirlister.h:55
KFileItem
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:41

KDE Home | KDE Accessibility Home | Description of Access Keys