mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: watch the sub-directories when listing recursively
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5d60973ab4
commit
9767ce8fc4
3 changed files with 22 additions and 37 deletions
|
@ -52,10 +52,6 @@ void KUrlTest::testUpUrl_data()
|
|||
<< KUrl("ftp://ftp.kde.org/foo?bar=baz#foobar")
|
||||
<< KUrl("ftp://ftp.kde.org/");
|
||||
}
|
||||
void KUrlTest::testUpUrl2_data()
|
||||
{
|
||||
testUpUrl_data();
|
||||
}
|
||||
|
||||
void KUrlTest::testUpUrl()
|
||||
{
|
||||
|
@ -73,6 +69,11 @@ void KUrlTest::testUpUrl()
|
|||
QCOMPARE(newPath[newPath.size() - 1], QChar::fromLatin1('/'));
|
||||
}
|
||||
|
||||
void KUrlTest::testUpUrl2_data()
|
||||
{
|
||||
testUpUrl_data();
|
||||
}
|
||||
|
||||
void KUrlTest::testUpUrl2()
|
||||
{
|
||||
QFETCH(KUrl, url);
|
||||
|
|
|
@ -113,9 +113,13 @@ void KDirListerPrivate::_k_slotEntries(KIO::Job *job, const KIO::UDSEntryList &e
|
|||
KDesktopFile desktopfile(itempath);
|
||||
const KUrl desktopurl = desktopfile.readUrl();
|
||||
if (desktopurl.isValid()) {
|
||||
desktopUrls.append(desktopurl);
|
||||
watchedUrls.append(desktopurl);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.isDir() && recursive) {
|
||||
watchedUrls.append(item.url());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,10 +140,8 @@ void KDirListerPrivate::_k_slotResult(KJob *job)
|
|||
emit m_parent->completed();
|
||||
|
||||
if (autoUpdate) {
|
||||
const KUrl::List towatch = KUrl::List()
|
||||
<< url
|
||||
<< desktopUrls;
|
||||
foreach (const KUrl &it, towatch) {
|
||||
watchedUrls.append(url);
|
||||
foreach (const KUrl &it, watchedUrls) {
|
||||
if (it.isLocalFile()) {
|
||||
const QString localfile = it.toLocalFile();
|
||||
kDebug(7003) << "watching" << localfile;
|
||||
|
@ -203,22 +205,11 @@ void KDirListerPrivate::_k_slotFilesAdded(const QString &path)
|
|||
{
|
||||
kDebug(7003) << "file added" << path;
|
||||
const KUrl pathurl(path);
|
||||
|
||||
if (pathurl == url) {
|
||||
_k_slotUpdateDirectory();
|
||||
return;
|
||||
}
|
||||
|
||||
const KUrl pathdirectory = pathurl.directory();
|
||||
if (pathdirectory == url) {
|
||||
_k_slotUpdateDirectory();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (const KUrl &it, desktopUrls) {
|
||||
foreach (const KUrl &it, watchedUrls) {
|
||||
if (it == pathdirectory || it == pathurl) {
|
||||
_k_slotUpdateDirectory();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,23 +219,16 @@ void KDirListerPrivate::_k_slotFilesChangedOrRemoved(const QStringList &paths)
|
|||
kDebug(7003) << "files changed" << paths;
|
||||
foreach (const QString &it, paths) {
|
||||
const KUrl pathurl(it);
|
||||
|
||||
if (pathurl == url) {
|
||||
_k_slotUpdateDirectory();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (const KFileItem &it2, filteredItems) {
|
||||
if (it2.url() == pathurl) {
|
||||
foreach (const KUrl &it2, watchedUrls) {
|
||||
if (it2 == pathurl) {
|
||||
_k_slotUpdateDirectory();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const KUrl &it2, desktopUrls) {
|
||||
if (it2 == pathurl) {
|
||||
foreach (const KFileItem &it2, filteredItems) {
|
||||
if (it2.url() == pathurl) {
|
||||
_k_slotUpdateDirectory();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,8 +266,7 @@ bool KDirLister::openUrl(const KUrl &url, bool recursive)
|
|||
d->dirWatch = nullptr;
|
||||
}
|
||||
if (d->dirNotify) {
|
||||
org::kde::KDirNotify::emitLeftDirectory(d->url.url());
|
||||
foreach (const KUrl &it, d->desktopUrls) {
|
||||
foreach (const KUrl &it, d->watchedUrls) {
|
||||
if (!it.isLocalFile()) {
|
||||
org::kde::KDirNotify::emitLeftDirectory(it.url());
|
||||
}
|
||||
|
@ -297,6 +280,7 @@ bool KDirLister::openUrl(const KUrl &url, bool recursive)
|
|||
d->url = url;
|
||||
d->recursive = recursive;
|
||||
d->allItems.clear();
|
||||
d->watchedUrls.clear();
|
||||
if (!d->filteredItems.isEmpty()) {
|
||||
emit itemsDeleted(d->filteredItems);
|
||||
d->filteredItems.clear();
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
KDirWatch* dirWatch;
|
||||
OrgKdeKDirNotifyInterface* dirNotify;
|
||||
QTimer* pendingUpdateTimer;
|
||||
KUrl::List desktopUrls;
|
||||
KUrl::List watchedUrls;
|
||||
|
||||
void _k_slotInfoMessage(KJob *job, const QString &msg);
|
||||
void _k_slotPercent(KJob *job, ulong value);
|
||||
|
|
Loading…
Add table
Reference in a new issue