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

@@ -198,7 +198,7 @@ QAbstractItemModel *ModulesHandler::model() const
void ModulesHandler::removeAll()
{
m_model->removeAllSubItems(m_model->rootItem());
m_model->removeItems();
}
Modules ModulesHandler::modules() const
@@ -228,13 +228,13 @@ void ModulesHandler::updateModule(const Module &module)
} else {
item = new ModuleItem;
item->module = module;
m_model->appendItem(m_model->rootItem(), item);
m_model->rootItem()->appendChild(item);
}
try { // MinGW occasionallly throws std::bad_alloc.
ElfReader reader(path);
item->module.elfData = reader.readHeaders();
m_model->updateItem(item);
item->update();
} catch(...) {
qWarning("%s: An exception occurred while reading module '%s'",
Q_FUNC_INFO, qPrintable(module.modulePath));