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
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 2023-05-15
 * Description : geolocation engine based on Marble.
 *               (c) 2007-2022 Marble Team
 *               https://invent.kde.org/education/marble/-/raw/master/data/credits_authors.html
 *
 * SPDX-FileCopyrightText: 2023-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 * ============================================================ */

#include "LatLonBoxWidget.h"

// Local includes

#include "GeoDataLatLonBox.h"
#include "ui_LatLonBoxWidget.h"

namespace Marble
{

class Q_DECL_HIDDEN LatLonBoxWidget::Private
{
public:

    explicit Private(QWidget* const parent);

    Ui::LatLonBoxWidget m_ui;
};

LatLonBoxWidget::Private::Private(QWidget* const parent)
{
    m_ui.setupUi(parent);
}

LatLonBoxWidget::LatLonBoxWidget(QWidget* const parent, Qt::WindowFlags const f)
    : QWidget(parent, f),
      d(new Private(this))
{
    // used for updating tiles count in DownloadRegionDialog

    connect(d->m_ui.northSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged()));
    connect(d->m_ui.southSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged()));
    connect(d->m_ui.eastSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged()));
    connect(d->m_ui.westSpinBox, SIGNAL(valueChanged(double)), SIGNAL(valueChanged()));

    // used for adjusting single step values

    connect(d->m_ui.northSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLatSingleStep()));
    connect(d->m_ui.southSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLatSingleStep()));
    connect(d->m_ui.eastSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLonSingleStep()));
    connect(d->m_ui.westSpinBox, SIGNAL(valueChanged(double)), SLOT(updateLonSingleStep()));
}

LatLonBoxWidget::~LatLonBoxWidget()
{
    delete d;
}

GeoDataLatLonBox LatLonBoxWidget::latLonBox() const
{
    return GeoDataLatLonBox(d->m_ui.northSpinBox->value(), d->m_ui.southSpinBox->value(),
                            d->m_ui.eastSpinBox->value(), d->m_ui.westSpinBox->value(),
                            GeoDataCoordinates::Degree);
}

void LatLonBoxWidget::setLatLonBox(GeoDataLatLonBox const& latLonBox)<--- Shadow argument
{
    d->m_ui.northSpinBox->setValue(latLonBox.north(GeoDataCoordinates::Degree));
    d->m_ui.southSpinBox->setValue(latLonBox.south(GeoDataCoordinates::Degree));
    d->m_ui.eastSpinBox->setValue(latLonBox.east(GeoDataCoordinates::Degree));
    d->m_ui.westSpinBox->setValue(latLonBox.west(GeoDataCoordinates::Degree));
}

void LatLonBoxWidget::updateLatSingleStep()
{
    double const singleStep =
        qAbs(d->m_ui.northSpinBox->value() - d->m_ui.southSpinBox->value()) / 10.0;
    d->m_ui.northSpinBox->setSingleStep(singleStep);
    d->m_ui.southSpinBox->setSingleStep(singleStep);
}

void LatLonBoxWidget::updateLonSingleStep()
{
    double const singleStep =
        qAbs(d->m_ui.eastSpinBox->value() - d->m_ui.westSpinBox->value()) / 10.0;
    d->m_ui.eastSpinBox->setSingleStep(singleStep);
    d->m_ui.westSpinBox->setSingleStep(singleStep);
}

} // namespace Marble

#include "moc_LatLonBoxWidget.cpp"