aboutsummaryrefslogtreecommitdiffstats
path: root/MainApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MainApp.cpp')
-rw-r--r--MainApp.cpp119
1 files changed, 5 insertions, 114 deletions
diff --git a/MainApp.cpp b/MainApp.cpp
index 8ff0488..f4c858d 100644
--- a/MainApp.cpp
+++ b/MainApp.cpp
@@ -52,13 +52,13 @@
using namespace std;
-MainApp::MainApp():QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
+MainApp::MainApp(Navigation *navigation):QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
networkManager(this),searchBtn(QIcon(tr(":/images/loupe-90.png")), tr(""), this),
lineEdit(this),keyboard(QRect(0, 688, COMPLETE_W_WITH_KB, 720), this),
mutex(QMutex::Recursive),token(""),currentSearchingText(""),currentSearchedText(""),
pSearchReply(NULL),pInfoPanel(NULL),pResultList(NULL),currentLatitude(36.136261),currentLongitude(-115.151254),
navicoreSession(0),currentIndex(0),fontId(-1),isInfoScreen(false),
- isInputDisplayed(false),isKeyboard(false),isAglNavi(false)
+ isInputDisplayed(false),isKeyboard(false),isAglNavi(false), naviapi(navigation)
{
//this->setAttribute(Qt::WA_TranslucentBackground);
this->setStyleSheet("border: none;");
@@ -117,8 +117,6 @@ MainApp::MainApp():QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
isAglNavi = true;
connect(this, SIGNAL(positionGotSignal()), this, SLOT(positionGot()));
- connect(this, SIGNAL(allRoutesGotSignal()), this, SLOT(allRoutesGot()));
- connect(this, SIGNAL(routeCreatedSignal()), this, SLOT(routeCreated()));
this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
this->setStyleSheet("background-image: url(:/images/AGL_POI_Background.png);");
@@ -277,11 +275,7 @@ void MainApp::textChanged(const QString & text)
}
this->currentSearchingText = text;
- /* we need to know our current position */
- std::vector<int32_t> Params;
- Params.push_back(naviapi::NAVICORE_LONGITUDE);
- Params.push_back(naviapi::NAVICORE_LATITUDE);
- naviapi.getPosition(Params);
+ emit positionGotSignal();
mutex.unlock();
}
@@ -580,7 +574,7 @@ void MainApp::SetDestination(int index)
this->destinationLatitude = Businesses[index].Latitude;
this->destinationLongitude = Businesses[index].Longitude;
- naviapi.getAllRoutes();
+ SetWayPoints(0);
mutex.unlock();
}
@@ -768,18 +762,6 @@ bool MainApp::IsCoordinatesConsistent(Business & business)
}
/* end of workaround */
-bool MainApp::CheckNaviApi(int argc, char *argv[])
-{
- bool ret = naviapi.connect(argc, argv, this);
-
- if (ret == true)
- {
- naviapi.getAllSessions();
- }
-
- return ret;
-}
-
int MainApp::AuthenticatePOI(const QString & CredentialsFile)
{
char buf[512];
@@ -901,12 +883,7 @@ int MainApp::StartMonitoringUserInput()
void MainApp::SetWayPoints(uint32_t myRoute)
{
/* set the destination : */
- naviapi::Waypoint destWp(this->destinationLatitude, this->destinationLongitude);
- std::vector<naviapi::Waypoint> myWayPoints;
- myWayPoints.push_back(destWp);
- naviapi.setWaypoints(navicoreSession, myRoute, true, myWayPoints);
-
- naviapi.calculateRoute(navicoreSession, myRoute);
+ naviapi->sendWaypoint(this->destinationLatitude, this->destinationLongitude);
/* reset search: */
currentSearchingText = tr("");
@@ -948,60 +925,6 @@ void MainApp::getAllSessions_reply(const std::map< uint32_t, std::string >& allS
mutex.unlock();
}
-
-void MainApp::getPosition_reply(std::map< int32_t, naviapi::variant > position)
-{
- mutex.lock();
-
- std::map< int32_t, naviapi::variant >::iterator it;
- for (it = position.begin(); it != position.end(); it++)
- {
- if (it->first == naviapi::NAVICORE_LATITUDE)
- {
- currentLatitude = it->second._double;
- }
- else if (it->first == naviapi::NAVICORE_LONGITUDE)
- {
- currentLongitude = it->second._double;
- }
- }
-
- TRACE_INFO("Current position: %f, %f", currentLatitude, currentLongitude);
-
- mutex.unlock();
-
- emit positionGotSignal();
-}
-
-void MainApp::getAllRoutes_reply(std::vector< uint32_t > allRoutes)
-{
- mutex.lock();
-
- uint32_t routeHandle = 0;
-
- if (allRoutes.size() != 0)
- {
- routeHandle = allRoutes[0];
- }
-
- this->currentRouteHandle = routeHandle;
-
- mutex.unlock();
-
- emit allRoutesGotSignal();
-}
-
-void MainApp::createRoute_reply(uint32_t routeHandle)
-{
- mutex.lock();
-
- this->currentRouteHandle = routeHandle;
-
- mutex.unlock();
-
- emit routeCreatedSignal();
-}
-
void MainApp::positionGot()
{
mutex.lock();
@@ -1023,35 +946,3 @@ void MainApp::positionGot()
mutex.unlock();
}
-
-void MainApp::allRoutesGot()
-{
- mutex.lock();
-
- /* check if a route already exists, if not create it : */
- if (this->currentRouteHandle == 0)
- {
- naviapi.createRoute(navicoreSession);
- }
- else
- {
- naviapi.pauseSimulation(navicoreSession);
- naviapi.setSimulationMode(navicoreSession, false);
- naviapi.cancelRouteCalculation(navicoreSession, this->currentRouteHandle);
- sleep(1);
-
- SetWayPoints(this->currentRouteHandle);
- }
-
- mutex.unlock();
-}
-
-void MainApp::routeCreated()
-{
- mutex.lock();
-
- SetWayPoints(this->currentRouteHandle);
-
- mutex.unlock();
-}
-