40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #ifndef QDECLARATIVEPIXMAPCACHE_H |
42 #ifndef QDECLARATIVEPIXMAPCACHE_H |
43 #define QDECLARATIVEPIXMAPCACHE_H |
43 #define QDECLARATIVEPIXMAPCACHE_H |
44 |
44 |
45 #include <QtCore/QString> |
45 #include <QtCore/qcoreapplication.h> |
46 #include <QtGui/QPixmap> |
46 #include <QtCore/qstring.h> |
|
47 #include <QtGui/qpixmap.h> |
47 #include <QtCore/qurl.h> |
48 #include <QtCore/qurl.h> |
48 #include <QtCore/QCoreApplication> |
|
49 |
49 |
50 QT_BEGIN_HEADER |
50 QT_BEGIN_HEADER |
51 |
51 |
52 QT_BEGIN_NAMESPACE |
52 QT_BEGIN_NAMESPACE |
53 |
53 |
54 QT_MODULE(Declarative) |
54 QT_MODULE(Declarative) |
|
55 |
55 class QDeclarativeEngine; |
56 class QDeclarativeEngine; |
56 class QNetworkReply; |
57 class QDeclarativePixmapData; |
57 class QDeclarativeImageReader; |
58 class Q_DECLARATIVE_EXPORT QDeclarativePixmap |
|
59 { |
|
60 Q_DECLARE_TR_FUNCTIONS(QDeclarativePixmap) |
|
61 public: |
|
62 QDeclarativePixmap(); |
|
63 QDeclarativePixmap(QDeclarativeEngine *, const QUrl &); |
|
64 QDeclarativePixmap(QDeclarativeEngine *, const QUrl &, const QSize &); |
|
65 ~QDeclarativePixmap(); |
58 |
66 |
59 class QDeclarativePixmapReplyPrivate; |
67 enum Status { Null, Ready, Error, Loading }; |
60 class Q_DECLARATIVE_EXPORT QDeclarativePixmapReply : public QObject |
|
61 { |
|
62 Q_OBJECT |
|
63 public: |
|
64 ~QDeclarativePixmapReply(); |
|
65 |
68 |
66 enum Status { Ready, Error, Unrequested, Loading }; |
69 bool isNull() const; |
|
70 bool isReady() const; |
|
71 bool isError() const; |
|
72 bool isLoading() const; |
|
73 |
67 Status status() const; |
74 Status status() const; |
68 QString errorString() const; |
75 QString error() const; |
|
76 const QUrl &url() const; |
|
77 const QSize &implicitSize() const; |
|
78 const QSize &requestSize() const; |
|
79 const QPixmap &pixmap() const; |
|
80 void setPixmap(const QPixmap &); |
69 |
81 |
70 const QUrl &url() const; |
82 QRect rect() const; |
71 int forcedWidth() const; |
83 int width() const; |
72 int forcedHeight() const; |
84 int height() const; |
73 QSize implicitSize() const; |
85 inline operator const QPixmap &() const; |
74 |
86 |
75 Q_SIGNALS: |
87 void load(QDeclarativeEngine *, const QUrl &); |
76 void finished(); |
88 void load(QDeclarativeEngine *, const QUrl &, bool); |
77 void downloadProgress(qint64, qint64); |
89 void load(QDeclarativeEngine *, const QUrl &, const QSize &); |
|
90 void load(QDeclarativeEngine *, const QUrl &, const QSize &, bool); |
78 |
91 |
79 protected: |
92 void clear(); |
80 bool event(QEvent *event); |
93 void clear(QObject *); |
|
94 |
|
95 bool connectFinished(QObject *, const char *); |
|
96 bool connectFinished(QObject *, int); |
|
97 bool connectDownloadProgress(QObject *, const char *); |
|
98 bool connectDownloadProgress(QObject *, int); |
81 |
99 |
82 private: |
100 private: |
83 void addRef(); |
101 Q_DISABLE_COPY(QDeclarativePixmap); |
84 bool release(bool defer=false); |
102 QDeclarativePixmapData *d; |
85 bool isLoading() const; |
|
86 void setLoading(); |
|
87 |
|
88 private: |
|
89 QDeclarativePixmapReply(QDeclarativeImageReader *reader, const QUrl &url, int req_width, int req_height); |
|
90 Q_DISABLE_COPY(QDeclarativePixmapReply) |
|
91 Q_DECLARE_PRIVATE(QDeclarativePixmapReply) |
|
92 friend class QDeclarativeImageRequestHandler; |
|
93 friend class QDeclarativeImageReader; |
|
94 friend class QDeclarativePixmapCache; |
|
95 }; |
103 }; |
96 |
104 |
97 class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache |
105 inline QDeclarativePixmap::operator const QPixmap &() const |
98 { |
106 { |
99 Q_DECLARE_TR_FUNCTIONS(QDeclarativePixmapCache) |
107 return pixmap(); |
100 public: |
108 } |
101 static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); |
|
102 static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0); |
|
103 static void cancel(const QUrl& url, QObject *obj); |
|
104 static int pendingRequests(); |
|
105 }; |
|
106 |
|
107 |
|
108 |
109 |
109 QT_END_NAMESPACE |
110 QT_END_NAMESPACE |
110 |
111 |
111 QT_END_HEADER |
112 QT_END_HEADER |
112 |
113 |