Changeset View
Changeset View
Standalone View
Standalone View
src/catalog/catalogstring.cpp
Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Line(s) | 274 | while (--i >= 0) { | |||
---|---|---|---|---|---|
276 | id2tagIndex.insert(t.id, i); | 276 | id2tagIndex.insert(t.id, i); | ||
277 | tagType2tagIndex.insert(t.type, i); | 277 | tagType2tagIndex.insert(t.type, i); | ||
278 | qCWarning(LOKALIZE_LOG) << "inserting" << t.id << t.type << i; | 278 | qCWarning(LOKALIZE_LOG) << "inserting" << t.id << t.type << i; | ||
279 | } | 279 | } | ||
280 | 280 | | |||
281 | QList<InlineTag> oldTags = target.tags; | 281 | QList<InlineTag> oldTags = target.tags; | ||
282 | target.tags.clear(); | 282 | target.tags.clear(); | ||
283 | //we actually walking from beginning to end: | 283 | //we actually walking from beginning to end: | ||
284 | qSort(oldTags.begin(), oldTags.end(), qGreater<InlineTag>()); | 284 | std::sort(oldTags.begin(), oldTags.end(), qGreater<InlineTag>()); | ||
285 | i = oldTags.size(); | 285 | i = oldTags.size(); | ||
286 | while (--i >= 0) { | 286 | while (--i >= 0) { | ||
287 | const InlineTag& targetTag = oldTags.at(i); | 287 | const InlineTag& targetTag = oldTags.at(i); | ||
288 | if (id2tagIndex.contains(targetTag.id)) { | 288 | if (id2tagIndex.contains(targetTag.id)) { | ||
289 | qCWarning(LOKALIZE_LOG) << "matched" << targetTag.id << i; | 289 | qCWarning(LOKALIZE_LOG) << "matched" << targetTag.id << i; | ||
290 | target.tags.append(targetTag); | 290 | target.tags.append(targetTag); | ||
291 | tagType2tagIndex.remove(targetTag.type, id2tagIndex.take(targetTag.id)); | 291 | tagType2tagIndex.remove(targetTag.type, id2tagIndex.take(targetTag.id)); | ||
292 | oldTags.removeAt(i); | 292 | oldTags.removeAt(i); | ||
293 | } | 293 | } | ||
294 | } | 294 | } | ||
295 | //qCWarning(LOKALIZE_LOG) << "HERE 0" << target.string; | 295 | //qCWarning(LOKALIZE_LOG) << "HERE 0" << target.string; | ||
296 | 296 | | |||
297 | //now all the tags left have to ID (exact) matches | 297 | //now all the tags left have to ID (exact) matches | ||
298 | i = oldTags.size(); | 298 | i = oldTags.size(); | ||
299 | while (--i >= 0) { | 299 | while (--i >= 0) { | ||
300 | InlineTag targetTag = oldTags.at(i); | 300 | InlineTag targetTag = oldTags.at(i); | ||
301 | if (tagType2tagIndex.contains(targetTag.type)) { | 301 | if (tagType2tagIndex.contains(targetTag.type)) { | ||
302 | //try to match by position | 302 | //try to match by position | ||
303 | //we're _taking_ first so the next one becomes new 'first' for the next time. | 303 | //we're _taking_ first so the next one becomes new 'first' for the next time. | ||
304 | QList<InlineTag> possibleRefMatches; | 304 | QList<InlineTag> possibleRefMatches; | ||
305 | foreach (int i, tagType2tagIndex.values(targetTag.type)) | 305 | foreach (int i, tagType2tagIndex.values(targetTag.type)) | ||
306 | possibleRefMatches << ref.tags.at(i); | 306 | possibleRefMatches << ref.tags.at(i); | ||
307 | qSort(possibleRefMatches); | 307 | std::sort(possibleRefMatches.begin(), possibleRefMatches.end()); | ||
308 | qCWarning(LOKALIZE_LOG) << "setting id:" << targetTag.id << possibleRefMatches.first().id; | 308 | qCWarning(LOKALIZE_LOG) << "setting id:" << targetTag.id << possibleRefMatches.first().id; | ||
309 | targetTag.id = possibleRefMatches.first().id; | 309 | targetTag.id = possibleRefMatches.first().id; | ||
310 | 310 | | |||
311 | target.tags.append(targetTag); | 311 | target.tags.append(targetTag); | ||
312 | qCWarning(LOKALIZE_LOG) << "id??:" << targetTag.id << target.tags.first().id; | 312 | qCWarning(LOKALIZE_LOG) << "id??:" << targetTag.id << target.tags.first().id; | ||
313 | tagType2tagIndex.remove(targetTag.type, id2tagIndex.take(targetTag.id)); | 313 | tagType2tagIndex.remove(targetTag.type, id2tagIndex.take(targetTag.id)); | ||
314 | oldTags.removeAt(i); | 314 | oldTags.removeAt(i); | ||
315 | } | 315 | } | ||
Show All 11 Lines |