comparison data/fileio/FileSource.cpp @ 981:c6f2b93a7d52

Respond tidily to user cancellation during download, instead of going on to attempt to load the nonexistent file as a non-audio format
author Chris Cannam
date Tue, 09 Sep 2014 16:52:24 +0100
parents 613ee830de5e
children 60e2927b1475
comparison
equal deleted inserted replaced
979:c598b1d880f2 981:c6f2b93a7d52
76 m_url(fileOrUrl, QUrl::StrictMode), 76 m_url(fileOrUrl, QUrl::StrictMode),
77 m_localFile(0), 77 m_localFile(0),
78 m_reply(0), 78 m_reply(0),
79 m_preferredContentType(preferredContentType), 79 m_preferredContentType(preferredContentType),
80 m_ok(false), 80 m_ok(false),
81 m_cancelled(false),
81 m_lastStatus(0), 82 m_lastStatus(0),
82 m_resource(fileOrUrl.startsWith(':')), 83 m_resource(fileOrUrl.startsWith(':')),
83 m_remote(isRemote(fileOrUrl)), 84 m_remote(isRemote(fileOrUrl)),
84 m_done(false), 85 m_done(false),
85 m_leaveLocalFile(false), 86 m_leaveLocalFile(false),
165 FileSource::FileSource(QUrl url, ProgressReporter *reporter) : 166 FileSource::FileSource(QUrl url, ProgressReporter *reporter) :
166 m_url(url), 167 m_url(url),
167 m_localFile(0), 168 m_localFile(0),
168 m_reply(0), 169 m_reply(0),
169 m_ok(false), 170 m_ok(false),
171 m_cancelled(false),
170 m_lastStatus(0), 172 m_lastStatus(0),
171 m_resource(false), 173 m_resource(false),
172 m_remote(isRemote(url.toString())), 174 m_remote(isRemote(url.toString())),
173 m_done(false), 175 m_done(false),
174 m_leaveLocalFile(false), 176 m_leaveLocalFile(false),
197 QObject(), 199 QObject(),
198 m_url(rf.m_url), 200 m_url(rf.m_url),
199 m_localFile(0), 201 m_localFile(0),
200 m_reply(0), 202 m_reply(0),
201 m_ok(rf.m_ok), 203 m_ok(rf.m_ok),
204 m_cancelled(rf.m_cancelled),
202 m_lastStatus(rf.m_lastStatus), 205 m_lastStatus(rf.m_lastStatus),
203 m_resource(rf.m_resource), 206 m_resource(rf.m_resource),
204 m_remote(rf.m_remote), 207 m_remote(rf.m_remote),
205 m_done(false), 208 m_done(false),
206 m_leaveLocalFile(false), 209 m_leaveLocalFile(false),
569 { 572 {
570 return m_done; 573 return m_done;
571 } 574 }
572 575
573 bool 576 bool
577 FileSource::wasCancelled() const
578 {
579 return m_cancelled;
580 }
581
582 bool
574 FileSource::isResource() const 583 FileSource::isResource() const
575 { 584 {
576 return m_resource; 585 return m_resource;
577 } 586 }
578 587
708 { 717 {
709 m_done = true; 718 m_done = true;
710 cleanup(); 719 cleanup();
711 720
712 m_ok = false; 721 m_ok = false;
722 m_cancelled = true;
713 m_errorString = tr("Download cancelled"); 723 m_errorString = tr("Download cancelled");
714 } 724 }
715 725
716 void 726 void
717 FileSource::replyFinished() 727 FileSource::replyFinished()