merge upstream

This commit is contained in:
Hamed Masafi 2018-01-08 12:40:16 +03:30
commit ed86677997
2 changed files with 0 additions and 135 deletions

View File

@ -1,81 +0,0 @@
/**************************************************************************
**
** This file is part of Nut project.
** https://github.com/HamedMasafi/Nut
**
** Nut is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Nut 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 Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with Nut. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************/
#include "dbgeography.h"
NUT_BEGIN_NAMESPACE
DbGeography::DbGeography() : m_longitude(0), m_latitude(0)
{
}
DbGeography::DbGeography(const DbGeography &other)
{
setLongitude(other.longitude());
setLatitude(other.latitude());
}
DbGeography::DbGeography(const QVariant &value)
{
QStringList parts = value.toString().split(',');
if (parts.count() == 2) {
setLongitude(parts[0].toDouble());
setLatitude(parts[1].toDouble());
} else {
qWarning("Input value for DbGeography is invalid: %s",
qPrintable(value.toString()));
setLongitude(0);
setLatitude(0);
}
}
qreal DbGeography::longitude() const
{
return m_longitude;
}
qreal DbGeography::latitude() const
{
return m_latitude;
}
void DbGeography::setLongitude(qreal longitude)
{
if (qFuzzyCompare(m_longitude, longitude))
return;
m_longitude = longitude;
}
void DbGeography::setLatitude(qreal latitude)
{
if (qFuzzyCompare(m_latitude, latitude))
return;
m_latitude = latitude;
}
DbGeography::operator QVariant()
{
return QVariant::fromValue(QString("%1,%2").arg(longitude()).arg(latitude()));
}
NUT_END_NAMESPACE

View File

@ -1,54 +0,0 @@
/**************************************************************************
**
** This file is part of Nut project.
** https://github.com/HamedMasafi/Nut
**
** Nut is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Nut 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 Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with Nut. If not, see <http://www.gnu.org/licenses/>.
**
**************************************************************************/
#ifndef DBGEOGRAPHY_H
#define DBGEOGRAPHY_H
#include "defines.h"
#include <QtCore/QObject>
#include <QtCore/qglobal.h>
#include <QVariant>
NUT_BEGIN_NAMESPACE
class NUT_EXPORT DbGeography
{
qreal m_longitude;
qreal m_latitude;
public:
explicit DbGeography();
DbGeography(const DbGeography &other);
DbGeography(const QVariant &value);
qreal longitude() const;
qreal latitude() const;
void setLongitude(qreal longitude);
void setLatitude(qreal latitude);
operator QVariant();
};
NUT_END_NAMESPACE
Q_DECLARE_METATYPE(NUT_WRAP_NAMESPACE(DbGeography))
#endif // DBGEOGRAPHY_H