| 100 | } |
| 101 | |
| 102 | const QString WorkingSetController::makeSetId(const QString& prefix) const |
| 103 | { |
| 104 | QString newId; |
| 105 | const uint maxRetries = 10; |
| 106 | auto* randomGenerator = QRandomGenerator::global(); |
| 107 | for (uint retry = 2; retry <= maxRetries; retry++) { |
| 108 | const auto random = randomGenerator->bounded(10000000); |
| 109 | newId = QStringLiteral("%1_%2").arg(prefix).arg(random); |
| 110 | WorkingSetIconParameters params(newId); |
| 111 | for (WorkingSet* set : m_workingSets) { |
| 112 | if(set->isEmpty()) { |
| 113 | continue; |
| 114 | } |
| 115 | // The last retry will always generate a valid set |
| 116 | if(retry != maxRetries && WorkingSetIconParameters(set->id()).similarity(params) >= retry*8) { |
| 117 | newId = QString(); |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | if(! newId.isEmpty()) { |
| 122 | break; |
| 123 | } |
| 124 | } |
| 125 | return newId; |
| 126 | } |
| 127 | |
| 128 | WorkingSet* WorkingSetController::newWorkingSet(const QString& prefix) |
| 129 | { |
nothing calls this directly
no test coverage detected