summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <[email protected]>2024-02-15 21:37:08 +0300
committerMichele Calgaro <[email protected]>2024-02-16 18:35:20 +0900
commit9d4be4eb1314b453c58b482827f4da5cc132192a (patch)
treeadecbe8e04ec76b57ad3a0dd858028f5545c097c
parentddaf1402a4db2d9712281c569a66eba7fdd7cd80 (diff)
downloadtdelibs-9d4be4eb1314b453c58b482827f4da5cc132192a.tar.gz
tdelibs-9d4be4eb1314b453c58b482827f4da5cc132192a.zip
tdeio/kdirlister: some refactoring
Signed-off-by: Alexander Golubev <[email protected]> (cherry picked from commit c4ebd9d0e7a54fedf79dcb959ad65c9e679b370c)
-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;
};