7 #include <QDragEnterEvent>
8 #include <QDragLeaveEvent>
9 #include <QDragMoveEvent>
26 using namespace swift::misc::db;
27 using namespace swift::misc::network;
28 using namespace swift::misc::aviation;
29 using namespace swift::misc::network;
33 CDbAirlineIcaoSelectorBase::CDbAirlineIcaoSelectorBase(QWidget *parent) : QFrame(parent)
35 this->setAcceptDrops(
true);
38 connect(
sGui->
getWebDataServices(), &CWebDataServices::dataRead,
this, &CDbAirlineIcaoSelectorBase::onCodesRead,
39 Qt::QueuedConnection);
46 QPointer<CDbAirlineIcaoSelectorBase> myself(
this);
49 if (!myself) {
return; }
50 this->onCodesRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c, {});
82 if (!event || !
acceptDrop(event->mimeData())) {
return; }
83 this->setBackgroundRole(QPalette::Highlight);
84 event->acceptProposedAction();
89 if (!event || !
acceptDrop(event->mimeData())) {
return; }
90 event->acceptProposedAction();
95 if (!event) {
return; }
101 if (!event || !
acceptDrop(event->mimeData())) {
return; }
114 if (icaos.
isEmpty()) {
return; }
121 int count,
const QUrl &url)
125 if (!
sGui) {
return; }
126 if (entity.testFlag(CEntityFlags::AirlineIcaoEntity) && CEntityFlags::isFinishedReadState(readState))
131 Q_ASSERT_X(c, Q_FUNC_INFO,
"missing converter");
132 connect(c, qOverload<const QString &>(&QCompleter::activated),
this,
133 &CDbAirlineIcaoSelectorBase::onCompleterActivated);
140 void CDbAirlineIcaoSelectorBase::onCompleterActivated(
const QString &icaoString)
142 const int dbKey = CDatastoreUtility::extractIntegerKey(icaoString);
143 if (dbKey < 0) {
return; }
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
swift::misc::aviation::CAirlineIcaoCode getAirlineIcaoCodeForDbKey(int id) const
ICAO code for id.
swift::misc::aviation::CAirlineIcaoCode smartAirlineIcaoSelector(const swift::misc::aviation::CAirlineIcaoCode &code, const swift::misc::aviation::CCallsign &callsign=swift::misc::aviation::CCallsign()) const
Smart airline selector.
int getAirlineIcaoCodesCount() const
Airline ICAO codes count.
bool acceptDrop(const QMimeData *mime) const
Accept drop?
swift::misc::CVariant toCVariant(const QMimeData *mime) const
Mime data to CVariant (normally encapsulating a value object)
void setAcceptedMetaTypeIds(const QList< int > &ids)
Accepted ids.
bool isSet() const
Set with valid value.
virtual ~CDbAirlineIcaoSelectorBase()
Destructor.
virtual void dragLeaveEvent(QDragLeaveEvent *event)
virtual QCompleter * createCompleter()=0
Create a new completer.
const swift::misc::aviation::CAirlineIcaoCode & getAirlineIcao() const
Airline ICAO.
virtual bool setAirlineIcao(const swift::misc::aviation::CAirlineIcaoCode &icao)
Current airline ICAO.
virtual void dragEnterEvent(QDragEnterEvent *event)
swift::misc::aviation::CAirlineIcaoCode m_currentIcao
current ICAO object
QScopedPointer< QCompleter > m_completer
completer used
void changedAirlineIcao(const swift::misc::aviation::CAirlineIcaoCode &icao)
ICAO was changed.
virtual void dropEvent(QDropEvent *event)
virtual void dragMoveEvent(QDragMoveEvent *event)
reference front()
Access the first element.
bool isEmpty() const
Synonym for empty.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
T value() const
Return the value converted to the type T.
bool isValid() const
True if this variant is valid.
bool canConvert(int typeId) const
True if this variant can be converted to the type with the given metatype ID.
Value object for ICAO classification.
bool hasCompleteData() const
Complete data.
Value object encapsulating a list of ICAO codes.
bool isLoadedFromDb() const
Loaded from DB.
bool hasValidDbKey() const
Has valid DB key.
ReadState
State of operation.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...