forked from qt-creator/qt-creator
TreeModel: Add function to remove all children of an item
Just convenience. Change-Id: Ieff2291ca63584cfa113a24cc2930adc3e764d08 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user