MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / merge

Method merge

launcher/meta/Index.cpp:101–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void Index::merge(const std::shared_ptr<Index> &other)
102{
103 const QVector<VersionListPtr> lists = std::dynamic_pointer_cast<Index>(other)->m_lists;
104 // initial load, no need to merge
105 if (m_lists.isEmpty())
106 {
107 beginResetModel();
108 m_lists = lists;
109 for (int i = 0; i < lists.size(); ++i)
110 {
111 m_uids.insert(lists.at(i)->uid(), lists.at(i));
112 connectVersionList(i, lists.at(i));
113 }
114 endResetModel();
115 }
116 else
117 {
118 for (const VersionListPtr &list : lists)
119 {
120 if (m_uids.contains(list->uid()))
121 {
122 m_uids[list->uid()]->mergeFromIndex(list);
123 }
124 else
125 {
126 beginInsertRows(QModelIndex(), m_lists.size(), m_lists.size());
127 connectVersionList(m_lists.size(), list);
128 m_lists.append(list);
129 m_uids.insert(list->uid(), list);
130 endInsertRows();
131 }
132 }
133 }
134}
135
136void Index::connectVersionList(const int row, const VersionListPtr &list)
137{

Callers 4

parseIndexFunction · 0.45
parseVersionListFunction · 0.45
parseVersionFunction · 0.45
test_mergeMethod · 0.45

Calls 9

QModelIndexClass · 0.85
isEmptyMethod · 0.80
insertMethod · 0.80
mergeFromIndexMethod · 0.80
appendMethod · 0.80
sizeMethod · 0.45
uidMethod · 0.45
atMethod · 0.45
containsMethod · 0.45

Tested by 1

test_mergeMethod · 0.36