mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
refs #535 completer for airline name
* common base class for airline completers * changed dependend classes
This commit is contained in:
146
src/blackgui/components/dbairlineicaoselectorbase.cpp
Normal file
146
src/blackgui/components/dbairlineicaoselectorbase.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dbairlineicaoselectorbase.h"
|
||||||
|
#include "blackgui/guiutility.h"
|
||||||
|
#include "blackmisc/datastoreutility.h"
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
using namespace BlackGui;
|
||||||
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
CDbAirlineIcaoSelectorBase::CDbAirlineIcaoSelectorBase(QWidget *parent) :
|
||||||
|
QFrame(parent)
|
||||||
|
{
|
||||||
|
this->setAcceptDrops(true);
|
||||||
|
this->setAcceptedMetaTypeIds({qMetaTypeId<CAirlineIcaoCode>(), qMetaTypeId<CAirlineIcaoCodeList>()});
|
||||||
|
}
|
||||||
|
|
||||||
|
CDbAirlineIcaoSelectorBase::~CDbAirlineIcaoSelectorBase()
|
||||||
|
{
|
||||||
|
gracefulShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider)
|
||||||
|
{
|
||||||
|
if (!webDataReaderProvider) { return; }
|
||||||
|
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
||||||
|
connectDataReadSignal(
|
||||||
|
this,
|
||||||
|
std::bind(&CDbAirlineIcaoSelectorBase::ps_codesRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
|
||||||
|
);
|
||||||
|
|
||||||
|
// already read a this time
|
||||||
|
int c = this->getAirlineIcaoCodesCount();
|
||||||
|
if (c > 0)
|
||||||
|
{
|
||||||
|
this->ps_codesRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::setAirlineIcao(const CAirlineIcaoCode &icao)
|
||||||
|
{
|
||||||
|
if (icao != m_currentIcao)
|
||||||
|
{
|
||||||
|
m_currentIcao = icao;
|
||||||
|
emit changedAirlineIcao(icao);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDbAirlineIcaoSelectorBase::setAirlineIcao(int key)
|
||||||
|
{
|
||||||
|
CAirlineIcaoCode icao(getAirlineIcaoCodeForDbKey(key));
|
||||||
|
if (icao.hasCompleteData())
|
||||||
|
{
|
||||||
|
this->setAirlineIcao(icao);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
if (!event || !acceptDrop(event->mimeData())) { return; }
|
||||||
|
setBackgroundRole(QPalette::Highlight);
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
{
|
||||||
|
if (!event || !acceptDrop(event->mimeData())) { return; }
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::dragLeaveEvent(QDragLeaveEvent *event)
|
||||||
|
{
|
||||||
|
if (!event) { return; }
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
if (!event || !acceptDrop(event->mimeData())) { return; }
|
||||||
|
CVariant valueVariant(toCVariant(event->mimeData()));
|
||||||
|
if (valueVariant.isValid())
|
||||||
|
{
|
||||||
|
if (valueVariant.canConvert<CAirlineIcaoCode>())
|
||||||
|
{
|
||||||
|
CAirlineIcaoCode icao(valueVariant.value<CAirlineIcaoCode>());
|
||||||
|
if (!icao.hasValidDbKey()) { return; }
|
||||||
|
this->setAirlineIcao(icao);
|
||||||
|
}
|
||||||
|
else if (valueVariant.canConvert<CAirlineIcaoCodeList>())
|
||||||
|
{
|
||||||
|
CAirlineIcaoCodeList icaos(valueVariant.value<CAirlineIcaoCodeList>());
|
||||||
|
if (icaos.isEmpty()) { return; }
|
||||||
|
this->setAirlineIcao(icaos.front());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::ps_codesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||||
|
{
|
||||||
|
if (!hasProvider()) { return; }
|
||||||
|
if (entity.testFlag(CEntityFlags::AirlineIcaoEntity) && readState == CEntityFlags::ReadFinished)
|
||||||
|
{
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
QCompleter *c = this->createCompleter();
|
||||||
|
Q_ASSERT_X(c, Q_FUNC_INFO, "missing converter");
|
||||||
|
this->connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbAirlineIcaoSelectorBase::ps_completerActivated);
|
||||||
|
m_completer.reset(c); // deletes any old completer
|
||||||
|
this->setReadOnly(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_completer.reset(nullptr);
|
||||||
|
this->setReadOnly(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorBase::ps_completerActivated(const QString &icaoString)
|
||||||
|
{
|
||||||
|
int dbKey = CDatastoreUtility::extractIntegerKey(icaoString);
|
||||||
|
if (dbKey < 0) { return; }
|
||||||
|
this->setAirlineIcao(dbKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
}// class
|
||||||
|
} // ns
|
||||||
93
src/blackgui/components/dbairlineicaoselectorbase.h
Normal file
93
src/blackgui/components/dbairlineicaoselectorbase.h
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_DBAIRLINEICAOSELECTORBASE_H
|
||||||
|
#define BLACKGUI_DBAIRLINEICAOSELECTORBASE_H
|
||||||
|
|
||||||
|
#include "blackcore/webdataservices.h"
|
||||||
|
#include "blackgui/dropbase.h"
|
||||||
|
#include "blackmisc/aviation/airlineicaocode.h"
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include <QCompleter>
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Airline ICAO selector base class
|
||||||
|
*/
|
||||||
|
class CDbAirlineIcaoSelectorBase :
|
||||||
|
public QFrame,
|
||||||
|
public BlackMisc::Network::CWebDataServicesAware,
|
||||||
|
public BlackGui::CDropBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Destructor
|
||||||
|
virtual ~CDbAirlineIcaoSelectorBase();
|
||||||
|
|
||||||
|
//! \copydoc CWebDataReaderAware::setProvider
|
||||||
|
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override;
|
||||||
|
|
||||||
|
//! Current airline ICAO
|
||||||
|
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
|
||||||
|
|
||||||
|
//! Current airline ICAO by key
|
||||||
|
bool setAirlineIcao(int key);
|
||||||
|
|
||||||
|
//! Airline ICAO
|
||||||
|
const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcao() const { return m_currentIcao; }
|
||||||
|
|
||||||
|
//! Read only
|
||||||
|
virtual void setReadOnly(bool readOnly) = 0;
|
||||||
|
|
||||||
|
//! Clear selection
|
||||||
|
virtual void clear() = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//! ICAO was changed
|
||||||
|
void changedAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Constructor
|
||||||
|
explicit CDbAirlineIcaoSelectorBase(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Create a new completer
|
||||||
|
virtual QCompleter *createCompleter() = 0;
|
||||||
|
|
||||||
|
//! \copydoc QWidget::dragEnterEvent
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
|
|
||||||
|
//! \copydoc QWidget::dragMoveEvent
|
||||||
|
virtual void dragMoveEvent(QDragMoveEvent *event) override;
|
||||||
|
|
||||||
|
//! \copydoc QWidget::dragLeaveEvent
|
||||||
|
virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||||
|
|
||||||
|
//! \copydoc QWidget::dropEvent
|
||||||
|
virtual void dropEvent(QDropEvent *event) override;
|
||||||
|
|
||||||
|
QScopedPointer<QCompleter> m_completer; //!< completer used
|
||||||
|
BlackMisc::Aviation::CAirlineIcaoCode m_currentIcao; //!< current ICAO object
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//! Airlines have been read
|
||||||
|
void ps_codesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||||
|
|
||||||
|
//! Data have been changed
|
||||||
|
void ps_completerActivated(const QString &icaoString);
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
#endif // guard
|
||||||
@@ -13,74 +13,26 @@
|
|||||||
#include "blackmisc/datastoreutility.h"
|
#include "blackmisc/datastoreutility.h"
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
|
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Network;
|
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
CDbAirlineIcaoSelectorComponent::CDbAirlineIcaoSelectorComponent(QWidget *parent) :
|
CDbAirlineIcaoSelectorComponent::CDbAirlineIcaoSelectorComponent(QWidget *parent) :
|
||||||
QFrame(parent),
|
CDbAirlineIcaoSelectorBase(parent),
|
||||||
ui(new Ui::CDbAirlineIcaoSelectorComponent)
|
ui(new Ui::CDbAirlineIcaoSelectorComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setAcceptDrops(true);
|
|
||||||
this->setAcceptedMetaTypeIds({qMetaTypeId<CAirlineIcaoCode>(), qMetaTypeId<CAirlineIcaoCodeList>()});
|
|
||||||
|
|
||||||
connect(ui->le_Airline, &QLineEdit::returnPressed, this, &CDbAirlineIcaoSelectorComponent::ps_dataChanged);
|
connect(ui->le_Airline, &QLineEdit::returnPressed, this, &CDbAirlineIcaoSelectorComponent::ps_dataChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbAirlineIcaoSelectorComponent::~CDbAirlineIcaoSelectorComponent()
|
CDbAirlineIcaoSelectorComponent::~CDbAirlineIcaoSelectorComponent()
|
||||||
{
|
{
|
||||||
gracefulShutdown();
|
// no inline destructor, read QScopedPointer Forward Declared Pointers
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider)
|
|
||||||
{
|
|
||||||
if (!webDataReaderProvider) { return; }
|
|
||||||
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
|
||||||
connectDataReadSignal(
|
|
||||||
this,
|
|
||||||
std::bind(&CDbAirlineIcaoSelectorComponent::ps_codesRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
|
|
||||||
);
|
|
||||||
int c = this->getAirlineIcaoCodesCount();
|
|
||||||
if (c > 0)
|
|
||||||
{
|
|
||||||
this->ps_codesRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::setAirlineIcao(const CAirlineIcaoCode &icao)
|
|
||||||
{
|
|
||||||
QString icaoStr(icao.getVDesignator());
|
|
||||||
this->ui->le_Airline->setText(icaoStr);
|
|
||||||
ui->lbl_Description->setText(icao.getName());
|
|
||||||
if (icao != m_currentIcao)
|
|
||||||
{
|
|
||||||
m_currentIcao = icao;
|
|
||||||
emit changedAirlineIcao(icao);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::setAirlineIcao(int key)
|
|
||||||
{
|
|
||||||
CAirlineIcaoCode icao(getAirlineIcaoCodeForDbKey(key));
|
|
||||||
ui->lbl_Description->setText("");
|
|
||||||
if (icao.hasCompleteData())
|
|
||||||
{
|
|
||||||
this->setAirlineIcao(icao);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CAirlineIcaoCode CDbAirlineIcaoSelectorComponent::getAirlineIcao() const
|
|
||||||
{
|
|
||||||
int key = CDatastoreUtility::extractIntegerKey(this->ui->le_Airline->text());
|
|
||||||
if (key < 0) { return CAirlineIcaoCode(); }
|
|
||||||
CAirlineIcaoCode icao(getAirlineIcaoCodeForDbKey(key));
|
|
||||||
return icao;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::setReadOnly(bool readOnly)
|
void CDbAirlineIcaoSelectorComponent::setReadOnly(bool readOnly)
|
||||||
@@ -88,84 +40,33 @@ namespace BlackGui
|
|||||||
this->ui->le_Airline->setReadOnly(readOnly);
|
this->ui->le_Airline->setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbAirlineIcaoSelectorComponent::setAirlineIcao(const CAirlineIcaoCode &icao)
|
||||||
|
{
|
||||||
|
CDbAirlineIcaoSelectorBase::setAirlineIcao(icao);
|
||||||
|
const QString icaoStr(icao.getVDesignator());
|
||||||
|
this->ui->le_Airline->setText(icaoStr);
|
||||||
|
ui->lbl_Description->setText(icao.getName());
|
||||||
|
}
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::withIcaoDescription(bool description)
|
void CDbAirlineIcaoSelectorComponent::withIcaoDescription(bool description)
|
||||||
{
|
{
|
||||||
this->ui->lbl_Description->setVisible(description);
|
this->ui->lbl_Description->setVisible(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDbAirlineIcaoSelectorComponent::isSet() const
|
|
||||||
{
|
|
||||||
return this->getAirlineIcao().hasCompleteData();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::clear()
|
void CDbAirlineIcaoSelectorComponent::clear()
|
||||||
{
|
{
|
||||||
this->ui->le_Airline->clear();
|
this->ui->le_Airline->clear();
|
||||||
|
this->ui->lbl_Description->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::dragEnterEvent(QDragEnterEvent *event)
|
QCompleter *CDbAirlineIcaoSelectorComponent::createCompleter()
|
||||||
{
|
{
|
||||||
if (!event || !acceptDrop(event->mimeData())) { return; }
|
QCompleter *c = new QCompleter(this->getAirlineIcaoCodes().toIcaoDesignatorCompleterStrings(), this);
|
||||||
setBackgroundRole(QPalette::Highlight);
|
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
event->acceptProposedAction();
|
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
}
|
c->setMaxVisibleItems(10);
|
||||||
|
this->ui->le_Airline->setCompleter(c);
|
||||||
void CDbAirlineIcaoSelectorComponent::dragMoveEvent(QDragMoveEvent *event)
|
return c;
|
||||||
{
|
|
||||||
if (!event || !acceptDrop(event->mimeData())) { return; }
|
|
||||||
event->acceptProposedAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::dragLeaveEvent(QDragLeaveEvent *event)
|
|
||||||
{
|
|
||||||
if (!event) { return; }
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::dropEvent(QDropEvent *event)
|
|
||||||
{
|
|
||||||
if (!event || !acceptDrop(event->mimeData())) { return; }
|
|
||||||
CVariant valueVariant(toCVariant(event->mimeData()));
|
|
||||||
if (valueVariant.isValid())
|
|
||||||
{
|
|
||||||
if (valueVariant.canConvert<CAirlineIcaoCode>())
|
|
||||||
{
|
|
||||||
CAirlineIcaoCode icao(valueVariant.value<CAirlineIcaoCode>());
|
|
||||||
if (!icao.hasValidDbKey()) { return; }
|
|
||||||
this->setAirlineIcao(icao);
|
|
||||||
}
|
|
||||||
else if (valueVariant.canConvert<CAirlineIcaoCodeList>())
|
|
||||||
{
|
|
||||||
CAirlineIcaoCodeList icaos(valueVariant.value<CAirlineIcaoCodeList>());
|
|
||||||
if (icaos.isEmpty()) { return; }
|
|
||||||
this->setAirlineIcao(icaos.front());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::ps_codesRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
|
||||||
{
|
|
||||||
if (!hasProvider()) { return; }
|
|
||||||
if (entity.testFlag(CEntityFlags::AirlineIcaoEntity) && readState == CEntityFlags::ReadFinished)
|
|
||||||
{
|
|
||||||
if (count > 0)
|
|
||||||
{
|
|
||||||
QCompleter *c = new QCompleter(this->getAirlineIcaoCodes().toCompleterStrings(), this);
|
|
||||||
c->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
c->setCompletionMode(QCompleter::PopupCompletion);
|
|
||||||
c->setMaxVisibleItems(10);
|
|
||||||
this->connect(c, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated), this, &CDbAirlineIcaoSelectorComponent::ps_completerActivated);
|
|
||||||
|
|
||||||
this->ui->le_Airline->setCompleter(c);
|
|
||||||
m_completerIcaoDescription.reset(c); // deletes any old completer
|
|
||||||
this->setReadOnly(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->m_completerIcaoDescription.reset(nullptr);
|
|
||||||
this->setReadOnly(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::ps_dataChanged()
|
void CDbAirlineIcaoSelectorComponent::ps_dataChanged()
|
||||||
@@ -181,18 +82,10 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// second choice, first object found by designator
|
// second choice, first object by name
|
||||||
CAirlineIcaoCode icao(getAirlineIcaoCodeForDesignator(s));
|
// CAirlineIcaoCode icao(getAirlineDesignatorWithName(s, starting with));
|
||||||
this->setAirlineIcao(icao);
|
// this->setAirlineIcao(icao);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbAirlineIcaoSelectorComponent::ps_completerActivated(const QString &icaoString)
|
|
||||||
{
|
|
||||||
int dbKey = CDatastoreUtility::extractIntegerKey(icaoString);
|
|
||||||
if (dbKey < 0) { return; }
|
|
||||||
this->setAirlineIcao(dbKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
}// class
|
}// class
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -9,16 +9,13 @@
|
|||||||
|
|
||||||
//! \file
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKGUI_DBAIRLINEICAOSELECTORCOMPONENT_H
|
#ifndef BLACKGUI_COMPONENTS_DBAIRLINEICAOSELECTORCOMPONENT_H
|
||||||
#define BLACKGUI_DBAIRLINEICAOSELECTORCOMPONENT_H
|
#define BLACKGUI_COMPONENTS_DBAIRLINEICAOSELECTORCOMPONENT_H
|
||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackcore/webdataservices.h"
|
#include "dbairlineicaoselectorbase.h"
|
||||||
#include "blackgui/dropbase.h"
|
|
||||||
#include "blackmisc/aviation/airlineicaocode.h"
|
#include "blackmisc/aviation/airlineicaocode.h"
|
||||||
#include <QFrame>
|
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QCompleter>
|
|
||||||
|
|
||||||
namespace Ui { class CDbAirlineIcaoSelectorComponent; }
|
namespace Ui { class CDbAirlineIcaoSelectorComponent; }
|
||||||
|
|
||||||
@@ -27,12 +24,9 @@ namespace BlackGui
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
/*!
|
/*!
|
||||||
* Distributor selector
|
* Airline ICAO selector
|
||||||
*/
|
*/
|
||||||
class BLACKGUI_EXPORT CDbAirlineIcaoSelectorComponent :
|
class BLACKGUI_EXPORT CDbAirlineIcaoSelectorComponent : public CDbAirlineIcaoSelectorBase
|
||||||
public QFrame,
|
|
||||||
public BlackMisc::Network::CWebDataServicesAware,
|
|
||||||
public BlackGui::CDropBase
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -41,65 +35,32 @@ namespace BlackGui
|
|||||||
explicit CDbAirlineIcaoSelectorComponent(QWidget *parent = nullptr);
|
explicit CDbAirlineIcaoSelectorComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
|
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
||||||
~CDbAirlineIcaoSelectorComponent();
|
~CDbAirlineIcaoSelectorComponent();
|
||||||
|
|
||||||
//! \copydoc CWebDataReaderAware::setProvider
|
//! \copydoc CDbAirlineIcaoSelectorBase::clear
|
||||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override;
|
virtual void setReadOnly(bool readOnly) override;
|
||||||
|
|
||||||
//! Current airline ICAO
|
//! \copydoc CDbAirlineIcaoSelectorBase::setAirlineIcao
|
||||||
void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
|
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao) override;
|
||||||
|
|
||||||
//! Current airline ICAO
|
|
||||||
void setAirlineIcao(int key);
|
|
||||||
|
|
||||||
//! Distributor
|
|
||||||
BlackMisc::Aviation::CAirlineIcaoCode getAirlineIcao() const;
|
|
||||||
|
|
||||||
//! Read only
|
|
||||||
void setReadOnly(bool readOnly);
|
|
||||||
|
|
||||||
//! Display distributor description
|
//! Display distributor description
|
||||||
void withIcaoDescription(bool description);
|
void withIcaoDescription(bool description);
|
||||||
|
|
||||||
//! Set with valid Distributor
|
//! \copydoc CDbAirlineIcaoSelectorBase::clear
|
||||||
bool isSet() const;
|
virtual void clear() override;
|
||||||
|
|
||||||
//! Clear selection
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
//! ICAO was changed
|
|
||||||
void changedAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc QWidget::dragEnterEvent
|
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
||||||
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
virtual QCompleter *createCompleter() override;
|
||||||
|
|
||||||
//! \copydoc QWidget::dragMoveEvent
|
|
||||||
virtual void dragMoveEvent(QDragMoveEvent *event) override;
|
|
||||||
|
|
||||||
//! \copydoc QWidget::dragLeaveEvent
|
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
|
|
||||||
|
|
||||||
//! \copydoc QWidget::dropEvent
|
|
||||||
virtual void dropEvent(QDropEvent *event) override;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Distributors have been read
|
|
||||||
void ps_codesRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
|
||||||
|
|
||||||
//! Data have been changed
|
//! Data have been changed
|
||||||
void ps_dataChanged();
|
void ps_dataChanged();
|
||||||
|
|
||||||
//! Data have been changed
|
|
||||||
void ps_completerActivated(const QString &icaoString);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbAirlineIcaoSelectorComponent> ui;
|
Ui::CDbAirlineIcaoSelectorComponent *ui;
|
||||||
QScopedPointer<QCompleter> m_completerIcaoDescription;
|
|
||||||
QList<QMetaObject::Connection> m_signals;
|
|
||||||
BlackMisc::Aviation::CAirlineIcaoCode m_currentIcao;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
} // ns
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
84
src/blackgui/components/dbairlinenameselectorcomponent.cpp
Normal file
84
src/blackgui/components/dbairlinenameselectorcomponent.cpp
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dbairlinenameselectorcomponent.h"
|
||||||
|
#include "ui_dbairlinenameselectorcomponent.h"
|
||||||
|
#include "blackmisc/aviation/aircrafticaocodelist.h"
|
||||||
|
#include "blackmisc/datastoreutility.h"
|
||||||
|
|
||||||
|
using namespace BlackGui;
|
||||||
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
CDbAirlineNameSelectorComponent::CDbAirlineNameSelectorComponent(QWidget *parent) :
|
||||||
|
CDbAirlineIcaoSelectorBase(parent),
|
||||||
|
ui(new Ui::CDbAirlineNameSelectorComponent)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
connect(this->ui->le_AirlineName, &QLineEdit::returnPressed, this, &CDbAirlineNameSelectorComponent::ps_dataChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
CDbAirlineNameSelectorComponent::~CDbAirlineNameSelectorComponent()
|
||||||
|
{
|
||||||
|
// no inline destructor, read QScopedPointer Forward Declared Pointers
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineNameSelectorComponent::setAirlineIcao(const CAirlineIcaoCode &icao)
|
||||||
|
{
|
||||||
|
CDbAirlineIcaoSelectorBase::setAirlineIcao(icao);
|
||||||
|
QString name(icao.getName());
|
||||||
|
this->ui->le_AirlineName->setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineNameSelectorComponent::clear()
|
||||||
|
{
|
||||||
|
this->ui->le_AirlineName->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineNameSelectorComponent::setReadOnly(bool readOnly)
|
||||||
|
{
|
||||||
|
this->ui->le_AirlineName->setReadOnly(readOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
QCompleter *CDbAirlineNameSelectorComponent::createCompleter()
|
||||||
|
{
|
||||||
|
QCompleter *c = new QCompleter(this->getAirlineIcaoCodes().toNameCompleterStrings(), this);
|
||||||
|
c->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
c->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
|
c->setMaxVisibleItems(10);
|
||||||
|
this->ui->le_AirlineName->setCompleter(c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbAirlineNameSelectorComponent::ps_dataChanged()
|
||||||
|
{
|
||||||
|
if (!hasProvider()) { return; }
|
||||||
|
QString s(this->ui->le_AirlineName->text());
|
||||||
|
if (s.isEmpty()) { return; }
|
||||||
|
int dbKey = CDatastoreUtility::extractIntegerKey(s);
|
||||||
|
if (dbKey >= 0)
|
||||||
|
{
|
||||||
|
CAirlineIcaoCode icao(getAirlineIcaoCodeForDbKey(dbKey));
|
||||||
|
this->setAirlineIcao(icao);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// second choice, first object found by designator
|
||||||
|
// for name
|
||||||
|
|
||||||
|
// CAirlineIcaoCode icao(getAirlineIcao));
|
||||||
|
// this->setAirlineIcao(icao);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
63
src/blackgui/components/dbairlinenameselectorcomponent.h
Normal file
63
src/blackgui/components/dbairlinenameselectorcomponent.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_COMPONENTS_DBAIRLINENAMESELECTORCOMPONENT_H
|
||||||
|
#define BLACKGUI_COMPONENTS_DBAIRLINENAMESELECTORCOMPONENT_H
|
||||||
|
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include "dbairlineicaoselectorbase.h"
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
namespace Ui { class CDbAirlineNameSelectorComponent; }
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Select airline by name
|
||||||
|
*/
|
||||||
|
class BLACKGUI_EXPORT CDbAirlineNameSelectorComponent : public CDbAirlineIcaoSelectorBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
explicit CDbAirlineNameSelectorComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
//! \note needed for forward declared QScopedPointer and needs to be in .cpp
|
||||||
|
virtual ~CDbAirlineNameSelectorComponent();
|
||||||
|
|
||||||
|
//! \copydoc CDbAirlineIcaoSelectorBase::setReadOnly
|
||||||
|
virtual void setReadOnly(bool readOnly) override;
|
||||||
|
|
||||||
|
//! \copydoc CDbAirlineIcaoSelectorBase::setAirlineIcao
|
||||||
|
virtual void setAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao) override;
|
||||||
|
|
||||||
|
//! \copydoc CDbAirlineIcaoSelectorBase::clear
|
||||||
|
virtual void clear() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc CDbAirlineIcaoSelectorBase::createCompleter
|
||||||
|
virtual QCompleter *createCompleter() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::CDbAirlineNameSelectorComponent> ui;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//! Data changed
|
||||||
|
void ps_dataChanged();
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
49
src/blackgui/components/dbairlinenameselectorcomponent.ui
Normal file
49
src/blackgui/components/dbairlinenameselectorcomponent.ui
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CDbAirlineNameSelectorComponent</class>
|
||||||
|
<widget class="QFrame" name="CDbAirlineNameSelectorComponent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>108</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Airline name selector</string>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vl_AirlineNameSelector">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="le_AirlineName">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>e.g. "British Airways"</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -30,8 +30,9 @@ namespace BlackGui
|
|||||||
this->ui->le_Id->setReadOnly(true);
|
this->ui->le_Id->setReadOnly(true);
|
||||||
this->ui->lai_Id->set(CIcons::appAirlineIcao16(), "Id:");
|
this->ui->lai_Id->set(CIcons::appAirlineIcao16(), "Id:");
|
||||||
|
|
||||||
this->ui->airline_Selector->withIcaoDescription(false);
|
this->ui->selector_AirlineDesignator->withIcaoDescription(false);
|
||||||
connect(this->ui->airline_Selector, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CAirlineIcaoForm::setValue);
|
connect(this->ui->selector_AirlineName, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CAirlineIcaoForm::setValue);
|
||||||
|
connect(this->ui->selector_AirlineDesignator, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CAirlineIcaoForm::setValue);
|
||||||
|
|
||||||
// drag and drop
|
// drag and drop
|
||||||
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAirlineIcaoForm::ps_droppedCode);
|
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAirlineIcaoForm::ps_droppedCode);
|
||||||
@@ -45,10 +46,10 @@ namespace BlackGui
|
|||||||
void CAirlineIcaoForm::setValue(const BlackMisc::Aviation::CAirlineIcaoCode &icao)
|
void CAirlineIcaoForm::setValue(const BlackMisc::Aviation::CAirlineIcaoCode &icao)
|
||||||
{
|
{
|
||||||
this->m_originalCode = icao;
|
this->m_originalCode = icao;
|
||||||
this->ui->airline_Selector->setAirlineIcao(icao);
|
this->ui->selector_AirlineDesignator->setAirlineIcao(icao);
|
||||||
|
this->ui->selector_AirlineName->setAirlineIcao(icao);
|
||||||
this->ui->le_Id->setText(icao.getDbKeyAsString());
|
this->ui->le_Id->setText(icao.getDbKeyAsString());
|
||||||
this->ui->le_TelephonyDesignator->setText(icao.getTelephonyDesignator());
|
this->ui->le_TelephonyDesignator->setText(icao.getTelephonyDesignator());
|
||||||
this->ui->le_Name->setText(icao.getName());
|
|
||||||
this->ui->le_Updated->setText(icao.getFormattedUtcTimestampYmdhms());
|
this->ui->le_Updated->setText(icao.getFormattedUtcTimestampYmdhms());
|
||||||
this->ui->cb_Va->setChecked(icao.isVirtualAirline());
|
this->ui->cb_Va->setChecked(icao.isVirtualAirline());
|
||||||
this->ui->country_Selector->setCountry(icao.getCountry());
|
this->ui->country_Selector->setCountry(icao.getCountry());
|
||||||
@@ -60,7 +61,7 @@ namespace BlackGui
|
|||||||
CAirlineIcaoCode code(m_originalCode);
|
CAirlineIcaoCode code(m_originalCode);
|
||||||
code.setVirtualAirline(this->ui->cb_Va->isChecked());
|
code.setVirtualAirline(this->ui->cb_Va->isChecked());
|
||||||
code.setCountry(this->ui->country_Selector->getCountry());
|
code.setCountry(this->ui->country_Selector->getCountry());
|
||||||
code.setName(this->ui->le_Name->text());
|
code.setName(this->ui->selector_AirlineName->getAirlineIcao().getName());
|
||||||
code.setTelephonyDesignator(this->ui->le_TelephonyDesignator->text());
|
code.setTelephonyDesignator(this->ui->le_TelephonyDesignator->text());
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
@@ -85,9 +86,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAirlineIcaoForm::setReadOnly(bool readOnly)
|
void CAirlineIcaoForm::setReadOnly(bool readOnly)
|
||||||
{
|
{
|
||||||
this->ui->airline_Selector->setReadOnly(readOnly);
|
this->ui->selector_AirlineDesignator->setReadOnly(readOnly);
|
||||||
|
this->ui->selector_AirlineName->setReadOnly(readOnly);
|
||||||
this->ui->le_TelephonyDesignator->setReadOnly(readOnly);
|
this->ui->le_TelephonyDesignator->setReadOnly(readOnly);
|
||||||
this->ui->le_Name->setReadOnly(readOnly);
|
|
||||||
this->ui->country_Selector->setReadOnly(readOnly);
|
this->ui->country_Selector->setReadOnly(readOnly);
|
||||||
this->ui->cb_Va->setEnabled(!readOnly);
|
this->ui->cb_Va->setEnabled(!readOnly);
|
||||||
}
|
}
|
||||||
@@ -101,7 +102,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
||||||
this->ui->country_Selector->setProvider(webDataReaderProvider);
|
this->ui->country_Selector->setProvider(webDataReaderProvider);
|
||||||
this->ui->airline_Selector->setProvider(webDataReaderProvider);
|
this->ui->selector_AirlineDesignator->setProvider(webDataReaderProvider);
|
||||||
|
this->ui->selector_AirlineName->setProvider(webDataReaderProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirlineIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped)
|
void CAirlineIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped)
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>CAirlineIcaoForm</class>
|
<class>CAirlineIcaoForm</class>
|
||||||
<widget class="QFrame" name="CAirlineIcaoForm">
|
<widget class="QFrame" name="CAirlineIcaoForm">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>232</width>
|
||||||
|
<height>210</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Airline ICAO</string>
|
<string>Airline ICAO</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="vl_AirlineIcaoCode">
|
<layout class="QVBoxLayout" name="vl_AirlineIcaoCode">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@@ -150,7 +152,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlackGui::Components::CDbAirlineIcaoSelectorComponent" name="airline_Selector">
|
<widget class="BlackGui::Components::CDbAirlineIcaoSelectorComponent" name="selector_AirlineDesignator">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -197,13 +199,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLineEdit" name="le_Name">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Airline's name (e.g. Lufthansa)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="le_TelephonyDesignator">
|
<widget class="QLineEdit" name="le_TelephonyDesignator">
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
@@ -241,6 +236,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="BlackGui::Components::CDbAirlineNameSelectorComponent" name="selector_AirlineName">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -276,12 +281,17 @@
|
|||||||
<header>blackgui/editors/validationindicator.h</header>
|
<header>blackgui/editors/validationindicator.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CDbAirlineNameSelectorComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/dbairlinenameselectorcomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>le_Id</tabstop>
|
<tabstop>le_Id</tabstop>
|
||||||
<tabstop>cb_Va</tabstop>
|
<tabstop>cb_Va</tabstop>
|
||||||
<tabstop>le_TelephonyDesignator</tabstop>
|
<tabstop>le_TelephonyDesignator</tabstop>
|
||||||
<tabstop>le_Name</tabstop>
|
|
||||||
<tabstop>le_Updated</tabstop>
|
<tabstop>le_Updated</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@@ -210,6 +210,19 @@ namespace BlackMisc
|
|||||||
return s.append(" ").append(getDbKeyAsStringInParentheses());
|
return s.append(" ").append(getDbKeyAsStringInParentheses());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CAirlineIcaoCode::getNameWithKey() const
|
||||||
|
{
|
||||||
|
if (!hasValidDbKey()) { return getName(); }
|
||||||
|
if (hasName())
|
||||||
|
{
|
||||||
|
return QString(getName()).append(" ").append(getDbKeyAsStringInParentheses());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return getDbKeyAsStringInParentheses();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CAirlineIcaoCode::updateMissingParts(const CAirlineIcaoCode &otherIcaoCode)
|
void CAirlineIcaoCode::updateMissingParts(const CAirlineIcaoCode &otherIcaoCode)
|
||||||
{
|
{
|
||||||
if (!this->hasValidDesignator()) { this->setDesignator(otherIcaoCode.getDesignator()); }
|
if (!this->hasValidDesignator()) { this->setDesignator(otherIcaoCode.getDesignator()); }
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ namespace BlackMisc
|
|||||||
//! Get name, e.g. "Lufthansa"
|
//! Get name, e.g. "Lufthansa"
|
||||||
const QString &getName() const { return this->m_name; }
|
const QString &getName() const { return this->m_name; }
|
||||||
|
|
||||||
|
//! Name plus key, e.g. "Lufthansa (3421)"
|
||||||
|
QString getNameWithKey() const;
|
||||||
|
|
||||||
//! Set name
|
//! Set name
|
||||||
void setName(const QString &name) { this->m_name = name.trimmed(); }
|
void setName(const QString &name) { this->m_name = name.trimmed(); }
|
||||||
|
|
||||||
|
|||||||
@@ -60,16 +60,30 @@ namespace BlackMisc
|
|||||||
return codes;
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CAirlineIcaoCodeList::toCompleterStrings() const
|
QStringList CAirlineIcaoCodeList::toIcaoDesignatorCompleterStrings() const
|
||||||
{
|
{
|
||||||
QStringList c;
|
QStringList c;
|
||||||
for (const CAirlineIcaoCode &icao : *this)
|
for (const CAirlineIcaoCode &icao : *this)
|
||||||
{
|
{
|
||||||
QString cs(icao.getCombinedStringWithKey());
|
if (!icao.hasValidDbKey()) { continue; }
|
||||||
|
const QString cs(icao.getCombinedStringWithKey());
|
||||||
|
if (cs.isEmpty()) { continue; }
|
||||||
c.append(cs);
|
c.append(cs);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList CAirlineIcaoCodeList::toNameCompleterStrings() const
|
||||||
|
{
|
||||||
|
QStringList c;
|
||||||
|
for (const CAirlineIcaoCode &icao : *this)
|
||||||
|
{
|
||||||
|
if (!icao.hasValidDbKey()) { continue; }
|
||||||
|
const QString cs(icao.getNameWithKey());
|
||||||
|
if (cs.isEmpty()) { continue; }
|
||||||
|
c.append(cs);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -49,8 +49,11 @@ namespace BlackMisc
|
|||||||
//! Find by v-designator, this should be unique
|
//! Find by v-designator, this should be unique
|
||||||
CAirlineIcaoCode findByVDesignator(const QString &designator);
|
CAirlineIcaoCode findByVDesignator(const QString &designator);
|
||||||
|
|
||||||
//! String list for completion
|
//! String list for completion by ICAO designator
|
||||||
QStringList toCompleterStrings() const;
|
QStringList toIcaoDesignatorCompleterStrings() const;
|
||||||
|
|
||||||
|
//! String list for completion by name
|
||||||
|
QStringList toNameCompleterStrings() const;
|
||||||
|
|
||||||
//! From our DB JSON
|
//! From our DB JSON
|
||||||
static CAirlineIcaoCodeList fromDatabaseJson(const QJsonArray &array, bool ignoreIncomplete = true);
|
static CAirlineIcaoCodeList fromDatabaseJson(const QJsonArray &array, bool ignoreIncomplete = true);
|
||||||
|
|||||||
Reference in New Issue
Block a user