mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 15:15:39 +08:00
Ref T111, made coordinate selector a form
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4d9ee1626d
commit
2476b9f412
@@ -7,27 +7,28 @@
|
|||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "coordinateselector.h"
|
#include "coordinateform.h"
|
||||||
#include "blackcore/webdataservices.h"
|
#include "blackcore/webdataservices.h"
|
||||||
#include "blackcore/db/airportdatareader.h"
|
#include "blackcore/db/airportdatareader.h"
|
||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackmisc/aviation/airport.h"
|
#include "blackmisc/aviation/airport.h"
|
||||||
#include "ui_coordinateselector.h"
|
#include "ui_coordinateform.h"
|
||||||
|
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
|
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Editors
|
||||||
{
|
{
|
||||||
CCoordinateSelector::CCoordinateSelector(QWidget *parent) :
|
CCoordinateForm::CCoordinateForm(QWidget *parent) :
|
||||||
QFrame(parent),
|
CForm(parent),
|
||||||
ui(new Ui::CCoordinateSelector)
|
ui(new Ui::CCoordinateForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@@ -45,30 +46,31 @@ namespace BlackGui
|
|||||||
ui->le_LngSec->setValidator(new QIntValidator(0, 60, ui->le_LngSec));
|
ui->le_LngSec->setValidator(new QIntValidator(0, 60, ui->le_LngSec));
|
||||||
ui->le_LngSecFrag->setValidator(new QIntValidator(0, 10E7, ui->le_LngSecFrag));
|
ui->le_LngSecFrag->setValidator(new QIntValidator(0, 10E7, ui->le_LngSecFrag));
|
||||||
|
|
||||||
connect(ui->le_Latitude, &QLineEdit::editingFinished, this, &CCoordinateSelector::latEntered);
|
connect(ui->le_Latitude, &QLineEdit::editingFinished, this, &CCoordinateForm::latEntered);
|
||||||
connect(ui->le_Longitude, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngEntered);
|
connect(ui->le_Longitude, &QLineEdit::editingFinished, this, &CCoordinateForm::lngEntered);
|
||||||
connect(ui->le_Elevation, &QLineEdit::editingFinished, this, &CCoordinateSelector::elvEntered);
|
connect(ui->le_Elevation, &QLineEdit::editingFinished, this, &CCoordinateForm::elvEntered);
|
||||||
|
|
||||||
connect(ui->le_LatDeg, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
|
connect(ui->le_LatDeg, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
|
||||||
connect(ui->le_LatMin, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
|
connect(ui->le_LatMin, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
|
||||||
connect(ui->le_LatSec, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
|
connect(ui->le_LatSec, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
|
||||||
connect(ui->le_LatSecFrag, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
|
connect(ui->le_LatSecFrag, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
|
||||||
|
|
||||||
connect(ui->le_LngDeg, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
|
connect(ui->le_LngDeg, &QLineEdit::editingFinished, this, &CCoordinateForm::lngCombinedEntered);
|
||||||
connect(ui->le_LngMin, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
|
connect(ui->le_LngMin, &QLineEdit::editingFinished, this, &CCoordinateForm::lngCombinedEntered);
|
||||||
connect(ui->le_LngSec, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
|
connect(ui->le_LngSec, &QLineEdit::editingFinished, this, &CCoordinateForm::lngCombinedEntered);
|
||||||
connect(ui->le_LngSecFrag, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
|
connect(ui->le_LngSecFrag, &QLineEdit::editingFinished, this, &CCoordinateForm::lngCombinedEntered);
|
||||||
|
|
||||||
connect(ui->le_Location, &QLineEdit::returnPressed, this, &CCoordinateSelector::locationEntered);
|
connect(ui->le_Location, &QLineEdit::returnPressed, this, &CCoordinateForm::locationEntered);
|
||||||
|
connect(ui->pb_Set, &QPushButton::pressed, this, &CCoordinateForm::changeCoordinate);
|
||||||
|
|
||||||
const CCoordinateGeodetic c;
|
const CCoordinateGeodetic c;
|
||||||
this->setCoordinate(c);
|
this->setCoordinate(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoordinateSelector::~CCoordinateSelector()
|
CCoordinateForm::~CCoordinateForm()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void CCoordinateSelector::setCoordinate(const ICoordinateGeodetic &coordinate)
|
void CCoordinateForm::setCoordinate(const ICoordinateGeodetic &coordinate)
|
||||||
{
|
{
|
||||||
m_coordinate = coordinate;
|
m_coordinate = coordinate;
|
||||||
|
|
||||||
@@ -115,7 +117,40 @@ namespace BlackGui
|
|||||||
ui->le_Elevation->setText(coordinate.geodeticHeightAsString());
|
ui->le_Elevation->setText(coordinate.geodeticHeightAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateSelector::locationEntered()
|
void CCoordinateForm::setReadOnly(bool readonly)
|
||||||
|
{
|
||||||
|
ui->le_Elevation->setReadOnly(readonly);
|
||||||
|
ui->le_LatDeg->setReadOnly(readonly);
|
||||||
|
ui->le_Latitude->setReadOnly(readonly);
|
||||||
|
ui->le_LatMin->setReadOnly(readonly);
|
||||||
|
ui->le_LatSec->setReadOnly(readonly);
|
||||||
|
ui->le_LatSecFrag->setReadOnly(readonly);
|
||||||
|
ui->le_LngDeg->setReadOnly(readonly);
|
||||||
|
ui->le_LngMin->setReadOnly(readonly);
|
||||||
|
ui->le_LngSec->setReadOnly(readonly);
|
||||||
|
ui->le_LngSecFrag->setReadOnly(readonly);
|
||||||
|
ui->le_Location->setReadOnly(readonly);
|
||||||
|
ui->le_Longitude->setReadOnly(readonly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCoordinateForm::setSelectOnly()
|
||||||
|
{
|
||||||
|
this->setReadOnly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
BlackMisc::CStatusMessageList CCoordinateForm::validate(bool nested) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(nested);
|
||||||
|
CStatusMessageList ml;
|
||||||
|
return ml;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCoordinateForm::showSetButton(bool visible)
|
||||||
|
{
|
||||||
|
ui->pb_Set->setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCoordinateForm::locationEntered()
|
||||||
{
|
{
|
||||||
const QString l = ui->le_Location->text().trimmed().toUpper();
|
const QString l = ui->le_Location->text().trimmed().toUpper();
|
||||||
|
|
||||||
@@ -135,7 +170,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateSelector::latEntered()
|
void CCoordinateForm::latEntered()
|
||||||
{
|
{
|
||||||
const QString ls = ui->le_Latitude->text();
|
const QString ls = ui->le_Latitude->text();
|
||||||
const CLatitude l = CLatitude::fromWgs84(ls);
|
const CLatitude l = CLatitude::fromWgs84(ls);
|
||||||
@@ -145,7 +180,7 @@ namespace BlackGui
|
|||||||
this->setCoordinate(c);
|
this->setCoordinate(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateSelector::latCombinedEntered()
|
void CCoordinateForm::latCombinedEntered()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int deg = ui->le_LatDeg->text().trimmed().toInt(&ok);
|
int deg = ui->le_LatDeg->text().trimmed().toInt(&ok);
|
||||||
@@ -167,7 +202,7 @@ namespace BlackGui
|
|||||||
this->setCoordinate(c);
|
this->setCoordinate(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateSelector::lngEntered()
|
void CCoordinateForm::lngEntered()
|
||||||
{
|
{
|
||||||
const QString ls = ui->le_Longitude->text();
|
const QString ls = ui->le_Longitude->text();
|
||||||
const CLongitude l = CLongitude::fromWgs84(ls);
|
const CLongitude l = CLongitude::fromWgs84(ls);
|
||||||
@@ -177,7 +212,7 @@ namespace BlackGui
|
|||||||
this->setCoordinate(c);
|
this->setCoordinate(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateSelector::lngCombinedEntered()
|
void CCoordinateForm::lngCombinedEntered()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int deg = ui->le_LngDeg->text().trimmed().toInt(&ok);
|
int deg = ui->le_LngDeg->text().trimmed().toInt(&ok);
|
||||||
@@ -199,7 +234,7 @@ namespace BlackGui
|
|||||||
this->setCoordinate(c);
|
this->setCoordinate(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCoordinateSelector::elvEntered()
|
void CCoordinateForm::elvEntered()
|
||||||
{
|
{
|
||||||
const QString e = ui->le_Elevation->text();
|
const QString e = ui->le_Elevation->text();
|
||||||
CAltitude a;
|
CAltitude a;
|
||||||
@@ -9,31 +9,34 @@
|
|||||||
|
|
||||||
//! \file
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKGUI_COMPONENTS_COORDINATESELECTOR_H
|
#ifndef BLACKGUI_EDITORS_COORDINATEFORM_H
|
||||||
#define BLACKGUI_COMPONENTS_COORDINATESELECTOR_H
|
#define BLACKGUI_EDITORS_COORDINATEFORM_H
|
||||||
|
|
||||||
#include "blackmisc/geo/coordinategeodetic.h"
|
#include "blackgui/editors/form.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include <QFrame>
|
#include "blackmisc/geo/coordinategeodetic.h"
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
|
||||||
namespace Ui { class CCoordinateSelector; }
|
class QWidget;
|
||||||
|
|
||||||
|
namespace Ui { class CCoordinateForm; }
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Editors
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Select / enter a geo position
|
* Select / enter a geo position
|
||||||
*/
|
*/
|
||||||
class BLACKGUI_EXPORT CCoordinateSelector : public QFrame
|
class BLACKGUI_EXPORT CCoordinateForm : public CForm
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Ctor
|
//! Ctor
|
||||||
explicit CCoordinateSelector(QWidget *parent = nullptr);
|
explicit CCoordinateForm(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! Dtor
|
//! Dtor
|
||||||
virtual ~CCoordinateSelector();
|
virtual ~CCoordinateForm();
|
||||||
|
|
||||||
//! Get the coordinate
|
//! Get the coordinate
|
||||||
BlackMisc::Geo::CCoordinateGeodetic getCoordinate() const { return m_coordinate; }
|
BlackMisc::Geo::CCoordinateGeodetic getCoordinate() const { return m_coordinate; }
|
||||||
@@ -41,8 +44,22 @@ namespace BlackGui
|
|||||||
//! Set the coordinate
|
//! Set the coordinate
|
||||||
void setCoordinate(const BlackMisc::Geo::ICoordinateGeodetic &coordinate);
|
void setCoordinate(const BlackMisc::Geo::ICoordinateGeodetic &coordinate);
|
||||||
|
|
||||||
|
//! \name Form class implementations
|
||||||
|
//! @{
|
||||||
|
virtual void setReadOnly(bool readonly) override;
|
||||||
|
virtual void setSelectOnly() override;
|
||||||
|
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Set button visible
|
||||||
|
void showSetButton(bool visible);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//! Change coordinate
|
||||||
|
void changeCoordinate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CCoordinateSelector> ui;
|
QScopedPointer<Ui::CCoordinateForm> ui;
|
||||||
|
|
||||||
void locationEntered();
|
void locationEntered();
|
||||||
void latEntered();
|
void latEntered();
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>CCoordinateSelector</class>
|
<class>CCoordinateForm</class>
|
||||||
<widget class="QFrame" name="CCoordinateSelector">
|
<widget class="QFrame" name="CCoordinateForm">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#define BLACKGUI_EDITORS_FORM_H
|
#define BLACKGUI_EDITORS_FORM_H
|
||||||
|
|
||||||
#include "blackgui/overlaymessagesframe.h"
|
#include "blackgui/overlaymessagesframe.h"
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackcore/data/authenticateduser.h"
|
#include "blackcore/data/authenticateduser.h"
|
||||||
#include "blackmisc/datacache.h"
|
#include "blackmisc/datacache.h"
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
@@ -28,7 +29,7 @@ namespace BlackGui
|
|||||||
/*!
|
/*!
|
||||||
* Form base class
|
* Form base class
|
||||||
*/
|
*/
|
||||||
class CForm : public COverlayMessagesFrame
|
class BLACKGUI_EXPORT CForm : public COverlayMessagesFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user