Marble

LatLonBoxWidget.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#include "LatLonBoxWidget.h"
4
5#include "GeoDataLatLonBox.h"
6#include "ui_LatLonBoxWidget.h"
7
8namespace Marble
9{
10
11class Q_DECL_HIDDEN LatLonBoxWidget::Private
12{
13public:
14 explicit Private(QWidget *const parent);
15 Ui::LatLonBoxWidget m_ui;
16};
17
18LatLonBoxWidget::Private::Private(QWidget *const parent)
19{
20 m_ui.setupUi(parent);
21}
22
23LatLonBoxWidget::LatLonBoxWidget(QWidget *const parent, Qt::WindowFlags const f)
24 : QWidget(parent, f)
25 , d(new Private(this))
26{
27 // used for updating tiles count in DownloadRegionDialog
28 connect(d->m_ui.northSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::valueChanged);
29 connect(d->m_ui.southSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::valueChanged);
30 connect(d->m_ui.eastSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::valueChanged);
31 connect(d->m_ui.westSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::valueChanged);
32 // used for adjusting single step values
33 connect(d->m_ui.northSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::updateLatSingleStep);
34 connect(d->m_ui.southSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::updateLatSingleStep);
35 connect(d->m_ui.eastSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::updateLonSingleStep);
36 connect(d->m_ui.westSpinBox, &QDoubleSpinBox::valueChanged, this, &LatLonBoxWidget::updateLonSingleStep);
37}
38
39LatLonBoxWidget::~LatLonBoxWidget()
40{
41 delete d;
42}
43
44GeoDataLatLonBox LatLonBoxWidget::latLonBox() const
45{
46 return {d->m_ui.northSpinBox->value(),
47 d->m_ui.southSpinBox->value(),
48 d->m_ui.eastSpinBox->value(),
49 d->m_ui.westSpinBox->value(),
50 GeoDataCoordinates::Degree};
51}
52
53void LatLonBoxWidget::setLatLonBox(GeoDataLatLonBox const &latLonBox)
54{
55 d->m_ui.northSpinBox->setValue(latLonBox.north(GeoDataCoordinates::Degree));
56 d->m_ui.southSpinBox->setValue(latLonBox.south(GeoDataCoordinates::Degree));
57 d->m_ui.eastSpinBox->setValue(latLonBox.east(GeoDataCoordinates::Degree));
58 d->m_ui.westSpinBox->setValue(latLonBox.west(GeoDataCoordinates::Degree));
59}
60
61void LatLonBoxWidget::updateLatSingleStep()
62{
63 double const singleStep = qAbs(d->m_ui.northSpinBox->value() - d->m_ui.southSpinBox->value()) / 10.0;
64 d->m_ui.northSpinBox->setSingleStep(singleStep);
65 d->m_ui.southSpinBox->setSingleStep(singleStep);
66}
67
68void LatLonBoxWidget::updateLonSingleStep()
69{
70 double const singleStep = qAbs(d->m_ui.eastSpinBox->value() - d->m_ui.westSpinBox->value()) / 10.0;
71 d->m_ui.eastSpinBox->setSingleStep(singleStep);
72 d->m_ui.westSpinBox->setSingleStep(singleStep);
73}
74
75}
76
77#include "moc_LatLonBoxWidget.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
void valueChanged(double d)
QObject * parent() const const
typedef WindowFlags
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.