Baloo

indexer.cpp
1 /*
2  This file is part of the KDE Baloo Project
3  SPDX-FileCopyrightText: 2015 Pinak Ahuja <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 
8 #include "indexer.h"
9 #include "basicindexingjob.h"
10 #include "database.h"
11 #include "./extractor/result.h"
12 
13 #include <KFileMetaData/Extractor>
14 #include <KFileMetaData/PropertyInfo>
15 
16 using namespace Baloo;
17 
18 Indexer::Indexer(const QString& url, Transaction* tr)
19  : m_url(url)
20  , m_tr(tr)
21 {
22 }
23 
24 void Indexer::index()
25 {
26  const QString mimetype = m_mimeDB.mimeTypeForFile(m_url).name();
27  BasicIndexingJob basicIJ(m_url, mimetype, BasicIndexingJob::NoLevel);
28  basicIJ.index();
29  Baloo::Document doc = basicIJ.document();
30 
31  Result result(m_url, mimetype, KFileMetaData::ExtractionResult::ExtractMetaData | KFileMetaData::ExtractionResult::ExtractPlainText);
32  result.setDocument(doc);
33 
34  const QList<KFileMetaData::Extractor*> exList = m_extractorCollection.fetchExtractors(mimetype);
35 
36  for (KFileMetaData::Extractor* ex : exList) {
37  ex->extract(&result);
38  }
39 
40  result.finish();
41  if (m_tr->hasDocument(doc.id())) {
42  m_tr->replaceDocument(doc, Everything);
43  } else {
44  m_tr->addDocument(result.document());
45  }
46 }
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
The result class is where all the data extracted by the KFileMetaData extractors is saved to....
Definition: result.h:26
Implements storage for docIds without any associated data Instantiated for:
Definition: coding.cpp:11
A document represents an indexed file to be stored in the Baloo engine.
Definition: document.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Nov 29 2023 03:56:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.