aboutsummaryrefslogtreecommitdiffstats
path: root/MainApp.h
blob: 909f68c045d0e35b4fbc17eca6b2de37bda93b7f (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef __MAINAPP_H__
#define __MAINAPP_H__

#include <QMainWindow>
#include <QtWidgets>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QMutex>
#include <QTreeWidget>
#include <vector>
#include "Business.h"
#include "InfoPanel.h"
#include "Keyboard.h"

#include <navigation.h>

typedef void (*NavWinRaiseCb_t)(void);

class MainApp: public QMainWindow
{
    Q_OBJECT

    public:
        explicit MainApp(Navigation *navigation);
        ~MainApp();
        int AuthenticatePOI(const QString & CredentialsFile);
        int StartMonitoringUserInput();
        void setInfoScreen(bool val) { isInfoScreen = val; }
        void setKeyboard(bool val)   { isKeyboard = val; }
        void setNavWindowRaiseCallback(NavWinRaiseCb_t val) { navWinRaiseCb = val; }

    private:
        void ParseJsonBusinessList(const char* buf, std::vector<Business> & Output);
        bool eventFilter(QObject *obj, QEvent *ev);
        void resizeEvent(QResizeEvent* event);
        void SetDestination(int index = 0);
        bool IsCoordinatesConsistent(Business & business);
        void DisplayLineEdit(bool display = true);
        void DisplayResultList(bool display);
        void DisplayInformation(bool display);
        int FillResultList(std::vector<Business> & list, int focusIndex = 0);
        void SetWayPoints(uint32_t myRoute);

        Navigation *naviapi;
        NavWinRaiseCb_t navWinRaiseCb = nullptr;
        QNetworkAccessManager networkManager;
        QPushButton searchBtn;
        QLineEdit lineEdit;
        Keyboard keyboard;
        QMutex mutex; // to protect pointers from concurrent access
        QString token;
        QString currentSearchingText;
        QString currentSearchedText;
        QNetworkReply *pSearchReply;
        InfoPanel *pInfoPanel;
        QTreeWidget *pResultList;
        double currentLatitude;
        double currentLongitude;
        double destinationLatitude;
        double destinationLongitude;
        uint32_t navicoreSession;
        uint32_t currentRouteHandle;
        int currentIndex;
        int fontId;
        bool isInfoScreen;
        bool isInputDisplayed;
        bool isKeyboard;
        bool isAglNavi;
        std::vector<Business> Businesses;
        QFont font;

    public:
        void getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions);
    //void getPosition_reply(std::map< int32_t, naviapi::variant > position);
    void getAllRoutes_reply(std::vector< uint32_t > allRoutes);
    void createRoute_reply(uint32_t routeHandle);

    private slots:
        void searchBtnClicked();
        void textChanged(const QString & text);
        void textAdded(const QString & text);
        void keyPressed(int key);
        void itemClicked();
        void networkReplySearch(QNetworkReply* reply);
        void UpdateAglSurfaces();
        void goClicked();
        void cancelClicked();
        void callNavWinRaiseCb() {
            if(navWinRaiseCb)
                navWinRaiseCb();
	}

        void positionGot();

    signals:
        void allSessionsGotSignal();
        void positionGotSignal();
        void allRoutesGotSignal();
        void routeCreatedSignal();
};

#endif // __MAINAPP_H__