#ifndef QAUGMENTEDREALITYCAMERA_H
#define QAUGMENTEDREALITYCAMERA_H

/*#include <QtDeclarative>
#include <QDeclarativeEngine>

#include <QList>
#include <QDeclarativeExtensionPlugin>
*/

#include "QNativeCamera.h"

#include <QGeoPositionInfo>
#include <QGeoPositionInfoSource>

QTM_USE_NAMESPACE

#include "qdll_global.h"

#include "accelerometerinfo.h"
#include "compassinfo.h"
#include "qaugmentedrealitycameraitem.h"
#include "qaugmentedrealitycameradelegate.h"
#include "qaugmentedrealitycameramodel.h"

// http://qt-project.org/forums/viewthread/14464
// http://doc.qt.nokia.com/4.7-snapshot/declarative-tutorials-extending-chapter6-plugins.html
// http://doc.qt.nokia.com/4.7-snapshot/declarative-cppextensions-plugins-plugin-cpp.html
// http://cdumez.blogspot.it/2010/11/how-to-use-c-list-model-in-qml.html

class QDLLSHARED_EXPORT QAugmentedRealityCamera : public QNativeCamera
{
    Q_OBJECT
    Q_CLASSINFO("Author", "Sebastiano Galazzo")
    Q_CLASSINFO("Email", "sebastiano.galazzo@gmail.com")

    //Q_PROPERTY(QVariantList model READ getModel WRITE setModel NOTIFY modelChanged)
    Q_PROPERTY(QAugmentedRealityCameraModel* model READ getModel WRITE setModel NOTIFY modelChanged)
    //Q_PROPERTY(QDeclarativeComponent* delegate READ getDelegate WRITE setDelegate NOTIFY delegateChanged)
    //Q_PROPERTY(QAugmentedRealityCameraDelegate* delegate READ getDelegate WRITE setDelegate NOTIFY delegateChanged)
    Q_PROPERTY(int distance READ distance WRITE setDistance)

public:
    explicit QAugmentedRealityCamera(QDeclarativeItem *parent = 0);

   /*void setModel(QVariantList const &m_data);
    QVariantList getModel() const;*/

    void setModel(QAugmentedRealityCameraModel* model);
    QAugmentedRealityCameraModel *getModel() const;

   /* void setItemDelegate(QAbstractItemDelegate *delegate);
    QAbstractItemDelegate *itemDelegate() const;*/

    //void setDelegate(QAugmentedRealityCameraDelegate *delegate);
    //QAugmentedRealityCameraDelegate *getDelegate() const;

    //void setDelegate(QObject *delegate);
    //void setDelegate(QDeclarativeComponent *delegate);
   // QDeclarativeComponent *getDelegate() const;

    /**
      * filtering distance in meters
      */
    int distance();
    /**
      * set filtering distance in meters
      */
    void setDistance(int value);

    void paint(QPainter *painter,
                       const QStyleOptionGraphicsItem *option,
                       QWidget *widget);

signals:
    void modelChanged();
    void delegateChanged(QDeclarativeComponent *delegate);

public slots:
    void captureImage();
    void imageAvailable(int,QVideoFrame);

private slots:
     void positionUpdated(const QGeoPositionInfo &info);

private:
    int m_distance;
    AccelerometerInfo m_accelerometer;
    CompassInfo m_compass;

    QGeoPositionInfo position;

    //QVariantList m_data;
    QAugmentedRealityCameraModel* m_data;

    //QDeclarativeComponent *m_delegate;
    QAugmentedRealityCameraDelegate* m_delegate;

private:
    void drawPins(QPainter *painter);
};

#endif // QAUGMENTEDREALITYCAMERA_H
