summaryrefslogtreecommitdiffstats
path: root/tdeio
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2024-02-15 21:37:08 +0300
committerTDE Gitea <gitea@mirror.git.trinitydesktop.org>2024-02-16 09:33:12 +0000
commitc4ebd9d0e7a54fedf79dcb959ad65c9e679b370c (patch)
tree0b3a96ae6c1d307eef1e28d7aa38079fac31a2ec /tdeio
parent6f9f01b2f4534e0f4f61f19097de7b9975cd91e8 (diff)
downloadtdelibs-c4ebd9d0e7a54fedf79dcb959ad65c9e679b370c.tar.gz
tdelibs-c4ebd9d0e7a54fedf79dcb959ad65c9e679b370c.zip
tdeio/kdirlister: some refactoring
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
Diffstat (limited to 'tdeio')
-rw-r--r--tdeio/tdeio/kdirlister.cpp51
-rw-r--r--tdeio/tdeio/kdirlister_p.h10
2 files changed, 34 insertions, 27 deletions
diff --git a/tdeio/tdeio/kdirlister.cpp b/tdeio/tdeio/kdirlister.cpp
index 31a705fa2..534ec6352 100644
--- a/tdeio/tdeio/kdirlister.cpp
+++ b/tdeio/tdeio/kdirlister.cpp
@@ -1946,44 +1946,47 @@ bool KDirLister::openURL( const KURL& _url, bool _keep, bool _reload )
d->changes = NONE;
+ // Some ioslaves like media:/ or home:/ can provide a local url istead of a remote one
// If a local path is available, monitor that instead of the given remote URL...
if (!_url.isLocalFile()) {
- TDEIO::LocalURLJob* localURLJob = TDEIO::localURL(_url);
- if (localURLJob) {
- d->openURL_url[localURLJob] = _url;
- d->openURL_keep[localURLJob] = _keep;
- d->openURL_reload[localURLJob] = _reload;
- connect(localURLJob, TQ_SIGNAL(localURL(TDEIO::LocalURLJob*, const KURL&, bool)), this, TQ_SLOT(slotOpenURLGotLocalURL(TDEIO::LocalURLJob*, const KURL&, bool)));
- connect(localURLJob, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotLocalURLKIODestroyed()));
- }
- return true;
+ TDEIO::LocalURLJob* localURLJob = TDEIO::localURL(_url);
+ if (localURLJob) {
+ d->openURLContext[localURLJob] = KDirListerPrivate::OpenURLContext{_url, _keep, _reload};
+ connect(localURLJob, TQ_SIGNAL(localURL(TDEIO::LocalURLJob*, const KURL&, bool)),
+ this, TQ_SLOT(slotOpenURLGotLocalURL(TDEIO::LocalURLJob*, const KURL&, bool)));
+ connect(localURLJob, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotLocalURLKIODestroyed()));
+ }
+ return true;
}
else {
- return s_pCache->listDir( this, _url, _keep, _reload );
+ return s_pCache->listDir( this, _url, _keep, _reload );
}
}
void KDirLister::slotOpenURLGotLocalURL(TDEIO::LocalURLJob *job, const KURL& url, bool isLocal) {
- KURL realURL = d->openURL_url[job];
+ auto jobIt = d->openURLContext.find(job);
+
+ Q_ASSERT( jobIt != d->openURLContext.end() );
+
+ auto ctx = jobIt.data();
+ KURL realURL = ctx.url;
if (isLocal) {
- realURL = url;
- realURL.setInternalReferenceURL(d->openURL_url[job].url());
- d->m_referenceURLMap[d->openURL_url[job].url()] = url.path();
+ realURL = url;
+ realURL.setInternalReferenceURL(ctx.url.url());
+ d->m_referenceURLMap[ctx.url.url()] = url.path();
}
- s_pCache->listDir( this, realURL, d->openURL_keep[job], d->openURL_reload[job] );
- d->openURL_url.remove(job);
- d->openURL_keep.remove(job);
- d->openURL_reload.remove(job);
+ d->openURLContext.remove(jobIt);
+ s_pCache->listDir( this, realURL, ctx.keep, ctx.reload );
}
void KDirLister::slotLocalURLKIODestroyed() {
- TDEIO::LocalURLJob* terminatedJob = const_cast<TDEIO::LocalURLJob*>(static_cast<const TDEIO::LocalURLJob*>(sender()));
+ TDEIO::Job* terminatedJob = const_cast<TDEIO::Job*>(static_cast<const TDEIO::Job*>(sender()));
+ auto jobIt = d->openURLContext.find(terminatedJob);
- if (d->openURL_url.contains(terminatedJob)) {
- s_pCache->listDir( this, d->openURL_url[terminatedJob], d->openURL_keep[terminatedJob], d->openURL_reload[terminatedJob] );
- d->openURL_url.remove(terminatedJob);
- d->openURL_keep.remove(terminatedJob);
- d->openURL_reload.remove(terminatedJob);
+ if (jobIt != d->openURLContext.end()) {
+ auto ctx = jobIt.data();
+ d->openURLContext.remove(jobIt);
+ s_pCache->listDir( this, ctx.url, ctx.keep, ctx.reload );
}
}
diff --git a/tdeio/tdeio/kdirlister_p.h b/tdeio/tdeio/kdirlister_p.h
index 3092e8e2e..7c3461c4b 100644
--- a/tdeio/tdeio/kdirlister_p.h
+++ b/tdeio/tdeio/kdirlister_p.h
@@ -111,9 +111,13 @@ public:
TQStringList mimeFilter, oldMimeFilter;
TQStringList mimeExcludeFilter, oldMimeExcludeFilter;
- TQMap<TDEIO::Job*, KURL> openURL_url;
- TQMap<TDEIO::Job*, bool> openURL_keep;
- TQMap<TDEIO::Job*, bool> openURL_reload;
+ struct OpenURLContext {
+ KURL url;
+ bool keep;
+ bool reload;
+ };
+
+ TQMap<TDEIO::Job*, OpenURLContext> openURLContext;
TQMap<TQString,TQString> m_referenceURLMap;
};