Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | List of all members
QDeclarativePixmap Class Reference

#include <qdeclarativepixmapcache_p.h>

Public Types

enum  Option { Asynchronous = 0x00000001, Cache = 0x00000002 }
 
enum  Status { Null, Ready, Error, Loading }
 

Public Functions

void clear ()
 
void clear (QObject *)
 
bool connectDownloadProgress (QObject *, const char *)
 
bool connectDownloadProgress (QObject *, int)
 
bool connectFinished (QObject *, const char *)
 
bool connectFinished (QObject *, int)
 
QString error () const
 
int height () const
 
const QSize & implicitSize () const
 
bool isError () const
 
bool isLoading () const
 
bool isNull () const
 
bool isReady () const
 
void load (QDeclarativeEngine *, const QUrl &)
 
void load (QDeclarativeEngine *, const QUrl &, QDeclarativePixmap::Options options)
 
void load (QDeclarativeEngine *, const QUrl &, const QSize &)
 
void load (QDeclarativeEngine *, const QUrl &, const QSize &, QDeclarativePixmap::Options options)
 
 operator const QPixmap & () const
 
const QPixmap & pixmap () const
 
 QDeclarativePixmap ()
 
 QDeclarativePixmap (QDeclarativeEngine *, const QUrl &)
 
 QDeclarativePixmap (QDeclarativeEngine *, const QUrl &, const QSize &)
 
QRect rect () const
 
const QSize & requestSize () const
 
void setPixmap (const QPixmap &)
 
Status status () const
 
const QUrl & url () const
 
int width () const
 
 ~QDeclarativePixmap ()
 

Static Public Functions

static void flushCache ()
 

Properties

QDeclarativePixmapData * d
 

Detailed Description

Definition at line 58 of file qdeclarativepixmapcache_p.h.

Enumerations

◆ Option

Enumerator
Asynchronous 
Cache 

Definition at line 69 of file qdeclarativepixmapcache_p.h.

◆ Status

Constructors and Destructors

◆ QDeclarativePixmap() [1/3]

QDeclarativePixmap::QDeclarativePixmap ( )

Definition at line 869 of file qdeclarativepixmapcache.cpp.

870 : d(0)
871 {
872 }
QDeclarativePixmapData * d

◆ QDeclarativePixmap() [2/3]

QDeclarativePixmap::QDeclarativePixmap ( QDeclarativeEngine *  engine,
const QUrl &  url 
)

Definition at line 874 of file qdeclarativepixmapcache.cpp.

875 : d(0)
876 {
877  load(engine, url);
878 }
QDeclarativePixmapData * d
void load(QDeclarativeEngine *, const QUrl &)

◆ QDeclarativePixmap() [3/3]

QDeclarativePixmap::QDeclarativePixmap ( QDeclarativeEngine *  engine,
const QUrl &  url,
const QSize &  size 
)

Definition at line 880 of file qdeclarativepixmapcache.cpp.

881 : d(0)
882 {
883  load(engine, url, size);
884 }
QDeclarativePixmapData * d
void load(QDeclarativeEngine *, const QUrl &)

◆ ~QDeclarativePixmap()

QDeclarativePixmap::~QDeclarativePixmap ( )

Definition at line 886 of file qdeclarativepixmapcache.cpp.

Referenced by load().

887 {
888  if (d) {
889  d->release();
890  d = 0;
891  }
892 }
QDeclarativePixmapData * d

Functions

◆ clear() [1/2]

void QDeclarativePixmap::clear ( )

Definition at line 1054 of file qdeclarativepixmapcache.cpp.

Referenced by setPixmap().

1055 {
1056  if (d) {
1057  d->release();
1058  d = 0;
1059  }
1060 }
QDeclarativePixmapData * d

◆ clear() [2/2]

void QDeclarativePixmap::clear ( QObject *  obj)

Definition at line 1062 of file qdeclarativepixmapcache.cpp.

1063 {
1064  if (d) {
1065  if (d->reply)
1066  QObject::disconnect(d->reply, 0, obj, 0);
1067  d->release();
1068  d = 0;
1069  }
1070 }
QDeclarativePixmapData * d
QDeclarativePixmapReply * reply
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895

◆ connectDownloadProgress() [1/2]

bool QDeclarativePixmap::connectDownloadProgress ( QObject *  object,
const char *  method 
)

Definition at line 1092 of file qdeclarativepixmapcache.cpp.

1093 {
1094  if (!d || !d->reply) {
1095  qWarning("QDeclarativePixmap: connectDownloadProgress() called when not loading.");
1096  return false;
1097  }
1098 
1099  return QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), object, method);
1100 }
QDeclarativePixmapData * d
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QDeclarativePixmapReply * reply
Q_CORE_EXPORT void qWarning(const char *,...)
__int64 qint64
Definition: qglobal.h:942

◆ connectDownloadProgress() [2/2]

bool QDeclarativePixmap::connectDownloadProgress ( QObject *  object,
int  method 
)

Definition at line 1102 of file qdeclarativepixmapcache.cpp.

1103 {
1104  if (!d || !d->reply) {
1105  qWarning("QDeclarativePixmap: connectDownloadProgress() called when not loading.");
1106  return false;
1107  }
1108 
1110 }
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Definition: qobject.cpp:3194
QDeclarativePixmapData * d
QDeclarativePixmapReply * reply
Q_CORE_EXPORT void qWarning(const char *,...)

◆ connectFinished() [1/2]

bool QDeclarativePixmap::connectFinished ( QObject *  object,
const char *  method 
)

Definition at line 1072 of file qdeclarativepixmapcache.cpp.

Referenced by QTextDocumentWithImageResources::loadResource().

1073 {
1074  if (!d || !d->reply) {
1075  qWarning("QDeclarativePixmap: connectFinished() called when not loading.");
1076  return false;
1077  }
1078 
1079  return QObject::connect(d->reply, SIGNAL(finished()), object, method);
1080 }
QDeclarativePixmapData * d
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QDeclarativePixmapReply * reply
Q_CORE_EXPORT void qWarning(const char *,...)

◆ connectFinished() [2/2]

bool QDeclarativePixmap::connectFinished ( QObject *  object,
int  method 
)

Definition at line 1082 of file qdeclarativepixmapcache.cpp.

1083 {
1084  if (!d || !d->reply) {
1085  qWarning("QDeclarativePixmap: connectFinished() called when not loading.");
1086  return false;
1087  }
1088 
1090 }
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Definition: qobject.cpp:3194
QDeclarativePixmapData * d
QDeclarativePixmapReply * reply
Q_CORE_EXPORT void qWarning(const char *,...)

◆ error()

QString QDeclarativePixmap::error ( ) const

Definition at line 914 of file qdeclarativepixmapcache.cpp.

Referenced by QTextDocumentWithImageResources::loadResource().

915 {
916  if (d)
917  return d->errorString;
918  else
919  return QString();
920 }
QDeclarativePixmapData * d
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ flushCache()

void QDeclarativePixmap::flushCache ( )
static

Definition at line 1112 of file qdeclarativepixmapcache.cpp.

1113 {
1114  pixmapStore()->flushCache();
1115 }

◆ height()

int QDeclarativePixmap::height ( ) const

Definition at line 978 of file qdeclarativepixmapcache.cpp.

979 {
980  if (d)
981  return d->pixmap.height();
982  else
983  return 0;
984 }
QDeclarativePixmapData * d
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645

◆ implicitSize()

const QSize & QDeclarativePixmap::implicitSize ( ) const

Definition at line 938 of file qdeclarativepixmapcache.cpp.

939 {
940  if (d)
941  return d->implicitSize;
942  else
943  return nullPixmap()->size;
944 }
QDeclarativePixmapData * d

◆ isError()

bool QDeclarativePixmap::isError ( ) const

◆ isLoading()

bool QDeclarativePixmap::isLoading ( ) const

◆ isNull()

bool QDeclarativePixmap::isNull ( ) const

Definition at line 894 of file qdeclarativepixmapcache.cpp.

895 {
896  return d == 0;
897 }
QDeclarativePixmapData * d

◆ isReady()

bool QDeclarativePixmap::isReady ( ) const

◆ load() [1/4]

void QDeclarativePixmap::load ( QDeclarativeEngine *  engine,
const QUrl &  url 
)

Definition at line 994 of file qdeclarativepixmapcache.cpp.

Referenced by load(), and QDeclarativePixmap().

995 {
996  load(engine, url, QSize(), QDeclarativePixmap::Cache);
997 }
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void load(QDeclarativeEngine *, const QUrl &)

◆ load() [2/4]

void QDeclarativePixmap::load ( QDeclarativeEngine *  engine,
const QUrl &  url,
QDeclarativePixmap::Options  options 
)

Definition at line 999 of file qdeclarativepixmapcache.cpp.

1000 {
1001  load(engine, url, QSize(), options);
1002 }
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void load(QDeclarativeEngine *, const QUrl &)

◆ load() [3/4]

void QDeclarativePixmap::load ( QDeclarativeEngine *  engine,
const QUrl &  url,
const QSize &  size 
)

Definition at line 1004 of file qdeclarativepixmapcache.cpp.

1005 {
1006  load(engine, url, size, QDeclarativePixmap::Cache);
1007 }
void load(QDeclarativeEngine *, const QUrl &)

◆ load() [4/4]

void QDeclarativePixmap::load ( QDeclarativeEngine *  engine,
const QUrl &  url,
const QSize &  requestSize,
QDeclarativePixmap::Options  options 
)

Definition at line 1009 of file qdeclarativepixmapcache.cpp.

1010 {
1011  if (d) { d->release(); d = 0; }
1012 
1013  QDeclarativePixmapKey key = { &url, &requestSize };
1014  QDeclarativePixmapStore *store = pixmapStore();
1015 
1017 
1018  if (iter == store->m_cache.end()) {
1019  if (options & QDeclarativePixmap::Asynchronous) {
1020  // pixmaps can only be loaded synchronously
1021  if (url.scheme() == QLatin1String("image")
1024  }
1025  }
1026 
1027  if (!(options & QDeclarativePixmap::Asynchronous)) {
1028  bool ok = false;
1029  d = createPixmapDataSync(engine, url, requestSize, &ok);
1030  if (ok) {
1031  if (options & QDeclarativePixmap::Cache)
1032  d->addToCache();
1033  return;
1034  }
1035  if (d) // loadable, but encountered error while loading
1036  return;
1037  }
1038 
1039  if (!engine)
1040  return;
1041 
1042  d = new QDeclarativePixmapData(url, requestSize);
1043  if (options & QDeclarativePixmap::Cache)
1044  d->addToCache();
1048  } else {
1049  d = *iter;
1050  d->addref();
1051  }
1052 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
QDeclarativePixmapData * d
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
const QUrl & url() const
QDeclarativeImageProvider::ImageType getImageProviderType(const QUrl &url)
QDeclarativePixmapReply * reply
QDeclarativePixmapReply * getImage(QDeclarativePixmapData *)
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
#define store(x)
int key
static QDeclarativePixmapData * createPixmapDataSync(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, bool *ok)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
QHash< QDeclarativePixmapKey, QDeclarativePixmapData * > m_cache
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
static QDeclarativePixmapReader * instance(QDeclarativeEngine *engine)

◆ operator const QPixmap &()

QDeclarativePixmap::operator const QPixmap & ( ) const
inline

Definition at line 113 of file qdeclarativepixmapcache_p.h.

114 {
115  return pixmap();
116 }
const QPixmap & pixmap() const

◆ pixmap()

const QPixmap & QDeclarativePixmap::pixmap ( ) const

Definition at line 954 of file qdeclarativepixmapcache.cpp.

Referenced by QTextDocumentWithImageResources::loadResource().

955 {
956  if (d)
957  return d->pixmap;
958  else
959  return nullPixmap()->pixmap;
960 }
QDeclarativePixmapData * d

◆ rect()

QRect QDeclarativePixmap::rect ( ) const

Definition at line 986 of file qdeclarativepixmapcache.cpp.

987 {
988  if (d)
989  return d->pixmap.rect();
990  else
991  return QRect();
992 }
QDeclarativePixmapData * d
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676

◆ requestSize()

const QSize & QDeclarativePixmap::requestSize ( ) const

Definition at line 946 of file qdeclarativepixmapcache.cpp.

947 {
948  if (d)
949  return d->requestSize;
950  else
951  return nullPixmap()->size;
952 }
QDeclarativePixmapData * d

◆ setPixmap()

void QDeclarativePixmap::setPixmap ( const QPixmap &  p)

Definition at line 962 of file qdeclarativepixmapcache.cpp.

963 {
964  clear();
965 
966  if (!p.isNull())
967  d = new QDeclarativePixmapData(p);
968 }
QDeclarativePixmapData * d
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

◆ status()

QDeclarativePixmap::Status QDeclarativePixmap::status ( ) const

Definition at line 922 of file qdeclarativepixmapcache.cpp.

Referenced by isError(), isLoading(), and isReady().

923 {
924  if (d)
925  return d->pixmapStatus;
926  else
927  return Null;
928 }
QDeclarativePixmapData * d
QDeclarativePixmap::Status pixmapStatus

◆ url()

const QUrl & QDeclarativePixmap::url ( ) const

Definition at line 930 of file qdeclarativepixmapcache.cpp.

Referenced by load().

931 {
932  if (d)
933  return d->url;
934  else
935  return nullPixmap()->url;
936 }
QDeclarativePixmapData * d

◆ width()

int QDeclarativePixmap::width ( ) const

Definition at line 970 of file qdeclarativepixmapcache.cpp.

971 {
972  if (d)
973  return d->pixmap.width();
974  else
975  return 0;
976 }
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QDeclarativePixmapData * d

Properties

◆ d

QDeclarativePixmapData* QDeclarativePixmap::d
private

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