void MultipleRemoveCommand::setItemsToDelete(IdList &itemsToDelete) { IdList itemsToUpdate; addEdgesToBeDeleted(itemsToDelete); // QGraphicsScene::selectedItems() returns items in no particular order, // so we should handle parent-child relationships manually while (!itemsToDelete.isEmpty()) { const Id currentItem = itemsToDelete.at(0); const IdList children = mGraphicalApi.children(currentItem); foreach (const Id &child, children) { itemsToDelete.removeAll(child); // Child remove commands will be added in currentItem delete command } const bool isEdge = !mLogicalApi.editorManagerInterface().isGraphicalElementNode(currentItem); if (isEdge) { const Id src = mGraphicalApi.from(currentItem); if (src != Id() && !itemsToUpdate.contains(src)) { itemsToUpdate.append(src); } const Id dst = mGraphicalApi.to(currentItem); if (dst != Id() && !itemsToUpdate.contains(dst)) { itemsToUpdate.append(dst); } insertPreAction(graphicalDeleteCommand(currentItem), 0); } else { addPreAction(graphicalDeleteCommand(currentItem)); } itemsToDelete.removeAll(currentItem); }
IdList TestReparentingStrategy::getParents(const QModelIndex &sourceChildIndex, const IdList &ignore) { if (!sourceChildIndex.isValid()) { kWarning() << "invalid index"; return IdList(); } if (sourceChildIndex.data(ParentListRole).canConvert<IdList>()) { IdList list = sourceChildIndex.data(ParentListRole).value<IdList>(); foreach (Id toRemove, ignore) { list.removeAll(toRemove); }