Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / uploader / uploadergadgetconfiguration.cpp
blob4715c3c9fa583bdb51f7ca1bd6a192bb4007101e
1 /**
2 ******************************************************************************
4 * @file uploadergadgetconfiguration.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup YModemUploader YModem Serial Uploader Plugin
9 * @{
10 * @brief The YModem protocol serial uploader plugin
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 "uploadergadgetconfiguration.h"
30 #include <QtSerialPort/QSerialPort>
32 /**
33 * Loads a saved configuration or defaults if non exist.
36 UploaderGadgetConfiguration::UploaderGadgetConfiguration(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_defaultTimeOut = 5000;
48 UploaderGadgetConfiguration::UploaderGadgetConfiguration(const UploaderGadgetConfiguration &obj) :
49 IUAVGadgetConfiguration(obj.classId(), obj.parent())
51 m_defaultSpeed = obj.m_defaultSpeed;
52 m_defaultDataBits = obj.m_defaultDataBits;
53 m_defaultFlow = obj.m_defaultFlow;
54 m_defaultParity = obj.m_defaultParity;
55 m_defaultStopBits = obj.m_defaultStopBits;
56 m_defaultPort = obj.m_defaultPort;
57 m_defaultTimeOut = obj.m_defaultTimeOut;
60 /**
61 * Clones a configuration.
64 IUAVGadgetConfiguration *UploaderGadgetConfiguration::clone() const
66 return new UploaderGadgetConfiguration(*this);
69 /**
70 * Saves a configuration.
73 void UploaderGadgetConfiguration::saveConfig(QSettings &settings) const
75 settings.setValue("defaultSpeed", m_defaultSpeed);
76 settings.setValue("defaultDataBits", m_defaultDataBits);
77 settings.setValue("defaultFlow", m_defaultFlow);
78 settings.setValue("defaultParity", m_defaultParity);
79 settings.setValue("defaultStopBits", m_defaultStopBits);
80 settings.setValue("defaultPort", m_defaultPort);