From 28b85835bb83b6edc4a976384ed90e2898e40a60 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 29 Nov 2013 07:59:43 +0100 Subject: Add deleteItems(), needed by QtQuick.Layouts (Picked from QGridLayoutEngine in qtquickcontrols) Change-Id: Ieb00f7fb0166669e6831f3d3dbe3a9ef78b57453 Reviewed-by: J-P Nurmi --- src/gui/util/qgridlayoutengine_p.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gui/util') diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 7f5bfcfaee..f85513285a 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -375,6 +375,18 @@ public: void insertItem(QGridLayoutItem *item, int index); void addItem(QGridLayoutItem *item); void removeItem(QGridLayoutItem *item); + void deleteItems() + { + const QList oldItems = q_items; + q_items.clear(); // q_items are used as input when the grid is regenerated in removeRows + // The following calls to removeRows are suboptimal + int rows = rowCount(Qt::Vertical); + removeRows(0, rows, Qt::Vertical); + rows = rowCount(Qt::Horizontal); + removeRows(0, rows, Qt::Horizontal); + qDeleteAll(oldItems); + } + QGridLayoutItem *itemAt(int row, int column, Qt::Orientation orientation = Qt::Vertical) const; inline void insertRow(int row, Qt::Orientation orientation = Qt::Vertical) { insertOrRemoveRows(row, +1, orientation); } -- cgit v1.2.3