This repository was archived by the owner on Sep 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDescriptionGPSLocationTab.cpp
More file actions
114 lines (88 loc) · 2.93 KB
/
DescriptionGPSLocationTab.cpp
File metadata and controls
114 lines (88 loc) · 2.93 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QDoubleValidator>
#include "DescriptionGPSLocationTab.h"
DescriptionGPSLocationTab::DescriptionGPSLocationTab(QWidget *parent) :
QWidget(parent)
{
QGridLayout *grid = new QGridLayout;
grid->addWidget(new QLabel(tr("Image Description:")), 0, 0);
_imageDescription = new QComboBox;
_imageDescription->setEditable(true);
_imageDescription->setInsertPolicy(QComboBox::InsertAtTop);
connect(_imageDescription, SIGNAL(activated(const QString &)), this, SLOT(setClicked(const QString &)));
grid->addWidget(_imageDescription, 0, 1);
_setButton = new QPushButton(tr("Set"));
connect(_setButton, SIGNAL(clicked()), this, SLOT(setClicked()));
grid->addWidget(_setButton, 0, 2);
_nextButton = new QPushButton(tr(">>"));
connect(_nextButton, SIGNAL(clicked()), this, SLOT(nextClicked()));
grid->addWidget(_nextButton, 0, 3);
grid->addWidget(new QLabel(tr("Latitude:")), 1, 0);
_latitudeEdit = new QLineEdit;
_latitudeEdit->setValidator(new QDoubleValidator(-90.0, 90.0, 5, this));
connect(_latitudeEdit, SIGNAL(returnPressed()), this, SLOT(latitudeSet()));
grid->addWidget(_latitudeEdit, 1, 1);
_latitudeButton = new QPushButton(tr("Set"));
connect(_latitudeButton, SIGNAL(clicked()), this, SLOT(latitudeSet()));
grid->addWidget(_latitudeButton, 1, 2);
grid->addWidget(new QLabel(tr("Longitude:")), 2, 0);
_longitudeEdit = new QLineEdit;
_longitudeEdit->setValidator(new QDoubleValidator(-180.0, 180.0, 5, this));
connect(_longitudeEdit, SIGNAL(returnPressed()), this, SLOT(longitudeSet()));
grid->addWidget(_longitudeEdit, 2, 1);
_longitudeButton = new QPushButton(tr("Set"));
connect(_longitudeButton, SIGNAL(clicked()), this, SLOT(longitudeSet()));
grid->addWidget(_longitudeButton, 2, 2);
setLayout(grid);
}
void DescriptionGPSLocationTab::set(const QString &description, const QString &latitude, const QString &longitude)
{
if (description == "")
{
_imageDescription->clearEditText();
}
else
{
_imageDescription->setEditText(description);
}
_latitudeEdit ->setText(latitude);
_longitudeEdit->setText(longitude);
}
void DescriptionGPSLocationTab::setClicked(const QString &text)
{
if (_imageDescription->findText(text, Qt::MatchFixedString|Qt::MatchCaseSensitive) == -1)
{
_imageDescription->addItem(text);
}
emit descriptionUpdated(text);
}
void DescriptionGPSLocationTab::setClicked()
{
setClicked(_imageDescription->currentText());
}
void DescriptionGPSLocationTab::nextClicked()
{
emit nextImageSelected();
}
void DescriptionGPSLocationTab::latitudeSet()
{
bool ok;
double value = _latitudeEdit->text().toDouble(&ok);
if (ok)
{
emit latitudeUpdated(value);
}
}
void DescriptionGPSLocationTab::longitudeSet()
{
bool ok;
double value = _longitudeEdit->text().toDouble(&ok);
if (ok)
{
emit longitudeUpdated(value);
}
}