AutoConnectSettings.cc 5.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#include "AutoConnectSettings.h"
11
#include "LinkManager.h"
12 13

#include <QQmlEngine>
Don Gagne's avatar
Don Gagne committed
14
#include <QtQml>
15

16 17
const char* AutoConnectSettings::name =                                 "AutoConnect";
const char* AutoConnectSettings::settingsGroup =                        "LinkManager";
18 19 20 21 22 23 24

const char* AutoConnectSettings:: autoConnectUDPSettingsName =          "AutoconnectUDP";
const char* AutoConnectSettings:: autoConnectPixhawkSettingsName =      "AutoconnectPixhawk";
const char* AutoConnectSettings:: autoConnectSiKRadioSettingsName =     "Autoconnect3DRRadio";
const char* AutoConnectSettings:: autoConnectPX4FlowSettingsName =      "AutoconnectPX4Flow";
const char* AutoConnectSettings:: autoConnectRTKGPSSettingsName =       "AutoconnectRTKGPS";
const char* AutoConnectSettings:: autoConnectLibrePilotSettingsName =   "AutoconnectLibrePilot";
25 26
const char* AutoConnectSettings:: autoConnectNmeaPortName =             "AutoconnectNmeaPort";
const char* AutoConnectSettings:: autoConnectNmeaBaudName =             "AutoconnectNmeaBaud";
27 28 29
const char* AutoConnectSettings:: udpListenPortName =                   "AutoconnectUDPListenPort";
const char* AutoConnectSettings:: udpTargetHostIPName =                 "AutoconnectUDPTargetHostIP";
const char* AutoConnectSettings:: udpTargetHostPortName =               "AutoconnectUDPTargetHostPort";
30

31 32

AutoConnectSettings::AutoConnectSettings(QObject* parent)
33
    : SettingsGroup             (name, settingsGroup, parent)
34 35 36 37 38
    , _autoConnectUDPFact       (NULL)
    , _autoConnectPixhawkFact   (NULL)
    , _autoConnectSiKRadioFact  (NULL)
    , _autoConnectPX4FlowFact   (NULL)
    , _autoConnectRTKGPSFact    (NULL)
39
    , _autoConnectLibrePilotFact(NULL)
40 41
    , _autoConnectNmeaPortFact  (NULL)
    , _autoConnectNmeaBaudFact  (NULL)
42 43 44
    , _udpListenPortFact        (NULL)
    , _udpTargetHostIPFact      (NULL)
    , _udpTargetHostPortFact    (NULL)
45 46 47 48
{
    QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
    qmlRegisterUncreatableType<AutoConnectSettings>("QGroundControl.SettingsManager", 1, 0, "AutoConnectSettings", "Reference only");
}
49 50 51 52 53 54 55 56 57 58 59 60 61 62

Fact* AutoConnectSettings::autoConnectUDP(void)
{
    if (!_autoConnectUDPFact) {
        _autoConnectUDPFact = _createSettingsFact(autoConnectUDPSettingsName);
    }

    return _autoConnectUDPFact;
}

Fact* AutoConnectSettings::autoConnectPixhawk(void)
{
    if (!_autoConnectPixhawkFact) {
        _autoConnectPixhawkFact = _createSettingsFact(autoConnectPixhawkSettingsName);
63 64 65
#ifdef __ios__
        _autoConnectPixhawkFact->setVisible(false);
#endif
66 67 68 69 70 71 72 73 74
    }

    return _autoConnectPixhawkFact;
}

Fact* AutoConnectSettings::autoConnectSiKRadio(void)
{
    if (!_autoConnectSiKRadioFact) {
        _autoConnectSiKRadioFact = _createSettingsFact(autoConnectSiKRadioSettingsName);
75 76 77
#ifdef __ios__
        _autoConnectSiKRadioFact->setVisible(false);
#endif
78 79 80 81 82 83 84 85 86
    }

    return _autoConnectSiKRadioFact;
}

Fact* AutoConnectSettings::autoConnectPX4Flow(void)
{
    if (!_autoConnectPX4FlowFact) {
        _autoConnectPX4FlowFact = _createSettingsFact(autoConnectPX4FlowSettingsName);
87 88 89
#ifdef __ios__
        _autoConnectPX4FlowFact->setVisible(false);
#endif
90 91 92 93 94 95 96 97 98
    }

    return _autoConnectPX4FlowFact;
}

Fact* AutoConnectSettings::autoConnectRTKGPS(void)
{
    if (!_autoConnectRTKGPSFact) {
        _autoConnectRTKGPSFact = _createSettingsFact(autoConnectRTKGPSSettingsName);
99 100 101
#ifdef __ios__
        _autoConnectRTKGPSFact->setVisible(false);
#endif
102 103 104 105 106 107 108 109 110
    }

    return _autoConnectRTKGPSFact;
}

Fact* AutoConnectSettings::autoConnectLibrePilot(void)
{
    if (!_autoConnectLibrePilotFact) {
        _autoConnectLibrePilotFact = _createSettingsFact(autoConnectLibrePilotSettingsName);
111 112 113
#ifdef __ios__
        _autoConnectLibrePilotFact->setVisible(false);
#endif
114 115 116 117
    }

    return _autoConnectLibrePilotFact;
}
118

119 120 121 122
Fact* AutoConnectSettings::autoConnectNmeaPort(void)
{
    if (!_autoConnectNmeaPortFact) {
        _autoConnectNmeaPortFact = _createSettingsFact(autoConnectNmeaPortName);
123 124 125
#ifdef __ios__
        _autoConnectNmeaPortFact->setVisible(false);
#endif
126 127 128 129 130 131 132 133 134
    }

    return _autoConnectNmeaPortFact;
}

Fact* AutoConnectSettings::autoConnectNmeaBaud(void)
{
    if (!_autoConnectNmeaBaudFact) {
        _autoConnectNmeaBaudFact = _createSettingsFact(autoConnectNmeaBaudName);
135 136 137
#ifdef __ios__
        _autoConnectNmeaBaudFact->setVisible(false);
#endif
138 139 140 141 142
    }

    return _autoConnectNmeaBaudFact;
}

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
Fact* AutoConnectSettings::udpListenPort(void)
{
    if (!_udpListenPortFact) {
        _udpListenPortFact = _createSettingsFact(udpListenPortName);
    }

    return _udpListenPortFact;
}

Fact* AutoConnectSettings::udpTargetHostIP(void)
{
    if (!_udpTargetHostIPFact) {
        _udpTargetHostIPFact = _createSettingsFact(udpTargetHostIPName);
    }

    return _udpTargetHostIPFact;
}

Fact* AutoConnectSettings::udpTargetHostPort(void)
{
    if (!_udpTargetHostPortFact) {
        _udpTargetHostPortFact = _createSettingsFact(udpTargetHostPortName);
    }

    return _udpTargetHostPortFact;
}