Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/mergedialog.cpp
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | |||||
154 | } | 154 | } | ||
155 | 155 | | |||
156 | void MergeDialog::feedDuplicateModelFromMatches(const QList<Match> &matches) | 156 | void MergeDialog::feedDuplicateModelFromMatches(const QList<Match> &matches) | ||
157 | { | 157 | { | ||
158 | Q_D(MergeDialog); | 158 | Q_D(MergeDialog); | ||
159 | QHash<QPersistentModelIndex, QList<Match> > compareTable; | 159 | QHash<QPersistentModelIndex, QList<Match> > compareTable; | ||
160 | QHash<QPersistentModelIndex, QPersistentModelIndex> doneIndexes; | 160 | QHash<QPersistentModelIndex, QPersistentModelIndex> doneIndexes; | ||
161 | 161 | | |||
162 | Q_FOREACH (const Match &match, matches) { | 162 | for (const Match &match : matches) { | ||
163 | QPersistentModelIndex destination = doneIndexes.value(match.indexA, match.indexA); | 163 | QPersistentModelIndex destination = doneIndexes.value(match.indexA, match.indexA); | ||
164 | QHash<QPersistentModelIndex, QList< Match > >::iterator currentValue = compareTable.find(destination); | 164 | QHash<QPersistentModelIndex, QList< Match > >::iterator currentValue = compareTable.find(destination); | ||
165 | 165 | | |||
166 | if (currentValue == compareTable.end()) { // new parent, create it | 166 | if (currentValue == compareTable.end()) { // new parent, create it | ||
167 | compareTable[match.indexA] = QList<Match>() << match; | 167 | compareTable[match.indexA] = QList<Match>() << match; | ||
168 | } else { //know parent, add child | 168 | } else { //know parent, add child | ||
169 | currentValue->append(match); | 169 | currentValue->append(match); | ||
170 | } | 170 | } | ||
171 | doneIndexes[match.indexB] = destination; | 171 | doneIndexes[match.indexB] = destination; | ||
172 | } | 172 | } | ||
173 | // now build the model : 1st dimension = person candidate, 2nd dimension = match | 173 | // now build the model : 1st dimension = person candidate, 2nd dimension = match | ||
174 | QStandardItem *rootItem = d->model->invisibleRootItem(); | 174 | QStandardItem *rootItem = d->model->invisibleRootItem(); | ||
175 | QHash<QPersistentModelIndex, QList< Match > >::const_iterator i; | 175 | QHash<QPersistentModelIndex, QList< Match > >::const_iterator i; | ||
176 | 176 | | |||
177 | for (i = compareTable.constBegin(); i != compareTable.constEnd(); ++i) { | 177 | for (i = compareTable.constBegin(); i != compareTable.constEnd(); ++i) { | ||
178 | // Build the merge Contact in the model | 178 | // Build the merge Contact in the model | ||
179 | QStandardItem *parent = itemMergeContactFromMatch(true, i->first()); | 179 | QStandardItem *parent = itemMergeContactFromMatch(true, i->first()); | ||
180 | rootItem->appendRow(parent); | 180 | rootItem->appendRow(parent); | ||
181 | 181 | | |||
182 | Q_FOREACH (const Match &matchChild, *i) { | 182 | for (const Match &matchChild : qAsConst(*i)) { | ||
183 | parent->appendRow(itemMergeContactFromMatch(false, matchChild)); | 183 | parent->appendRow(itemMergeContactFromMatch(false, matchChild)); | ||
184 | } | 184 | } | ||
185 | } | 185 | } | ||
186 | 186 | | |||
187 | rootItem->sortChildren(0); | 187 | rootItem->sortChildren(0); | ||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | QStandardItem *MergeDialog::itemMergeContactFromMatch(bool isParent, const Match &match) | 190 | QStandardItem *MergeDialog::itemMergeContactFromMatch(bool isParent, const Match &match) | ||
Show All 38 Lines |