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