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:
hjk
2016-07-06 11:14:03 +02:00
committed by hjk
parent 20ec978b56
commit e6069d8b03
2 changed files with 11 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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;