Add deleteItems(), needed by QtQuick.Layouts

(Picked from QGridLayoutEngine in qtquickcontrols)

Change-Id: Ieb00f7fb0166669e6831f3d3dbe3a9ef78b57453
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
bb10
Jan Arve Saether 2013-11-29 07:59:43 +01:00 committed by The Qt Project
parent 14170bbf09
commit 28b85835bb
1 changed files with 12 additions and 0 deletions

View File

@ -375,6 +375,18 @@ public:
void insertItem(QGridLayoutItem *item, int index);
void addItem(QGridLayoutItem *item);
void removeItem(QGridLayoutItem *item);
void deleteItems()
{
const QList<QGridLayoutItem *> 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); }