kio Library API Documentation

kdirlister.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1999 David Faure <faure@kde.org>
00003                  2001, 2002, 2004 Michael Brade <brade@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef kdirlister_h
00022 #define kdirlister_h
00023 
00024 #include "kfileitem.h"
00025 #include "kdirnotify.h"
00026 
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029 
00030 #include <kurl.h>
00031 
00032 namespace KIO { class Job; class ListJob; }
00033 
00054 class KIO_EXPORT KDirLister : public QObject
00055 {
00056   class KDirListerPrivate;
00057   friend class KDirListerPrivate;
00058   friend class KDirListerCache;
00059 
00060   Q_OBJECT
00061   Q_PROPERTY( bool autoUpdate READ autoUpdate WRITE setAutoUpdate )
00062   Q_PROPERTY( bool showingDotFiles READ showingDotFiles WRITE setShowingDotFiles )
00063   Q_PROPERTY( bool dirOnlyMode READ dirOnlyMode WRITE setDirOnlyMode )
00064   Q_PROPERTY( bool autoErrorHandlingEnabled READ autoErrorHandlingEnabled )
00065   Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
00066   Q_PROPERTY( QStringList mimeFilter READ mimeFilters WRITE setMimeFilter RESET clearMimeFilter )
00067 
00068 public:
00074   KDirLister( bool _delayedMimeTypes = false );
00075 
00079   virtual ~KDirLister();
00080 
00104   virtual bool openURL( const KURL& _url, bool _keep = false, bool _reload = false );
00105 
00113   virtual void stop();
00114 
00124   virtual void stop( const KURL& _url );
00125 
00131   bool autoUpdate() const;
00132 
00138   virtual void setAutoUpdate( bool enable );
00139 
00147   bool autoErrorHandlingEnabled() const;
00148 
00158   void setAutoErrorHandlingEnabled( bool enable, QWidget *parent );
00159 
00167   bool showingDotFiles() const;
00168 
00177   virtual void setShowingDotFiles( bool _showDotFiles );
00178 
00185   bool dirOnlyMode() const;
00186 
00192   virtual void setDirOnlyMode( bool dirsOnly );
00193 
00202   const KURL& url() const;
00203 
00213   const KURL::List& directories() const;
00214 
00219   virtual void emitChanges();
00220 
00232   virtual void updateDirectory( const KURL& _dir );
00233 
00238   bool isFinished() const;
00239 
00244   KFileItem *rootItem() const;
00245 
00251   virtual KFileItem *findByURL( const KURL& _url ) const;
00252 #ifndef KDE_NO_COMPAT
00253   KFileItem *find( const KURL& _url ) const;
00254 #endif
00255 
00261   virtual KFileItem *findByName( const QString& name ) const;
00262 
00273   virtual void setNameFilter( const QString &filter );
00274 
00280   const QString& nameFilter() const;
00281 
00293   virtual void setMimeFilter( const QStringList &mimeList );
00294 
00310   void setMimeExcludeFilter(const QStringList &mimeList );
00311 
00312 
00318   virtual void clearMimeFilter();
00319 
00324   const QStringList& mimeFilters() const;
00325 
00332   bool matchesFilter( const QString& name ) const;
00333 
00341   bool matchesMimeFilter( const QString& mime ) const;
00342 
00349   void setMainWindow( QWidget *window );
00350 
00356   QWidget *mainWindow();
00357 
00362   enum WhichItems
00363   {
00364       AllItems = 0,
00365       FilteredItems = 1
00366   };
00367 
00385   KFileItemList items( WhichItems which = FilteredItems ) const;
00386 
00407   KFileItemList itemsForDir( const KURL& dir,
00408                              WhichItems which = FilteredItems ) const;
00409 
00410 signals:
00420   void started( const KURL& _url );
00421 
00425   void completed();
00426 
00433   void completed( const KURL& _url );
00434 
00438   void canceled();
00439 
00446   void canceled( const KURL& _url );
00447 
00454   void redirection( const KURL& _url );
00455 
00461   void redirection( const KURL& oldUrl, const KURL& newUrl );
00462 
00467   void clear();
00468 
00474   void clear( const KURL& _url );
00475 
00480   void newItems( const KFileItemList& items );
00481 
00486   void itemsFilteredByMime( const KFileItemList& items );
00487 
00497   void deleteItem( KFileItem *_fileItem );
00498 
00504   void refreshItems( const KFileItemList& items );
00505 
00511   void infoMessage( const QString& msg );
00512 
00518   void percent( int percent );
00519 
00524   void totalSize( KIO::filesize_t size );
00525 
00530   void processedSize( KIO::filesize_t size );
00531 
00536   void speed( int bytes_per_second );
00537 
00538 protected:
00539   enum Changes {
00540     NONE=0, NAME_FILTER=1, MIME_FILTER=2, DOT_FILES=4, DIR_ONLY_MODE=8
00541   };
00542 
00555   virtual bool matchesFilter( const KFileItem * ) const;
00556 
00569   virtual bool matchesMimeFilter( const KFileItem * ) const;
00570 
00578   virtual bool doNameFilter( const QString& name, const QPtrList<QRegExp>& filters ) const;
00579 
00587   virtual bool doMimeFilter( const QString& mime, const QStringList& filters ) const;
00588 
00592   bool doMimeExcludeFilter( const QString& mimeExclude, const QStringList& filters ) const;
00593 
00599   virtual bool validURL( const KURL& ) const;
00600 
00602   virtual void handleError( KIO::Job * );
00603 
00604 protected:
00605   virtual void virtual_hook( int id, void *data );
00606 
00607 private slots:
00608   void slotInfoMessage( KIO::Job *, const QString& );
00609   void slotPercent( KIO::Job *, unsigned long );
00610   void slotTotalSize( KIO::Job *, KIO::filesize_t );
00611   void slotProcessedSize( KIO::Job *, KIO::filesize_t );
00612   void slotSpeed( KIO::Job *, unsigned long );
00613 
00614 private:
00615   void jobDone( KIO::ListJob * );
00616   void jobStarted( KIO::ListJob * );
00617   uint numJobs();
00618 
00619 private:
00620   virtual void addNewItem( const KFileItem *item );
00621   virtual void addNewItems( const KFileItemList& items );
00622   /*virtual*/ void aboutToRefreshItem( const KFileItem *item );  // TODO: KDE 4.0 make virtual
00623   virtual void addRefreshItem( const KFileItem *item );
00624   virtual void emitItems();
00625   virtual void emitDeleteItem( KFileItem *item );
00626 
00627   KDirListerPrivate *d;
00628 };
00629 
00630 #endif
00631 
KDE Logo
This file is part of the documentation for kio Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jul 21 13:14:25 2006 by doxygen 1.4.0 written by Dimitri van Heesch, © 1997-2003