28 QMap<QString, QgsFetchedContent *>::const_iterator it = mFileRegistry.constBegin();
29 for ( ; it != mFileRegistry.constEnd(); ++it )
33 mFileRegistry.clear();
39 if ( mFileRegistry.contains( url ) )
41 return mFileRegistry.value( url );
46 mFileRegistry.insert( url, content );
48 if ( fetchingMode == Qgis::ActionStart::Immediate )
57 QFile *file =
nullptr;
58 const QString path = filePathOrUrl;
60 if ( !QUrl::fromUserInput( filePathOrUrl ).isLocalFile() )
62 if ( mFileRegistry.contains( path ) )
67 file = content->
file();
81 file =
new QFile( filePathOrUrl );
88 QString path = filePathOrUrl;
90 if ( !QUrl::fromUserInput( filePathOrUrl ).isLocalFile() )
92 if ( mFileRegistry.contains( path ) )
144 if ( mFetchingTask && mFetchingTask->
canCancel() )
150 mFile->deleteLater();
151 mFilePath = QString();
156 void QgsFetchedContent::taskCompleted()
158 if ( !mFetchingTask || !mFetchingTask->
reply() )
162 mError = QNetworkReply::OperationCanceledError;
163 mFilePath = QString();
167 QNetworkReply *reply = mFetchingTask->
reply();
168 if ( reply->error() == QNetworkReply::NoError )
172 const QString extension = QFileInfo( reply->request().url().fileName() ).completeSuffix();
174 QTemporaryFile *tf =
new QTemporaryFile( extension.isEmpty() ? QString(
"XXXXXX" ) :
175 QString(
"%1/XXXXXX.%2" ).arg( QDir::tempPath(), extension ) );
178 mFile->write( reply->readAll() );
180 mFilePath = tf->fileName();
187 mError = reply->error();
188 mFilePath = QString();