mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: implement listing of directory links for KIO::ListJob
tested with dolphin file search slave, more hammering will be done in the future for reference: https://ivailo-monev.atlassian.net/browse/KDE-20 Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
175aba2477
commit
1aa97c216a
4 changed files with 61 additions and 42 deletions
|
@ -80,7 +80,7 @@ namespace KIO
|
||||||
KUrl::List dirs;
|
KUrl::List dirs;
|
||||||
KUrl::List m_srcList;
|
KUrl::List m_srcList;
|
||||||
KUrl::List::iterator m_currentStat;
|
KUrl::List::iterator m_currentStat;
|
||||||
QSet<QString> m_parentDirs;
|
QSet<QString> m_parentDirs;
|
||||||
QTimer *m_reportTimer;
|
QTimer *m_reportTimer;
|
||||||
|
|
||||||
void statNextSrc();
|
void statNextSrc();
|
||||||
|
|
|
@ -111,8 +111,8 @@ void DirectorySizeJobPrivate::processNextItem()
|
||||||
while (m_currentItem < m_lstItems.count())
|
while (m_currentItem < m_lstItems.count())
|
||||||
{
|
{
|
||||||
const KFileItem item = m_lstItems[m_currentItem++];
|
const KFileItem item = m_lstItems[m_currentItem++];
|
||||||
if ( !item.isLink() )
|
if ( !item.isLink() )
|
||||||
{
|
{
|
||||||
if ( item.isDir() )
|
if ( item.isDir() )
|
||||||
{
|
{
|
||||||
//kDebug(7007) << "dir -> listing";
|
//kDebug(7007) << "dir -> listing";
|
||||||
|
|
|
@ -1705,6 +1705,7 @@ public:
|
||||||
QString m_displayPrefix;
|
QString m_displayPrefix;
|
||||||
unsigned long m_processedEntries;
|
unsigned long m_processedEntries;
|
||||||
KUrl m_redirectionURL;
|
KUrl m_redirectionURL;
|
||||||
|
KUrl::List m_visited;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -1778,7 +1779,7 @@ void ListJobPrivate::slotListEntries(const KIO::UDSEntryList &list)
|
||||||
itemURL.addPath(fileName);
|
itemURL.addPath(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.isDir() && !entry.isLink()) {
|
if (entry.isDir()) {
|
||||||
const QString filename = itemURL.fileName();
|
const QString filename = itemURL.fileName();
|
||||||
QString displayName = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME);
|
QString displayName = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME);
|
||||||
if (displayName.isEmpty()) {
|
if (displayName.isEmpty()) {
|
||||||
|
@ -1786,18 +1787,36 @@ void ListJobPrivate::slotListEntries(const KIO::UDSEntryList &list)
|
||||||
}
|
}
|
||||||
// skip hidden dirs when listing if requested
|
// skip hidden dirs when listing if requested
|
||||||
if (filename != ".." && filename != "." && (includeHidden || filename[0] != '.')) {
|
if (filename != ".." && filename != "." && (includeHidden || filename[0] != '.')) {
|
||||||
ListJob *job = ListJobPrivate::newJobNoUi(
|
bool listItem = true;
|
||||||
itemURL,
|
if (entry.isLink()) {
|
||||||
true /*recursive*/,
|
const KUrl linkDest(itemURL, entry.stringValue(KIO::UDSEntry::UDS_LINK_DEST));
|
||||||
m_prefix + filename + '/',
|
if (!m_visited.contains(linkDest.path())) {
|
||||||
m_displayPrefix + displayName + '/',
|
m_visited.append(linkDest);
|
||||||
includeHidden
|
} else {
|
||||||
);
|
// the link was already listed
|
||||||
q->connect(
|
listItem = false;
|
||||||
job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
|
}
|
||||||
SLOT(gotEntries(KIO::Job*,KIO::UDSEntryList))
|
}
|
||||||
);
|
if (m_visited.contains(itemURL)) {
|
||||||
q->addSubjob(job);
|
// the directory was already listed
|
||||||
|
listItem = false;
|
||||||
|
}
|
||||||
|
if (listItem) {
|
||||||
|
m_visited.append(itemURL);
|
||||||
|
ListJob *job = ListJobPrivate::newJobNoUi(
|
||||||
|
itemURL,
|
||||||
|
true /*recursive*/,
|
||||||
|
m_prefix + filename + '/',
|
||||||
|
m_displayPrefix + displayName + '/',
|
||||||
|
includeHidden
|
||||||
|
);
|
||||||
|
job->d_func()->m_visited = m_visited;
|
||||||
|
q->connect(
|
||||||
|
job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
|
||||||
|
SLOT(gotEntries(KIO::Job*,KIO::UDSEntryList))
|
||||||
|
);
|
||||||
|
q->addSubjob(job);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace KIO {
|
||||||
* directory (unix-style), -1 for default permissions.
|
* directory (unix-style), -1 for default permissions.
|
||||||
* @return A pointer to the job handling the operation.
|
* @return A pointer to the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * mkdir( const KUrl& url, int permissions = -1 ); // TODO KDE5: return a MkdirJob and make that class public again
|
KIO_EXPORT SimpleJob* mkdir(const KUrl &url, int permissions = -1); // TODO KDE5: return a MkdirJob and make that class public again
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a single directory.
|
* Removes a single directory.
|
||||||
|
@ -49,7 +49,7 @@ namespace KIO {
|
||||||
* @param url The URL of the directory to remove.
|
* @param url The URL of the directory to remove.
|
||||||
* @return A pointer to the job handling the operation.
|
* @return A pointer to the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * rmdir( const KUrl& url );
|
KIO_EXPORT SimpleJob* rmdir(const KUrl &url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes permissions on a file or directory.
|
* Changes permissions on a file or directory.
|
||||||
|
@ -60,7 +60,7 @@ namespace KIO {
|
||||||
* @param permissions The permissions to set.
|
* @param permissions The permissions to set.
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * chmod( const KUrl& url, int permissions );
|
KIO_EXPORT SimpleJob* chmod(const KUrl &url, int permissions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes ownership and group of a file or directory.
|
* Changes ownership and group of a file or directory.
|
||||||
|
@ -70,7 +70,7 @@ namespace KIO {
|
||||||
* @param group the new group
|
* @param group the new group
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * chown( const KUrl& url, const QString& owner, const QString& group );
|
KIO_EXPORT SimpleJob* chown(const KUrl &url, const QString &owner, const QString &group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the modification time on a file or directory.
|
* Changes the modification time on a file or directory.
|
||||||
|
@ -79,7 +79,7 @@ namespace KIO {
|
||||||
* @param permissions The permissions to set.
|
* @param permissions The permissions to set.
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob *setModificationTime( const KUrl& url, const QDateTime& mtime );
|
KIO_EXPORT SimpleJob* setModificationTime(const KUrl &url, const QDateTime &mtime);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +93,7 @@ namespace KIO {
|
||||||
* @param flags Can be Overwrite here
|
* @param flags Can be Overwrite here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * rename( const KUrl& src, const KUrl & dest, JobFlags flags = DefaultFlags );
|
KIO_EXPORT SimpleJob* rename(const KUrl &src, const KUrl &dest, JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create or move a symlink.
|
* Create or move a symlink.
|
||||||
|
@ -105,7 +105,7 @@ namespace KIO {
|
||||||
* @param flags Can be Overwrite and HideProgressInfo
|
* @param flags Can be Overwrite and HideProgressInfo
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * symlink( const QString & target, const KUrl& dest, JobFlags flags = DefaultFlags );
|
KIO_EXPORT SimpleJob* symlink(const QString &target, const KUrl&dest, JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute any command that is specific to one slave (protocol).
|
* Execute any command that is specific to one slave (protocol).
|
||||||
|
@ -117,7 +117,7 @@ namespace KIO {
|
||||||
* @param flags Can be HideProgressInfo here
|
* @param flags Can be HideProgressInfo here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob * special( const KUrl& url, const QByteArray & data, JobFlags flags = DefaultFlags );
|
KIO_EXPORT SimpleJob* special(const KUrl& url, const QByteArray &data, JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all details for one file or directory.
|
* Find all details for one file or directory.
|
||||||
|
@ -126,7 +126,7 @@ namespace KIO {
|
||||||
* @param flags Can be HideProgressInfo here
|
* @param flags Can be HideProgressInfo here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT StatJob * stat( const KUrl& url, JobFlags flags = DefaultFlags );
|
KIO_EXPORT StatJob* stat(const KUrl &url, JobFlags flags = DefaultFlags);
|
||||||
/**
|
/**
|
||||||
* Find all details for one file or directory.
|
* Find all details for one file or directory.
|
||||||
* This version of the call includes two additional booleans, @p sideIsSource and @p details.
|
* This version of the call includes two additional booleans, @p sideIsSource and @p details.
|
||||||
|
@ -154,8 +154,8 @@ namespace KIO {
|
||||||
* @param flags Can be HideProgressInfo here
|
* @param flags Can be HideProgressInfo here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT StatJob * stat( const KUrl& url, KIO::StatJob::StatSide side,
|
KIO_EXPORT StatJob* stat(const KUrl &url, KIO::StatJob::StatSide side,
|
||||||
short int details, JobFlags flags = DefaultFlags );
|
short int details, JobFlags flags = DefaultFlags);
|
||||||
/**
|
/**
|
||||||
* Get (a.k.a. read).
|
* Get (a.k.a. read).
|
||||||
* This is the job to use in order to "download" a file into memory.
|
* This is the job to use in order to "download" a file into memory.
|
||||||
|
@ -165,7 +165,7 @@ namespace KIO {
|
||||||
* @param flags Can be HideProgressInfo here
|
* @param flags Can be HideProgressInfo here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT TransferJob *get( const KUrl& url, JobFlags flags = DefaultFlags );
|
KIO_EXPORT TransferJob* get(const KUrl &url, JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put (a.k.a. write)
|
* Put (a.k.a. write)
|
||||||
|
@ -177,8 +177,8 @@ namespace KIO {
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
* @see get()
|
* @see get()
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT TransferJob *put( const KUrl& url, int permissions,
|
KIO_EXPORT TransferJob* put(const KUrl& url, int permissions,
|
||||||
JobFlags flags = DefaultFlags );
|
JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get (a.k.a. read), into a single QByteArray.
|
* Get (a.k.a. read), into a single QByteArray.
|
||||||
|
@ -188,7 +188,7 @@ namespace KIO {
|
||||||
* @param flags Can be HideProgressInfo here
|
* @param flags Can be HideProgressInfo here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT StoredTransferJob *storedGet( const KUrl& url, JobFlags flags = DefaultFlags );
|
KIO_EXPORT StoredTransferJob* storedGet(const KUrl &url, JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put (a.k.a. write) data from a single QByteArray.
|
* Put (a.k.a. write) data from a single QByteArray.
|
||||||
|
@ -201,8 +201,8 @@ namespace KIO {
|
||||||
* Setting Resume means that the data will be appended to @p dest if @p dest exists.
|
* Setting Resume means that the data will be appended to @p dest if @p dest exists.
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT StoredTransferJob *storedPut( const QByteArray& arr, const KUrl& url, int permissions,
|
KIO_EXPORT StoredTransferJob* storedPut(const QByteArray &arr, const KUrl &url, int permissions,
|
||||||
JobFlags flags = DefaultFlags );
|
JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a single file.
|
* Copy a single file.
|
||||||
|
@ -216,8 +216,8 @@ namespace KIO {
|
||||||
* Setting Resume means that the data will be appended to @p dest if @p dest exists.
|
* Setting Resume means that the data will be appended to @p dest if @p dest exists.
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT FileCopyJob *file_copy( const KUrl& src, const KUrl& dest, int permissions=-1,
|
KIO_EXPORT FileCopyJob* file_copy(const KUrl &src, const KUrl &dest, int permissions = -1,
|
||||||
JobFlags flags = DefaultFlags );
|
JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a single file.
|
* Move a single file.
|
||||||
|
@ -231,8 +231,8 @@ namespace KIO {
|
||||||
* Setting Resume means that the data will be appended to @p dest if @p dest exists.
|
* Setting Resume means that the data will be appended to @p dest if @p dest exists.
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT FileCopyJob *file_move( const KUrl& src, const KUrl& dest, int permissions=-1,
|
KIO_EXPORT FileCopyJob* file_move(const KUrl &src, const KUrl &dest, int permissions = -1,
|
||||||
JobFlags flags = DefaultFlags );
|
JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a single file.
|
* Delete a single file.
|
||||||
|
@ -241,7 +241,7 @@ namespace KIO {
|
||||||
* @param flags Can be HideProgressInfo here
|
* @param flags Can be HideProgressInfo here
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT SimpleJob *file_delete( const KUrl& src, JobFlags flags = DefaultFlags );
|
KIO_EXPORT SimpleJob* file_delete(const KUrl &src, JobFlags flags = DefaultFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List the contents of @p url, which is assumed to be a directory.
|
* List the contents of @p url, which is assumed to be a directory.
|
||||||
|
@ -255,8 +255,8 @@ namespace KIO {
|
||||||
* files/dirs (whose names start with dot)
|
* files/dirs (whose names start with dot)
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT ListJob *listDir( const KUrl& url, JobFlags flags = DefaultFlags,
|
KIO_EXPORT ListJob* listDir(const KUrl &url, JobFlags flags = DefaultFlags,
|
||||||
bool includeHidden = true );
|
bool includeHidden = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The same as the previous method, but recurses subdirectories.
|
* The same as the previous method, but recurses subdirectories.
|
||||||
|
@ -271,8 +271,8 @@ namespace KIO {
|
||||||
* files/dirs (whose names start with dot)
|
* files/dirs (whose names start with dot)
|
||||||
* @return the job handling the operation.
|
* @return the job handling the operation.
|
||||||
*/
|
*/
|
||||||
KIO_EXPORT ListJob *listRecursive( const KUrl& url, JobFlags flags = DefaultFlags,
|
KIO_EXPORT ListJob* listRecursive(const KUrl &url, JobFlags flags = DefaultFlags,
|
||||||
bool includeHidden = true );
|
bool includeHidden = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue