Changeset View
Changeset View
Standalone View
Standalone View
src/file/fileindexerconfig.cpp
Show First 20 Lines • Show All 307 Lines • ▼ Show 20 Line(s) | |||||
308 | } | 308 | } | ||
309 | 309 | | |||
310 | void FileIndexerConfig::buildFolderCache() | 310 | void FileIndexerConfig::buildFolderCache() | ||
311 | { | 311 | { | ||
312 | if (!m_folderCacheDirty) { | 312 | if (!m_folderCacheDirty) { | ||
313 | return; | 313 | return; | ||
314 | } | 314 | } | ||
315 | 315 | | |||
316 | if (!m_devices) { | | |||
317 | m_devices = new StorageDevices(this); | | |||
318 | } | | |||
319 | | ||||
320 | KConfigGroup group = m_config.group("General"); | 316 | KConfigGroup group = m_config.group("General"); | ||
321 | QStringList includeFoldersPlain = group.readPathEntry("folders", QStringList() << QDir::homePath()); | 317 | QStringList includeFoldersPlain = group.readPathEntry("folders", QStringList() << QDir::homePath()); | ||
322 | QStringList excludeFoldersPlain = group.readPathEntry("exclude folders", QStringList()); | 318 | QStringList excludeFoldersPlain = group.readPathEntry("exclude folders", QStringList()); | ||
323 | 319 | | |||
324 | // Add all removable media and network shares as ignored unless they have | 320 | // Add all removable media and network shares as ignored unless they have | ||
325 | // been explicitly added in the include list | 321 | // been explicitly added in the include list | ||
326 | const auto allMedia = m_devices->allMedia(); | 322 | for (const auto& device: storageDevices()->allMedia()) { | ||
bruns: This is bad, you remove the const from the QList<>
Read up about Qt and detaching ... | |||||
According to https://www.dvratil.cz/2015/06/qt-containers-and-c11-range-based-loops this particular example will detach with or without the const intermediate. smithjd: According to https://www.dvratil.cz/2015/06/qt-containers-and-c11-range-based-loops this… | |||||
Citing from above:
bruns: Citing from above:
> To sum this up, when using range-based loops with Qt containers:
> Make… | |||||
327 | for (const auto& device: allMedia) { | | |||
328 | const QString mountPath = device.mountPath(); | 323 | const QString mountPath = device.mountPath(); | ||
329 | if (!device.isUsable() && !mountPath.isEmpty()) { | 324 | if (!device.isUsable() && !mountPath.isEmpty()) { | ||
330 | if (!includeFoldersPlain.contains(mountPath)) { | 325 | if (!includeFoldersPlain.contains(mountPath)) { | ||
331 | excludeFoldersPlain << mountPath; | 326 | excludeFoldersPlain << mountPath; | ||
332 | } | 327 | } | ||
333 | } | 328 | } | ||
334 | } | 329 | } | ||
335 | 330 | | |||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 387 | { | |||
393 | return m_config.group("Basic Settings").readEntry("Indexing-Enabled", true); | 388 | return m_config.group("Basic Settings").readEntry("Indexing-Enabled", true); | ||
394 | } | 389 | } | ||
395 | 390 | | |||
396 | uint FileIndexerConfig::maxUncomittedFiles() | 391 | uint FileIndexerConfig::maxUncomittedFiles() | ||
397 | { | 392 | { | ||
398 | return m_maxUncomittedFiles; | 393 | return m_maxUncomittedFiles; | ||
399 | } | 394 | } | ||
400 | 395 | | |||
396 | StorageDevices* FileIndexerConfig::storageDevices() | ||||
397 | { | ||||
398 | if (!m_devices) { | ||||
399 | m_devices = new StorageDevices(this); | ||||
400 | } | ||||
401 | | ||||
402 | return m_devices; | ||||
403 | } |
This is bad, you remove the const from the QList<>
Read up about Qt and detaching ...