summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-01-30 21:47:38 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-31 09:33:44 +0000
commitfa58926f51b532bd82baf9cd9f1e75548139235a (patch)
tree1e40a6077d24da899bf5c90d7a1e98648e1a275f
parent9ef81d240ad8d27ea482f9a15d2647a6eee1f7f2 (diff)
downloadqtlocation-fa58926f51b532bd82baf9cd9f1e75548139235a.tar.gz
Add mapItemOpacity signal to QDeclarativeGeoMapItemBase
Map items are different from regular QQuickItems in that they could be rendered externally of the qtquick scene graph renderer. With the introduction of MapItemGroups, the opacity of map items can be changed not only by setting the opacity property of an item, but also by changing the opacity property of a MapItemGroup, which would affect the opacity of all the items contained inside. When these items are handed over to a plugin for rendering, it becomes therefore impossible to know when the opacity of the group changes. The new signal mapItemOpacity serves the purpose of communicating whether either the opacity property of an item, or the opacity property of its MapItemGroup parent (if the item happens to be inside a group) changes. The associated mapItemOpacity is then in charge of returning the correct combined opacity of the item. Change-Id: I0ecbd1fc4c220291209e649bb44848854760f682 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitembase.cpp16
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitembase_p.h7
2 files changed, 21 insertions, 2 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
index c4d43b45..49438a32 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp
@@ -77,11 +77,18 @@ QGeoMapViewportChangeEvent &QGeoMapViewportChangeEvent::operator=(const QGeoMapV
}
QDeclarativeGeoMapItemBase::QDeclarativeGeoMapItemBase(QQuickItem *parent)
-: QQuickItem(parent), map_(0), quickMap_(0), geoGeometryDirty_(true), geoMaterialDirty_(true)
+: QQuickItem(parent), map_(0), quickMap_(0), geoGeometryDirty_(true), geoMaterialDirty_(true), parentGroup_(0)
{
setFiltersChildMouseEvents(true);
connect(this, SIGNAL(childrenChanged()),
this, SLOT(afterChildrenChanged()));
+ // Changing opacity on a mapItemGroup should affect also the opacity on the children.
+ // This must be notified to plugins, if they are to render the item.
+ connect(this, &QQuickItem::opacityChanged, this, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged);
+ parentGroup_ = qobject_cast<QDeclarativeGeoMapItemGroup *>(parent);
+ if (parentGroup_)
+ connect(qobject_cast<QDeclarativeGeoMapItemGroup *>(parent), &QQuickItem::opacityChanged,
+ this, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged);
}
QDeclarativeGeoMapItemBase::~QDeclarativeGeoMapItemBase()
@@ -256,6 +263,13 @@ QSGNode *QDeclarativeGeoMapItemBase::updateMapItemPaintNode(QSGNode *oldNode, Up
return 0;
}
+qreal QDeclarativeGeoMapItemBase::mapItemOpacity() const
+{
+ if (parentGroup_)
+ return parentGroup_->opacity() * opacity();
+ return opacity();
+}
+
bool QDeclarativeGeoMapItemBase::isDirty() const
{
return geoGeometryDirty_ || geoMaterialDirty_;
diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h
index ff887676..3755cfa1 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h
@@ -97,13 +97,16 @@ public:
virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *);
virtual QGeoMap::ItemType itemType() const = 0;
-
+ qreal mapItemOpacity() const;
// Data-related bool. Used by QGeoMaps that render the item directly.
bool isDirty() const;
bool isGeoMaterialDirty() const;
bool isGeoGeometryDirty() const;
void markClean();
+Q_SIGNALS:
+ void mapItemOpacityChanged();
+
protected Q_SLOTS:
virtual void afterChildrenChanged();
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) = 0;
@@ -138,6 +141,8 @@ private:
QSizeF lastSize_;
QGeoCameraData lastCameraData_;
+ QDeclarativeGeoMapItemGroup *parentGroup_;
+
friend class QDeclarativeGeoMap;
};