mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
refs #432, adjusted originators
This commit is contained in:
@@ -16,29 +16,19 @@ namespace BlackGui
|
||||
{
|
||||
|
||||
CCommandInput::CCommandInput(QWidget *parent) :
|
||||
QLineEdit(parent)
|
||||
QLineEdit(parent),
|
||||
COriginatorAware(this)
|
||||
{
|
||||
connect(this, &CCommandInput::returnPressed, this, &CCommandInput::validateCommand);
|
||||
connect(this, &CCommandInput::returnPressed, this, &CCommandInput::ps_validateCommand);
|
||||
}
|
||||
|
||||
void CCommandInput::validateCommand()
|
||||
void CCommandInput::ps_validateCommand()
|
||||
{
|
||||
QString commandLine = text();
|
||||
setText(QString());
|
||||
|
||||
QString commandLine(this->text().trimmed());
|
||||
this->setText(QString());
|
||||
if (commandLine.startsWith('.'))
|
||||
{
|
||||
emit commandEntered(commandLine, commandInputOriginator());
|
||||
emit commandEntered(commandLine, originator());
|
||||
}
|
||||
}
|
||||
|
||||
COriginator CCommandInput::commandInputOriginator()
|
||||
{
|
||||
if (m_originator.getName().isEmpty())
|
||||
m_originator = COriginator(QStringLiteral("COMMANDINPUT"));
|
||||
|
||||
return m_originator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -13,44 +13,33 @@
|
||||
#define BLACKGUI_COMMANDINPUT_H
|
||||
|
||||
#include "blackguiexport.h"
|
||||
#include "blackmisc/originator.h"
|
||||
#include "blackmisc/originatoraware.h"
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
//! Specialized LineEdit for command inputs
|
||||
class BLACKGUI_EXPORT CCommandInput : public QLineEdit
|
||||
class BLACKGUI_EXPORT CCommandInput :
|
||||
public QLineEdit,
|
||||
public BlackMisc::COriginatorAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
CCommandInput(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CCommandInput() {}
|
||||
|
||||
//! Originator
|
||||
BlackMisc::COriginator commandInputOriginator();
|
||||
|
||||
signals:
|
||||
|
||||
//! Command was entered
|
||||
void commandEntered(const QString &command, const BlackMisc::COriginator &originator);
|
||||
|
||||
private slots:
|
||||
|
||||
//! Basic command validation
|
||||
void validateCommand();
|
||||
|
||||
private:
|
||||
|
||||
BlackMisc::COriginator m_originator;
|
||||
void ps_validateCommand();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CCOMMANDINPUT_H
|
||||
#endif // guard
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace BlackGui
|
||||
{
|
||||
CAtcStationComponent::CAtcStationComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
COriginatorAware(this),
|
||||
ui(new Ui::CAtcStationComponent),
|
||||
m_updateTimer(new CUpdateTimer("CAtcStationComponent", &CAtcStationComponent::update, this))
|
||||
{
|
||||
@@ -275,14 +276,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
COriginator CAtcStationComponent::originator()
|
||||
{
|
||||
if (m_originator.getName().isEmpty())
|
||||
m_originator = COriginator(QStringLiteral("ATCSTATIOCOMPONENT"));
|
||||
|
||||
return m_originator;
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index)
|
||||
{
|
||||
this->ui->te_AtcStationsOnlineInfo->setText(""); // reset
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
#include "blackmisc/originator.h"
|
||||
#include "blackmisc/originatoraware.h"
|
||||
#include "blackmisc/aviation/atcstation.h"
|
||||
#include <QTabWidget>
|
||||
#include <QModelIndex>
|
||||
@@ -32,7 +32,8 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CAtcStationComponent :
|
||||
public QTabWidget,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public CEnableForRuntime
|
||||
public CEnableForRuntime,
|
||||
public BlackMisc::COriginatorAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -112,16 +113,12 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
void updateTreeView();
|
||||
BlackMisc::COriginator originator();
|
||||
|
||||
QScopedPointer<Ui::CAtcStationComponent> ui;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
QDateTime m_timestampLastReadOnlineStations = CUpdateTimer::epoch(); //!< stations read
|
||||
QDateTime m_timestampOnlineStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed
|
||||
QDateTime m_timestampLastReadBookedStations = CUpdateTimer::epoch(); //!< stations read
|
||||
QDateTime m_timestampBookedStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed
|
||||
BlackMisc::COriginator m_originator;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace BlackGui
|
||||
{
|
||||
CCockpitComComponent::CCockpitComComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
BlackMisc::COriginatorAware(this),
|
||||
ui(new Ui::CCockpitMainComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -62,7 +63,7 @@ namespace BlackGui
|
||||
|
||||
// init from aircraft
|
||||
CAircraft ownAircraft = this->getOwnAircraft();
|
||||
this->ps_updateCockpitFromContext(ownAircraft, COriginator("dummyInitialValues"));
|
||||
this->ps_updateCockpitFromContext(ownAircraft, COriginator("dummyInitialValues")); // intentionally different name here
|
||||
|
||||
// SELCAL pairs in cockpit
|
||||
this->ui->frp_ComPanelSelcalBottom->clear();
|
||||
@@ -111,12 +112,12 @@ namespace BlackGui
|
||||
|
||||
void CCockpitComComponent::ps_guiChangedSelcal()
|
||||
{
|
||||
this->getIContextOwnAircraft()->updateSelcal(this->getSelcal(), cockpitOriginator());
|
||||
this->getIContextOwnAircraft()->updateSelcal(this->getSelcal(), originator());
|
||||
}
|
||||
|
||||
void CCockpitComComponent::ps_updateCockpitFromContext(const CAircraft &ownAircraft, const COriginator &originator)
|
||||
{
|
||||
if (originator == CCockpitComComponent::cockpitOriginator()) return; // comes from myself
|
||||
if (isMyOriginator(originator)) { return; } // comes from myself
|
||||
|
||||
// update GUI elements
|
||||
// avoid unnecessary change events as far as possible
|
||||
@@ -184,7 +185,7 @@ namespace BlackGui
|
||||
|
||||
void CCockpitComComponent::ps_onChangedSelcal(const CSelcal &selcal, const COriginator &originator)
|
||||
{
|
||||
if (originator == CCockpitComComponent::cockpitOriginator()) return; // comes from myself
|
||||
if (isMyOriginator(originator)) { return; } // comes from myself
|
||||
this->ui->frp_ComPanelSelcalBottom->setSelcalCode(selcal);
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ namespace BlackGui
|
||||
|
||||
bool CCockpitComComponent::updateOwnCockpitInContext(const CAircraft &ownAircraft)
|
||||
{
|
||||
return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), CCockpitComComponent::cockpitOriginator());
|
||||
return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), originator());
|
||||
}
|
||||
|
||||
void CCockpitComComponent::updateFrequencyDisplaysFromComSystems(const CComSystem &com1, const CComSystem &com2)
|
||||
@@ -286,13 +287,7 @@ namespace BlackGui
|
||||
Q_UNUSED(connected);
|
||||
}
|
||||
|
||||
COriginator CCockpitComComponent::cockpitOriginator()
|
||||
{
|
||||
if (m_originator.getName().isEmpty())
|
||||
m_originator = COriginator(QStringLiteral("COCKPITCOMCOMPONENT"));
|
||||
|
||||
return m_originator;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "enablefordockwidgetinfoarea.h"
|
||||
#include "enableforruntime.h"
|
||||
#include "blackmisc/originator.h"
|
||||
#include "blackmisc/originatoraware.h"
|
||||
#include "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/aviation/transponder.h"
|
||||
#include "blackmisc/audio/voiceroomlist.h"
|
||||
@@ -29,6 +29,7 @@ namespace BlackGui
|
||||
//! The main cockpit area
|
||||
class BLACKGUI_EXPORT CCockpitComComponent :
|
||||
public QFrame,
|
||||
public BlackMisc::COriginatorAware,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public CEnableForRuntime
|
||||
{
|
||||
@@ -97,12 +98,8 @@ namespace BlackGui
|
||||
//! COM frequencies displayed
|
||||
void updateFrequencyDisplaysFromComSystems(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);
|
||||
|
||||
//! Identifies sender of cockpit updates
|
||||
BlackMisc::COriginator cockpitOriginator();
|
||||
|
||||
QScopedPointer<Ui::CCockpitMainComponent> ui;
|
||||
BlackMisc::COriginator m_originator;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace BlackGui
|
||||
{
|
||||
CCockpitTransponderModeLedsComponent::CCockpitTransponderModeLedsComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
COriginatorAware(this),
|
||||
m_ledStandby(new CLedWidget(false, CLedWidget::Blue, CLedWidget::Black, CLedWidget::Rounded, "standby", "", LedWidth, this)),
|
||||
m_ledModes(new CLedWidget(false, CLedWidget::Green, CLedWidget::Black, CLedWidget::Rounded, "mode C", "", LedWidth, this)),
|
||||
m_ledIdent(new CLedWidget(false, CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Rounded, "ident", "", LedWidth, this))
|
||||
@@ -38,7 +39,7 @@ namespace BlackGui
|
||||
|
||||
void CCockpitTransponderModeLedsComponent::ps_onAircraftCockpitChanged(const CAircraft &aircraft, const BlackMisc::COriginator &originator)
|
||||
{
|
||||
if (ledsOriginator() == originator) { return; }
|
||||
if (isMyOriginator(originator)) { return; }
|
||||
this->setMode(aircraft.getTransponderMode());
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ namespace BlackGui
|
||||
this->setMode(mode);
|
||||
CTransponder xpdr = ownAircraft.getTransponder();
|
||||
xpdr.setTransponderMode(mode);
|
||||
this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, ledsOriginator());
|
||||
this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, originator());
|
||||
}
|
||||
|
||||
void CCockpitTransponderModeLedsComponent::init(bool horizontal)
|
||||
@@ -133,13 +134,5 @@ namespace BlackGui
|
||||
return getIContextOwnAircraft()->getOwnAircraft();
|
||||
}
|
||||
|
||||
BlackMisc::COriginator CCockpitTransponderModeLedsComponent::ledsOriginator()
|
||||
{
|
||||
if (m_originator.getName().isEmpty())
|
||||
m_originator = COriginator(QStringLiteral("XPDRLEDSCOMCOMPONENT"));
|
||||
|
||||
return m_originator;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "enableforruntime.h"
|
||||
#include "../led.h"
|
||||
#include "blackmisc/originator.h"
|
||||
#include "blackmisc/originatoraware.h"
|
||||
#include "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/aviation/transponder.h"
|
||||
#include <QFrame>
|
||||
@@ -26,7 +26,10 @@ namespace BlackGui
|
||||
{
|
||||
|
||||
//! LEDs representing transponder mode state
|
||||
class BLACKGUI_EXPORT CCockpitTransponderModeLedsComponent : public QFrame, public CEnableForRuntime
|
||||
class BLACKGUI_EXPORT CCockpitTransponderModeLedsComponent :
|
||||
public QFrame,
|
||||
public CEnableForRuntime,
|
||||
public BlackMisc::COriginatorAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -60,16 +63,10 @@ namespace BlackGui
|
||||
//! Own Aircraft
|
||||
BlackMisc::Aviation::CAircraft getOwnAircraft() const;
|
||||
|
||||
//! Identifies sender of cockpit updates
|
||||
BlackMisc::COriginator ledsOriginator();
|
||||
|
||||
QScopedPointer<BlackGui::CLedWidget> m_ledStandby;
|
||||
QScopedPointer<BlackGui::CLedWidget> m_ledModes;
|
||||
QScopedPointer<BlackGui::CLedWidget> m_ledIdent;
|
||||
BlackMisc::COriginator m_originator;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in New Issue
Block a user