tdeio/kdirlister: some refactoring

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit c4ebd9d0e7)
pull/271/head
Alexander Golubev 10 months ago committed by Michele Calgaro
parent ddaf1402a4
commit 9d4be4eb13
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1946,14 +1946,14 @@ bool KDirLister::openURL( const KURL& _url, bool _keep, bool _reload )
d->changes = NONE; 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 a local path is available, monitor that instead of the given remote URL...
if (!_url.isLocalFile()) { if (!_url.isLocalFile()) {
TDEIO::LocalURLJob* localURLJob = TDEIO::localURL(_url); TDEIO::LocalURLJob* localURLJob = TDEIO::localURL(_url);
if (localURLJob) { if (localURLJob) {
d->openURL_url[localURLJob] = _url; d->openURLContext[localURLJob] = KDirListerPrivate::OpenURLContext{_url, _keep, _reload};
d->openURL_keep[localURLJob] = _keep; connect(localURLJob, TQ_SIGNAL(localURL(TDEIO::LocalURLJob*, const KURL&, bool)),
d->openURL_reload[localURLJob] = _reload; this, TQ_SLOT(slotOpenURLGotLocalURL(TDEIO::LocalURLJob*, const KURL&, bool)));
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())); connect(localURLJob, TQ_SIGNAL(destroyed()), this, TQ_SLOT(slotLocalURLKIODestroyed()));
} }
return true; return true;
@ -1964,26 +1964,29 @@ bool KDirLister::openURL( const KURL& _url, bool _keep, bool _reload )
} }
void KDirLister::slotOpenURLGotLocalURL(TDEIO::LocalURLJob *job, const KURL& url, bool isLocal) { 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) { if (isLocal) {
realURL = url; realURL = url;
realURL.setInternalReferenceURL(d->openURL_url[job].url()); realURL.setInternalReferenceURL(ctx.url.url());
d->m_referenceURLMap[d->openURL_url[job].url()] = url.path(); d->m_referenceURLMap[ctx.url.url()] = url.path();
} }
s_pCache->listDir( this, realURL, d->openURL_keep[job], d->openURL_reload[job] ); d->openURLContext.remove(jobIt);
d->openURL_url.remove(job); s_pCache->listDir( this, realURL, ctx.keep, ctx.reload );
d->openURL_keep.remove(job);
d->openURL_reload.remove(job);
} }
void KDirLister::slotLocalURLKIODestroyed() { 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)) { if (jobIt != d->openURLContext.end()) {
s_pCache->listDir( this, d->openURL_url[terminatedJob], d->openURL_keep[terminatedJob], d->openURL_reload[terminatedJob] ); auto ctx = jobIt.data();
d->openURL_url.remove(terminatedJob); d->openURLContext.remove(jobIt);
d->openURL_keep.remove(terminatedJob); s_pCache->listDir( this, ctx.url, ctx.keep, ctx.reload );
d->openURL_reload.remove(terminatedJob);
} }
} }

@ -111,9 +111,13 @@ public:
TQStringList mimeFilter, oldMimeFilter; TQStringList mimeFilter, oldMimeFilter;
TQStringList mimeExcludeFilter, oldMimeExcludeFilter; TQStringList mimeExcludeFilter, oldMimeExcludeFilter;
TQMap<TDEIO::Job*, KURL> openURL_url; struct OpenURLContext {
TQMap<TDEIO::Job*, bool> openURL_keep; KURL url;
TQMap<TDEIO::Job*, bool> openURL_reload; bool keep;
bool reload;
};
TQMap<TDEIO::Job*, OpenURLContext> openURLContext;
TQMap<TQString,TQString> m_referenceURLMap; TQMap<TQString,TQString> m_referenceURLMap;
}; };

Loading…
Cancel
Save