kio
kdirlister.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00055 class KIO_EXPORT KDirLister : public QObject
00056 {
00057 class KDirListerPrivate;
00058 friend class KDirListerPrivate;
00059 friend class KDirListerCache;
00060
00061 Q_OBJECT
00062 Q_PROPERTY( bool autoUpdate READ autoUpdate WRITE setAutoUpdate )
00063 Q_PROPERTY( bool showingDotFiles READ showingDotFiles WRITE setShowingDotFiles )
00064 Q_PROPERTY( bool dirOnlyMode READ dirOnlyMode WRITE setDirOnlyMode )
00065 Q_PROPERTY( bool autoErrorHandlingEnabled READ autoErrorHandlingEnabled )
00066 Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
00067 Q_PROPERTY( QStringList mimeFilter READ mimeFilters WRITE setMimeFilter RESET clearMimeFilter )
00068
00069 public:
00075 KDirLister( bool _delayedMimeTypes = false );
00076
00080 virtual ~KDirLister();
00081
00105 virtual bool openURL( const KURL& _url, bool _keep = false, bool _reload = false );
00106
00114 virtual void stop();
00115
00125 virtual void stop( const KURL& _url );
00126
00132 bool autoUpdate() const;
00133
00139 virtual void setAutoUpdate( bool enable );
00140
00148 bool autoErrorHandlingEnabled() const;
00149
00159 void setAutoErrorHandlingEnabled( bool enable, QWidget *parent );
00160
00168 bool showingDotFiles() const;
00169
00178 virtual void setShowingDotFiles( bool _showDotFiles );
00179
00186 bool dirOnlyMode() const;
00187
00193 virtual void setDirOnlyMode( bool dirsOnly );
00194
00203 const KURL& url() const;
00204
00214 const KURL::List& directories() const;
00215
00220 virtual void emitChanges();
00221
00233 virtual void updateDirectory( const KURL& _dir );
00234
00239 bool isFinished() const;
00240
00245 KFileItem *rootItem() const;
00246
00252 virtual KFileItem *findByURL( const KURL& _url ) const;
00253 #ifndef KDE_NO_COMPAT
00254 KFileItem *find( const KURL& _url ) const;
00255 #endif
00256
00262 virtual KFileItem *findByName( const QString& name ) const;
00263
00274 virtual void setNameFilter( const QString &filter );
00275
00281 const QString& nameFilter() const;
00282
00294 virtual void setMimeFilter( const QStringList &mimeList );
00295
00311 void setMimeExcludeFilter(const QStringList &mimeList );
00312
00313
00319 virtual void clearMimeFilter();
00320
00325 const QStringList& mimeFilters() const;
00326
00333 bool matchesFilter( const QString& name ) const;
00334
00342 bool matchesMimeFilter( const QString& mime ) const;
00343
00350 void setMainWindow( QWidget *window );
00351
00357 QWidget *mainWindow();
00358
00363 enum WhichItems
00364 {
00365 AllItems = 0,
00366 FilteredItems = 1
00367 };
00368
00386 KFileItemList items( WhichItems which = FilteredItems ) const;
00387
00408 KFileItemList itemsForDir( const KURL& dir,
00409 WhichItems which = FilteredItems ) const;
00410
00411 signals:
00421 void started( const KURL& _url );
00422
00426 void completed();
00427
00433 void completed( const KURL& _url );
00434
00438 void canceled();
00439
00445 void canceled( const KURL& _url );
00446
00453 void redirection( const KURL& _url );
00454
00460 void redirection( const KURL& oldUrl, const KURL& newUrl );
00461
00466 void clear();
00467
00473 void clear( const KURL& _url );
00474
00479 void newItems( const KFileItemList& items );
00480
00485 void itemsFilteredByMime( const KFileItemList& items );
00486
00496 void deleteItem( KFileItem *_fileItem );
00497
00503 void refreshItems( const KFileItemList& items );
00504
00510 void infoMessage( const QString& msg );
00511
00517 void percent( int percent );
00518
00523 void totalSize( KIO::filesize_t size );
00524
00529 void processedSize( KIO::filesize_t size );
00530
00535 void speed( int bytes_per_second );
00536
00537 protected:
00538 enum Changes {
00539 NONE=0, NAME_FILTER=1, MIME_FILTER=2, DOT_FILES=4, DIR_ONLY_MODE=8
00540 };
00541
00554 virtual bool matchesFilter( const KFileItem * ) const;
00555
00568 virtual bool matchesMimeFilter( const KFileItem * ) const;
00569
00577 virtual bool doNameFilter( const QString& name, const QPtrList<QRegExp>& filters ) const;
00578
00586 virtual bool doMimeFilter( const QString& mime, const QStringList& filters ) const;
00587
00591 bool doMimeExcludeFilter( const QString& mimeExclude, const QStringList& filters ) const;
00592
00598 virtual bool validURL( const KURL& ) const;
00599
00601 virtual void handleError( KIO::Job * );
00602
00603 protected:
00604 virtual void virtual_hook( int id, void *data );
00605
00606 private slots:
00607 void slotInfoMessage( KIO::Job *, const QString& );
00608 void slotPercent( KIO::Job *, unsigned long );
00609 void slotTotalSize( KIO::Job *, KIO::filesize_t );
00610 void slotProcessedSize( KIO::Job *, KIO::filesize_t );
00611 void slotSpeed( KIO::Job *, unsigned long );
00612
00613 private:
00614 void jobStarted( KIO::ListJob * );
00615 void connectJob( KIO::ListJob * );
00616 void jobDone( KIO::ListJob * );
00617
00618 uint numJobs();
00619
00620 private:
00621 virtual void addNewItem( const KFileItem *item );
00622 virtual void addNewItems( const KFileItemList& items );
00623 void aboutToRefreshItem( const KFileItem *item );
00624 virtual void addRefreshItem( const KFileItem *item );
00625 virtual void emitItems();
00626 virtual void emitDeleteItem( KFileItem *item );
00627
00628 KDirListerPrivate *d;
00629 };
00630
00631 #endif
00632