KIO
kdirlister.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 1999 David Faure <faure@kde.org> 00003 2001, 2002, 2004-2006 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., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef kdirlister_h 00022 #define kdirlister_h 00023 00024 #include "kfileitem.h" 00025 #include "kdirnotify.h" 00026 00027 #include <QtCore/QString> 00028 #include <QtCore/QStringList> 00029 00030 #include <kurl.h> 00031 00032 class KJob; 00033 namespace KIO { class Job; class ListJob; } 00034 00057 class KIO_EXPORT KDirLister : public QObject 00058 { 00059 friend class KDirListerCache; 00060 friend struct KDirListerCacheDirectoryData; 00061 00062 Q_OBJECT 00063 Q_PROPERTY( bool autoUpdate READ autoUpdate WRITE setAutoUpdate ) 00064 Q_PROPERTY( bool showingDotFiles READ showingDotFiles WRITE setShowingDotFiles ) 00065 Q_PROPERTY( bool dirOnlyMode READ dirOnlyMode WRITE setDirOnlyMode ) 00066 Q_PROPERTY( bool autoErrorHandlingEnabled READ autoErrorHandlingEnabled ) 00067 Q_PROPERTY( bool delayedMimeTypes READ delayedMimeTypes WRITE setDelayedMimeTypes ) 00068 Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter ) 00069 Q_PROPERTY( QStringList mimeFilter READ mimeFilters WRITE setMimeFilter RESET clearMimeFilter ) 00070 00071 public: 00072 enum OpenUrlFlag 00073 { 00074 NoFlags = 0x0, 00075 00076 Keep = 0x1, 00077 00078 00079 00080 00081 Reload = 0x2 00082 00083 00084 00085 }; 00086 00087 Q_DECLARE_FLAGS(OpenUrlFlags, OpenUrlFlag) 00088 00089 00092 KDirLister( QObject* parent = 0 ); 00093 00097 virtual ~KDirLister(); 00098 00115 virtual bool openUrl( const KUrl& _url, OpenUrlFlags _flags = NoFlags ); 00116 00124 virtual void stop(); 00125 00135 virtual void stop( const KUrl& _url ); 00136 00141 bool delayedMimeTypes() const; 00142 00151 void setDelayedMimeTypes( bool delayedMimeTypes ); 00152 00153 00159 bool autoUpdate() const; 00160 00166 virtual void setAutoUpdate( bool enable ); 00167 00175 bool autoErrorHandlingEnabled() const; 00176 00186 void setAutoErrorHandlingEnabled( bool enable, QWidget *parent ); 00187 00195 bool showingDotFiles() const; 00196 00205 virtual void setShowingDotFiles( bool _showDotFiles ); 00206 00213 bool dirOnlyMode() const; 00214 00221 virtual void setDirOnlyMode( bool dirsOnly ); 00222 00231 KUrl url() const; 00232 00241 KUrl::List directories() const; 00242 00247 virtual void emitChanges(); 00248 00260 virtual void updateDirectory( const KUrl& _dir ); 00261 00266 bool isFinished() const; 00267 00274 KFileItem rootItem() const; 00275 00281 virtual KFileItem findByUrl( const KUrl& _url ) const; 00282 00288 virtual KFileItem findByName( const QString& name ) const; 00289 00301 virtual void setNameFilter( const QString &filter ); 00302 00308 QString nameFilter() const; 00309 00323 virtual void setMimeFilter( const QStringList &mimeList ); 00324 00339 void setMimeExcludeFilter(const QStringList &mimeList ); 00340 00341 00349 virtual void clearMimeFilter(); 00350 00355 QStringList mimeFilters() const; 00356 00363 bool matchesFilter( const QString& name ) const; 00364 00372 bool matchesMimeFilter( const QString& mime ) const; 00373 00379 void setMainWindow( QWidget *window ); 00380 00385 QWidget *mainWindow(); 00386 00391 enum WhichItems 00392 { 00393 AllItems = 0, 00394 FilteredItems = 1 00395 }; 00396 00413 KFileItemList items( WhichItems which = FilteredItems ) const; 00414 00434 KFileItemList itemsForDir( const KUrl& dir, 00435 WhichItems which = FilteredItems ) const; 00436 00447 static KFileItem cachedItemForUrl(const KUrl& url); 00448 00449 Q_SIGNALS: 00450 00460 void started( const KUrl& _url ); 00461 00465 void completed(); 00466 00472 void completed( const KUrl& _url ); 00473 00477 void canceled(); 00478 00484 void canceled( const KUrl& _url ); 00485 00492 void redirection( const KUrl& _url ); 00493 00499 void redirection( const KUrl& oldUrl, const KUrl& newUrl ); 00500 00505 void clear(); 00506 00512 void clear( const KUrl& _url ); 00513 00519 void newItems( const KFileItemList& items ); 00520 00529 void itemsAdded(const KUrl& directoryUrl, const KFileItemList& items); 00530 00535 void itemsFilteredByMime( const KFileItemList& items ); 00536 00544 void deleteItem( const KFileItem &_fileItem ); // KDE5: remove, and port to itemsDeleted 00545 00554 void itemsDeleted( const KFileItemList& items ); 00555 00564 void refreshItems( const QList<QPair<KFileItem, KFileItem> >& items ); 00565 00571 void infoMessage( const QString& msg ); 00572 00578 void percent( int percent ); 00579 00584 void totalSize( KIO::filesize_t size ); 00585 00590 void processedSize( KIO::filesize_t size ); 00591 00596 void speed( int bytes_per_second ); 00597 00598 protected: 00600 enum Changes { NONE=0, NAME_FILTER=1, MIME_FILTER=2, DOT_FILES=4, DIR_ONLY_MODE=8 }; 00601 00614 virtual bool matchesFilter( const KFileItem& ) const; 00615 00628 virtual bool matchesMimeFilter( const KFileItem& ) const; 00629 00637 virtual bool doNameFilter( const QString& name, const QList<QRegExp>& filters ) const; 00638 00646 virtual bool doMimeFilter( const QString& mime, const QStringList& filters ) const; 00647 00649 virtual void handleError( KIO::Job * ); 00650 00651 private: 00652 class Private; 00653 Private* const d; 00654 friend class Private; 00655 00656 Q_PRIVATE_SLOT( d, void _k_slotInfoMessage( KJob*, const QString& ) ) 00657 Q_PRIVATE_SLOT( d, void _k_slotPercent( KJob*, unsigned long ) ) 00658 Q_PRIVATE_SLOT( d, void _k_slotTotalSize( KJob*, qulonglong ) ) 00659 Q_PRIVATE_SLOT( d, void _k_slotProcessedSize( KJob*, qulonglong ) ) 00660 Q_PRIVATE_SLOT( d, void _k_slotSpeed( KJob*, unsigned long ) ) 00661 }; 00662 00663 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirLister::OpenUrlFlags) 00664 00665 #endif 00666
KDE 4.6 API Reference