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 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 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 public:
00071   KDirLister( bool _delayedMimeTypes = false );
00072 
00076   virtual ~KDirLister();
00077 
00099   virtual bool openURL( const KURL& _url, bool _keep = false, bool _reload = false );
00100 
00108   virtual void stop();
00109 
00119   virtual void stop( const KURL& _url );
00120 
00125   bool autoUpdate() const;
00126 
00131   virtual void setAutoUpdate( bool enable );
00132 
00136   bool autoErrorHandlingEnabled() const;
00137   void setAutoErrorHandlingEnabled( bool enable, QWidget* parent );
00138 
00142   bool showingDotFiles() const;
00143 
00148   virtual void setShowingDotFiles( bool _showDotFiles );
00149 
00153   bool dirOnlyMode() const;
00154 
00158   virtual void setDirOnlyMode( bool dirsOnly );
00159 
00166   const KURL& url() const;
00167 
00172   virtual void emitChanges();
00173 
00185   virtual void updateDirectory( const KURL& _dir );
00186 
00190   bool isFinished() const;
00191 
00195   KFileItem* rootItem() const;
00196 
00202   virtual KFileItem* findByURL( const KURL& _url ) const;
00203 #ifndef KDE_NO_COMPAT
00204   KFileItem* find( const KURL& _url ) const;
00205 #endif
00206 
00212   virtual KFileItem* findByName( const QString& name ) const;
00213 
00224   virtual void setNameFilter( const QString& );
00225 
00229   const QString& nameFilter() const;
00230 
00242   virtual void setMimeFilter( const QStringList& );
00243 
00260   void setMimeExcludeFilter(const QStringList &);
00261 
00262 
00268   virtual void clearMimeFilter();
00269 
00274   const QStringList& mimeFilters() const;
00275 
00281   bool matchesFilter( const QString& name ) const;
00282 
00290   bool matchesMimeFilter( const QString& mime ) const;
00291 
00297   void setMainWindow(QWidget *window);
00298 
00303   QWidget *mainWindow();
00304 
00309   enum WhichItems
00310   {
00311       AllItems = 0,
00312       FilteredItems = 1
00313   };
00314 
00333   KFileItemList items( WhichItems which = FilteredItems ) const;
00334 
00355   KFileItemList itemsForDir( const KURL& dir,
00356                              WhichItems which = FilteredItems ) const;
00357 
00358 signals:
00367   void started( const KURL& _url );
00368 
00372   void completed();
00373 
00380   void completed( const KURL& _url );
00381 
00385   void canceled();
00386 
00393   void canceled( const KURL& _url );
00394 
00400   void redirection( const KURL& _url );
00401 
00405   void redirection( const KURL& oldUrl, const KURL& newUrl );
00406 
00411   void clear();
00412 
00417   void clear( const KURL& _url );
00418 
00422   void newItems( const KFileItemList& items );
00423 
00427   void itemsFilteredByMime( const KFileItemList& items );
00428 
00437   void deleteItem( KFileItem *_fileItem );
00438 
00443   void refreshItems( const KFileItemList& items );
00444 
00449   void infoMessage( const QString& msg );
00450 
00455   void percent( int percent );
00456 
00460   void totalSize( KIO::filesize_t size );
00461 
00465   void processedSize( KIO::filesize_t size );
00466 
00470   void speed( int bytes_per_second );
00471 
00472 protected:
00473   enum Changes {
00474     NONE=0, NAME_FILTER=1, MIME_FILTER=2, DOT_FILES=4, DIR_ONLY_MODE=8
00475   };
00476 
00489   virtual bool matchesFilter( const KFileItem * ) const;
00490 
00491   virtual bool matchesMimeFilter( const KFileItem * ) const;
00492 
00498   virtual bool doNameFilter( const QString& name, const QPtrList<QRegExp>& filters ) const;
00499   virtual bool doMimeFilter( const QString& mime, const QStringList& filters ) const;
00503   bool doMimeExcludeFilter( const QString& mimeExclude, const QStringList& filters ) const;
00504 
00510   virtual bool validURL( const KURL& ) const;
00511 
00513   virtual void handleError( KIO::Job* );
00514 
00515 protected:
00516   virtual void virtual_hook( int id, void* data );
00517 
00518 private slots:
00519   void slotInfoMessage( KIO::Job *, const QString& );
00520   void slotPercent( KIO::Job *, unsigned long );
00521   void slotTotalSize( KIO::Job *, KIO::filesize_t );
00522   void slotProcessedSize( KIO::Job *, KIO::filesize_t );
00523   void slotSpeed( KIO::Job *, unsigned long );
00524 
00525   void slotJobToBeKilled( const KURL& );
00526   void slotClearState();
00527 
00528 private:
00529   virtual void addNewItem( const KFileItem *item );
00530   virtual void addNewItems( const KFileItemList& items );
00531   virtual void addRefreshItem( const KFileItem *item );
00532   virtual void emitItems();
00533   virtual void emitDeleteItem( KFileItem *item );
00534 
00535   KDirListerPrivate *d;
00536 };
00537 
00538 #endif
00539 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:28 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001