diff options
author | David Laing <david.laing@nokia.com> | 2010-03-16 10:45:46 +1000 |
---|---|---|
committer | David Laing <david.laing@nokia.com> | 2010-03-16 10:45:46 +1000 |
commit | 8d1f2e907c9b737e898691f047f8cf754590f1b2 (patch) | |
tree | c530537ff0602e34cf4f21572635c0a082374a24 | |
parent | fdd67c86cd7190e6934c04ae13065ab24be4bb84 (diff) |
Added serialization functions for QGeoSatelliteInfo.
-rw-r--r-- | src/location/qgeopositioninfo.cpp | 10 | ||||
-rw-r--r-- | src/location/qgeopositioninfo.h | 12 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfo.cpp | 40 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfo.h | 10 | ||||
-rw-r--r-- | src/location/qnmeapositioninfosource.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp | 19 |
6 files changed, 81 insertions, 12 deletions
diff --git a/src/location/qgeopositioninfo.cpp b/src/location/qgeopositioninfo.cpp index 5cb639fbc4..d038469761 100644 --- a/src/location/qgeopositioninfo.cpp +++ b/src/location/qgeopositioninfo.cpp @@ -246,13 +246,13 @@ bool QGeoPositionInfo::hasAttribute(Attribute attribute) const } #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QGeoPositionInfo &update) +QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info) { - dbg.nospace() << "QGeoPositionInfo(" << update.d->dateTime; + dbg.nospace() << "QGeoPositionInfo(" << info.d->dateTime; dbg.nospace() << ", "; - dbg.nospace() << update.d->coord; + dbg.nospace() << info.d->coord; - QList<int> attribs = update.d->doubleAttribs.keys(); + QList<int> attribs = info.d->doubleAttribs.keys(); for (int i = 0; i < attribs.count(); i++) { dbg.nospace() << ", "; switch (attribs[i]) { @@ -275,7 +275,7 @@ QDebug operator<<(QDebug dbg, const QGeoPositionInfo &update) dbg.nospace() << "VerticalAccuracy="; break; } - dbg.nospace() << update.d->doubleAttribs[attribs[i]]; + dbg.nospace() << info.d->doubleAttribs[attribs[i]]; } dbg.nospace() << ')'; return dbg; diff --git a/src/location/qgeopositioninfo.h b/src/location/qgeopositioninfo.h index 0d6bee9c7b..e22c1644c3 100644 --- a/src/location/qgeopositioninfo.h +++ b/src/location/qgeopositioninfo.h @@ -95,22 +95,22 @@ public: private: #ifndef QT_NO_DEBUG_STREAM - friend Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &update); + friend Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info); #endif #ifndef QT_NO_DATASTREAM - friend Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &update); - friend Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &update); + friend Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info); + friend Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info); #endif QGeoPositionInfoPrivate *d; }; #ifndef QT_NO_DEBUG_STREAM -Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &update); +Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info); #endif #ifndef QT_NO_DATASTREAM -Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &update); -Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &update); +Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info); +Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info); #endif QTM_END_NAMESPACE diff --git a/src/location/qgeosatelliteinfo.cpp b/src/location/qgeosatelliteinfo.cpp index 00faa2aa91..08233ac7e8 100644 --- a/src/location/qgeosatelliteinfo.cpp +++ b/src/location/qgeosatelliteinfo.cpp @@ -42,6 +42,7 @@ #include <QHash> #include <QDebug> +#include <QDataStream> QTM_BEGIN_NAMESPACE @@ -229,4 +230,43 @@ QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info) } #endif +#ifndef QT_NO_DATASTREAM +/*! + \fn QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info) + \relates QGeoSatelliteInfo + + Writes the given \a info to the specified \a stream. + + \sa {Format of the QDataStream Operators} +*/ + +QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info) +{ + stream << info.d->prn; + stream << info.d->signal; + stream << info.d->doubleAttribs; + return stream; +} +#endif + +#ifndef QT_NO_DATASTREAM +/*! + \fn QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info) + \relates QGeoSatelliteInfo + + Reads satellite information from the specified \a stream into the given + \a info. + + \sa {Format of the QDataStream Operators} +*/ + +QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info) +{ + stream >> info.d->prn; + stream >> info.d->signal; + stream >> info.d->doubleAttribs; + return stream; +} +#endif + QTM_END_NAMESPACE diff --git a/src/location/qgeosatelliteinfo.h b/src/location/qgeosatelliteinfo.h index 92e4d42910..b925731760 100644 --- a/src/location/qgeosatelliteinfo.h +++ b/src/location/qgeosatelliteinfo.h @@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE class QDebug; +class QDataStream; QT_END_NAMESPACE QT_BEGIN_HEADER @@ -87,6 +88,10 @@ private: #ifndef QT_NO_DEBUG_STREAM friend Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info); #endif +#ifndef QT_NO_DATASTREAM + friend Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info); + friend Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info); +#endif QGeoSatelliteInfoPrivate *d; }; @@ -94,6 +99,11 @@ private: Q_LOCATION_EXPORT QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info); #endif +#ifndef QT_NO_DATASTREAM +Q_LOCATION_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info); +Q_LOCATION_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info); +#endif + QTM_END_NAMESPACE QT_END_HEADER diff --git a/src/location/qnmeapositioninfosource.cpp b/src/location/qnmeapositioninfosource.cpp index 42041c2b7d..5755a0382e 100644 --- a/src/location/qnmeapositioninfosource.cpp +++ b/src/location/qnmeapositioninfosource.cpp @@ -44,7 +44,6 @@ #include <QIODevice> #include <QBasicTimer> #include <QTimerEvent> -#include <QDebug> #include <QTimer> QTM_BEGIN_NAMESPACE @@ -361,6 +360,7 @@ void QNmeaPositionInfoSourcePrivate::updateRequestTimeout() void QNmeaPositionInfoSourcePrivate::notifyNewUpdate(QGeoPositionInfo *update, bool hasFix) { + // include <QDebug> before uncommenting //qDebug() << "QNmeaPositionInfoSourcePrivate::notifyNewUpdate()" << update->dateTime() << hasFix << m_invokedStart << (m_requestTimer && m_requestTimer->isActive()); QDate date = update->dateTime().date(); diff --git a/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp b/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp index 00d5b10f02..8cbabdf466 100644 --- a/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp +++ b/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp @@ -308,6 +308,25 @@ private slots: attribute_data(); } + void datastream() + { + QFETCH(QGeoSatelliteInfo, info); + + QByteArray ba; + QDataStream out(&ba, QIODevice::WriteOnly); + out << info; + + QDataStream in(&ba, QIODevice::ReadOnly); + QGeoSatelliteInfo inInfo; + in >> inInfo; + QCOMPARE(inInfo, info); + } + + void datastream_data() + { + addTestData_update(); + } + void debug() { QFETCH(QGeoSatelliteInfo, info); |