7#include <QtCore/private/qnumeric_p.h>
8#include <QtQml/qqmlinfo.h>
221 return d->orientation;
237 return d->engine.sizeHint(whichSizeHint,
QSizeF(),
d->styleInfo);
258 return d->m_layoutDirection;
264 if (
d->m_layoutDirection ==
dir)
266 d->m_layoutDirection =
dir;
268 emit layoutDirectionChanged();
288 d->engine.setStretchFactor(
item, stretchFactor, orient);
303 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::componentComplete()" <<
this <<
parent();
320 if (qobject_cast<QQuickLayout*>(par))
323 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::componentComplete(). COMPLETED" <<
this <<
parent();
363 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::invalidate()" <<
this <<
", invalidated:" <<
invalidated();
365 if (
d->m_rearranging) {
366 if (!
d->m_invalidateAfterRearrange.contains(childItem))
367 d->m_invalidateAfterRearrange << childItem;
376 d->engine.invalidate();
378 qCDebug(lcQuickLayouts) <<
"calling QQuickLayout::invalidate();";
381 if (
auto *parentLayout = qobject_cast<QQuickLayout *>(
parentItem()))
382 parentLayout->invalidate(
this);
383 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::invalidate() LEAVING" <<
this;
392 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::updateLayoutItems ENTERING" <<
this;
393 d->engine.deleteItems();
395 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::updateLayoutItems() LEAVING" <<
this;
407 return d->engine.itemCount();
413 const int index = gridItem->firstRow(
d->orientation);
414 d->engine.removeItem(gridItem);
415 d->engine.removeRows(
index, 1,
d->orientation);
423 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::itemDestroyed";
425 removeGridItem(gridItem);
437 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::itemVisibilityChanged()";
447 qCDebug(lcQuickLayouts) <<
"QQuickGridLayoutBase::rearrange" <<
d->m_recurRearrangeCounter <<
this;
449 --(
d->m_recurRearrangeCounter);
451 if (
d->m_recurRearrangeCounter++ == 2) {
454 qWarning() <<
"Qt Quick Layouts: Detected recursive rearrange. Aborting after two iterations.";
462 d->m_rearranging =
true;
465 d->engine.setVisualDirection(visualDir);
478 d->m_rearranging =
false;
480 for (
auto childItem : std::as_const(
d->m_invalidateAfterRearrange))
482 d->m_invalidateAfterRearrange.clear();
641 return d->engine.uniformCellWidths();
651 emit uniformCellWidthsChanged();
672 return d->engine.uniformCellHeights();
682 emit uniformCellHeightsChanged();
690 int nextCellPos[2] = {0,0};
691 int &nextColumn = nextCellPos[0];
692 int &nextRow = nextCellPos[1];
695 const int flowOrientation =
flow();
696 int &flowColumn = nextCellPos[flowOrientation];
697 int &flowRow = nextCellPos[1 - flowOrientation];
701 flowBound = std::numeric_limits<int>::max();
717 int &columnSpan =
span[0];
718 int &rowSpan =
span[1];
721 if (
info->isRowSet() ||
info->isColumnSet()) {
736 if (gridSize.
width() >= 0 &&
info->column() >= gridSize.
width()) {
742 rowSpan =
info->rowSpan();
743 columnSpan =
info->columnSpan();
744 if (columnSpan < 1) {
748 }
else if (rowSpan < 1) {
753 hStretch =
info->horizontalStretchFactor();
754 if (hStretch >= 0 && !
info->fillWidth())
755 qmlWarning(
child) <<
"horizontalStretchFactor requires fillWidth to also be set to true";
756 vStretch =
info->verticalStretchFactor();
757 if (vStretch >= 0 && !
info->fillHeight())
758 qmlWarning(
child) <<
"verticalStretchFactor requires fillHeight to also be set to true";
763 const int sp =
span[flowOrientation];
785 bool cellAcceptsItem;
788 cellAcceptsItem = (flowColumn +
sp) <= flowBound;
791 for (
int rs = 0; cellAcceptsItem && rs < rowSpan; ++rs) {
792 for (
int cs = 0; cellAcceptsItem && cs < columnSpan; ++cs) {
793 if (
d->engine.itemAt(nextRow + rs, nextColumn + cs)) {
794 cellAcceptsItem =
false;
801 if (flowColumn == flowBound) {
882 Q_ASSERT(
d->engine.uniformCellWidths() ==
d->engine.uniformCellHeights());
883 return d->engine.uniformCellWidths();
889 Q_ASSERT(
d->engine.uniformCellWidths() ==
d->engine.uniformCellHeights());
895 emit uniformCellSizesChanged();
915 return d->engine.spacing(
d->orientation,
d->styleInfo);
945 bool fillWidth =
false;
946 bool fillHeight =
false;
949 hStretch =
info->horizontalStretchFactor();
950 vStretch =
info->verticalStretchFactor();
951 fillWidth =
info->fillWidth();
952 fillHeight =
info->fillHeight();
955 const int index =
d->engine.rowCount(
d->orientation);
956 d->engine.insertRow(
index,
d->orientation);
959 int gridColumn =
index;
961 qSwap(gridRow, gridColumn);
966 qmlWarning(
child) <<
"horizontalStretchFactor requires fillWidth to also be set to true";
971 qmlWarning(
child) <<
"verticalStretchFactor requires fillHeight to also be set to true";
980#include "moc_qquicklinearlayout_p.cpp"
QString objectName
the name of this object
\inmodule QtCore\reentrant
Qt::LayoutDirection layoutDirection
int itemCount() const override
void itemVisibilityChanged(QQuickItem *item) override
Qt::LayoutDirection effectiveLayoutDirection() const
QQuickItem * itemAt(int index) const override
QSizeF sizeHint(Qt::SizeHint whichSizeHint) const override
virtual void insertLayoutItems()
void setLayoutDirection(Qt::LayoutDirection dir)
Qt::Orientation orientation() const
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void rearrange(const QSizeF &size) override
void itemDestroyed(QQuickItem *item) override
QQuickGridLayoutBase()
Identical to \l GridLayout, but having only one row.
void setStretchFactor(QQuickItem *item, int stretchFactor, Qt::Orientation orient) override
void setAlignment(QQuickItem *item, Qt::Alignment align) override
void invalidate(QQuickItem *childItem=nullptr) override
void updateLayoutItems() override
void setOrientation(Qt::Orientation orientation)
QQuickGridLayout(QQuickItem *parent=nullptr)
void columnSpacingChanged()
void setColumns(int columns)
void setUniformCellHeights(bool uniformCellHeights)
FINALbool uniformCellHeights
void setUniformCellWidths(bool uniformCellWidths)
void insertLayoutItems() override
void setRowSpacing(qreal spacing)
void setColumnSpacing(qreal spacing)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QList< QQuickItem * > childItems() const
Returns the children of this item.
qreal width
This property holds the width of this item.
QQuickItem * parentItem() const
QQuickItem * parent
\qmlproperty Item QtQuick::Item::parent This property holds the visual parent of the item.
qreal height
This property holds the height of this item.
void maybeSubscribeToBaseLineOffsetChanges(QQuickItem *item)
virtual void rearrange(const QSizeF &)
virtual void invalidate(QQuickItem *childItem=nullptr)
bool shouldIgnoreItem(QQuickItem *child) const
void checkAnchors(QQuickItem *item) const
void ensureLayoutItemsUpdated(EnsureLayoutItemsUpdatedOptions options={}) const
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void deactivateRecur()
QQuickLayout::deactivateRecur.
void insertLayoutItems() override
QML_ANONYMOUSqreal spacing
void setSpacing(qreal spacing)
QQuickLinearLayout(Qt::Orientation orientation, QQuickItem *parent=nullptr)
void setUniformCellSizes(bool uniformCellSizes)
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Combined button and popup list for selecting options.
#define qCDebug(category,...)
static Q_DECL_CONST_FUNCTION bool qt_is_nan(double d)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void GLsizei void void * span
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static void layoutItem(QQuickItem *item, qreal y, qreal width)
QQuickLayoutAttached * attachedLayoutObject(QQuickItem *item, bool create=true)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)