forked from qt-creator/qt-creator
TreeModel: Introduce a recursive TreeItem::updateAll() function
Useful in cases where e.g. siblings are affected (e.g. font changes to indicate active items). Change-Id: Ib2f8018688d00bd682bb6aaff08156f0be04f5dc Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -730,6 +730,16 @@ void TreeItem::update()
|
||||
}
|
||||
}
|
||||
|
||||
void TreeItem::updateAll()
|
||||
{
|
||||
if (m_model) {
|
||||
QModelIndex idx = index();
|
||||
m_model->dataChanged(idx, idx.sibling(idx.row(), m_model->m_columnCount - 1));
|
||||
foreach (TreeItem *item, m_children)
|
||||
item->updateAll();
|
||||
}
|
||||
}
|
||||
|
||||
void TreeItem::updateColumn(int column)
|
||||
{
|
||||
if (m_model) {
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
void removeChildren();
|
||||
void sortChildren(const std::function<bool(const TreeItem *, const TreeItem *)> &cmp);
|
||||
void update();
|
||||
void updateAll();
|
||||
void updateColumn(int column);
|
||||
void expand();
|
||||
TreeItem *firstChild() const;
|
||||
|
||||
Reference in New Issue
Block a user