forked from qt-creator/qt-creator
TreeModel: Consolidate child()/childAt() and rowCount()/childCount()
We never used the possibility to overload the virtual child() and rowCount() functions, it's unlikely to be needed in future. Change-Id: I7ebdf4dfc70bb0bcadea9ef3fb88f16632a95696 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -157,8 +157,8 @@ QVariant ModuleItem::data(int column, int role) const
|
||||
static ModuleItem *moduleFromPath(TreeItem *root, const QString &modulePath)
|
||||
{
|
||||
// Recent modules are more likely to be unloaded first.
|
||||
for (int i = root->rowCount(); --i >= 0; ) {
|
||||
auto item = static_cast<ModuleItem *>(root->child(i));
|
||||
for (int i = root->childCount(); --i >= 0; ) {
|
||||
auto item = static_cast<ModuleItem *>(root->childAt(i));
|
||||
if (item->module.modulePath == modulePath)
|
||||
return item;
|
||||
}
|
||||
@@ -199,8 +199,8 @@ Modules ModulesHandler::modules() const
|
||||
{
|
||||
Modules mods;
|
||||
TreeItem *root = m_model->rootItem();
|
||||
for (int i = root->rowCount(); --i >= 0; )
|
||||
mods.append(static_cast<ModuleItem *>(root->child(i))->module);
|
||||
for (int i = root->childCount(); --i >= 0; )
|
||||
mods.append(static_cast<ModuleItem *>(root->childAt(i))->module);
|
||||
return mods;
|
||||
}
|
||||
|
||||
@@ -239,15 +239,15 @@ void ModulesHandler::updateModule(const Module &module)
|
||||
void ModulesHandler::beginUpdateAll()
|
||||
{
|
||||
TreeItem *root = m_model->rootItem();
|
||||
for (int i = root->rowCount(); --i >= 0; )
|
||||
static_cast<ModuleItem *>(root->child(i))->updated = false;
|
||||
for (int i = root->childCount(); --i >= 0; )
|
||||
static_cast<ModuleItem *>(root->childAt(i))->updated = false;
|
||||
}
|
||||
|
||||
void ModulesHandler::endUpdateAll()
|
||||
{
|
||||
TreeItem *root = m_model->rootItem();
|
||||
for (int i = root->rowCount(); --i >= 0; ) {
|
||||
auto item = static_cast<ModuleItem *>(root->child(i));
|
||||
for (int i = root->childCount(); --i >= 0; ) {
|
||||
auto item = static_cast<ModuleItem *>(root->childAt(i));
|
||||
if (!item->updated)
|
||||
m_model->destroyItem(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user