Baloo

indexer.cpp
1/*
2 This file is part of the KDE Baloo Project
3 SPDX-FileCopyrightText: 2015 Pinak Ahuja <pinak.ahuja@gmail.com>
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
16using namespace Baloo;
17
18Indexer::Indexer(const QString& url, Transaction* tr)
19 : m_url(url)
20 , m_tr(tr)
21{
22}
23
24void 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}
A document represents an indexed file to be stored in the Baloo engine.
Definition document.h:31
QList< Extractor * > fetchExtractors(const QString &mimetype) const
The result class is where all the data extracted by the KFileMetaData extractors is saved to.
Definition result.h:27
Implements storage for docIds without any associated data Instantiated for:
Definition coding.cpp:11
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.