poi-yelp: fix compile issue with SDK
[apps/poi-yelp.git] / MainApp.h
1 #ifndef __MAINAPP_H__
2 #define __MAINAPP_H__
3
4 #include <QMainWindow>
5 #include <QtWidgets>
6 #include <QNetworkAccessManager>
7 #include <QNetworkReply>
8 #include <QMutex>
9 #include <QTreeWidget>
10 #include <vector>
11 #include "Business.h"
12 #include "InfoPanel.h"
13 #include "Keyboard.h"
14
15 #include <libnavicore.hpp>
16
17 class MainApp: public QMainWindow, public naviapi::NavicoreListener
18 {
19     Q_OBJECT
20
21     public:
22         explicit MainApp();
23         ~MainApp();
24         bool CheckNaviApi(int argc, char *argv[]);
25         int AuthenticatePOI(const QString & CredentialsFile);
26         int StartMonitoringUserInput();
27         void setInfoScreen(bool val) { isInfoScreen = val; }
28         void setKeyboard(bool val)   { isKeyboard = val; }
29
30     private:
31         void ParseJsonBusinessList(const char* buf, std::vector<Business> & Output);
32         bool eventFilter(QObject *obj, QEvent *ev);
33         void resizeEvent(QResizeEvent* event);
34         void SetDestination(int index = 0);
35         bool IsCoordinatesConsistent(Business & business);
36         void DisplayLineEdit(bool display = true);
37         void DisplayResultList(bool display, bool RefreshDisplay = true);
38         void DisplayInformation(bool display, bool RefreshDisplay = true);
39         int FillResultList(std::vector<Business> & list, int focusIndex = 0);
40         void SetWayPoints(uint32_t myRoute);
41
42         naviapi::Navicore naviapi;
43         QNetworkAccessManager networkManager;
44         QPushButton searchBtn;
45         QLineEdit lineEdit;
46         Keyboard keyboard;
47         QMutex mutex; // to protect pointers from concurrent access
48         QString token;
49         QString currentSearchingText;
50         QString currentSearchedText;
51         QNetworkReply *pSearchReply;
52         InfoPanel *pInfoPanel;
53         QTreeWidget *pResultList;
54         double currentLatitude;
55         double currentLongitude;
56         double destinationLatitude;
57         double destinationLongitude;
58         uint32_t navicoreSession;
59         uint32_t currentRouteHandle;
60         int currentIndex;
61         int fontId;
62         bool isInfoScreen;
63         bool isInputDisplayed;
64         bool isKeyboard;
65         bool isAglNavi;
66         std::vector<Business> Businesses;
67         QFont font;
68
69     public:
70         void getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions);
71         void getPosition_reply(std::map< int32_t, naviapi::variant > position);
72         void getAllRoutes_reply(std::vector< uint32_t > allRoutes);
73         void createRoute_reply(uint32_t routeHandle);
74
75     private slots:
76         void searchBtnClicked();
77         void textChanged(const QString & text);
78         void textAdded(const QString & text);
79         void keyPressed(int key);
80         void itemClicked();
81         void networkReplySearch(QNetworkReply* reply);
82         void UpdateAglSurfaces();
83         void goClicked();
84         void cancelClicked();
85
86         void allSessionsGot();
87         void positionGot();
88         void allRoutesGot();
89         void routeCreated();
90
91     signals:
92         void allSessionsGotSignal();
93         void positionGotSignal();
94         void allRoutesGotSignal();
95         void routeCreatedSignal();
96 };
97
98 #endif // __MAINAPP_H__