Skip to content

Commit

Permalink
Clean up SettingsGroup name and settingsGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed May 29, 2018
1 parent e660d0d commit 4a399fc
Show file tree
Hide file tree
Showing 19 changed files with 65 additions and 48 deletions.
6 changes: 4 additions & 2 deletions src/Settings/AppSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include <QtQml>
#include <QStandardPaths>

const char* AppSettings::settingsGroup = "App";
const char* AppSettings::name = "App";
const char* AppSettings::settingsGroup = ""; // settings are in root group

const char* AppSettings::offlineEditingFirmwareTypeSettingsName = "OfflineEditingFirmwareType";
const char* AppSettings::offlineEditingVehicleTypeSettingsName = "OfflineEditingVehicleType";
const char* AppSettings::offlineEditingCruiseSpeedSettingsName = "OfflineEditingCruiseSpeed";
Expand Down Expand Up @@ -58,7 +60,7 @@ const char* AppSettings::videoDirectory = "Video";
const char* AppSettings::crashDirectory = "CrashLogs";

AppSettings::AppSettings(QObject* parent)
: SettingsGroup (settingsGroup, QString() /* root settings group */, parent)
: SettingsGroup (name, settingsGroup, parent)
, _offlineEditingFirmwareTypeFact (NULL)
, _offlineEditingVehicleTypeFact (NULL)
, _offlineEditingCruiseSpeedFact (NULL)
Expand Down
1 change: 1 addition & 0 deletions src/Settings/AppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class AppSettings : public SettingsGroup
static MAV_AUTOPILOT offlineEditingFirmwareTypeFromFirmwareType(MAV_AUTOPILOT firmwareType);
static MAV_TYPE offlineEditingVehicleTypeFromVehicleType(MAV_TYPE vehicleType);

static const char* name;
static const char* settingsGroup;

static const char* offlineEditingFirmwareTypeSettingsName;
Expand Down
6 changes: 3 additions & 3 deletions src/Settings/AutoConnectSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <QQmlEngine>
#include <QtQml>

const char* AutoConnectSettings::_settingsGroup = "LinkManager";
const char* AutoConnectSettings::name = "AutoConnect";
const char* AutoConnectSettings::settingsGroup = "LinkManager";

const char* AutoConnectSettings:: autoConnectUDPSettingsName = "AutoconnectUDP";
const char* AutoConnectSettings:: autoConnectPixhawkSettingsName = "AutoconnectPixhawk";
Expand All @@ -27,10 +28,9 @@ const char* AutoConnectSettings:: udpListenPortName = "Autocon
const char* AutoConnectSettings:: udpTargetHostIPName = "AutoconnectUDPTargetHostIP";
const char* AutoConnectSettings:: udpTargetHostPortName = "AutoconnectUDPTargetHostPort";

const char* AutoConnectSettings::autoConnectSettingsGroupName = "AutoConnect";

AutoConnectSettings::AutoConnectSettings(QObject* parent)
: SettingsGroup (autoConnectSettingsGroupName, _settingsGroup, parent)
: SettingsGroup (name, settingsGroup, parent)
, _autoConnectUDPFact (NULL)
, _autoConnectPixhawkFact (NULL)
, _autoConnectSiKRadioFact (NULL)
Expand Down
5 changes: 2 additions & 3 deletions src/Settings/AutoConnectSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class AutoConnectSettings : public SettingsGroup
Fact* udpTargetHostIP (void);
Fact* udpTargetHostPort (void);

static const char* autoConnectSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* autoConnectUDPSettingsName;
static const char* autoConnectPixhawkSettingsName;
Expand All @@ -69,8 +70,6 @@ class AutoConnectSettings : public SettingsGroup
SettingsFact* _udpListenPortFact;
SettingsFact* _udpTargetHostIPFact;
SettingsFact* _udpTargetHostPortFact;

static const char* _settingsGroup;
};

#endif
10 changes: 6 additions & 4 deletions src/Settings/BrandImageSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#include <QQmlEngine>
#include <QtQml>

const char* BrandImageSettings::brandImageSettingsGroupName = "BrandImage";
const char* BrandImageSettings::userBrandImageIndoorName = "UserBrandImageIndoor";
const char* BrandImageSettings::userBrandImageOutdoorName = "UserBrandImageOutdoor";
const char* BrandImageSettings::name = "BrandImage";
const char* BrandImageSettings::settingsGroup = ""; // settings are in root group

const char* BrandImageSettings::userBrandImageIndoorName = "UserBrandImageIndoor";
const char* BrandImageSettings::userBrandImageOutdoorName = "UserBrandImageOutdoor";

BrandImageSettings::BrandImageSettings(QObject* parent)
: SettingsGroup(brandImageSettingsGroupName, QString() /* root settings group */, parent)
: SettingsGroup(name, settingsGroup, parent)
, _userBrandImageIndoorFact(NULL)
, _userBrandImageOutdoorFact(NULL)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Settings/BrandImageSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class BrandImageSettings : public SettingsGroup
Fact* userBrandImageIndoor (void);
Fact* userBrandImageOutdoor (void);

static const char* brandImageSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* userBrandImageIndoorName;
static const char* userBrandImageOutdoorName;
Expand Down
11 changes: 6 additions & 5 deletions src/Settings/FlightMapSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
#include <QQmlEngine>
#include <QtQml>

const char* FlightMapSettings::flightMapSettingsGroupName = "FlightMap";
const char* FlightMapSettings::mapProviderSettingsName = "MapProvider";
const char* FlightMapSettings::mapTypeSettingsName = "MapType";
const char* FlightMapSettings::_settingsGroupName = "FlightMap";
const char* FlightMapSettings::name = "FlightMap";
const char* FlightMapSettings::settingsGroup = "FlightMap";

const char* FlightMapSettings::mapProviderSettingsName = "MapProvider";
const char* FlightMapSettings::mapTypeSettingsName = "MapType";

FlightMapSettings::FlightMapSettings(QObject* parent)
: SettingsGroup(flightMapSettingsGroupName, QString(_settingsGroupName) /* root settings group */, parent)
: SettingsGroup(name, settingsGroup, parent)
, _mapProviderFact(NULL)
, _mapTypeFact(NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Settings/FlightMapSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class FlightMapSettings : public SettingsGroup
Fact* mapProvider (void);
Fact* mapType (void);

static const char* flightMapSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* mapProviderSettingsName;
static const char* mapTypeSettingsName;

Expand All @@ -61,8 +63,6 @@ private slots:
SettingsFact* _mapTypeFact;
QStringList _savedMapTypeStrings;
QVariantList _savedMapTypeValues;

static const char* _settingsGroupName;
};

#endif
6 changes: 4 additions & 2 deletions src/Settings/GuidedSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
#include <QtQml>
#include <QStandardPaths>

const char* GuidedSettings::guidedSettingsGroupName = "Guided";
const char* GuidedSettings::name = "Guided";
const char* GuidedSettings::settingsGroup = ""; // settings are in root group

const char* GuidedSettings::fixedWingMinimumAltitudeName = "FixedWingMinimumAltitude";
const char* GuidedSettings::fixedWingMaximumAltitudeName = "FixedWingMaximumAltitude";
const char* GuidedSettings::vehicleMinimumAltitudeName = "VehicleMinimumAltitude";
const char* GuidedSettings::vehicleMaximumAltitudeName = "VehicleMaximumAltitude";

GuidedSettings::GuidedSettings(QObject* parent)
: SettingsGroup(guidedSettingsGroupName, QString() /* root settings group */, parent)
: SettingsGroup(name, settingsGroup, parent)
, _fixedWingMinimumAltitudeFact (NULL)
, _fixedWingMaximumAltitudeFact (NULL)
, _vehicleMinimumAltitudeFact (NULL)
Expand Down
3 changes: 2 additions & 1 deletion src/Settings/GuidedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class GuidedSettings : public SettingsGroup
Fact* vehicleMinimumAltitude (void);
Fact* vehicleMaximumAltitude (void);

static const char* guidedSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* fixedWingMinimumAltitudeName;
static const char* fixedWingMaximumAltitudeName;
Expand Down
6 changes: 4 additions & 2 deletions src/Settings/RTKSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#include <QQmlEngine>
#include <QtQml>

const char* RTKSettings::RTKSettingsGroupName = "RTK";
const char* RTKSettings::name = "RTK";
const char* RTKSettings::settingsGroup = "RTK";

const char* RTKSettings::surveyInAccuracyLimitName = "SurveyInAccuracyLimit";
const char* RTKSettings::surveyInMinObservationDurationName = "SurveyInMinObservationDuration";

RTKSettings::RTKSettings(QObject* parent)
: SettingsGroup(RTKSettingsGroupName, QString(RTKSettingsGroupName), parent)
: SettingsGroup(name, settingsGroup, parent)
, _surveyInAccuracyLimitFact(NULL)
, _surveyInMinObservationDurationFact(NULL)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Settings/RTKSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class RTKSettings : public SettingsGroup
Fact* surveyInAccuracyLimit (void);
Fact* surveyInMinObservationDuration(void);

static const char* RTKSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* surveyInAccuracyLimitName;
static const char* surveyInMinObservationDurationName;
Expand Down
12 changes: 6 additions & 6 deletions src/Settings/SettingsGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
#include "QGCApplication.h"

SettingsGroup::SettingsGroup(const QString& name, const QString& settingsGroup, QObject* parent)
: QObject(parent)
, _name(name)
: QObject (parent)
, _name (name)
, _settingsGroup(settingsGroup)
, _visible(qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(name))
, _visible (qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(_name))
{
QString jsonNameFormat(":/json/%1.SettingsGroup.json");

_nameToMetaDataMap = FactMetaData::createMapFromJsonFile(jsonNameFormat.arg(name), this);
_nameToMetaDataMap = FactMetaData::createMapFromJsonFile(jsonNameFormat.arg(_name), this);
}

SettingsFact* SettingsGroup::_createSettingsFact(const QString& name)
SettingsFact* SettingsGroup::_createSettingsFact(const QString& factName)
{
return new SettingsFact(_settingsGroup, _nameToMetaDataMap[name], this);
return new SettingsFact(_settingsGroup, _nameToMetaDataMap[factName], this);
}

6 changes: 3 additions & 3 deletions src/Settings/SettingsGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class SettingsGroup : public QObject
Q_PROPERTY(bool visible MEMBER _visible CONSTANT)

protected:
SettingsFact* _createSettingsFact(const QString& name);
SettingsFact* _createSettingsFact(const QString& factName);

QString _name;
QString _settingsGroup;
QString _name; ///< Name for group. Used to generate name for loaded json meta data file.
QString _settingsGroup; ///< QSettings group which contains these settings. empty for settings in root
bool _visible;

QMap<QString, FactMetaData*> _nameToMetaDataMap;
Expand Down
14 changes: 8 additions & 6 deletions src/Settings/UnitsSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
#include <QQmlEngine>
#include <QtQml>

const char* UnitsSettings::unitsSettingsGroupName = "Units";
const char* UnitsSettings::distanceUnitsSettingsName = "DistanceUnits";
const char* UnitsSettings::areaUnitsSettingsName = "AreaUnits";
const char* UnitsSettings::speedUnitsSettingsName = "SpeedUnits";
const char* UnitsSettings::temperatureUnitsSettingsName = "TemperatureUnits";
const char* UnitsSettings::name = "Units";
const char* UnitsSettings::settingsGroup = ""; // settings are in root group

const char* UnitsSettings::distanceUnitsSettingsName = "DistanceUnits";
const char* UnitsSettings::areaUnitsSettingsName = "AreaUnits";
const char* UnitsSettings::speedUnitsSettingsName = "SpeedUnits";
const char* UnitsSettings::temperatureUnitsSettingsName = "TemperatureUnits";

UnitsSettings::UnitsSettings(QObject* parent)
: SettingsGroup(unitsSettingsGroupName, QString() /* root settings group */, parent)
: SettingsGroup(name, settingsGroup, parent)
, _distanceUnitsFact(NULL)
, _areaUnitsFact(NULL)
, _speedUnitsFact(NULL)
Expand Down
3 changes: 2 additions & 1 deletion src/Settings/UnitsSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class UnitsSettings : public SettingsGroup
Fact* speedUnits (void);
Fact* temperatureUnits (void);

static const char* unitsSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* distanceUnitsSettingsName;
static const char* areaUnitsSettingsName;
Expand Down
5 changes: 3 additions & 2 deletions src/Settings/VideoSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <QCameraInfo>
#endif

const char* VideoSettings::videoSettingsGroupName = "Video";
const char* VideoSettings::name = "Video";
const char* VideoSettings::settingsGroup = ""; // settings are in root group

const char* VideoSettings::videoSourceName = "VideoSource";
const char* VideoSettings::udpPortName = "VideoUDPPort";
Expand All @@ -40,7 +41,7 @@ const char* VideoSettings::videoSourceRTSP = "RTSP Video Stream";
const char* VideoSettings::videoSourceTCP = "TCP-MPEG2 Video Stream";

VideoSettings::VideoSettings(QObject* parent)
: SettingsGroup(videoSettingsGroupName, QString() /* root settings group */, parent)
: SettingsGroup(name, settingsGroup, parent)
, _videoSourceFact(NULL)
, _udpPortFact(NULL)
, _tcpUrlFact(NULL)
Expand Down
3 changes: 2 additions & 1 deletion src/Settings/VideoSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class VideoSettings : public SettingsGroup
Fact* disableWhenDisarmed (void);
bool streamConfigured (void);

static const char* videoSettingsGroupName;
static const char* name;
static const char* settingsGroup;

static const char* videoSourceName;
static const char* udpPortName;
Expand Down
4 changes: 2 additions & 2 deletions src/api/QGCCorePlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class QGCCorePlugin : public QGCTool
virtual QGCOptions* options(void);

/// Allows the core plugin to override the visibility for a settings group
/// @param name - Setting group name
/// @param name - SettingsGroup name
/// @return true: Show settings ui, false: Hide settings ui
virtual bool overrideSettingsGroupVisibility(QString name);

/// Allows the core plugin to override the setting meta data before the setting fact is created.
/// @param settingsGroup - Settings group which contains this value
/// @param settingsGroup - QSettings group which contains this item
/// @param metaData - MetaData for setting fact
/// @return true: Setting should be visible in ui, false: Setting should not be shown in ui
virtual bool adjustSettingMetaData(const QString& settingsGroup, FactMetaData& metaData);
Expand Down

0 comments on commit 4a399fc

Please sign in to comment.