MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / syncProjectItems

Method syncProjectItems

src/plugins/smartut/common/projectitemmodel.cpp:67–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void ProjectItemModelPrivate::syncProjectItems(NodeItem *targetItem, NodeItem *srcItem)
68{
69 if (!targetItem || !srcItem)
70 return;
71
72 QHash<QString, NodeItem *> targetChildren;
73 for (int i = 0; i < targetItem->rowCount(); ++i) {
74 NodeItem *child = static_cast<NodeItem *>(targetItem->child(i));
75 if (child)
76 targetChildren.insert(child->filePath(), child);
77 }
78
79 for (int i = 0; i < srcItem->rowCount(); ++i) {
80 NodeItem *sourceChild = static_cast<NodeItem *>(srcItem->child(i));
81 if (!sourceChild)
82 continue;
83
84 QString key = sourceChild->filePath();
85 if (targetChildren.contains(key)) {
86 syncProjectItems(targetChildren[key], sourceChild);
87 targetChildren.remove(key);
88 } else {
89 auto newItem = new NodeItem(sourceChild->itemNode);
90 targetItem->appendRow(newItem);
91 if (sourceChild->hasChildren()) {
92 QSet<Node *> seen;
93 addFolderNode(newItem, newItem->itemNode->asFolderNode(), &seen);
94 }
95 }
96 }
97
98 for (NodeItem *item : qAsConst(targetChildren)) {
99 if (item->state != Generating)
100 targetItem->removeRow(item->row());
101 }
102}
103
104ProjectItemModel::ProjectItemModel(ProjectTreeView *parent)
105 : QStandardItemModel(parent),

Callers 1

updateProjectNodeMethod · 0.80

Calls 10

childMethod · 0.80
insertMethod · 0.80
rowMethod · 0.80
rowCountMethod · 0.45
filePathMethod · 0.45
containsMethod · 0.45
removeMethod · 0.45
appendRowMethod · 0.45
hasChildrenMethod · 0.45
asFolderNodeMethod · 0.45

Tested by

no test coverage detected