mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Use lambda to combine common logic
This commit is contained in:
@@ -123,8 +123,8 @@ namespace swift::gui::views
|
||||
auto *text = new QAction(CIcons::appTextMessages16(), "Show text messages", this);
|
||||
auto *resize = new QAction(CIcons::resize16(), "Resize", this);
|
||||
|
||||
connect(com1, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom1);
|
||||
connect(com2, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom2);
|
||||
connect(com1, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com1); });
|
||||
connect(com2, &QAction::triggered, this, [this]() { tuneInAtc(CComSystem::Com2); });
|
||||
connect(text, &QAction::triggered, this, &CAtcStationTreeView::requestTextMessage);
|
||||
connect(resize, &QAction::triggered, this, &CAtcStationTreeView::fullResizeToContentsImpl);
|
||||
|
||||
@@ -160,18 +160,11 @@ namespace swift::gui::views
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationTreeView::tuneInAtcCom1()
|
||||
void CAtcStationTreeView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit)
|
||||
{
|
||||
const CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com1);
|
||||
}
|
||||
|
||||
void CAtcStationTreeView::tuneInAtcCom2()
|
||||
{
|
||||
const CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com2);
|
||||
emit this->requestComFrequency(s.getFrequency(), unit);
|
||||
}
|
||||
|
||||
void CAtcStationTreeView::requestTextMessage()
|
||||
|
||||
@@ -107,8 +107,7 @@ namespace swift::gui
|
||||
|
||||
//! @{
|
||||
//! Tune in/invoke
|
||||
void tuneInAtcCom1();
|
||||
void tuneInAtcCom2();
|
||||
void tuneInAtc(misc::aviation::CComSystem::ComUnit unit);
|
||||
void requestTextMessage();
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -59,12 +59,12 @@ namespace swift::gui::views
|
||||
{
|
||||
if (m_actions.isEmpty()) { m_actions = QList<QAction *>({ nullptr, nullptr, nullptr }); }
|
||||
|
||||
m_actions[0] =
|
||||
menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1",
|
||||
CMenuAction::pathClientCom(), { this, &CAtcStationView::tuneInAtcCom1 });
|
||||
m_actions[1] =
|
||||
menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2",
|
||||
CMenuAction::pathClientCom(), { this, &CAtcStationView::tuneInAtcCom2 });
|
||||
m_actions[0] = menuActions.addAction(m_actions[0], CIcons::appCockpit16(), "Tune in COM1",
|
||||
CMenuAction::pathClientCom(),
|
||||
{ this, [this]() { tuneInAtc(CComSystem::Com1); } });
|
||||
m_actions[1] = menuActions.addAction(m_actions[1], CIcons::appCockpit16(), "Tune in COM2",
|
||||
CMenuAction::pathClientCom(),
|
||||
{ this, [this]() { tuneInAtc(CComSystem::Com2); } });
|
||||
m_actions[2] =
|
||||
menuActions.addAction(m_actions[2], CIcons::appTextMessages16(), "Show text messages",
|
||||
CMenuAction::pathClientCom(), { this, &CAtcStationView::requestTextMessage });
|
||||
@@ -72,18 +72,11 @@ namespace swift::gui::views
|
||||
CViewBase::customMenu(menuActions);
|
||||
}
|
||||
|
||||
void CAtcStationView::tuneInAtcCom1()
|
||||
void CAtcStationView::tuneInAtc(const misc::aviation::CComSystem::ComUnit unit)
|
||||
{
|
||||
const CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com1);
|
||||
}
|
||||
|
||||
void CAtcStationView::tuneInAtcCom2()
|
||||
{
|
||||
const CAtcStation s(this->selectedObject());
|
||||
if (s.getCallsign().isEmpty()) { return; }
|
||||
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com2);
|
||||
emit this->requestComFrequency(s.getFrequency(), unit);
|
||||
}
|
||||
|
||||
void CAtcStationView::requestTextMessage()
|
||||
|
||||
@@ -64,8 +64,7 @@ namespace swift::gui
|
||||
private:
|
||||
void emitTestRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
|
||||
void emitTestRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
|
||||
void tuneInAtcCom1();
|
||||
void tuneInAtcCom2();
|
||||
void tuneInAtc(misc::aviation::CComSystem::ComUnit unit);
|
||||
void requestTextMessage();
|
||||
|
||||
QList<QAction *> m_actions; //!< real actions
|
||||
|
||||
Reference in New Issue
Block a user