#include <QQuickItem>
#include <QtWidgets/QApplication>
#include <QQmlApplicationEngine>
#include <QQmlEngine>
#include <QQmlContext>
#include <QtPrintSupport/QPrinter>
#include "anchor.h"
#include "tag.h"
#include "customplotitem.h"

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    //QGuiApplication app(argc, argv);
    QApplication app(argc, argv);

    QScopedPointer<Anchor> anchor0T0(new Anchor);
    QScopedPointer<Anchor> anchor1T0(new Anchor);
    QScopedPointer<Anchor> anchor2T0(new Anchor);
    QScopedPointer<Anchor> anchor3T0(new Anchor);
    QScopedPointer<Anchor> anchor4T0(new Anchor);
    anchor0T0->setXY(0.1,4);
    anchor1T0->setXY(5.5,0.7);
    anchor2T0->setXY(4,7.5);
    anchor3T0->setXY(9,0.5);
    anchor4T0->setXY(9,5);


    QScopedPointer<Anchor> anchor0T1(new Anchor);
    QScopedPointer<Anchor> anchor1T1(new Anchor);
    QScopedPointer<Anchor> anchor2T1(new Anchor);
    QScopedPointer<Anchor> anchor3T1(new Anchor);
    QScopedPointer<Anchor> anchor4T1(new Anchor);
    anchor0T1->setXY(0.1,4);
    anchor1T1->setXY(5.5,0.7);
    anchor2T1->setXY(4,7.5);
    anchor3T1->setXY(9,0.5);
    anchor4T1->setXY(9,5);

    QScopedPointer<Anchor> anchor0T2(new Anchor);
    QScopedPointer<Anchor> anchor1T2(new Anchor);
    QScopedPointer<Anchor> anchor2T2(new Anchor);
    QScopedPointer<Anchor> anchor3T2(new Anchor);
    QScopedPointer<Anchor> anchor4T2(new Anchor);
    anchor0T2->setXY(0.1,4);
    anchor1T2->setXY(5.5,0.7);
    anchor2T2->setXY(4,7.5);
    anchor3T2->setXY(9,0.5);
    anchor4T2->setXY(9,5);

    QScopedPointer<Tag> tag0(new Tag);
    QScopedPointer<Tag> tag1(new Tag);
    QScopedPointer<Tag> tag2(new Tag);
    QScopedPointer<Tag> tag3(new Tag);
    tag0->setName("C7:53:A9:74:77:AF");
    tag1->setName("C7:53:A8:68:71:BE");
    tag2->setName("C7:53:A8:74:75:AE");

    qmlRegisterType<CustomPlotItem>("CustomPlot", 1, 0, "CustomPlotItem");

    QQmlApplicationEngine engine;
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));

    tag0->setCoordinates(49.226001,16.575552);
    tag1->setCoordinates(49.222729,16.582327);
    tag2->setCoordinates(49.629348,15.382387);

    engine.rootContext()->setContextProperty("tag0",tag0.data());
    engine.rootContext()->setContextProperty("tag1",tag1.data());
    engine.rootContext()->setContextProperty("tag2",tag2.data());

    engine.rootContext()->setContextProperty("anchor0T0",anchor0T0.data());
    engine.rootContext()->setContextProperty("anchor1T0",anchor1T0.data());
    engine.rootContext()->setContextProperty("anchor2T0",anchor2T0.data());
    engine.rootContext()->setContextProperty("anchor3T0",anchor3T0.data());
    engine.rootContext()->setContextProperty("anchor4T0",anchor4T0.data());

    engine.rootContext()->setContextProperty("anchor0T1",anchor0T1.data());
    engine.rootContext()->setContextProperty("anchor1T1",anchor1T1.data());
    engine.rootContext()->setContextProperty("anchor2T1",anchor2T1.data());
    engine.rootContext()->setContextProperty("anchor3T1",anchor3T1.data());
    engine.rootContext()->setContextProperty("anchor4T1",anchor4T1.data());

    engine.rootContext()->setContextProperty("anchor0T2",anchor0T2.data());
    engine.rootContext()->setContextProperty("anchor1T2",anchor1T2.data());
    engine.rootContext()->setContextProperty("anchor2T2",anchor2T2.data());
    engine.rootContext()->setContextProperty("anchor3T2",anchor3T2.data());
    engine.rootContext()->setContextProperty("anchor4T2",anchor4T2.data());

    return app.exec();
}
