diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-02-11 15:33:56 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2020-02-25 15:43:16 +0100 |
commit | aa9c6f983215b9a1e5eb0b6be1ed10f30a30f78a (patch) | |
tree | 794262d755bd2033b1d763557ee269c30958da1d /src/widgets/graphicsview/qgraphicslayoutitem.cpp | |
parent | 26059d1b9b84bbaaa6c5a50a7dea88ffa9051c5a (diff) |
Introduce QGraphicsLayoutItem::isEmpty()
This change does basically two things:
* Renames QGraphicsGridLayoutEngineItem::isIgnored() to
QGraphicsGridLayoutEngineItem::isEmpty() to be consistent with
QLayoutItem::isEmpty()
* Creates a new public API function QGraphicsLayoutItem::isEmpty() so
that there is a public method of overriding the behavior.
Change-Id: I771a8fb429f9764a75e220f0ff9d07f578f981d3
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicslayoutitem.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicslayoutitem.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp index 8694dcb36b..2c484321e4 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp @@ -45,6 +45,7 @@ #include "qgraphicslayoutitem_p.h" #include "qwidget.h" #include "qgraphicswidget.h" +#include "qgraphicsitem_p.h" #include <QtDebug> @@ -826,6 +827,22 @@ void QGraphicsLayoutItem::updateGeometry() } /*! + * returns \c true if this item is empty, i.e whether it has no content and + * should not occupy any space. + * + * The default implementation returns true if the item has been hidden unless + * its size policy has retainSizeWhenHidden set to \c true + */ +bool QGraphicsLayoutItem::isEmpty() const +{ + bool isHidden = false; + if (QGraphicsItem *item = graphicsItem()) + isHidden = QGraphicsItemPrivate::get(item)->explicitlyHidden; + + return isHidden && !sizePolicy().retainSizeWhenHidden(); +} + +/*! Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with |