LP-419 cleanup QSettings usage throughout GCS
[librepilot.git] / ground / gcs / src / plugins / gpsdisplay / gpsdisplaygadgetconfiguration.cpp
blobce17bdf602c255bdcc3793cbb4282cdf47f63221
1 /**
2 ******************************************************************************
4 * @file gpsdisplaygadgetconfiguration.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup GPSGadgetPlugin GPS Gadget Plugin
9 * @{
10 * @brief A gadget that displays GPS status and enables basic configuration
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "gpsdisplaygadgetconfiguration.h"
29 #include <QtSerialPort/QSerialPort>
30 #include <QtSerialPort/QSerialPortInfo>
32 /**
33 * Loads a saved configuration or defaults if non exist.
36 GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, QSettings &settings, QObject *parent) :
37 IUAVGadgetConfiguration(classId, parent)
39 m_defaultPort = settings.value("defaultPort", "Unknown").toString();
40 m_defaultSpeed = (QSerialPort::BaudRate)settings.value("defaultSpeed", QSerialPort::UnknownBaud).toInt();
41 m_defaultDataBits = (QSerialPort::DataBits)settings.value("defaultDataBits", QSerialPort::UnknownDataBits).toInt();
42 m_defaultFlow = (QSerialPort::FlowControl)settings.value("defaultFlow", QSerialPort::UnknownFlowControl).toInt();
43 m_defaultParity = (QSerialPort::Parity)settings.value("defaultParity", QSerialPort::UnknownParity).toInt();
44 m_defaultStopBits = (QSerialPort::StopBits)settings.value("defaultStopBits", QSerialPort::UnknownStopBits).toInt();
45 m_connectionMode = settings.value("connectionMode", "Serial").toString();
46 m_defaultTimeOut = 5000;
49 GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(const GpsDisplayGadgetConfiguration &obj) :
50 IUAVGadgetConfiguration(obj.classId(), obj.parent())
52 m_defaultSpeed = obj.m_defaultSpeed;
53 m_defaultDataBits = obj.m_defaultDataBits;
54 m_defaultFlow = obj.m_defaultFlow;
55 m_defaultParity = obj.m_defaultParity;
56 m_defaultStopBits = obj.m_defaultStopBits;
57 m_defaultPort = obj.m_defaultPort;
58 m_connectionMode = obj.m_connectionMode;
59 m_defaultTimeOut = obj.m_defaultTimeOut;
62 /**
63 * Clones a configuration.
66 IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone() const
68 return new GpsDisplayGadgetConfiguration(*this);
71 /**
72 * Saves a configuration.
75 void GpsDisplayGadgetConfiguration::saveConfig(QSettings &settings) const
77 settings.setValue("defaultSpeed", m_defaultSpeed);
78 settings.setValue("defaultDataBits", m_defaultDataBits);
79 settings.setValue("defaultFlow", m_defaultFlow);
80 settings.setValue("defaultParity", m_defaultParity);
81 settings.setValue("defaultStopBits", m_defaultStopBits);
82 settings.setValue("defaultPort", m_defaultPort);
83 settings.setValue("connectionMode", m_connectionMode);