Add gitlab issue/merge request templates
[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 <navigation.h>
16
17 typedef void (*NavWinRaiseCb_t)(void);
18
19 class MainApp: public QMainWindow
20 {
21     Q_OBJECT
22
23     public:
24         explicit MainApp(Navigation *navigation);
25         ~MainApp();
26         int AuthenticatePOI(const QString & CredentialsFile);
27         int StartMonitoringUserInput();
28         void setInfoScreen(bool val) { isInfoScreen = val; }
29         void setKeyboard(bool val)   { isKeyboard = val; }
30         void setNavWindowRaiseCallback(NavWinRaiseCb_t val) { navWinRaiseCb = val; }
31
32     private:
33         void ParseJsonBusinessList(const char* buf, std::vector<Business> & Output);
34         bool eventFilter(QObject *obj, QEvent *ev);
35         void resizeEvent(QResizeEvent* event);
36         void SetDestination(int index = 0);
37         bool IsCoordinatesConsistent(Business & business);
38         void DisplayLineEdit(bool display = true);
39         void DisplayResultList(bool display);
40         void DisplayInformation(bool display);
41         int FillResultList(std::vector<Business> & list, int focusIndex = 0);
42         void SetWayPoints(uint32_t myRoute);
43
44         Navigation *naviapi;
45         NavWinRaiseCb_t navWinRaiseCb = nullptr;
46         QNetworkAccessManager networkManager;
47         QPushButton searchBtn;
48         QLineEdit lineEdit;
49         Keyboard keyboard;
50         QMutex mutex; // to protect pointers from concurrent access
51         QString token;
52         QString currentSearchingText;
53         QString currentSearchedText;
54         QNetworkReply *pSearchReply;
55         InfoPanel *pInfoPanel;
56         QTreeWidget *pResultList;
57         double currentLatitude;
58         double currentLongitude;
59         double destinationLatitude;
60         double destinationLongitude;
61         uint32_t navicoreSession;
62         uint32_t currentRouteHandle;
63         int currentIndex;
64         int fontId;
65         bool isInfoScreen;
66         bool isInputDisplayed;
67         bool isKeyboard;
68         bool isAglNavi;
69         std::vector<Business> Businesses;
70         QFont font;
71
72     public:
73         void getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions);
74     //void getPosition_reply(std::map< int32_t, naviapi::variant > position);
75     void getAllRoutes_reply(std::vector< uint32_t > allRoutes);
76     void createRoute_reply(uint32_t routeHandle);
77
78     private slots:
79         void searchBtnClicked();
80         void textChanged(const QString & text);
81         void textAdded(const QString & text);
82         void keyPressed(int key);
83         void itemClicked();
84         void networkReplySearch(QNetworkReply* reply);
85         void UpdateAglSurfaces();
86         void goClicked();
87         void cancelClicked();
88         void callNavWinRaiseCb() {
89             if(navWinRaiseCb)
90                 navWinRaiseCb();
91         }
92
93         void positionGot();
94
95     signals:
96         void allSessionsGotSignal();
97         void positionGotSignal();
98         void allRoutesGotSignal();
99         void routeCreatedSignal();
100 };
101
102 #endif // __MAINAPP_H__