8 #include <QStringBuilder>
9 #include <QStringListModel>
11 #include "ui_aircraftpartshistory.h"
21 using namespace swift::misc::aviation;
22 using namespace swift::misc::network;
24 using namespace swift::core::context;
37 &CAircraftPartsHistory::callsignEntered);
40 if (this->hasContexts())
43 &CAircraftPartsHistory::valuesChanged);
45 &CAircraftPartsHistory::connectionStatusChanged);
52 void CAircraftPartsHistory::initGui()
55 const bool needCallsigns = this->partsHistoryEnabled();
56 if (needCallsigns && !m_timerUpdateHistory.
isActive()) { m_timerUpdateHistory.
start(); }
57 else if (!needCallsigns) { m_timerUpdateHistory.
stop(); }
61 ui->cb_PartsHistoryEnabled->setChecked(c);
64 bool CAircraftPartsHistory::hasContexts()
const
69 bool CAircraftPartsHistory::partsHistoryEnabled()
const {
return this->hasContexts(); }
71 void CAircraftPartsHistory::updatePartsHistory()
73 if (!this->hasContexts()) {
return; }
75 const CCallsign cs(ui->comp_CallsignCompleter->getCallsign());
76 if (cs.isEmpty()) {
return; }
81 if (currentAircraftParts ==
CAircraftParts() && aircraftPartsHistory.isEmpty())
83 html = cs.toQString() % u
" does not support aircraft parts or nothing received yet.";
89 u
" " %
90 currentAircraftParts.getLights().toQString() %
103 u
" " %
104 currentAircraftParts.getEngines().toQString() %
109 if (ui->cb_PartsHistoryEnabled->isChecked())
111 html += u
"<hr>" % aircraftPartsHistory.toHtml(CStatusMessageList::timestampHtmlOutput());
115 const size_t hash =
qHash(html);
116 if (hash == m_htmlHash) {
return; }
119 ui->te_Messages->setDocument(&m_text);
121 if (ui->cb_AutoScrollEnabled->isChecked())
125 ui->te_Messages->setTextCursor(c);
129 void CAircraftPartsHistory::callsignEntered()
131 this->updatePartsHistory();
132 m_timerUpdateHistory.
start();
135 void CAircraftPartsHistory::valuesChanged() { this->initGui(); }
137 void CAircraftPartsHistory::toggleHistoryEnabled(
bool enabled)
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
bool isDeveloperFlagSet() const
Running with dev.flag?
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
virtual bool isAircraftPartsHistoryEnabled() const =0
Is storing the aircraft parts history enabled?
virtual swift::misc::CStatusMessageList getAircraftPartsHistory(const swift::misc::aviation::CCallsign &callsign) const =0
Get aircraft parts history.
virtual swift::misc::aviation::CAircraftPartsList getRemoteAircraftParts(const swift::misc::aviation::CCallsign &callsign) const =0
Get remote aircraft parts.
virtual void enableAircraftPartsHistory(bool enabled)=0
Enable storing of aircraft parts.
History frame for received aircraft parts.
virtual ~CAircraftPartsHistory()
Destructor.
void validChangedCallsignEntered()
Changed callsign entered.
const_reference frontOrDefault() const
Access the first element, or a default-initialized value if the sequence is empty.
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of a callsign.
Value object encapsulating information about a connection status.
bool isConnected() const
Query status.
bool isDisconnected() const
Query status.
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.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * sender() const const
QString number(double n, char format, int precision)
bool movePosition(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode, int n)
void setDefaultStyleSheet(const QString &sheet)
void setHtml(const QString &html)
void setInterval(int msec)
bool isActive() const const