mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refactor: Remove inline ATC settings (all/in range, valid freqs.)
Fixes #193
This commit is contained in:
@@ -409,7 +409,6 @@ add_library(gui SHARED
|
||||
components/commandinput.h
|
||||
components/configsimulatorcomponent.ui
|
||||
components/datamaininfoareacomponent.cpp
|
||||
components/settingsatcstationsinlinecomponent.cpp
|
||||
components/applicationclosedialog.cpp
|
||||
components/settingshotkeycomponent.h
|
||||
components/datamaininfoareacomponent.h
|
||||
@@ -550,7 +549,6 @@ add_library(gui SHARED
|
||||
components/dbcountryselectorcomponent.ui
|
||||
components/dbusserveraddressselector.h
|
||||
components/copysettingsandcachescomponent.cpp
|
||||
components/settingstextmessageinlinecomponent.ui
|
||||
components/colorselector.ui
|
||||
components/dbusserveraddressselector.cpp
|
||||
components/audioadvanceddistributedcomponent.h
|
||||
@@ -622,7 +620,6 @@ add_library(gui SHARED
|
||||
components/texteditdialog.cpp
|
||||
components/dbairlineicaoselectorbase.cpp
|
||||
components/aircraftmodelstringcompleter.h
|
||||
components/settingsatcstationsinlinecomponent.ui
|
||||
components/modelbrowserdialog.cpp
|
||||
components/airportdialog.cpp
|
||||
components/rawfsdmessagescomponent.ui
|
||||
@@ -657,7 +654,6 @@ add_library(gui SHARED
|
||||
components/dblogincomponent.cpp
|
||||
components/aircraftmodelsetvalidationdialog.h
|
||||
components/audiodevicevolumesetupcomponent.cpp
|
||||
components/settingsatcstationsinlinecomponent.h
|
||||
components/aboutdialog.h
|
||||
components/textmessagecomponent.ui
|
||||
components/aircraftmodelsetvalidationdialog.cpp
|
||||
@@ -904,10 +900,8 @@ add_library(gui SHARED
|
||||
settings/navigatorsettings.cpp
|
||||
settings/guisettings.cpp
|
||||
settings/textmessagesettings.h
|
||||
settings/atcstationssettings.h
|
||||
settings/dockwidgetsettings.cpp
|
||||
settings/textmessagesettings.cpp
|
||||
settings/atcstationssettings.cpp
|
||||
managedstatusbar.cpp
|
||||
sharedstringlistcompleter.cpp
|
||||
overlaymessages.ui
|
||||
|
||||
@@ -101,8 +101,6 @@ namespace BlackGui::Components
|
||||
connect(ui->tvp_AtcStationsOnlineTree, &CAtcStationTreeView::objectSelected, this, &CAtcStationComponent::onOnlineAtcStationSelected, Qt::QueuedConnection);
|
||||
connect(ui->tvp_AtcStationsOnlineTree, &CAtcStationTreeView::requestTextMessageWidget, this, &CAtcStationComponent::requestTextMessageWidget);
|
||||
|
||||
connect(ui->comp_AtcStationsSettings, &CSettingsAtcStationsInlineComponent::changed, this, &CAtcStationComponent::forceUpdate, Qt::QueuedConnection);
|
||||
|
||||
connect(ui->tb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::requestAtisUpdates);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update);
|
||||
|
||||
@@ -164,12 +162,6 @@ namespace BlackGui::Components
|
||||
return c && parentDockableWidget;
|
||||
}
|
||||
|
||||
void CAtcStationComponent::forceUpdate()
|
||||
{
|
||||
m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
|
||||
this->update();
|
||||
}
|
||||
|
||||
void CAtcStationComponent::update()
|
||||
{
|
||||
if (!this->canAccessContext()) { return; }
|
||||
@@ -190,25 +182,14 @@ namespace BlackGui::Components
|
||||
// update
|
||||
if (m_timestampOnlineStationsChanged > m_timestampLastReadOnlineStations)
|
||||
{
|
||||
const CAtcStationsSettings settings = ui->comp_AtcStationsSettings->getSettings();
|
||||
CAtcStationList onlineStations = sGui->getIContextNetwork()->getAtcStationsOnline(true);
|
||||
const int allStationsCount = onlineStations.sizeInt();
|
||||
int inRangeCount = -1;
|
||||
|
||||
if (settings.showOnlyWithValidFrequency()) { onlineStations = onlineStations.stationsWithValidFrequency(); }
|
||||
if (settings.showOnlyInRange())
|
||||
{
|
||||
onlineStations.removeIfOutsideRange();
|
||||
inRangeCount = onlineStations.sizeInt();
|
||||
}
|
||||
|
||||
const int stationsCount = onlineStations.sizeInt();
|
||||
ui->tvp_AtcStationsOnline->updateContainerMaybeAsync(onlineStations);
|
||||
m_timestampLastReadOnlineStations = QDateTime::currentDateTimeUtc();
|
||||
m_timestampOnlineStationsChanged = m_timestampLastReadOnlineStations;
|
||||
this->updateTreeView();
|
||||
this->setOnlineTabs(allStationsCount, stationsCount);
|
||||
ui->comp_AtcStationsSettings->setCounts(allStationsCount, inRangeCount);
|
||||
|
||||
if (stationsCount < 1 && allStationsCount > 0)
|
||||
{
|
||||
@@ -480,7 +461,6 @@ namespace BlackGui::Components
|
||||
}
|
||||
|
||||
ui->te_AtcStationsOnlineInfo->setVisible(checked);
|
||||
ui->comp_AtcStationsSettings->setVisible(checked);
|
||||
ui->le_AtcStationsOnlineMetar->setVisible(checked);
|
||||
ui->tb_AtcStationsAtisReload->setVisible(checked);
|
||||
ui->tb_AtcStationsLoadMetar->setVisible(checked);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#define BLACKGUI_COMPONENTS_ATCSTATIONCOMPONENT_H
|
||||
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackgui/settings/atcstationssettings.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/aviation/atcstation.h"
|
||||
@@ -84,9 +83,6 @@ namespace BlackGui
|
||||
void requestAudioWidget();
|
||||
|
||||
private:
|
||||
//! Set timestampd and call update
|
||||
void forceUpdate();
|
||||
|
||||
//! ATC station disconnected
|
||||
void atcStationDisconnected(const BlackMisc::Aviation::CAtcStation &station);
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="gb_Details">
|
||||
<property name="title">
|
||||
<string>Details (METAR, ATIS, range)</string>
|
||||
<string>Details (METAR, ATIS)</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
@@ -141,16 +141,6 @@
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CSettingsAtcStationsInlineComponent" name="comp_AtcStationsSettings">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="wi_ButtonsAndEntry" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_ButtonsAndEntry">
|
||||
@@ -265,12 +255,6 @@
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/atcstationview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSettingsAtcStationsInlineComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/settingsatcstationsinlinecomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CAtcStationTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace BlackGui::Components
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsActionHotkeys, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsActionHotkeys.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsTextMessages, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsTextMessage.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsAtcStations, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAtcStations.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsDirectories, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsDirectories.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsConsolidation, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsConsolidation.getFilename()));
|
||||
@@ -119,7 +118,6 @@ namespace BlackGui::Components
|
||||
void CCopySettingsAndCachesComponent::initMisc()
|
||||
{
|
||||
ui->cb_SettingsActionHotkeys->setText(checkBoxText(TActionHotkeys::humanReadable(), true));
|
||||
ui->cb_SettingsAtcStations->setText(checkBoxText(TAtcStationsSettings::humanReadable(), true));
|
||||
ui->cb_SettingsTextMessages->setText(checkBoxText(TextMessageSettings::humanReadable(), true));
|
||||
ui->cb_SettingsDirectories->setText(checkBoxText(TDirectorySettings::humanReadable(), true));
|
||||
}
|
||||
@@ -362,20 +360,6 @@ namespace BlackGui::Components
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsAtcStations->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsAtcStations.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CAtcStationsSettings settings = CAtcStationsSettings::fromJsonNoThrow(joStr, true, success, errMsg);
|
||||
if (this->parsingMessage(success, errMsg, m_settingsAtcStations.getKey()))
|
||||
{
|
||||
this->displayStatusMessage(m_settingsAtcStations.setAndSave(settings), settings.toQString(true));
|
||||
copied++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsTextMessages->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsTextMessage.getFilename());
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "blackgui/settings/dockwidgetsettings.h"
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackgui/settings/textmessagesettings.h"
|
||||
#include "blackgui/settings/atcstationssettings.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/data/launchersetup.h"
|
||||
@@ -116,7 +115,6 @@ namespace BlackGui::Components
|
||||
BlackMisc::CSetting<Settings::TDockWidget> m_settingsDockWidget { this };
|
||||
BlackMisc::CSetting<Settings::TViewUpdateSettings> m_settingsViewUpdate { this };
|
||||
BlackMisc::CSetting<Settings::TBackgroundConsolidation> m_settingsConsolidation { this }; //!< consolidation time
|
||||
BlackMisc::CSetting<Settings::TAtcStationsSettings> m_settingsAtcStations { this };
|
||||
BlackMisc::CSetting<Settings::TextMessageSettings> m_settingsTextMessage { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_settingsEnabledSimulators { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_settingsActionHotkeys { this };
|
||||
|
||||
@@ -222,13 +222,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsAtcStations">
|
||||
<property name="text">
|
||||
<string>ATC stations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsTextMessages">
|
||||
<property name="text">
|
||||
@@ -351,7 +344,6 @@
|
||||
<tabstop>cb_SettingsConsolidation</tabstop>
|
||||
<tabstop>cb_SettingsActionHotkeys</tabstop>
|
||||
<tabstop>cb_SettingsDirectories</tabstop>
|
||||
<tabstop>cb_SettingsAtcStations</tabstop>
|
||||
<tabstop>cb_SettingsTextMessages</tabstop>
|
||||
<tabstop>le_Status</tabstop>
|
||||
<tabstop>pb_DeselectAll</tabstop>
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "settingsatcstationsinlinecomponent.h"
|
||||
#include "ui_settingsatcstationsinlinecomponent.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPointer>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackGui::Settings;
|
||||
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
CSettingsAtcStationsInlineComponent::CSettingsAtcStationsInlineComponent(QWidget *parent) : QFrame(parent),
|
||||
ui(new Ui::CSettingsAtcStationsInlineComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->rb_All->setChecked(true); // default for AFV
|
||||
|
||||
connect(ui->rb_InRange, &QRadioButton::toggled, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection);
|
||||
connect(ui->cb_Frequency, &QRadioButton::released, this, &CSettingsAtcStationsInlineComponent::changeSettings, Qt::QueuedConnection);
|
||||
|
||||
QPointer<CSettingsAtcStationsInlineComponent> myself(this);
|
||||
QTimer::singleShot(2000, this, [=] {
|
||||
if (!myself) { return; }
|
||||
this->onSettingsChanged();
|
||||
});
|
||||
}
|
||||
|
||||
CSettingsAtcStationsInlineComponent::~CSettingsAtcStationsInlineComponent()
|
||||
{}
|
||||
|
||||
void CSettingsAtcStationsInlineComponent::setCounts(int all, int inRange)
|
||||
{
|
||||
static const QString sAll = ui->rb_All->text();
|
||||
static const QString sInRange = ui->rb_InRange->text();
|
||||
|
||||
ui->rb_All->setText(all < 0 ? sAll : sAll % QStringLiteral(" (%1)").arg(all));
|
||||
ui->rb_InRange->setText(inRange < 0 ? sInRange : sInRange % QStringLiteral(" (%1)").arg(inRange));
|
||||
}
|
||||
|
||||
void CSettingsAtcStationsInlineComponent::onSettingsChanged()
|
||||
{
|
||||
const CAtcStationsSettings s = m_atcSettings.getThreadLocal();
|
||||
if (s.showOnlyInRange())
|
||||
{
|
||||
ui->rb_InRange->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->rb_All->setChecked(true);
|
||||
}
|
||||
|
||||
ui->cb_Frequency->setChecked(s.showOnlyWithValidFrequency());
|
||||
}
|
||||
|
||||
void CSettingsAtcStationsInlineComponent::changeSettings()
|
||||
{
|
||||
const bool onlyInRange = ui->rb_InRange->isChecked();
|
||||
const bool freq = ui->cb_Frequency->isChecked();
|
||||
CAtcStationsSettings s = m_atcSettings.getThreadLocal();
|
||||
const CAtcStationsSettings oldSettings = s;
|
||||
s.setShowOnlyInRange(onlyInRange);
|
||||
s.setShowOnlyWithValidFrequency(freq);
|
||||
if (oldSettings == s) { return; }
|
||||
m_atcSettings.setAndSave(s);
|
||||
emit this->changed();
|
||||
}
|
||||
} // ns
|
||||
@@ -1,53 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_SETTINGSATCSTATIONSINLINECOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_SETTINGSATCSTATIONSINLINECOMPONENT_H
|
||||
|
||||
#include "blackgui/settings/atcstationssettings.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CSettingsAtcStationsInlineComponent;
|
||||
}
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
/*!
|
||||
* How ATC stations will be displayed
|
||||
*/
|
||||
class CSettingsAtcStationsInlineComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsAtcStationsInlineComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSettingsAtcStationsInlineComponent();
|
||||
|
||||
//! Get the settings
|
||||
Settings::CAtcStationsSettings getSettings() const { return m_atcSettings.get(); }
|
||||
|
||||
//! Set count information
|
||||
void setCounts(int all, int inRange);
|
||||
|
||||
signals:
|
||||
//! Changed value
|
||||
void changed();
|
||||
|
||||
private:
|
||||
//! Settings have been changed
|
||||
void onSettingsChanged();
|
||||
|
||||
//! Change the settings
|
||||
void changeSettings();
|
||||
|
||||
QScopedPointer<Ui::CSettingsAtcStationsInlineComponent> ui;
|
||||
BlackMisc::CSetting<BlackGui::Settings::TAtcStationsSettings> m_atcSettings { this, &CSettingsAtcStationsInlineComponent::onSettingsChanged };
|
||||
};
|
||||
} // ns
|
||||
#endif // guard
|
||||
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsAtcStationsInlineComponent</class>
|
||||
<widget class="QFrame" name="CSettingsAtcStationsInlineComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>291</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>ATC stations settings</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_AtcStationsInlineComponent">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Frequency">
|
||||
<property name="toolTip">
|
||||
<string>valid frequencies only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>freq. only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Settings">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_All">
|
||||
<property name="text">
|
||||
<string>all</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_InRange">
|
||||
<property name="text">
|
||||
<string>in range</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackgui/settings/guisettings.h"
|
||||
#include "blackgui/settings/textmessagesettings.h"
|
||||
#include "blackgui/settings/atcstationssettings.h"
|
||||
#include "blackgui/components/registermetadatacomponents.h"
|
||||
|
||||
namespace BlackGui
|
||||
@@ -19,7 +18,6 @@ namespace BlackGui
|
||||
BlackGui::Settings::CViewUpdateSettings::registerMetadata();
|
||||
BlackGui::Settings::CGeneralGuiSettings::registerMetadata();
|
||||
BlackGui::Settings::CTextMessageSettings::registerMetadata();
|
||||
BlackGui::Settings::CAtcStationsSettings::registerMetadata();
|
||||
BlackGui::Components::registerMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "atcstationssettings.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
BLACK_DEFINE_VALUEOBJECT_MIXINS(BlackGui::Settings, CAtcStationsSettings)
|
||||
|
||||
namespace BlackGui::Settings
|
||||
{
|
||||
CAtcStationsSettings::CAtcStationsSettings()
|
||||
{}
|
||||
|
||||
QString CAtcStationsSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n)
|
||||
static const QString s("In range only: %1 valid freq: %2");
|
||||
return s.arg(boolToOnOff(this->showOnlyInRange()), boolToOnOff(this->showOnlyWithValidFrequency()));
|
||||
}
|
||||
|
||||
QVariant CAtcStationsSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInRangeOnly: return QVariant::fromValue(m_showOnlyInRange);
|
||||
case IndexValidFrequencyOnly: return QVariant::fromValue(m_onlyWithValidFrequency);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationsSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
(*this) = variant.value<CAtcStationsSettings>();
|
||||
return;
|
||||
}
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInRangeOnly: this->setShowOnlyInRange(variant.toBool()); break;
|
||||
case IndexValidFrequencyOnly: this->setShowOnlyWithValidFrequency(variant.toBool()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
@@ -1,81 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_SETTINGS_ATCSTATIONSSETTINGS_H
|
||||
#define BLACKGUI_SETTINGS_ATCSTATIONSSETTINGS_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include <QString>
|
||||
|
||||
BLACK_DECLARE_VALUEOBJECT_MIXINS(BlackGui::Settings, CAtcStationsSettings)
|
||||
|
||||
namespace BlackGui::Settings
|
||||
{
|
||||
//! How to display ATC stations
|
||||
class BLACKGUI_EXPORT CAtcStationsSettings : public BlackMisc::CValueObject<CAtcStationsSettings>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexInRangeOnly = BlackMisc::CPropertyIndexRef::GlobalIndexCAtcStationsSettings,
|
||||
IndexValidFrequencyOnly
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CAtcStationsSettings();
|
||||
|
||||
//! Show in range ATC stations only?
|
||||
bool showOnlyInRange() const { return m_showOnlyInRange; }
|
||||
|
||||
//! Show in range ATC stations only
|
||||
void setShowOnlyInRange(bool onlyInRange) { m_showOnlyInRange = onlyInRange; }
|
||||
|
||||
//! Show only with valid frequency?
|
||||
bool showOnlyWithValidFrequency() const { return m_onlyWithValidFrequency; }
|
||||
|
||||
//! Show only with valid frequency
|
||||
void setShowOnlyWithValidFrequency(bool onlyValidFrequency) { m_onlyWithValidFrequency = onlyValidFrequency; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(BlackMisc::CPropertyIndexRef index, const QVariant &variant);
|
||||
|
||||
private:
|
||||
bool m_showOnlyInRange = true;
|
||||
bool m_onlyWithValidFrequency = true;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CAtcStationsSettings,
|
||||
BLACK_METAMEMBER(showOnlyInRange),
|
||||
BLACK_METAMEMBER(onlyWithValidFrequency)
|
||||
);
|
||||
};
|
||||
|
||||
//! ATC stations settings
|
||||
struct TAtcStationsSettings : public BlackMisc::TSettingTrait<CAtcStationsSettings>
|
||||
{
|
||||
//! \copydoc BlackMisc::TSettingTrait::key
|
||||
static const char *key() { return "atcstations"; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable()
|
||||
{
|
||||
static const QString name("ATC stations");
|
||||
return name;
|
||||
}
|
||||
};
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackGui::Settings::CAtcStationsSettings)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackGui::Settings::CAtcStationsSettings>)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user