forked from CCOMJHC/camp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaypointdetails.cpp
53 lines (46 loc) · 1.38 KB
/
waypointdetails.cpp
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
#include "waypointdetails.h"
#include "ui_waypointdetails.h"
#include <QDebug>
#include "waypoint.h"
WaypointDetails::WaypointDetails(QWidget *parent) :
QWidget(parent),
ui(new Ui::WaypointDetails),m_waypoint(nullptr)
{
ui->setupUi(this);
}
WaypointDetails::~WaypointDetails()
{
delete ui;
}
void WaypointDetails::setWaypoint(Waypoint *waypoint)
{
m_waypoint = waypoint;
qDebug() << "setting waypoint " << static_cast<const void *>(m_waypoint) << m_waypoint->location();
disconnect(moveConnection);
moveConnection = connect(waypoint,&Waypoint::waypointMoved,this,&WaypointDetails::onLocationChanged);
onLocationChanged();
}
void WaypointDetails::onLocationChanged()
{
//qDebug() << m_waypoint->location();
ui->latitudeLineEdit->setText(QString::number(m_waypoint->location().latitude(),'f',8));
ui->longitudeLineEdit->setText(QString::number(m_waypoint->location().longitude(),'f',8));
}
void WaypointDetails::updateWaypoint()
{
if(m_waypoint)
{
QGeoCoordinate location;
location.setLatitude(ui->latitudeLineEdit->text().toDouble());
location.setLongitude(ui->longitudeLineEdit->text().toDouble());
m_waypoint->setLocation(location);
}
}
void WaypointDetails::on_latitudeLineEdit_editingFinished()
{
updateWaypoint();
}
void WaypointDetails::on_longitudeLineEdit_editingFinished()
{
updateWaypoint();
}