2010-06-16 10:52:59 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file opmapgadgetconfiguration.cpp
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
* @defgroup opmap
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opmapgadgetconfiguration.h"
|
|
|
|
#include <QtCore/QDataStream>
|
2010-06-19 18:59:51 +02:00
|
|
|
#include <QDir>
|
2010-06-16 10:52:59 +02:00
|
|
|
|
|
|
|
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
|
|
|
|
IUAVGadgetConfiguration(classId, parent),
|
2010-06-19 18:59:51 +02:00
|
|
|
m_mapProvider("GoogleHybrid"),
|
2010-06-17 20:54:12 +02:00
|
|
|
m_defaultZoom(2),
|
2010-06-16 10:52:59 +02:00
|
|
|
m_defaultLatitude(0),
|
2010-06-18 21:07:04 +02:00
|
|
|
m_defaultLongitude(0),
|
2010-06-29 13:11:35 +02:00
|
|
|
m_useOpenGL(false),
|
|
|
|
m_showTileGridLines(false),
|
2010-06-25 11:03:54 +02:00
|
|
|
m_accessMode("ServerAndCache"),
|
2010-06-18 21:07:04 +02:00
|
|
|
m_useMemoryCache(true),
|
2010-06-19 18:59:51 +02:00
|
|
|
m_cacheLocation(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator())
|
2010-06-16 10:52:59 +02:00
|
|
|
{
|
2010-06-19 18:59:51 +02:00
|
|
|
if (state.count() > 0)
|
|
|
|
{
|
2010-06-16 10:52:59 +02:00
|
|
|
QDataStream stream(state);
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-29 13:11:35 +02:00
|
|
|
QString mapProvider;
|
|
|
|
int zoom;
|
2010-06-16 10:52:59 +02:00
|
|
|
double latitude;
|
|
|
|
double longitude;
|
2010-06-29 13:11:35 +02:00
|
|
|
bool useOpenGL;
|
|
|
|
bool showTileGridLines;
|
2010-06-25 11:03:54 +02:00
|
|
|
QString accessMode;
|
2010-06-18 21:07:04 +02:00
|
|
|
bool useMemoryCache;
|
|
|
|
QString cacheLocation;
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-29 13:11:35 +02:00
|
|
|
stream >> mapProvider;
|
2010-06-18 21:07:04 +02:00
|
|
|
stream >> zoom;
|
2010-06-16 10:52:59 +02:00
|
|
|
stream >> latitude;
|
|
|
|
stream >> longitude;
|
2010-06-29 13:11:35 +02:00
|
|
|
stream >> useOpenGL;
|
|
|
|
stream >> showTileGridLines;
|
2010-06-25 11:03:54 +02:00
|
|
|
stream >> accessMode;
|
2010-06-18 21:07:04 +02:00
|
|
|
stream >> useMemoryCache;
|
|
|
|
stream >> cacheLocation;
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-29 13:11:35 +02:00
|
|
|
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
|
2010-06-18 21:07:04 +02:00
|
|
|
m_defaultZoom = zoom;
|
2010-06-16 10:52:59 +02:00
|
|
|
m_defaultLatitude = latitude;
|
|
|
|
m_defaultLongitude = longitude;
|
2010-06-29 13:11:35 +02:00
|
|
|
m_useOpenGL = useOpenGL;
|
|
|
|
m_showTileGridLines = showTileGridLines;
|
|
|
|
|
2010-06-25 11:03:54 +02:00
|
|
|
if (!accessMode.isEmpty()) m_accessMode = accessMode;
|
2010-06-18 21:07:04 +02:00
|
|
|
m_useMemoryCache = useMemoryCache;
|
2010-06-19 18:59:51 +02:00
|
|
|
if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation;
|
2010-06-16 10:52:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-19 18:59:51 +02:00
|
|
|
IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
2010-06-16 10:52:59 +02:00
|
|
|
{
|
|
|
|
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-29 13:11:35 +02:00
|
|
|
m->m_mapProvider = m_mapProvider;
|
2010-06-16 10:52:59 +02:00
|
|
|
m->m_defaultZoom = m_defaultZoom;
|
|
|
|
m->m_defaultLatitude = m_defaultLatitude;
|
|
|
|
m->m_defaultLongitude = m_defaultLongitude;
|
2010-06-29 13:11:35 +02:00
|
|
|
m->m_useOpenGL = m_useOpenGL;
|
|
|
|
m->m_showTileGridLines = m_showTileGridLines;
|
2010-06-25 11:03:54 +02:00
|
|
|
m->m_accessMode = m_accessMode;
|
2010-06-18 21:07:04 +02:00
|
|
|
m->m_useMemoryCache = m_useMemoryCache;
|
|
|
|
m->m_cacheLocation = m_cacheLocation;
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-16 10:52:59 +02:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray OPMapGadgetConfiguration::saveState() const
|
|
|
|
{
|
|
|
|
QByteArray bytes;
|
|
|
|
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-29 13:11:35 +02:00
|
|
|
stream << m_mapProvider;
|
2010-06-16 10:52:59 +02:00
|
|
|
stream << m_defaultZoom;
|
|
|
|
stream << m_defaultLatitude;
|
|
|
|
stream << m_defaultLongitude;
|
2010-06-29 13:11:35 +02:00
|
|
|
stream << m_useOpenGL;
|
|
|
|
stream << m_showTileGridLines;
|
2010-06-25 11:03:54 +02:00
|
|
|
stream << m_accessMode;
|
2010-06-18 21:07:04 +02:00
|
|
|
stream << m_useMemoryCache;
|
|
|
|
stream << m_cacheLocation;
|
2010-06-19 18:59:51 +02:00
|
|
|
|
2010-06-16 10:52:59 +02:00
|
|
|
return bytes;
|
|
|
|
}
|