2010-06-23 04:11:01 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2010-06-28 00:28:30 +00:00
|
|
|
* @file IPconnectionconfiguration.cpp
|
2010-06-23 04:11:01 +00:00
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
* @defgroup map
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2010-06-28 00:28:30 +00:00
|
|
|
#include "ipconnectionconfiguration.h"
|
2010-06-23 04:11:01 +00:00
|
|
|
#include <QtCore/QDataStream>
|
2010-06-24 04:58:19 +00:00
|
|
|
#include <coreplugin/icore.h>
|
2010-06-23 04:11:01 +00:00
|
|
|
|
2010-06-28 00:28:30 +00:00
|
|
|
IPconnectionConfiguration::IPconnectionConfiguration(QString classId, const QByteArray &state, QObject *parent) :
|
2010-06-23 04:11:01 +00:00
|
|
|
IUAVGadgetConfiguration(classId, parent),
|
|
|
|
m_HostName("127.0.0.1"),
|
2010-06-27 11:04:24 +00:00
|
|
|
m_Port(1000),
|
|
|
|
m_UseTCP(1)
|
2010-06-23 04:11:01 +00:00
|
|
|
{
|
2010-06-24 04:58:19 +00:00
|
|
|
settings = Core::ICore::instance()->settings();
|
|
|
|
}
|
2010-06-28 00:28:30 +00:00
|
|
|
IPconnectionConfiguration::~IPconnectionConfiguration()
|
2010-06-24 04:58:19 +00:00
|
|
|
{
|
2010-06-23 04:11:01 +00:00
|
|
|
}
|
2010-06-28 00:28:30 +00:00
|
|
|
IUAVGadgetConfiguration *IPconnectionConfiguration::clone()
|
2010-06-23 04:11:01 +00:00
|
|
|
{
|
2010-06-28 00:28:30 +00:00
|
|
|
IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId());
|
2010-06-23 04:11:01 +00:00
|
|
|
m->m_Port = m_Port;
|
|
|
|
m->m_HostName = m_HostName;
|
2010-06-27 11:04:24 +00:00
|
|
|
m->m_UseTCP = m_UseTCP;
|
2010-06-23 04:11:01 +00:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2010-06-28 00:28:30 +00:00
|
|
|
QByteArray IPconnectionConfiguration::saveState() const
|
2010-06-23 04:11:01 +00:00
|
|
|
{
|
2010-06-24 04:58:19 +00:00
|
|
|
QByteArray bytes;
|
2010-06-23 04:11:01 +00:00
|
|
|
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
|
|
|
stream << m_Port;
|
|
|
|
stream << m_HostName;
|
2010-06-27 11:04:24 +00:00
|
|
|
stream << m_UseTCP;
|
2010-06-23 04:11:01 +00:00
|
|
|
return bytes;
|
2010-06-24 04:58:19 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-28 00:28:30 +00:00
|
|
|
void IPconnectionConfiguration::savesettings() const
|
2010-06-24 04:58:19 +00:00
|
|
|
{
|
2010-06-28 00:28:30 +00:00
|
|
|
settings->beginGroup(QLatin1String("IPconnection"));
|
2010-06-24 04:58:19 +00:00
|
|
|
|
|
|
|
settings->beginWriteArray("Current");
|
|
|
|
settings->setArrayIndex(0);
|
|
|
|
settings->setValue(QLatin1String("HostName"), m_HostName);
|
|
|
|
settings->setValue(QLatin1String("Port"), m_Port);
|
2010-06-27 11:04:24 +00:00
|
|
|
settings->setValue(QLatin1String("UseTCP"), m_UseTCP);
|
2010-06-24 04:58:19 +00:00
|
|
|
settings->endArray();
|
|
|
|
settings->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-28 00:28:30 +00:00
|
|
|
void IPconnectionConfiguration::restoresettings()
|
2010-06-24 04:58:19 +00:00
|
|
|
{
|
2010-06-28 00:28:30 +00:00
|
|
|
settings->beginGroup(QLatin1String("IPconnection"));
|
2010-06-24 04:58:19 +00:00
|
|
|
|
|
|
|
settings->beginReadArray("Current");
|
|
|
|
settings->setArrayIndex(0);
|
|
|
|
m_HostName = (settings->value(QLatin1String("HostName"), tr("")).toString());
|
|
|
|
m_Port = (settings->value(QLatin1String("Port"), tr("")).toInt());
|
2010-06-27 11:04:24 +00:00
|
|
|
m_UseTCP = (settings->value(QLatin1String("UseTCP"), tr("")).toInt());
|
2010-06-24 04:58:19 +00:00
|
|
|
settings->endArray();
|
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
2010-06-23 04:11:01 +00:00
|
|
|
}
|
|
|
|
|