foreach (AbstractInventoryItem *item, children) { if (item->GetItemType() == AbstractInventoryItem::Type_Folder) { InventoryFolder *folder = dynamic_cast<InventoryFolder*>(item); if (!folder) continue; CheckChildrenForDirtys(folder->GetChildren()); if (!folder->IsDirty()) continue; QModelIndexList all_items = persistentIndexList(); foreach (QModelIndex index, all_items) if (item == reinterpret_cast<AbstractInventoryItem *>(index.internalPointer())) emit IndexModelIsDirty(index); folder->SetDirty(false); }
bool WebDavInventoryDataModel::FetchInventoryDescendents(AbstractInventoryItem *item) { InventoryFolder *selected = dynamic_cast<InventoryFolder *>(item); if (!selected) return false; // Delete children selected->GetChildren().clear(); QString itemPath = selected->GetID(); QStringList children = webdavclient_.call("listResources", QVariantList() << itemPath).toStringList(); if ( children.count() >=1 ) { // Process child list to map QMap<QString, QString> childMap; for (int index=0; index<=children.count(); index++) { childMap[children.value(index)] = children.value(index+1); index++; } AbstractInventoryItem *newItem = 0; QString path, name, type; for (QMap<QString, QString>::iterator iter = childMap.begin(); iter!=childMap.end(); ++iter) { path = iter.key(); name = path.midRef(path.lastIndexOf("/")+1).toString(); type = iter.value(); if (name != "") { if (type == "resource") newItem = new InventoryAsset(path, "", name, selected); else newItem = new InventoryFolder(path, name, selected, true); selected->AddChild(newItem); } } InventoryModule::LogInfo(QString("Webdav | Fetched %1 children to path /%2").arg(QString::number(childMap.count()), itemPath).toStdString()); } return true; }
void InventoryItemModel::CheckTreeForDirtys() { InventoryFolder *root = dynamic_cast<InventoryFolder*>(dataModel_->GetRoot()); if (root) CheckChildrenForDirtys(root->GetChildren()); }