mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T171, callsign completer class
* completer used in 3 places, makes sense to encapsulate as class * automatically updating from network context
This commit is contained in:
73
src/blackgui/components/callsigncompleter.h
Normal file
73
src/blackgui/components/callsigncompleter.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* Copyright (C) 2017
|
||||
* 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_CALLSIGNCOMPLETER_H
|
||||
#define BLACKGUI_COMPONENTS_CALLSIGNCOMPLETER_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackcore/network.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
#include <QCompleter>
|
||||
|
||||
namespace Ui { class CCallsignCompleter; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Completer for aircraft callsigns
|
||||
*/
|
||||
class BLACKGUI_EXPORT CCallsignCompleter : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CCallsignCompleter(QWidget *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CCallsignCompleter();
|
||||
|
||||
//! Get the entered callsign
|
||||
BlackMisc::Aviation::CCallsign getCallsign() const;
|
||||
|
||||
//! String as entered
|
||||
QString getRawCallsignString() const;
|
||||
|
||||
//! Is valid callsign?
|
||||
bool hasValidCallsign() const;
|
||||
|
||||
signals:
|
||||
//! Callsign entered
|
||||
void validCallsignEntered();
|
||||
|
||||
//! Editing finished
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
void updateCallsignsFromContext();
|
||||
void onEditingFinished();
|
||||
void onChangedAircraftInRange();
|
||||
void onChangedConnectionStatus(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||
bool isValidKnownCallsign(const QString &callsignString) const;
|
||||
|
||||
QScopedPointer <Ui::CCallsignCompleter> ui;
|
||||
QCompleter *m_currentCompleter = nullptr;
|
||||
BlackMisc::Aviation::CCallsignSet m_validCallsigns;
|
||||
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &CCallsignCompleter::onChangedAircraftInRange, 5000, 5 };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user