Ref T111, made coordinate selector a form

This commit is contained in:
Klaus Basan
2017-08-03 18:07:35 +02:00
committed by Mathew Sutcliffe
parent 4d9ee1626d
commit 2476b9f412
4 changed files with 92 additions and 39 deletions

View File

@@ -7,27 +7,28 @@
* contained in the LICENSE file.
*/
#include "coordinateselector.h"
#include "coordinateform.h"
#include "blackcore/webdataservices.h"
#include "blackcore/db/airportdatareader.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/aviation/airport.h"
#include "ui_coordinateselector.h"
#include "ui_coordinateform.h"
#include <QIntValidator>
using namespace BlackGui;
using namespace BlackMisc;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackGui
{
namespace Components
namespace Editors
{
CCoordinateSelector::CCoordinateSelector(QWidget *parent) :
QFrame(parent),
ui(new Ui::CCoordinateSelector)
CCoordinateForm::CCoordinateForm(QWidget *parent) :
CForm(parent),
ui(new Ui::CCoordinateForm)
{
ui->setupUi(this);
@@ -45,30 +46,31 @@ namespace BlackGui
ui->le_LngSec->setValidator(new QIntValidator(0, 60, ui->le_LngSec));
ui->le_LngSecFrag->setValidator(new QIntValidator(0, 10E7, ui->le_LngSecFrag));
connect(ui->le_Latitude, &QLineEdit::editingFinished, this, &CCoordinateSelector::latEntered);
connect(ui->le_Longitude, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngEntered);
connect(ui->le_Elevation, &QLineEdit::editingFinished, this, &CCoordinateSelector::elvEntered);
connect(ui->le_Latitude, &QLineEdit::editingFinished, this, &CCoordinateForm::latEntered);
connect(ui->le_Longitude, &QLineEdit::editingFinished, this, &CCoordinateForm::lngEntered);
connect(ui->le_Elevation, &QLineEdit::editingFinished, this, &CCoordinateForm::elvEntered);
connect(ui->le_LatDeg, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
connect(ui->le_LatMin, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
connect(ui->le_LatSec, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
connect(ui->le_LatSecFrag, &QLineEdit::editingFinished, this, &CCoordinateSelector::latCombinedEntered);
connect(ui->le_LatDeg, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
connect(ui->le_LatMin, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
connect(ui->le_LatSec, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
connect(ui->le_LatSecFrag, &QLineEdit::editingFinished, this, &CCoordinateForm::latCombinedEntered);
connect(ui->le_LngDeg, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
connect(ui->le_LngMin, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
connect(ui->le_LngSec, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
connect(ui->le_LngSecFrag, &QLineEdit::editingFinished, this, &CCoordinateSelector::lngCombinedEntered);
connect(ui->le_LngDeg, &QLineEdit::editingFinished, this, &CCoordinateForm::lngCombinedEntered);
connect(ui->le_LngMin, &QLineEdit::editingFinished, this, &CCoordinateForm::lngCombinedEntered);
connect(ui->le_LngSec, &QLineEdit::editingFinished, this, &CCoordinateForm::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;
this->setCoordinate(c);
}
CCoordinateSelector::~CCoordinateSelector()
CCoordinateForm::~CCoordinateForm()
{ }
void CCoordinateSelector::setCoordinate(const ICoordinateGeodetic &coordinate)
void CCoordinateForm::setCoordinate(const ICoordinateGeodetic &coordinate)
{
m_coordinate = coordinate;
@@ -115,7 +117,40 @@ namespace BlackGui
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();
@@ -135,7 +170,7 @@ namespace BlackGui
}
}
void CCoordinateSelector::latEntered()
void CCoordinateForm::latEntered()
{
const QString ls = ui->le_Latitude->text();
const CLatitude l = CLatitude::fromWgs84(ls);
@@ -145,7 +180,7 @@ namespace BlackGui
this->setCoordinate(c);
}
void CCoordinateSelector::latCombinedEntered()
void CCoordinateForm::latCombinedEntered()
{
bool ok;
int deg = ui->le_LatDeg->text().trimmed().toInt(&ok);
@@ -167,7 +202,7 @@ namespace BlackGui
this->setCoordinate(c);
}
void CCoordinateSelector::lngEntered()
void CCoordinateForm::lngEntered()
{
const QString ls = ui->le_Longitude->text();
const CLongitude l = CLongitude::fromWgs84(ls);
@@ -177,7 +212,7 @@ namespace BlackGui
this->setCoordinate(c);
}
void CCoordinateSelector::lngCombinedEntered()
void CCoordinateForm::lngCombinedEntered()
{
bool ok;
int deg = ui->le_LngDeg->text().trimmed().toInt(&ok);
@@ -199,7 +234,7 @@ namespace BlackGui
this->setCoordinate(c);
}
void CCoordinateSelector::elvEntered()
void CCoordinateForm::elvEntered()
{
const QString e = ui->le_Elevation->text();
CAltitude a;

View File

@@ -9,31 +9,34 @@
//! \file
#ifndef BLACKGUI_COMPONENTS_COORDINATESELECTOR_H
#define BLACKGUI_COMPONENTS_COORDINATESELECTOR_H
#ifndef BLACKGUI_EDITORS_COORDINATEFORM_H
#define BLACKGUI_EDITORS_COORDINATEFORM_H
#include "blackmisc/geo/coordinategeodetic.h"
#include "blackgui/editors/form.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 Components
namespace Editors
{
/**
* Select / enter a geo position
*/
class BLACKGUI_EXPORT CCoordinateSelector : public QFrame
class BLACKGUI_EXPORT CCoordinateForm : public CForm
{
Q_OBJECT
public:
//! Ctor
explicit CCoordinateSelector(QWidget *parent = nullptr);
explicit CCoordinateForm(QWidget *parent = nullptr);
//! Dtor
virtual ~CCoordinateSelector();
virtual ~CCoordinateForm();
//! Get the coordinate
BlackMisc::Geo::CCoordinateGeodetic getCoordinate() const { return m_coordinate; }
@@ -41,8 +44,22 @@ namespace BlackGui
//! Set the 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:
QScopedPointer<Ui::CCoordinateSelector> ui;
QScopedPointer<Ui::CCoordinateForm> ui;
void locationEntered();
void latEntered();

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CCoordinateSelector</class>
<widget class="QFrame" name="CCoordinateSelector">
<class>CCoordinateForm</class>
<widget class="QFrame" name="CCoordinateForm">
<property name="geometry">
<rect>
<x>0</x>

View File

@@ -13,6 +13,7 @@
#define BLACKGUI_EDITORS_FORM_H
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/blackguiexport.h"
#include "blackcore/data/authenticateduser.h"
#include "blackmisc/datacache.h"
#include <QFrame>
@@ -28,7 +29,7 @@ namespace BlackGui
/*!
* Form base class
*/
class CForm : public COverlayMessagesFrame
class BLACKGUI_EXPORT CForm : public COverlayMessagesFrame
{
Q_OBJECT