// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef EXAMPLEITEM_H
#define EXAMPLEITEM_H

#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QTimer>
#include <QtCore/QAbstractItemModel>
#include <QtDeclarative/QDeclarativeItem>

class MapView : public QDeclarativeItem
{
    Q_OBJECT

    Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
    Q_PROPERTY(int blockSize READ blockSize WRITE setBlockSize NOTIFY blockSizeChanged)

public:
    MapView(QDeclarativeItem *parent = 0);

    virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);

    QVariant model() const;
    void setModel(QVariant);

    int blockSize() const;
    void setBlockSize(int);

signals:
    void modelChanged();
    void blockSizeChanged();

private slots:
    void triggerUpdate();
    void updateImplicitSize();

private:
    QPixmap m_pixmap;
    QVariant m_modelVariant;
    QAbstractItemModel *m_model;

    int m_blockSize;

    Q_DISABLE_COPY(MapView)
};

#endif // EXAMPLEITEM_H
