Scribus
Open source desktop publishing at your fingertips
ScImageCacheProxy Class Reference

Scribus image cache proxy. More...

#include <scimagecacheproxy.h>

Public Member Functions

 ScImageCacheProxy (const QString &fn)
 Construct a cache proxy object. More...
 
bool enabled () const
 Check if the image cache is enabled.
 
const QString & getFilename () const
 Get original image file name.
 
bool load (QImage &image)
 Load image from cache. More...
 
bool save (const QImage &image)
 Save image to cache. More...
 
bool touch () const
 Touch an image in the cache. More...
 
void addMetadata (const QString &key, const QString &value)
 Add or overwrite image metadata.
 
void addModifier (const QString &key, const QString &value)
 Add or overwrite an image modifier.
 
void delModifier (const QString &key)
 Delete an image modifier.
 
bool canUseCachedImage () const
 Check if the cached image can be used in place of the original. More...
 
void addInfo (const QString &key, const QString &value)
 Add image information.
 
QString getInfo (const QString &key) const
 Retrieve image information.
 

Static Public Member Functions

static QString getBaseName (const QString &metafile)
 Get base name of reference/image file from meta file. More...
 
static bool getRefCount (const QString &reffile, int &refcount)
 Get reference count from a reference file. More...
 
static bool fixRefCount (const QString &reffile, int refcount)
 Set reference count in a reference file. More...
 
static bool removeCacheEntry (const QString &metafile, bool haveMasterLock=false)
 Remove an entry from the image cache. More...
 

Static Public Attributes

static const QString metaSuffix
 Meta file suffix.
 
static const QString referenceSuffix
 Reference file suffix.
 
static const QString imageSuffix
 Cache image file suffix.
 

Detailed Description

Scribus image cache proxy.

Author
Marcus Holland-Moritz

Constructor & Destructor Documentation

ScImageCacheProxy::ScImageCacheProxy ( const QString &  fn)

Construct a cache proxy object.

Parameters
fnFull path to the original image file

Member Function Documentation

bool ScImageCacheProxy::canUseCachedImage ( ) const

Check if the cached image can be used in place of the original.

Returns
true if the cached image can be used, false otherwise
bool ScImageCacheProxy::fixRefCount ( const QString &  reffile,
int  refcount 
)
static

Set reference count in a reference file.

Parameters
reffilePath to reference file relative to the cache root directory
refcountThe reference count to write to the file
Returns
true if the reference count could be written, false otherwise
QString ScImageCacheProxy::getBaseName ( const QString &  metafile)
static

Get base name of reference/image file from meta file.

Parameters
metafilePath to meta file relative to the cache root directory
Returns
Reference/image file basename, i.e. path and filename without the suffix
bool ScImageCacheProxy::getRefCount ( const QString &  reffile,
int &  refcount 
)
static

Get reference count from a reference file.

Parameters
reffilePath to reference file relative to the cache root directory
refcountReference to the variable receiving the reference counter
Returns
true if the reference count could be read, false otherwise
bool ScImageCacheProxy::load ( QImage &  image)

Load image from cache.

Parameters
imageQImage object to which to load the cached image
Returns
true if the image could be loaded, false otherwise
bool ScImageCacheProxy::removeCacheEntry ( const QString &  metafile,
bool  haveMasterLock = false 
)
static

Remove an entry from the image cache.

Attempts to remove a meta file from the image cache. Decrements the reference counter of the referenced image. If the reference counter drops to zero, the image and its reference file will also be removed.

Parameters
metafilePath to meta file relative to the cache root directory
haveMasterLocktrue if a master lock has already been acquired
Returns
true if the reference count could be written, false otherwise
bool ScImageCacheProxy::save ( const QImage &  image)

Save image to cache.

Parameters
imageQImage object from which to save the cached image
Returns
true if the image could be saved, false otherwise
bool ScImageCacheProxy::touch ( ) const

Touch an image in the cache.

Returns
true if the image could be touched, false otherwise

The documentation for this class was generated from the following files: