1
#include "imageprovider.h"
6
QHash<QString,QPixmap> provider_pixmap_hash;
8
ImageProvider::ImageProvider() :
9
QDeclarativeImageProvider( QDeclarativeImageProvider::Pixmap )
13
QString ImageProvider::getId()
15
static int id_pointer = -1;
17
return QString::number( id_pointer );
20
void ImageProvider::addPixmap( const QString & id , const QPixmap & pixmap )
22
provider_pixmap_hash.insert( id , pixmap );
24
provider_pixmap_hash.remove( id );
27
QPixmap ImageProvider::pixmap( const QString & id )
29
return provider_pixmap_hash.value(id);
32
QPixmap ImageProvider::requestPixmap( const QString & id, QSize *size, const QSize & requestedSize )
38
*size = QSize(width, height);
40
QPixmap pixmap = provider_pixmap_hash.value(id).scaled( requestedSize.width() > 0 ? requestedSize.width() : width,
41
requestedSize.height() > 0 ? requestedSize.height() : height,
42
Qt::KeepAspectRatio , Qt::FastTransformation );
47
ImageProvider::~ImageProvider()