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

Method onCheckSetSelectionsFolderChanged

plugins/clazy/checksetselectionmanager.cpp:294–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void CheckSetSelectionManager::onCheckSetSelectionsFolderChanged(const QString& checkSetSelectionFolderPath)
295{
296 CheckSetSelectionFileInfoLookup& checkSetSelectionFileInfoLookup =
297 m_checkSetSelectionFileInfoLookupPerFolder[checkSetSelectionFolderPath];
298
299 // TODO: reparse for new, removed and changed files
300 // assume all are removed and unlocked in the beginning
301 QVector<QString> removedCheckSetSelectionIds = checkSetSelectionFileInfoLookup.keys().toVector();
302 QVector<CheckSetSelection> newCheckSetSelections;
303 QVector<CheckSetSelection> changedCheckSetSelections;
304
305 QVector<QString> newUnlockedCheckSetSelectionIds = lockedCheckSetSelectionIds(checkSetSelectionFileInfoLookup);
306 QVector<QString> newLockedCheckSetSelectionIds;
307 // iterate all files in folder
308 const QFileInfoList checkSetSelectionFileInfoList =
309 QDir(checkSetSelectionFolderPath).entryInfoList(checkSetSelectionFileNameFilter(), QDir::Files);
310
311 for (const QFileInfo& checkSetSelectionFileInfo : checkSetSelectionFileInfoList) {
312 // a lock file ?
313 if (checkSetSelectionFileInfo.suffix() == QLatin1String("kdevlock")) {
314 const QString lockedCheckSetSelectionId = checkSetSelectionFileInfo.baseName();
315 // if not in old locks, is a new lock
316 if (!newUnlockedCheckSetSelectionIds.removeOne(lockedCheckSetSelectionId)) {
317 newLockedCheckSetSelectionIds.append(lockedCheckSetSelectionId);
318 }
319 continue;
320 }
321
322 // not a checkset file ?
323 if (checkSetSelectionFileInfo.suffix() != QLatin1String("kdevczcs")) {
324 continue;
325 }
326
327 // all other files assumed to be checkSetSelection files
328 const QString checkSetSelectionId = checkSetSelectionFileInfo.baseName();
329 // load file
330 const CheckSetSelection checkSetSelection = loadCheckSetSelection(checkSetSelectionFileInfo.absoluteFilePath());
331 // loading failed? Treat as not existing
332 if (checkSetSelection.id().isEmpty()) {
333 continue;
334 }
335
336 const CheckSetSelectionFileInfoLookup::Iterator infoIt =
337 checkSetSelectionFileInfoLookup.find(checkSetSelectionId);
338 const bool isKnown = (infoIt != checkSetSelectionFileInfoLookup.end());
339 const QDateTime fileInfoLastModified = checkSetSelectionFileInfo.lastModified();
340 // is known?
341 if (isKnown) {
342 removedCheckSetSelectionIds.removeOne(checkSetSelectionId);
343
344 // check timestamp
345 if (fileInfoLastModified == infoIt->lastModified()) {
346 continue;
347 }
348
349 // update timestamp
350 infoIt->setLastModified(fileInfoLastModified);
351 } else {

Callers

nothing calls this directly

Calls 15

toVectorMethod · 0.80
baseNameMethod · 0.80
removeOneMethod · 0.80
updateLockStatusFunction · 0.70
QDirClass · 0.50
keysMethod · 0.45
appendMethod · 0.45
isEmptyMethod · 0.45
idMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected