1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Declarative module of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef DATAPARTICLE_H
43 #define DATAPARTICLE_H
51 QT_MODULE(Declarative)
52 class QSGVisualDataModel;
53 class DataParticleAttached;
55 class DataParticle : public ParticleType
59 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
60 Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
61 Q_PROPERTY(int modelCount READ modelCount NOTIFY modelCountChanged)
62 Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
63 Q_CLASSINFO("DefaultProperty", "delegate")
65 explicit DataParticle(QSGItem *parent = 0);
66 QVariant model() const;
67 void setModel(const QVariant &);
69 QDeclarativeComponent *delegate() const;
70 void setDelegate(QDeclarativeComponent *);
72 int modelCount() const;
74 bool fade() const { return m_fade; }
76 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
77 virtual void load(ParticleData*);
78 virtual void reload(ParticleData*);
79 virtual void setCount(int c);
82 static DataParticleAttached *qmlAttachedProperties(QObject *object);
85 void delegateChanged();
86 void modelCountChanged();
90 void freeze(QSGItem* item);
91 void unfreeze(QSGItem* item);
93 void setFade(bool arg){if(arg == m_fade) return; m_fade = arg; emit fadeChanged();}
96 void prepareNextFrame();
101 QDeclarativeComponent* m_comp;
102 QSGVisualDataModel *m_model;
103 QVariant m_dataSource;
104 QList<QPointer<QSGItem> > m_deletables;
108 QList<QSGItem*> m_pendingItems;
109 QVector<QSGItem*> m_items;
110 QVector<ParticleData*> m_data;
112 QList<int> m_available;
113 QSet<QSGItem*> m_stasis;
119 class DataParticleAttached : public QObject
122 Q_PROPERTY(DataParticle* particle READ particle CONSTANT);
124 DataParticleAttached(QObject* parent)
125 : QObject(parent), m_mp(0)
127 DataParticle* particle() {return m_mp;}
128 void detach(){emit detached();}
129 void attach(){emit attached();}
132 friend class DataParticle;
140 QML_DECLARE_TYPEINFO(DataParticle, QML_HAS_ATTACHED_PROPERTIES)
143 #endif // DATAPARTICLE_H