swift
modelmatcherlogcomponent.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include <QCompleter>
7 #include <QStringListModel>
8 
9 #include "ui_modelmatcherlogcomponent.h"
10 
13 #include "gui/guiapplication.h"
14 #include "gui/uppercasevalidator.h"
15 #include "misc/htmlutils.h"
16 #include "misc/propertyindexlist.h"
17 
18 using namespace swift::misc;
19 using namespace swift::misc::aviation;
20 using namespace swift::core;
21 using namespace swift::core::context;
22 
23 namespace swift::gui::components
24 {
25  CModelMatcherLogComponent::CModelMatcherLogComponent(QWidget *parent)
26  : QFrame(parent), ui(new Ui::CModelMatcherLogComponent)
27  {
28  ui->setupUi(this);
29  m_text.setDefaultStyleSheet(CStatusMessageList::htmlStyleSheet());
30  connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validCallsignEnteredDigest, this,
31  &CModelMatcherLogComponent::callsignEntered);
32  }
33 
35 
36  bool CModelMatcherLogComponent::hasContexts() const
37  {
39  }
40 
41  bool CModelMatcherLogComponent::enabledMessages() const
42  {
43  return this->hasContexts() &&
44  (ui->comp_EnableLog->isMatchingLogEnabled() || ui->comp_EnableLog->isReverseLookupLogEnabled());
45  }
46 
47  void CModelMatcherLogComponent::callsignEntered()
48  {
49  if (!this->hasContexts()) { return; }
50  const CCallsign cs(ui->comp_CallsignCompleter->getCallsign());
51  if (cs.isEmpty()) { return; }
52  const CStatusMessageList reverseLookupMessages = sGui->getIContextNetwork()->getReverseLookupMessages(cs);
53  const CStatusMessageList matchingMessages = sGui->getIContextSimulator()->getMatchingMessages(cs);
54 
55  CStatusMessageList allMessages(reverseLookupMessages);
56  allMessages.push_back(matchingMessages);
57 
58  const QString html = allMessages.toHtml();
59  m_text.setHtml(html);
60  ui->te_Messages->setDocument(&m_text);
61  }
62 } // namespace swift::gui::components
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
virtual swift::misc::CStatusMessageList getReverseLookupMessages(const swift::misc::aviation::CCallsign &callsign) const =0
Get reverse lookup messages.
virtual swift::misc::CStatusMessageList getMatchingMessages(const swift::misc::aviation::CCallsign &callsign) const =0
Get mapping messages.
void validCallsignEnteredDigest()
Changed callsign entered.
Special logs for matching and reverse lookup.
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of a callsign.
Definition: callsign.h:30
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.
Definition: actionbind.cpp:7
High level reusable GUI components.
Definition: aboutdialog.cpp:13
Free functions in swift::misc.