mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 10:15:43 +08:00
refs #634, fixes and improvements in selectors/completers
* upper case * get raw data from selector * sort completers
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include "aircraftcombinedtypeselector.h"
|
#include "aircraftcombinedtypeselector.h"
|
||||||
#include "ui_aircraftcombinedtypeselector.h"
|
#include "ui_aircraftcombinedtypeselector.h"
|
||||||
#include "blackgui/guiutility.h"
|
#include "blackgui/guiutility.h"
|
||||||
|
#include "blackgui/uppercasevalidator.h"
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@ namespace BlackGui
|
|||||||
this->connect(ui->cb_EngineCount, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
this->connect(ui->cb_EngineCount, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
||||||
this->connect(ui->cb_EngineType, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
this->connect(ui->cb_EngineType, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
||||||
this->connect(ui->cb_Type, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
this->connect(ui->cb_Type, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox);
|
||||||
|
|
||||||
|
ui->le_CombinedType->setValidator(new CUpperCaseValidator(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftCombinedTypeSelector::~CAircraftCombinedTypeSelector()
|
CAircraftCombinedTypeSelector::~CAircraftCombinedTypeSelector()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/uppercasevalidator.h"
|
#include "blackgui/uppercasevalidator.h"
|
||||||
#include "blackmisc/datastoreutility.h"
|
#include "blackmisc/datastoreutility.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
@@ -79,6 +80,11 @@ namespace BlackGui
|
|||||||
this->ui->le_Aircraft->setReadOnly(readOnly);
|
this->ui->le_Aircraft->setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CDbAircraftIcaoSelectorComponent::getRawDesignator() const
|
||||||
|
{
|
||||||
|
return stripDesignatorFromCompleterString(ui->le_Aircraft->text());
|
||||||
|
}
|
||||||
|
|
||||||
void CDbAircraftIcaoSelectorComponent::withIcaoDescription(bool description)
|
void CDbAircraftIcaoSelectorComponent::withIcaoDescription(bool description)
|
||||||
{
|
{
|
||||||
this->ui->lbl_Description->setVisible(description);
|
this->ui->lbl_Description->setVisible(description);
|
||||||
@@ -141,7 +147,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
QCompleter *c = new QCompleter(sGui->getWebDataServices()->getAircraftIcaoCodes().toCompleterStrings(true, true), this);
|
QCompleter *c = new QCompleter(sGui->getWebDataServices()->getAircraftIcaoCodes().toCompleterStrings(true, true, true), this);
|
||||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
c->setMaxVisibleItems(10);
|
c->setMaxVisibleItems(10);
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ namespace BlackGui
|
|||||||
//! Distributor
|
//! Distributor
|
||||||
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcao() const;
|
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcao() const;
|
||||||
|
|
||||||
|
//! Raw designator
|
||||||
|
QString getRawDesignator() const;
|
||||||
|
|
||||||
//! Read only
|
//! Read only
|
||||||
void setReadOnly(bool readOnly);
|
void setReadOnly(bool readOnly);
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
CDbAirlineIcaoSelectorBase::~CDbAirlineIcaoSelectorBase()
|
CDbAirlineIcaoSelectorBase::~CDbAirlineIcaoSelectorBase()
|
||||||
{
|
{ }
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorBase::setAirlineIcao(const CAirlineIcaoCode &icao)
|
void CDbAirlineIcaoSelectorBase::setAirlineIcao(const CAirlineIcaoCode &icao)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/uppercasevalidator.h"
|
#include "blackgui/uppercasevalidator.h"
|
||||||
#include "blackmisc/datastoreutility.h"
|
#include "blackmisc/datastoreutility.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
@@ -62,9 +63,14 @@ namespace BlackGui
|
|||||||
this->ui->lbl_Description->clear();
|
this->ui->lbl_Description->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CDbAirlineIcaoSelectorComponent::getRawDesignator() const
|
||||||
|
{
|
||||||
|
return stripDesignatorFromCompleterString(ui->le_Airline->text());
|
||||||
|
}
|
||||||
|
|
||||||
QCompleter *CDbAirlineIcaoSelectorComponent::createCompleter()
|
QCompleter *CDbAirlineIcaoSelectorComponent::createCompleter()
|
||||||
{
|
{
|
||||||
QCompleter *c = new QCompleter(sGui->getWebDataServices()->getAirlineIcaoCodes().toIcaoDesignatorCompleterStrings(), this);
|
QCompleter *c = new QCompleter(sGui->getWebDataServices()->getAirlineIcaoCodes().toIcaoDesignatorCompleterStrings(true, true), this);
|
||||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
c->setMaxVisibleItems(10);
|
c->setMaxVisibleItems(10);
|
||||||
|
|||||||
@@ -38,18 +38,19 @@ namespace BlackGui
|
|||||||
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
||||||
~CDbAirlineIcaoSelectorComponent();
|
~CDbAirlineIcaoSelectorComponent();
|
||||||
|
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::clear
|
//! \name Base class overrides
|
||||||
|
//! @{
|
||||||
virtual void setReadOnly(bool readOnly) override;
|
virtual void setReadOnly(bool readOnly) override;
|
||||||
|
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::setAirlineIcao
|
|
||||||
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao) override;
|
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao) override;
|
||||||
|
virtual void clear() override;
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
//! Raw text designator
|
||||||
|
QString getRawDesignator() const;
|
||||||
|
|
||||||
//! Display ICAO description
|
//! Display ICAO description
|
||||||
void withIcaoDescription(bool description);
|
void withIcaoDescription(bool description);
|
||||||
|
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::clear
|
|
||||||
virtual void clear() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
||||||
virtual QCompleter *createCompleter() override;
|
virtual QCompleter *createCompleter() override;
|
||||||
|
|||||||
@@ -37,14 +37,12 @@ namespace BlackGui
|
|||||||
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
||||||
virtual ~CDbAirlineNameSelectorComponent();
|
virtual ~CDbAirlineNameSelectorComponent();
|
||||||
|
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::setReadOnly
|
//! \name Base class overrides
|
||||||
|
//! @{
|
||||||
virtual void setReadOnly(bool readOnly) override;
|
virtual void setReadOnly(bool readOnly) override;
|
||||||
|
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::setAirlineIcao
|
|
||||||
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao) override;
|
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao) override;
|
||||||
|
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::clear
|
|
||||||
virtual void clear() override;
|
virtual void clear() override;
|
||||||
|
//! @}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
||||||
|
|||||||
@@ -158,8 +158,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
QStringList keysAndAliases(sGui->getWebDataServices()->getDistributors().getDbKeysAndAliases());
|
const QStringList keysAndAliases(sGui->getWebDataServices()->getDistributors().getDbKeysAndAliases(true));
|
||||||
keysAndAliases.sort(Qt::CaseInsensitive);
|
|
||||||
QCompleter *c = new QCompleter(keysAndAliases, this);
|
QCompleter *c = new QCompleter(keysAndAliases, this);
|
||||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
|
|||||||
@@ -69,21 +69,24 @@ namespace BlackGui
|
|||||||
this->ui->cb_XPlane->isChecked(), this->ui->cb_P3D->isChecked());
|
this->ui->cb_XPlane->isChecked(), this->ui->cb_P3D->isChecked());
|
||||||
case RadioButtons:
|
case RadioButtons:
|
||||||
return CSimulatorInfo(this->ui->rb_FSX->isChecked(), this->ui->rb_FS9->isChecked(),
|
return CSimulatorInfo(this->ui->rb_FSX->isChecked(), this->ui->rb_FS9->isChecked(),
|
||||||
this->ui->rb_XPlane->isChecked(), this->ui->cb_P3D->isChecked());
|
this->ui->rb_XPlane->isChecked(), this->ui->rb_P3D->isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorSelector::setValue(const CSimulatorInfo &info)
|
void CSimulatorSelector::setValue(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
this->ui->cb_FSX->setChecked(info.fsx());
|
const CSimulatorInfo current(getValue());
|
||||||
this->ui->cb_FS9->setChecked(info.fs9());
|
if (simulator == current) { return; } // avoid unnecessary signals
|
||||||
this->ui->cb_XPlane->setChecked(info.xplane());
|
|
||||||
this->ui->cb_P3D->setChecked(info.p3d());
|
|
||||||
|
|
||||||
if (info.fsx()) { this->ui->cb_FSX->setChecked(info.fsx()); return; }
|
this->ui->cb_FSX->setChecked(simulator.fsx());
|
||||||
if (info.fs9()) { this->ui->cb_FS9->setChecked(info.fs9()); return; }
|
this->ui->cb_FS9->setChecked(simulator.fs9());
|
||||||
if (info.xplane()) { this->ui->cb_XPlane->setChecked(info.xplane()); return; }
|
this->ui->cb_XPlane->setChecked(simulator.xplane());
|
||||||
if (info.p3d()) { this->ui->cb_P3D->setChecked(info.p3d()); return; }
|
this->ui->cb_P3D->setChecked(simulator.p3d());
|
||||||
|
|
||||||
|
if (simulator.fsx()) { this->ui->cb_FSX->setChecked(simulator.fsx()); return; }
|
||||||
|
if (simulator.fs9()) { this->ui->cb_FS9->setChecked(simulator.fs9()); return; }
|
||||||
|
if (simulator.xplane()) { this->ui->cb_XPlane->setChecked(simulator.xplane()); return; }
|
||||||
|
if (simulator.p3d()) { this->ui->cb_P3D->setChecked(simulator.p3d()); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorSelector::setAll()
|
void CSimulatorSelector::setAll()
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace BlackGui
|
|||||||
BlackMisc::Simulation::CSimulatorInfo getValue() const;
|
BlackMisc::Simulation::CSimulatorInfo getValue() const;
|
||||||
|
|
||||||
//! Set the value
|
//! Set the value
|
||||||
void setValue(const BlackMisc::Simulation::CSimulatorInfo &info);
|
void setValue(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Set all, only making sense with checkboxes
|
//! Set all, only making sense with checkboxes
|
||||||
void setAll();
|
void setAll();
|
||||||
@@ -65,7 +65,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Value has been changed
|
//! Value has been changed
|
||||||
void changed(const BlackMisc::Simulation::CSimulatorInfo &info);
|
void changed(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Radio button changed
|
//! Radio button changed
|
||||||
|
|||||||
@@ -77,3 +77,17 @@ QByteArray BlackMisc::byteArrayFromHexString(const QString &hexString)
|
|||||||
}
|
}
|
||||||
return ba;
|
return ba;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString BlackMisc::stripDesignatorFromCompleterString(const QString &candidate)
|
||||||
|
{
|
||||||
|
const QString s(candidate.trimmed().toUpper());
|
||||||
|
if (s.isEmpty()) { return QString(); }
|
||||||
|
if (s.contains(' '))
|
||||||
|
{
|
||||||
|
return s.left(s.indexOf(' '));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ namespace BlackMisc
|
|||||||
//! Byte array from hex value string per byte, 2 digits
|
//! Byte array from hex value string per byte, 2 digits
|
||||||
BLACKMISC_EXPORT QByteArray byteArrayFromHexString(const QString &hexString);
|
BLACKMISC_EXPORT QByteArray byteArrayFromHexString(const QString &hexString);
|
||||||
|
|
||||||
|
//! Strip a designator from a combined string
|
||||||
|
BLACKMISC_EXPORT QString stripDesignatorFromCompleterString(const QString &candidate);
|
||||||
|
|
||||||
namespace Mixin
|
namespace Mixin
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Reference in New Issue
Block a user