swift
callsigncompleter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_COMPONENTS_CALLSIGNCOMPLETER_H
7 #define SWIFT_GUI_COMPONENTS_CALLSIGNCOMPLETER_H
8 
9 #include <QCompleter>
10 #include <QFrame>
11 #include <QScopedPointer>
12 #include <QTimer>
13 
15 #include "gui/swiftguiexport.h"
17 #include "misc/digestsignal.h"
19 
20 namespace Ui
21 {
22  class CCallsignCompleter;
23 }
24 namespace swift::gui::components
25 {
29  class SWIFT_GUI_EXPORT CCallsignCompleter : public QFrame
30  {
31  Q_OBJECT
32 
33  public:
35  explicit CCallsignCompleter(QWidget *parent = nullptr);
36 
38  virtual ~CCallsignCompleter() override;
39 
41  swift::misc::aviation::CCallsign getCallsign(bool onlyKnownCallsign = true) const;
42 
44  void setCallsign(const swift::misc::aviation::CCallsign &cs);
45 
47  QString getRawCallsignString() const;
48 
50  bool hasValidCallsign() const;
51 
53  void setReadOnly(bool readOnly);
54 
56  void addOwnCallsign(bool add) { m_addOwnCallsign = add; }
57 
59  void onlyWithParts(bool partsOnly) { m_onlyWithParts = partsOnly; }
60 
61  signals:
64 
67 
70 
71  private:
72  void updateCallsignsFromContext();
73  void onEditingFinished();
74  void onChangedAircraftInRange();
75  void onChangedConnectionStatus(const swift::misc::network::CConnectionStatus &from,
77  bool isValidKnownCallsign(const QString &callsignString) const;
78 
80  static CSharedStringListCompleter *completer();
81 
82  QScopedPointer<Ui::CCallsignCompleter> ui;
83  swift::misc::CDigestSignal m_dsAircraftsInRangeChanged { this, &CCallsignCompleter::onChangedAircraftInRange,
84  std::chrono::milliseconds(5000), 5 };
86  std::chrono::milliseconds(500), 3 };
88  std::chrono::milliseconds(500), 3 };
89  QString m_lastValue;
90 
91  bool m_addOwnCallsign = false;
92  bool m_onlyWithParts = false;
93  };
94 } // namespace swift::gui::components
95 #endif // SWIFT_GUI_COMPONENTS_CALLSIGNCOMPLETER_H
Completer shared among multiple UI elements.
Completer for aircraft callsigns.
void onlyWithParts(bool partsOnly)
Only with parts.
void editingFinishedDigest()
Editing finished.
void addOwnCallsign(bool add)
Add own callsign.
void validCallsignEnteredDigest()
Changed callsign entered.
void validChangedCallsignEntered()
Changed callsign entered.
Receive 1..n signals, collect them over time, and resend afer n milliseconds.
Definition: digestsignal.h:18
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Value object encapsulating information about a connection status.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.