19#include "moc_qgssourcecache.cpp" 
   27#include <QTemporaryDir> 
   31QgsSourceCacheEntry::QgsSourceCacheEntry( 
const QString &path )
 
   38  const QgsSourceCacheEntry *otherSource = 
dynamic_cast< const QgsSourceCacheEntry * 
>( other );
 
   40  if ( !otherSource || otherSource->filePath != filePath )
 
   46int QgsSourceCacheEntry::dataSize()
 const 
   48  return filePath.size();
 
   51void QgsSourceCacheEntry::dump()
 const 
   61  temporaryDir.reset( 
new QTemporaryDir() );
 
 
   68  const QString file = path.trimmed();
 
   72  const QMutexLocker locker( &
mMutex );
 
   74  QgsSourceCacheEntry *currentEntry = 
findExistingEntry( 
new QgsSourceCacheEntry( file ) );
 
   77  if ( currentEntry->filePath.isEmpty() )
 
   80    const QString filePath = fetchSource( file, isBroken, blocking );
 
   81    currentEntry->filePath = filePath;
 
   84  return currentEntry->filePath;
 
 
   87QString QgsSourceCache::fetchSource( 
const QString &path, 
bool &isBroken, 
bool blocking )
 const 
   91  if ( !path.startsWith( QLatin1String( 
"base64:" ) ) && QFile::exists( path ) )
 
   97    const QByteArray ba = 
getContent( path, QByteArray( 
"broken" ), QByteArray( 
"fetching" ), blocking );
 
  106      filePath = temporaryDir->filePath( QString::number( 
id ) );
 
  107      while ( QFile::exists( filePath ) )
 
  108        filePath = temporaryDir->filePath( QString::number( ++
id ) );
 
  110      QFile file( filePath );
 
  111      file.open( QIODevice::WriteOnly );
 
void remoteContentFetched(const QString &url)
Emitted when the cache has finished retrieving content from a remote url.
 
Base class for entries in a QgsAbstractContentCache.
 
Abstract base class for file content caches, such as SVG or raster image caches.
 
QByteArray getContent(const QString &path, const QByteArray &missingContent, const QByteArray &fetchingContent, bool blocking=false) const
Gets the file content corresponding to the given path.
 
QgsSourceCacheEntry * findExistingEntry(QgsSourceCacheEntry *entryTemplate)
Returns the existing entry from the cache which matches entryTemplate (deleting entryTemplate when do...
 
QgsSourceCache(QObject *parent=nullptr)
Constructor for QgsSourceCache, with the specified parent object.
 
void remoteSourceFetched(const QString &url)
Emitted when the cache has finished retrieving a 3D model from a remote url.
 
QString localFilePath(const QString &path, bool blocking=false)
Returns a local file path reflecting the content of a specified source path.
 
#define QgsDebugMsgLevel(str, level)