KIO
kdirlister.cpp
Go to the documentation of this file.
64 kdirnotify = new org::kde::KDirNotify(QString(), QString(), QDBusConnection::sessionBus(), this);
65 connect(kdirnotify, SIGNAL(FileRenamed(QString,QString)), SLOT(slotFileRenamed(QString,QString)));
70 // The use of KUrl::url() in ~DirItem (sendSignal) crashes if the static for QRegExpEngine got deleted already,
242 kDebug(7004) << "Entry currently being listed:" << _url << "by" << dirData.listersCurrentlyListing;
264 KDirLister::Private::CachedItemsJob *cachedItemsJob = new KDirLister::Private::CachedItemsJob(lister, _url, _reload);
268 // ### If it finishes before the CachedItemsJob, then we'll emit cached items after completed(), not sure how bad this is.
281 KDirLister::Private::CachedItemsJob* KDirLister::Private::cachedItemsJobForUrl(const KUrl& url) const
290 KDirLister::Private::CachedItemsJob::CachedItemsJob(KDirLister* lister, const KUrl& url, bool reload)
325 void KDirListerCache::emitItemsFromCache(KDirLister::Private::CachedItemsJob* cachedItemsJob, KDirLister* lister, const KUrl& _url, bool _reload, bool _emitCompleted)
367 void KDirListerCache::forgetCachedItemsJob(KDirLister::Private::CachedItemsJob* cachedItemsJob, KDirLister* lister, const KUrl& _url)
385 //kDebug(7004) << "Still having a listjob" << listJob << ", so not moving to currently-holding.";
486 // So, change of plan, let's kill it after all, in a way that triggers slotResult/slotUpdateResult.
544 // noauto -> manually mounted. Otherwise, mounted at boot time, won't be unmounted any time soon hopefully.
602 // 2) [**] becomes: if (Drive is hotpluggable or Volume is removable) "set to dirty" else "keep watch"
603 const KMountPoint::List possibleMountPoints = KMountPoint::possibleMountPoints(KMountPoint::NeedMountOptions);
872 void KDirListerCache::slotFilesRemoved( const QStringList &fileList ) // from KDirNotify signals
901 for (KFileItemList::iterator fit = dirItem->lstItems.begin(), fend = dirItem->lstItems.end(); fit != fend ; ++fit) {
905 // If we found a fileitem, we can test if it's a dir. If not, we'll go to deleteDir just in case.
932 void KDirListerCache::slotFilesChanged( const QStringList &fileList ) // from KDirNotify signals
966 void KDirListerCache::slotFileRenamed( const QString &_src, const QString &_dst ) // from KDirNotify signals
1005 // #172945 - if the fileitem was the root item of a DirItem that was just removed from the cache,
1013 if (!oldItem.isLocalFile() && !oldItem.localPath().isEmpty()) { // it uses UDS_LOCAL_PATH? ouch, needs an update then
1033 QSet<KDirLister*> KDirListerCache::emitRefreshItem(const KFileItem& oldItem, const KFileItem& fileitem)
1073 dirs << canonicalUrls.value(dir).toSet().toList(); /* make unique; there are faster ways, but this is really small anyway */
1195 kError(7004) << "Internal error: job is listing" << url << "but itemsInUse only knows about" << itemsInUse.keys();
1202 kError(7004) << "Internal error: job is listing" << url << "but directoryData doesn't know about that url, only about:" << directoryData.keys();
1208 kError(7004) << "Internal error: job is listing" << url << "but directoryData says no listers are currently listing " << urlStr;
1276 jobUrl.adjustPath(KUrl::RemoveTrailingSlash); // need remove trailing slashes again, in case of redirections
1422 // only in this case there can newUrl already be in listersCurrentlyListing or listersCurrentlyHolding
1474 // emit old items: listers, holders. NOT: newUrlListers/newUrlHolders, they already have them listed
1674 const QList<QString> cachedDirs = itemsCached.keys(); // seems slow, but there's no qcache iterator...
1692 jobUrl.adjustPath(KUrl::RemoveTrailingSlash); // need remove trailing slashes again, in case of redirections
1753 for ( KFileItemList::iterator kit = dir->lstItems.begin(), kend = dir->lstItems.end() ; kit != kend ; ++kit )
1878 void KDirListerCache::deleteUnmarkedItems( const QList<KDirLister *>& listers, KFileItemList &lstItems )
1895 void KDirListerCache::itemsDeleted(const QList<KDirLister *>& listers, const KFileItemList& deletedItems)
2022 kDebug(7004) << " " << dit.key() << (*dit).listersCurrentlyListing.count() << "listers:" << list;
2036 kDebug(7004) << " " << dit.key() << (*dit).listersCurrentlyHolding.count() << "holders:" << list;
2042 kDebug(7004) << " " << jit.key() << "listing" << joburl( jit.key() ) << ":" << (*jit).count() << "entries.";
2299 if (mimeFilter.contains(QLatin1String("application/octet-stream")) || mimeFilter.contains(QLatin1String("all/allfiles"))) // all files
2393 bool KDirLister::Private::doMimeExcludeFilter( const QString& mime, const QStringList& filters ) const
2447 // Of course if there is no filter and we can do a range-insertion instead of a loop, that might be good.
2454 void KDirLister::Private::addRefreshItem(const KUrl& directoryUrl, const KFileItem& oldItem, const KFileItem& item)
2783 //kDebug(7004) << "Not moving" << kdl << "to listersCurrentlyHolding because it still has job" << kdl->d->m_cachedItemsJobs;
virtual void setWindow(QWidget *window)
Associate this job with a window given by window.
Definition: jobuidelegate.cpp:58
An alternative URL (If different from the caption).
Definition: udsentry.h:190
void slotFilesRemoved(const QStringList &fileList)
Notify that files have been deleted.
Definition: kdirlister.cpp:872
QString i18n(const char *text)
bool kill(KillVerbosity verbosity=Quietly)
void clear()
void percent(int percent)
Progress signal showing the overall progress of the KDirLister.
void adjustPath(AdjustPathOption trailing)
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QT_MOC_COMPAT void deleteItem(const KFileItem &_fileItem)
Signals that an item has been deleted.
Definition: kdirlister_p.h:448
void clear()
iterator insert(const Key &key, const T &value)
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
KMimeType::Ptr determineMimeType() const
Returns the mimetype of the file item.
Definition: kfileitem.cpp:779
static KDirWatch * self()
iterator remove(iterator pos)
virtual void setShowingDotFiles(bool _showDotFiles)
Changes the "is viewing dot files" setting.
Definition: kdirlister.cpp:2128
virtual KFileItem findByName(const QString &name) const
Find an item by its name.
Definition: kdirlister.cpp:2265
bool matchesMimeFilter(const QString &mime) const
Checks whether mime matches a filter in the list of mime types.
Definition: kdirlister.cpp:2332
const Key key(const T &value) const
void _k_slotInfoMessage(KJob *, const QString &)
Definition: kdirlister.cpp:2563
virtual void setAutoUpdate(bool enable)
Enable/disable automatic directory updating, when a directory changes (using KDirWatch).
Definition: kdirlister.cpp:2114
KUrl::List directories() const
Returns all URLs that are listed by this KDirLister.
Definition: kdirlister.cpp:2167
const Key & key() const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
int timeout
A ListJob is allows you to get the get the content of a directory.
Definition: jobclasses.h:936
bool hasNext() const
bool delayedMimeTypes() const
#define K_GLOBAL_STATIC(TYPE, NAME)
virtual void handleError(KIO::Job *)
Reimplement to customize error handling.
Definition: kdirlister.cpp:2406
const_iterator constBegin() const
Definition: netaccess.h:36
Previous directories aren't forgotten (they are still watched by kdirwatch and their items are kept f...
Definition: kdirlister.h:76
void refresh()
Throw away and re-read (for local files) all information about the file.
Definition: kfileitem.cpp:512
QString host() const
void cleanPath(const CleanPathOption &options=SimplifyDirSeparators)
KStandardDirs * dirs()
bool contains(const QString &str, Qt::CaseSensitivity cs) const
int stat(const QString &path, KDE_struct_stat *buf)
virtual bool openUrl(const KUrl &_url, OpenUrlFlags _flags=NoFlags)
Run the directory lister on the given url.
Definition: kdirlister.cpp:2088
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
virtual KFileItem findByUrl(const KUrl &_url) const
Find an item by its URL.
Definition: kdirlister.cpp:2255
iterator erase(iterator pos)
static KFileItem cachedItemForUrl(const KUrl &url)
Return the KFileItem for the given URL, if we listed it recently and it's still in the cache - which ...
Definition: kdirlister.cpp:2788
QDBusConnection sessionBus()
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
QStringList mimeExcludeFilter
Definition: kdirlister_p.h:160
QList< KDirLister * > listersCurrentlyListing
Definition: kdirlister_p.h:457
void forgetCachedItemsJob(KDirLister::Private::CachedItemsJob *job, KDirLister *lister, const KUrl &url)
Definition: kdirlister.cpp:367
void setMainWindow(QWidget *window)
Pass the main window this object is associated with this is used for caching authentication data...
Definition: kdirlister.cpp:2683
const_iterator insert(const T &value)
QString & remove(int position, int n)
QString nameFilter() const
Returns the current name filter, as set via setNameFilter()
bool dirOnlyMode() const
Checks whether the KDirLister only lists directories or all files.
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void stopListingUrl(KDirLister *lister, const KUrl &_url, bool silent=false)
Definition: kdirlister.cpp:439
bool isParentOf(const KUrl &u) const
void addNewItem(const KUrl &directoryUrl, const KFileItem &item)
Definition: kdirlister.cpp:2415
static bool manually_mounted(const QString &path, const KMountPoint::List &possibleMountPoints)
Definition: kdirlister.cpp:532
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool isEmpty() const
void _k_slotPercent(KJob *, unsigned long)
Definition: kdirlister.cpp:2568
void slotFileRenamed(const QString &srcUrl, const QString &dstUrl)
Definition: kdirlister.cpp:966
T * take(const Key &key)
void setPath(const QString &path)
KFileItem itemForUrl(const KUrl &url) const
Definition: kdirlister.cpp:782
T value(int i) const
void clear()
ListJob * listDir(const KUrl &url, JobFlags flags=DefaultFlags, bool includeHidden=true)
List the contents of url, which is assumed to be a directory.
Definition: job.cpp:2735
bool autoErrorHandlingEnabled() const
Check whether auto error handling is enabled.
QList< KDirLister * > listersCurrentlyHolding
Definition: kdirlister_p.h:459
bool isItemVisible(const KFileItem &item) const
Should this item be visible according to the current filter settings?
Definition: kdirlister.cpp:2535
virtual void stop()
Stop listing all directories currently being listed.
Definition: kdirlister.cpp:2099
const char * name() const
bool isShowingDotFiles
Definition: kdirlister_p.h:156
virtual void setNameFilter(const QString &filter)
Set a name filter to only list items matching this name, e.g.
Definition: kdirlister.cpp:2273
QString canonicalFilePath() const
void addPath(const QString &txt)
QString number(int n, int base)
void _k_slotProcessedSize(KJob *, qulonglong)
Definition: kdirlister.cpp:2606
int count(const T &value) const
virtual bool doNameFilter(const QString &name, const QList< QRegExp > &filters) const
Called by the public matchesFilter() to do the actual filtering.
Definition: kdirlister.cpp:2365
void append(const T &value)
Indicates whether to use the cache or to reread the directory from the disk.
Definition: kdirlister.h:81
QString & insert(int position, QChar ch)
QVariant property(const char *name) const
const_iterator constEnd() const
virtual void setDirOnlyMode(bool dirsOnly)
Call this to list only directories.
Definition: kdirlister.cpp:2142
void prepareForSettingsChange()
Definition: kdirlister_p.h:99
Item next()
void emitItemsDeleted(const KFileItemList &items)
Definition: kdirlister.cpp:2544
CachedItemsJob(KDirLister *lister, const KUrl &url, bool reload)
Definition: kdirlister.cpp:290
KFileItemList items(WhichItems which=FilteredItems) const
Returns the items listed for the current url().
Definition: kdirlister.cpp:2693
void speed(int bytes_per_second)
Emitted to display information about the speed of the jobs.
QString protocol() const
QWidget * mainWindow()
Returns the main window associated with this object.
Definition: kdirlister.cpp:2688
bool isEmpty() const
void infoMessage(const QString &msg)
Emitted to display information about running jobs.
QString localPath() const
Returns the local path if isLocalFile() == true or the KIO item has a UDS_LOCAL_PATH atom...
Definition: kfileitem.cpp:602
bool isEmpty() const
void setAutoErrorHandlingEnabled(bool enable, QWidget *parent)
Enable or disable auto error handling is enabled.
Definition: kdirlister.cpp:2156
int removeAll(const T &value)
const_iterator constEnd() const
iterator begin()
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
List of KFileItems, which adds a few helper methods to QList.
Definition: kfileitem.h:674
bool isFinished() const
Returns true if no io operation is currently in progress.
Definition: kdirlister.cpp:2245
void slotFilesChanged(const QStringList &fileList)
Notify that files have been changed.
Definition: kdirlister.cpp:932
QList< QRegExp > lstFilters
Definition: kdirlister_p.h:158
void setDelayedMimeTypes(bool delayedMimeTypes)
Delayed mimetypes feature: If enabled, mime types will be fetched on demand, which leads to a faster ...
Definition: kdirlister.cpp:2727
void remove()
virtual void setMimeFilter(const QStringList &mimeList)
Set mime-based filter to only list items matching the given mimetypes.
Definition: kdirlister.cpp:2293
iterator end()
static QString protocolClass(const QString &protocol)
const Key & key() const
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
Definition: kdirlister.h:393
KJobUiDelegate * uiDelegate() const
iterator begin()
bool listDir(KDirLister *lister, const KUrl &_url, bool _keep, bool _reload)
Definition: kdirlister.cpp:91
bool showingDotFiles() const
Checks whether hidden files (files beginning with a dot) will be shown.
QList< CachedItemsJob * > m_cachedItemsJobs
Definition: kdirlister_p.h:150
KFileItem * findByUrl(const KDirLister *lister, const KUrl &url) const
Definition: kdirlister.cpp:823
Definition: kdirlister_p.h:42
void clear()
iterator end()
const T value(const Key &key) const
KUrl url() const
Returns the top level URL that is listed by this KDirLister.
Definition: kdirlister.cpp:2162
iterator find(const Key &key)
Item next()
bool hasNext() const
bool contains(const T &value) const
WhichItems
Used by items() and itemsForDir() to specify whether you want all items for a directory or just the f...
Definition: kdirlister.h:391
CachedItemsJob * cachedItemsJobForUrl(const KUrl &url) const
Definition: kdirlister.cpp:281
virtual bool doMimeFilter(const QString &mime, const QStringList &filters) const
Called by the public matchesMimeFilter() to do the actual filtering.
Definition: kdirlister.cpp:2374
const Key key(const T &value) const
void processedSize(KIO::filesize_t size)
Regularly emitted to show the progress of this KDirLister.
void redirect(const KUrl &oldUrl, const KUrl &newUrl, bool keepItems)
Redirect this dirlister from oldUrl to newUrl.
Definition: kdirlister.cpp:2733
Design of the cache: There is a single KDirListerCache for the whole process.
Definition: kdirlister_p.h:181
const_iterator constBegin() const
void setAutoUpdate(KDirLister *lister, bool enable)
Definition: kdirlister.cpp:498
KFileItem findByName(const KDirLister *lister, const QString &_name) const
Definition: kdirlister.cpp:807
bool isValid() const
QString mid(int position, int n) const
QString dir(const QString &fileClass)
Returns the most recently used directory accociated with this file-class.
Definition: krecentdirs.cpp:68
virtual void showErrorMessage()
void setEmitCompleted(bool b)
Definition: kdirlister_p.h:478
static List possibleMountPoints(DetailsNeededFlags infoNeeded=BasicInfoNeeded)
bool autoUpdate() const
Checks whether KDirWatch will automatically update directories.
T & next()
Ptr findByPath(const QString &path) const
int count() const
iterator end()
QString name(bool lowerCase=false) const
Return the name of the file item (without a path).
Definition: kfileitem.cpp:1591
Filename - as displayed in directory listings etc.
Definition: udsentry.h:163
void _k_slotTotalSize(KJob *, qulonglong)
Definition: kdirlister.cpp:2591
KIO::filesize_t processedSize
Definition: kdirlister_p.h:136
void emitItemsFromCache(KDirLister::Private::CachedItemsJob *job, KDirLister *lister, const KUrl &_url, bool _reload, bool _emitCompleted)
Definition: kdirlister.cpp:325
void slotFilesAdded(const QString &urlDirectory)
Notify that files have been added in directory The receiver will list that directory again to find th...
Definition: kdirlister.cpp:859
Definition: kdirlister_p.h:134
int length() const
bool toBool() const
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void _k_slotSpeed(KJob *, unsigned long)
Definition: kdirlister.cpp:2621
void prepend(const T &value)
bool setProperty(const char *name, const QVariant &value)
iterator insert(const Key &key, const T &value)
void setHost(const QString &host)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
bool doMimeExcludeFilter(const QString &mimeExclude, const QStringList &filters) const
Definition: kdirlister.cpp:2393
static bool exists()
int find(QChar c, int i, bool cs) const
static bool supportsListing(const KUrl &url)
Returns whether the protocol can list files/objects.
Definition: kprotocolmanager.cpp:1032
Helper class for the kiojob used to list and update a directory.
Definition: kdirlister.h:57
iterator end()
const T & value() const
void moveListersWithoutCachedItemsJob(const KUrl &url)
Definition: kdirlister.cpp:2763
const_iterator constEnd() const
const_iterator constBegin() const
bool isLocalFile() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
const KShortcut & end()
iterator find(const T &value)
void setMimeExcludeFilter(const QStringList &mimeList)
Filtering should be done with KFileFilter.
Definition: kdirlister.cpp:2305
void addRefreshItem(const KUrl &directoryUrl, const KFileItem &oldItem, const KFileItem &item)
Definition: kdirlister.cpp:2454
bool remove(const Key &key)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QStringList mimeFilters() const
Returns the list of mime based filters, as set via setMimeFilter().
Definition: kdirlister.cpp:2322
static QDebug kFatal(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void itemsDeleted(const KFileItemList &items)
Signal that items have been deleted.
iterator begin()
iterator find(const T &t)
KFileItemList * itemsForDir(const KUrl &dir) const
Definition: kdirlister.cpp:801
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
void addNewItems(const KUrl &directoryUrl, const KFileItemList &items)
Definition: kdirlister.cpp:2443
virtual void emitChanges()
Actually emit the changes made with setShowingDotFiles, setDirOnlyMode, setNameFilter and setMimeFilt...
Definition: kdirlister.cpp:2172
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
bool matchesFilter(const QString &name) const
Checks whether name matches a filter in the list of name filters.
Definition: kdirlister.cpp:2327
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:45
QWidget * window() const
bool hasNext() const
void append(const T &value)
int error() const
QStringList list(const QString &fileClass)
Returns a list of directories associated with this file-class.
Definition: krecentdirs.cpp:60
void clear()
KFileItemList itemsForDir(const KUrl &dir, WhichItems which=FilteredItems) const
Returns the items listed for the given dir.
Definition: kdirlister.cpp:2698
virtual void updateDirectory(const KUrl &_dir)
Update the directory _dir.
Definition: kdirlister.cpp:2240
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.