File indexing completed on 2025-01-05 03:59:36
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2007 Torsten Rahn <tackat@kde.org> 0004 0005 #include "LatLonBoxWidget.h" 0006 0007 #include "GeoDataLatLonBox.h" 0008 #include "ui_LatLonBoxWidget.h" 0009 0010 namespace Marble 0011 { 0012 0013 class Q_DECL_HIDDEN LatLonBoxWidget::Private 0014 { 0015 public: 0016 explicit Private( QWidget * const parent ); 0017 Ui::LatLonBoxWidget m_ui; 0018 }; 0019 0020 LatLonBoxWidget::Private::Private( QWidget * const parent ) 0021 { 0022 m_ui.setupUi( parent ); 0023 } 0024 0025 0026 LatLonBoxWidget::LatLonBoxWidget( QWidget * const parent, Qt::WindowFlags const f ) 0027 : QWidget( parent, f ), 0028 d( new Private( this )) 0029 { 0030 // used for updating tiles count in DownloadRegionDialog 0031 connect( d->m_ui.northSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged())); 0032 connect( d->m_ui.southSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged())); 0033 connect( d->m_ui.eastSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged())); 0034 connect( d->m_ui.westSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged())); 0035 // used for adjusting single step values 0036 connect( d->m_ui.northSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLatSingleStep())); 0037 connect( d->m_ui.southSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLatSingleStep())); 0038 connect( d->m_ui.eastSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLonSingleStep())); 0039 connect( d->m_ui.westSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLonSingleStep())); 0040 } 0041 0042 LatLonBoxWidget::~LatLonBoxWidget() 0043 { 0044 delete d; 0045 } 0046 0047 GeoDataLatLonBox LatLonBoxWidget::latLonBox() const 0048 { 0049 return GeoDataLatLonBox( d->m_ui.northSpinBox->value(), d->m_ui.southSpinBox->value(), 0050 d->m_ui.eastSpinBox->value(), d->m_ui.westSpinBox->value(), 0051 GeoDataCoordinates::Degree ); 0052 } 0053 0054 void LatLonBoxWidget::setLatLonBox( GeoDataLatLonBox const & latLonBox ) 0055 { 0056 d->m_ui.northSpinBox->setValue( latLonBox.north( GeoDataCoordinates::Degree )); 0057 d->m_ui.southSpinBox->setValue( latLonBox.south( GeoDataCoordinates::Degree )); 0058 d->m_ui.eastSpinBox->setValue( latLonBox.east( GeoDataCoordinates::Degree )); 0059 d->m_ui.westSpinBox->setValue( latLonBox.west( GeoDataCoordinates::Degree )); 0060 } 0061 0062 void LatLonBoxWidget::updateLatSingleStep() 0063 { 0064 double const singleStep = 0065 qAbs( d->m_ui.northSpinBox->value() - d->m_ui.southSpinBox->value() ) / 10.0; 0066 d->m_ui.northSpinBox->setSingleStep( singleStep ); 0067 d->m_ui.southSpinBox->setSingleStep( singleStep ); 0068 } 0069 0070 void LatLonBoxWidget::updateLonSingleStep() 0071 { 0072 double const singleStep = 0073 qAbs( d->m_ui.eastSpinBox->value() - d->m_ui.westSpinBox->value() ) / 10.0; 0074 d->m_ui.eastSpinBox->setSingleStep( singleStep ); 0075 d->m_ui.westSpinBox->setSingleStep( singleStep ); 0076 } 0077 0078 } 0079 0080 #include "moc_LatLonBoxWidget.cpp"