Commit 3d0537fa authored by hjk's avatar hjk
Browse files

TreeModel: Add function to remove all children of an item



Just convenience.

Change-Id: Ieff2291ca63584cfa113a24cc2930adc3e764d08
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 82c2f51a
......@@ -326,6 +326,17 @@ void TreeModel::removeItem(TreeItem *item)
endRemoveRows();
}
void TreeModel::removeAllSubItems(TreeItem *item)
{
QTC_ASSERT(item, return);
if (item->rowCount() == 0)
return;
QModelIndex idx = indexFromItem(item);
beginRemoveRows(idx, 0, item->rowCount() - 1);
item->clear();
endRemoveRows();
}
QModelIndex TreeModel::indexFromItemHelper(const TreeItem *needle,
TreeItem *parentItem, const QModelIndex &parentIndex) const
{
......
......@@ -177,6 +177,7 @@ public:
void appendItem(TreeItem *parent, TreeItem *item);
void removeItem(TreeItem *item); // item is not destroyed.
void removeAllSubItems(TreeItem *item); // item is not destroyed.
void updateItem(TreeItem *item); // call to trigger dataChanged
UntypedTreeLevelItems untypedLevelItems(int level = 0, TreeItem *start = 0) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment