summaryrefslogtreecommitdiffstats
path: root/examples/qmlListView/creator.h
blob: 6f081fb67f678dc53b3bd6befa3597ec0cd7865b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef _CREATOR_H
#define _CREATOR_H

#include <qgraphicslistview.h>

class QmlEngine;
class QmlComponent;
class QmlContext;
class Context;

class Creator : public QtGraphicsListViewItemCreatorBase
{
public:
    Creator(QmlEngine *engine, QmlComponent *component);
    ~Creator();

    // creator api
    QGraphicsObject *create(int index, QtGraphicsListView *view);
    QGraphicsObject *reassign(int index, QGraphicsObject *item, QtGraphicsListView *view);
    void recycle(QGraphicsObject *item, QtGraphicsListView *view);

    // FIXME: make the creator a qobject and connect to itemsChanged
    // the creator should keep a list of active objects so it can
    // update the data in items that change in the model

private:
    void setContextProperties(int index, QmlContext *context, QtGraphicsListView *view) const;
    QmlEngine *m_engine;
    QmlComponent *m_component;
    QHash<QGraphicsObject*, Context*> m_contexts;
};

#endif // _CREATOR_H