25 QMap<QString, QgsFetchedContent *>::const_iterator it = mFileRegistry.constBegin();
26 for ( ; it != mFileRegistry.constEnd(); ++it )
30 mFileRegistry.clear();
36 if ( mFileRegistry.contains( url ) )
38 return mFileRegistry.value( url );
43 mFileRegistry.insert( url, content );
54 QFile *file =
nullptr;
55 QString path = filePathOrUrl;
57 if ( !QUrl::fromUserInput( filePathOrUrl ).isLocalFile() )
59 if ( mFileRegistry.contains( path ) )
64 file = content->
file();
78 file =
new QFile( filePathOrUrl );
85 QString path = filePathOrUrl;
87 if ( !QUrl::fromUserInput( filePathOrUrl ).isLocalFile() )
89 if ( mFileRegistry.contains( path ) )
139 if ( mFetchingTask && mFetchingTask->
canCancel() )
145 mFile->deleteLater();
146 mFilePath = QString();
151 void QgsFetchedContent::taskCompleted()
153 if ( !mFetchingTask || !mFetchingTask->
reply() )
157 mError = QNetworkReply::OperationCanceledError;
158 mFilePath = QString();
162 QNetworkReply *reply = mFetchingTask->
reply();
163 if ( reply->error() == QNetworkReply::NoError )
165 QTemporaryFile *tf =
new QTemporaryFile( QStringLiteral(
"XXXXXX" ) );
168 mFile->write( reply->readAll() );
170 mFilePath = tf->fileName();
177 mError = reply->error();
178 mFilePath = QString();