src/declarative/util/qdeclarativepixmapcache_p.h
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QDECLARATIVEPIXMAPCACHE_H
       
    43 #define QDECLARATIVEPIXMAPCACHE_H
       
    44 
       
    45 #include <QtCore/QString>
       
    46 #include <QtGui/QPixmap>
       
    47 #include <QtCore/qurl.h>
       
    48 #include <QtCore/QCoreApplication>
       
    49 
       
    50 QT_BEGIN_HEADER
       
    51 
       
    52 QT_BEGIN_NAMESPACE
       
    53 
       
    54 QT_MODULE(Declarative)
       
    55 class QDeclarativeEngine;
       
    56 class QNetworkReply;
       
    57 class QDeclarativeImageReader;
       
    58 
       
    59 class QDeclarativePixmapReplyPrivate;
       
    60 class Q_DECLARATIVE_EXPORT QDeclarativePixmapReply : public QObject
       
    61 {
       
    62     Q_OBJECT
       
    63 public:
       
    64     ~QDeclarativePixmapReply();
       
    65 
       
    66     enum Status { Ready, Error, Unrequested, Loading };
       
    67     Status status() const;
       
    68     QString errorString() const;
       
    69 
       
    70     const QUrl &url() const;
       
    71     int forcedWidth() const;
       
    72     int forcedHeight() const;
       
    73     QSize implicitSize() const;
       
    74 
       
    75 Q_SIGNALS:
       
    76     void finished();
       
    77     void downloadProgress(qint64, qint64);
       
    78 
       
    79 protected:
       
    80     bool event(QEvent *event);
       
    81 
       
    82 private:
       
    83     void addRef();
       
    84     bool release(bool defer=false);
       
    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 };
       
    96 
       
    97 class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache
       
    98 {
       
    99     Q_DECLARE_TR_FUNCTIONS(QDeclarativePixmapCache)
       
   100 public:
       
   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 QT_END_NAMESPACE
       
   110 
       
   111 QT_END_HEADER
       
   112 
       
   113 #endif // QDECLARATIVEPIXMAPCACHE_H