16 #ifndef _FILE_SOURCE_H_ 17 #define _FILE_SOURCE_H_ 23 #include <QNetworkReply> 75 QString preferredContentType =
"");
190 static bool isRemote(QString fileOrUrl);
QString getExtension() const
Return the file extension for this file, if any.
void setLeaveLocalFile(bool leave)
Specify whether any local, cached file should remain on disc after this FileSource has been destroyed...
bool isResource() const
Return true if this FileSource is referring to a QRC resource.
QString getLocation() const
Return the location filename or URL as passed to the constructor.
void downloadProgress(qint64 done, qint64 total)
FileSource(QString fileOrUrl, ProgressReporter *reporter=0, QString preferredContentType="")
Construct a FileSource using the given local file path or URL.
bool isDone() const
Return true if the entire file has been retrieved and is available.
void statusAvailable()
Emitted when the file's existence has been tested and/or response header received.
static QMutex m_fileCreationMutex
QString m_preferredContentType
static RemoteLocalMap m_remoteLocalMap
void waitForData()
Block on a sub-event-loop until the whole of the data has been retrieved (if it is remote).
void progress(int percent)
Emitted during URL retrieval, when the retrieval progress notches up to a new percentage.
void waitForStatus()
Block on a sub-event-loop until the availability of the file or remote URL is known.
bool isOK() const
Return true if the FileSource object is valid and neither error nor cancellation occurred while retri...
std::map< QUrl, QString > RemoteLocalMap
void replyFailed(QNetworkReply::NetworkError)
ProgressReporter * m_reporter
FileSource & operator=(const FileSource &)
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
std::map< QUrl, int > RemoteRefCountMap
bool isRemote() const
Return true if this FileSource is referring to a remote URL.
QString getErrorString() const
Return an error message, if isOK() is false.
QString getLocalFilename() const
Return the name of the local file this FileSource refers to.
QString getBasename() const
Return the base name, i.e.
static RemoteRefCountMap m_refCountMap
bool wasCancelled() const
Return true if the operation was cancelled by the user through the ProgressReporter interface.
void ready()
Emitted when the entire file data has been retrieved and the local file is complete (if no error has ...
static bool canHandleScheme(QUrl url)
Return true if FileSource can handle the retrieval scheme for the given URL (or if the URL is for a l...
QString getContentType() const
Return the MIME content type of this file, if known.
bool isAvailable()
Return true if the file or remote URL exists.