Changeset View
Changeset View
Standalone View
Standalone View
src/filemetadataprovider.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 131 | { | |||
---|---|---|---|---|---|
132 | FileFetchJob* fetchJob = static_cast<FileFetchJob*>(job); | 132 | FileFetchJob* fetchJob = static_cast<FileFetchJob*>(job); | ||
133 | QList<QVariantMap> files = fetchJob->data(); | 133 | QList<QVariantMap> files = fetchJob->data(); | ||
134 | 134 | | |||
135 | Q_ASSERT(!files.isEmpty()); | 135 | Q_ASSERT(!files.isEmpty()); | ||
136 | 136 | | |||
137 | if (files.size() > 1) { | 137 | if (files.size() > 1) { | ||
138 | insertCommonData(files); | 138 | insertCommonData(files); | ||
139 | } else { | 139 | } else { | ||
140 | m_data = files.first(); | 140 | m_data = unite(m_data, files.first()); | ||
141 | insertSingleFileBasicData(); | | |||
142 | } | 141 | } | ||
143 | m_readOnly = !fetchJob->canEditAll(); | 142 | m_readOnly = !fetchJob->canEditAll(); | ||
144 | 143 | | |||
145 | insertEditableData(); | 144 | insertEditableData(); | ||
146 | emit loadingFinished(); | 145 | emit loadingFinished(); | ||
147 | } | 146 | } | ||
148 | 147 | | |||
149 | void FileMetaDataProvider::slotLoadingFinished(KJob* job) | 148 | void FileMetaDataProvider::slotLoadingFinished(KJob* job) | ||
150 | { | 149 | { | ||
151 | IndexedDataRetriever* ret = dynamic_cast<IndexedDataRetriever*>(job); | 150 | IndexedDataRetriever* ret = dynamic_cast<IndexedDataRetriever*>(job); | ||
152 | m_data = unite(m_data, ret->data()); | 151 | m_data = unite(m_data, ret->data()); | ||
153 | m_readOnly = !ret->canEdit(); | 152 | m_readOnly = !ret->canEdit(); | ||
154 | 153 | | |||
154 | insertEditableData(); | ||||
155 | emit loadingFinished(); | 155 | emit loadingFinished(); | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | void FileMetaDataProvider::insertSingleFileBasicData() | 158 | void FileMetaDataProvider::insertSingleFileBasicData() | ||
159 | { | 159 | { | ||
160 | // TODO: Handle case if remote URLs are used properly. isDir() does | 160 | // TODO: Handle case if remote URLs are used properly. isDir() does | ||
161 | // not work, the modification date needs also to be adjusted... | 161 | // not work, the modification date needs also to be adjusted... | ||
162 | Q_ASSERT(m_fileItems.count() <= 1); | 162 | Q_ASSERT(m_fileItems.count() <= 1); | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | |||||
298 | void FileMetaDataProvider::setFileItem() | 298 | void FileMetaDataProvider::setFileItem() | ||
299 | { | 299 | { | ||
300 | // There are 3 code paths - | 300 | // There are 3 code paths - | ||
301 | // Remote file | 301 | // Remote file | ||
302 | // Single local file - | 302 | // Single local file - | ||
303 | // * Not Indexed | 303 | // * Not Indexed | ||
304 | // * Indexed | 304 | // * Indexed | ||
305 | // | 305 | // | ||
306 | insertSingleFileBasicData(); | ||||
306 | const QUrl url = m_fileItems.first().targetUrl(); | 307 | const QUrl url = m_fileItems.first().targetUrl(); | ||
307 | if (!url.isLocalFile()) { | 308 | if (!url.isLocalFile()) { | ||
308 | // FIXME - are extended attributes supported for remote files? | 309 | // FIXME - are extended attributes supported for remote files? | ||
309 | m_readOnly = true; | 310 | m_readOnly = true; | ||
310 | insertSingleFileBasicData(); | | |||
311 | emit loadingFinished(); | 311 | emit loadingFinished(); | ||
312 | return; | 312 | return; | ||
313 | } | 313 | } | ||
314 | 314 | | |||
315 | // Not indexed or only basic file indexing (no content) | 315 | // Not indexed or only basic file indexing (no content) | ||
316 | const QString filePath = url.toLocalFile(); | 316 | const QString filePath = url.toLocalFile(); | ||
317 | if (!m_config.fileIndexingEnabled() || !m_config.shouldBeIndexed(filePath) | 317 | if (!m_config.fileIndexingEnabled() || !m_config.shouldBeIndexed(filePath) | ||
318 | || m_config.onlyBasicIndexing()) { | 318 | || m_config.onlyBasicIndexing()) { | ||
319 | m_realTimeIndexing = true; | 319 | m_realTimeIndexing = true; | ||
320 | 320 | | |||
321 | insertSingleFileBasicData(); | | |||
322 | insertEditableData(); | | |||
323 | | ||||
324 | IndexedDataRetriever *ret = new IndexedDataRetriever(filePath, this); | 321 | IndexedDataRetriever *ret = new IndexedDataRetriever(filePath, this); | ||
325 | connect(ret, &IndexedDataRetriever::finished, this, &FileMetaDataProvider::slotLoadingFinished); | 322 | connect(ret, &IndexedDataRetriever::finished, this, &FileMetaDataProvider::slotLoadingFinished); | ||
326 | ret->start(); | 323 | ret->start(); | ||
327 | 324 | | |||
328 | // Fully indexed by Baloo | 325 | // Fully indexed by Baloo | ||
329 | } else { | 326 | } else { | ||
330 | FileFetchJob* job = new FileFetchJob(QStringList{filePath}, true, this); | 327 | FileFetchJob* job = new FileFetchJob(QStringList{filePath}, true, this); | ||
331 | connect(job, &FileFetchJob::finished, this, &FileMetaDataProvider::slotFileFetchFinished); | 328 | connect(job, &FileFetchJob::finished, this, &FileMetaDataProvider::slotFileFetchFinished); | ||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |