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

KDE's Doxygen guidelines are available online.