| 292 | } |
| 293 | |
| 294 | void 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 { |
nothing calls this directly
no test coverage detected