* @brief Lower-is-better score: prefers names sharing the dotted prefix. */
| 66 | * @brief Lower-is-better score: prefers names sharing the dotted prefix. |
| 67 | */ |
| 68 | static int similarityScore(const QString& want, const QString& have) |
| 69 | { |
| 70 | const auto wantParts = want.split(QLatin1Char('.')); |
| 71 | const auto haveParts = have.split(QLatin1Char('.')); |
| 72 | |
| 73 | int sharedSegments = 0; |
| 74 | const int minSeg = std::min(wantParts.size(), haveParts.size()); |
| 75 | for (int i = 0; i < minSeg; ++i) |
| 76 | if (wantParts[i].compare(haveParts[i], Qt::CaseInsensitive) == 0) |
| 77 | sharedSegments += 1; |
| 78 | else |
| 79 | break; |
| 80 | |
| 81 | const int dist = editDistance(want, have); |
| 82 | |
| 83 | return dist - (sharedSegments * 6); |
| 84 | } |
| 85 | |
| 86 | //-------------------------------------------------------------------------------------------------- |
| 87 | // Singleton access |
no test coverage detected