Initial import from qtquick2.
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsgimagebase_p.h
1 // Commit: ab71df83ba4eb9d749efc0f3a2d4a0fe5486023f
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 **
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
15 ** this package.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QSGIMAGEBASE_P_H
44 #define QSGIMAGEBASE_P_H
45
46 #include "qsgimplicitsizeitem_p.h"
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52 class QSGImageBasePrivate;
53 class Q_AUTOTEST_EXPORT QSGImageBase : public QSGImplicitSizeItem
54 {
55     Q_OBJECT
56     Q_ENUMS(Status)
57
58     Q_PROPERTY(Status status READ status NOTIFY statusChanged)
59     Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
60     Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
61     Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
62     Q_PROPERTY(bool cache READ cache WRITE setCache NOTIFY cacheChanged)
63     Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged)
64     Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged)
65
66 public:
67     QSGImageBase(QSGItem *parent=0);
68     ~QSGImageBase();
69     enum Status { Null, Ready, Loading, Error };
70     Status status() const;
71     qreal progress() const;
72
73     QUrl source() const;
74     virtual void setSource(const QUrl &url);
75
76     bool asynchronous() const;
77     void setAsynchronous(bool);
78
79     bool cache() const;
80     void setCache(bool);
81
82     virtual void setSourceSize(const QSize&);
83     QSize sourceSize() const;
84
85     virtual void setMirror(bool mirror);
86     bool mirror() const;
87
88 Q_SIGNALS:
89     void sourceChanged(const QUrl &);
90     void sourceSizeChanged();
91     void statusChanged(QSGImageBase::Status);
92     void progressChanged(qreal progress);
93     void asynchronousChanged();
94     void cacheChanged();
95     void mirrorChanged();
96
97 protected:
98     virtual void load();
99     virtual void componentComplete();
100     virtual void pixmapChange();
101     QSGImageBase(QSGImageBasePrivate &dd, QSGItem *parent);
102
103 private Q_SLOTS:
104     virtual void requestFinished();
105     void requestProgress(qint64,qint64);
106
107 private:
108     Q_DISABLE_COPY(QSGImageBase)
109     Q_DECLARE_PRIVATE(QSGImageBase)
110 };
111
112 QT_END_NAMESPACE
113
114 QT_END_HEADER
115
116 #endif // QSGIMAGEBASE_P_H