TreeModel: Add model pointer to TreeItem

... and use the items themselves as main entry point for
item related operations.

With non-uniform tree items it's easier to have item specific
functionality directly in the item implementation instead of
the model.

Change-Id: I4e9b7db98d16b91ddef81917417691129bb83621
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-01-14 09:09:15 +01:00
parent 6bc0b9e5d3
commit 7e522c8a37
8 changed files with 130 additions and 79 deletions

View File

@@ -131,7 +131,7 @@ DebuggerItemModel::DebuggerItemModel()
void DebuggerItemModel::addDebugger(const DebuggerItem &item, bool changed)
{
int group = item.isAutoDetected() ? 0 : 1;
appendItem(rootItem()->child(group), new DebuggerTreeItem(item, changed));
rootItem()->child(group)->appendChild(new DebuggerTreeItem(item, changed));
}
void DebuggerItemModel::updateDebugger(const DebuggerItem &item)
@@ -146,8 +146,7 @@ void DebuggerItemModel::updateDebugger(const DebuggerItem &item)
const DebuggerItem *orig = DebuggerItemManager::findById(item.id());
treeItem->m_changed = !orig || *orig != item;
treeItem->m_item = item;
updateItem(treeItem); // Notify views.
treeItem->update(); // Notify views.
}
QModelIndex DebuggerItemModel::lastIndex() const