MCPcopy Create free account
hub / github.com/KDE/kdevelop / makeSetId

Method makeSetId

kdevplatform/shell/workingsetcontroller.cpp:102–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102const 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
128WorkingSet* WorkingSetController::newWorkingSet(const QString& prefix)
129{

Callers

nothing calls this directly

Calls 5

similarityMethod · 0.80
QStringClass · 0.70
isEmptyMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected