summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean Gressmann <jean.gressmann@nokia.com>2012-02-28 09:26:53 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-29 01:11:15 +0100
commit36bb8ce507ecfe9f6fbed75882b10d9da8e5df06 (patch)
treeb0891deeda8d238b489fcf3c99f4483c28c487a6 /src
parentcb4f4d65f4d85820da7478181234b23fffbc1e55 (diff)
downloadqtlocation-36bb8ce507ecfe9f6fbed75882b10d9da8e5df06.tar.gz
isEmpty() functions for place data classes
Added isEmpty() method to QPlace, QPlaceSupplier, and QPlaceRatings. Bugfix for QTBUG-23557 Change-Id: I49d71ac2428003ef3127bbab2e46f83a8bb6ecd3 Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/location/places/qplace.cpp28
-rw-r--r--src/location/places/qplace.h2
-rw-r--r--src/location/places/qplace_p.h2
-rw-r--r--src/location/places/qplaceratings.cpp13
-rw-r--r--src/location/places/qplaceratings.h2
-rw-r--r--src/location/places/qplaceratings_p.h2
-rw-r--r--src/location/places/qplacesupplier.cpp17
-rw-r--r--src/location/places/qplacesupplier.h2
-rw-r--r--src/location/places/qplacesupplier_p.h2
-rw-r--r--src/location/qgeolocation.cpp16
-rw-r--r--src/location/qgeolocation.h2
-rw-r--r--src/location/qgeolocation_p.h2
12 files changed, 90 insertions, 0 deletions
diff --git a/src/location/places/qplace.cpp b/src/location/places/qplace.cpp
index b82eb685..27fa1781 100644
--- a/src/location/places/qplace.cpp
+++ b/src/location/places/qplace.cpp
@@ -603,6 +603,15 @@ QtLocation::Visibility QPlace::visibility() const
return d->visibility;
}
+/*!
+ Returns a boolean indicating whether the all the fields of the place are empty or not.
+*/
+bool QPlace::isEmpty() const
+{
+ Q_D(const QPlace);
+ return d->isEmpty();
+}
+
/*******************************************************************************
*******************************************************************************/
@@ -686,4 +695,23 @@ bool QPlacePrivate::operator== (const QPlacePrivate &other) const
);
}
+
+bool QPlacePrivate::isEmpty() const
+{
+ return (categories.isEmpty()
+ && location.isEmpty()
+ && ratings.isEmpty()
+ && supplier.isEmpty()
+ && contentCollections.isEmpty()
+ && contentCounts.isEmpty()
+ && name.isEmpty()
+ && placeId.isEmpty()
+ && attribution.isEmpty()
+ && contacts.isEmpty()
+ && extendedAttributes.isEmpty()
+ && QtLocation::UnspecifiedVisibility == visibility
+ && icon.isEmpty()
+ );
+}
+
QT_END_NAMESPACE
diff --git a/src/location/places/qplace.h b/src/location/places/qplace.h
index 041ed38c..2de45693 100644
--- a/src/location/places/qplace.h
+++ b/src/location/places/qplace.h
@@ -128,6 +128,8 @@ public:
QtLocation::Visibility visibility() const;
void setVisibility(QtLocation::Visibility visibility);
+ bool isEmpty() const;
+
private:
QSharedDataPointer<QPlacePrivate> d_ptr;
diff --git a/src/location/places/qplace_p.h b/src/location/places/qplace_p.h
index 0d60dd95..4e50552a 100644
--- a/src/location/places/qplace_p.h
+++ b/src/location/places/qplace_p.h
@@ -76,6 +76,8 @@ public:
bool operator==(const QPlacePrivate &other) const;
+ bool isEmpty() const;
+
QList<QPlaceCategory> categories;
QGeoLocation location;
QPlaceRatings ratings;
diff --git a/src/location/places/qplaceratings.cpp b/src/location/places/qplaceratings.cpp
index 30311370..9fc791ac 100644
--- a/src/location/places/qplaceratings.cpp
+++ b/src/location/places/qplaceratings.cpp
@@ -63,6 +63,11 @@ bool QPlaceRatingsPrivate::operator==(const QPlaceRatingsPrivate &other) const
return average == other.average && maximum == other.maximum && count == other.count;
}
+bool QPlaceRatingsPrivate::isEmpty() const
+{
+ return count == 0 && average == 0 && maximum == 0;
+}
+
/*!
\class QPlaceRatings
\inmodule QtLocation
@@ -176,3 +181,11 @@ void QPlaceRatings::setCount(int count)
{
d->count = count;
}
+
+/*!
+ Returns true if all fields of the place ratings are 0; otherwise returns false.
+*/
+bool QPlaceRatings::isEmpty() const
+{
+ return d->isEmpty();
+}
diff --git a/src/location/places/qplaceratings.h b/src/location/places/qplaceratings.h
index 6aa5ce2c..0c94a615 100644
--- a/src/location/places/qplaceratings.h
+++ b/src/location/places/qplaceratings.h
@@ -76,6 +76,8 @@ public:
qreal maximum() const;
void setMaximum(qreal max);
+ bool isEmpty() const;
+
private:
QSharedDataPointer<QPlaceRatingsPrivate> d;
};
diff --git a/src/location/places/qplaceratings_p.h b/src/location/places/qplaceratings_p.h
index 49a7edb2..ea469902 100644
--- a/src/location/places/qplaceratings_p.h
+++ b/src/location/places/qplaceratings_p.h
@@ -56,6 +56,8 @@ public:
bool operator==(const QPlaceRatingsPrivate &other) const;
+ bool isEmpty() const;
+
qreal average;
qreal maximum;
int count;
diff --git a/src/location/places/qplacesupplier.cpp b/src/location/places/qplacesupplier.cpp
index f4867322..cc56d830 100644
--- a/src/location/places/qplacesupplier.cpp
+++ b/src/location/places/qplacesupplier.cpp
@@ -71,6 +71,15 @@ bool QPlaceSupplierPrivate::operator==(const QPlaceSupplierPrivate &other) const
);
}
+bool QPlaceSupplierPrivate::isEmpty() const
+{
+ return (name.isEmpty()
+ && supplierId.isEmpty()
+ && url.isEmpty()
+ && icon.isEmpty()
+ );
+}
+
/*!
\class QPlaceSupplier
\inmodule QtLocation
@@ -199,3 +208,11 @@ void QPlaceSupplier::setIcon(const QPlaceIcon &icon)
{
d->icon = icon;
}
+
+/*!
+ Returns true if all fields of the place supplier are 0; otherwise returns false.
+*/
+bool QPlaceSupplier::isEmpty() const
+{
+ return d->isEmpty();
+}
diff --git a/src/location/places/qplacesupplier.h b/src/location/places/qplacesupplier.h
index b7f15ed6..bffed1b0 100644
--- a/src/location/places/qplacesupplier.h
+++ b/src/location/places/qplacesupplier.h
@@ -79,6 +79,8 @@ public:
QPlaceIcon icon() const;
void setIcon(const QPlaceIcon &icon);
+ bool isEmpty() const;
+
private:
QSharedDataPointer<QPlaceSupplierPrivate> d;
};
diff --git a/src/location/places/qplacesupplier_p.h b/src/location/places/qplacesupplier_p.h
index 1cadfdfe..bc3b2962 100644
--- a/src/location/places/qplacesupplier_p.h
+++ b/src/location/places/qplacesupplier_p.h
@@ -60,6 +60,8 @@ public:
bool operator==(const QPlaceSupplierPrivate &other) const;
+ bool isEmpty() const;
+
QString name;
QString supplierId;
QUrl url;
diff --git a/src/location/qgeolocation.cpp b/src/location/qgeolocation.cpp
index f430f8ed..d0689c71 100644
--- a/src/location/qgeolocation.cpp
+++ b/src/location/qgeolocation.cpp
@@ -69,6 +69,14 @@ bool QGeoLocationPrivate::operator==(const QGeoLocationPrivate &other) const
}
+bool QGeoLocationPrivate::isEmpty() const
+{
+ return (address.isEmpty()
+ && !coordinate.isValid()
+ && viewport.isEmpty()
+ );
+}
+
/*!
\class QGeoLocation
\inmodule QtLocation
@@ -177,3 +185,11 @@ void QGeoLocation::setBoundingBox(const QGeoBoundingBox &boundingBox)
{
d->viewport = boundingBox;
}
+
+/*!
+ Returns true if all fields of the location are 0; otherwise returns false.
+*/
+bool QGeoLocation::isEmpty() const
+{
+ return d->isEmpty();
+}
diff --git a/src/location/qgeolocation.h b/src/location/qgeolocation.h
index e8945f97..78224b5f 100644
--- a/src/location/qgeolocation.h
+++ b/src/location/qgeolocation.h
@@ -80,6 +80,8 @@ public:
QGeoBoundingBox boundingBox() const;
void setBoundingBox(const QGeoBoundingBox &box);
+ bool isEmpty() const;
+
private:
QSharedDataPointer<QGeoLocationPrivate> d;
};
diff --git a/src/location/qgeolocation_p.h b/src/location/qgeolocation_p.h
index f32906a9..7a2a002d 100644
--- a/src/location/qgeolocation_p.h
+++ b/src/location/qgeolocation_p.h
@@ -56,6 +56,8 @@ public:
bool operator==(const QGeoLocationPrivate &other) const;
+ bool isEmpty() const;
+
QGeoAddress address;
QGeoCoordinate coordinate;
QGeoBoundingBox viewport;