diff --git a/autotests/integration/querytest.cpp b/autotests/integration/querytest.cpp --- a/autotests/integration/querytest.cpp +++ b/autotests/integration/querytest.cpp @@ -67,7 +67,7 @@ QString fileName = url.mid(url.lastIndexOf('/') + 1); - TermGenerator tg(&doc); + TermGenerator tg(doc); tg.indexText(text); tg.indexFileNameText(fileName); doc.setId(id); diff --git a/autotests/unit/engine/termgeneratortest.cpp b/autotests/unit/engine/termgeneratortest.cpp --- a/autotests/unit/engine/termgeneratortest.cpp +++ b/autotests/unit/engine/termgeneratortest.cpp @@ -53,7 +53,7 @@ QString str = QString::fromLatin1("The quick (\"brown\") 'fox' can't jump 32.3 feet, right? No-Wrong;xx.txt"); Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str); QList words = allWords(doc); @@ -71,7 +71,7 @@ QString str = QString::fromLatin1("_plant"); Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str); QList words = allWords(doc); @@ -87,7 +87,7 @@ QString str = QString::fromLatin1("Hello_Howdy"); Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str); QList words = allWords(doc); @@ -103,7 +103,7 @@ QString str = QString::fromUtf8("Como est\xC3\xA1 K\xC3\xBBg"); // "Como está Kûg" Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str); QList words = allWords(doc); @@ -121,7 +121,7 @@ QString str2 = QLatin1Literal("ma") + QChar(0xfb00) + QStringLiteral("ab"); Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str2); QList words = allWords(doc); @@ -137,7 +137,7 @@ QString str = QString::fromUtf8("\xF0\x9D\x90\xBB\xF0\x9D\x91\x92\xF0\x9D\x91\x91\xF0\x9D\x91\x94\xF0\x9D\x91\x92"); Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str); QList words = allWords(doc); @@ -150,7 +150,7 @@ QString str = QString::fromLatin1("me@vhanda.in"); Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); termGen.indexText(str); QList words = allWords(doc); @@ -164,7 +164,7 @@ void TermGeneratorTest::testWordPositions() { Document doc; - TermGenerator termGen(&doc); + TermGenerator termGen(doc); QString str = QString::fromLatin1("Hello hi how hi"); termGen.indexText(str); diff --git a/src/engine/termgenerator.h b/src/engine/termgenerator.h --- a/src/engine/termgenerator.h +++ b/src/engine/termgenerator.h @@ -23,17 +23,16 @@ #include #include "engine_export.h" +#include "document.h" namespace Baloo { -class Document; - class BALOO_ENGINE_EXPORT TermGenerator { public: - explicit TermGenerator(Document* doc); + explicit TermGenerator(Document& doc); - void setDocument(Document* doc) { + void setDocument(Document& doc) { m_doc = doc; } @@ -52,7 +51,7 @@ // Trim all terms to this size const static int maxTermSize = 25; private: - Document* m_doc; + Document& m_doc; int m_position; }; } diff --git a/src/engine/termgenerator.cpp b/src/engine/termgenerator.cpp --- a/src/engine/termgenerator.cpp +++ b/src/engine/termgenerator.cpp @@ -26,7 +26,7 @@ using namespace Baloo; -TermGenerator::TermGenerator(Document* doc) +TermGenerator::TermGenerator(Document& doc) : m_doc(doc) , m_position(1) { @@ -89,7 +89,7 @@ QByteArray finalArr = prefix + arr; finalArr = finalArr.mid(0, maxTermSize); - m_doc->addPositionTerm(finalArr, m_position); + m_doc.addPositionTerm(finalArr, m_position); m_position++; } } @@ -103,7 +103,7 @@ QByteArray finalArr = prefix + arr; finalArr = finalArr.mid(0, maxTermSize); - m_doc->addFileNamePositionTerm(finalArr, m_position); + m_doc.addFileNamePositionTerm(finalArr, m_position); m_position++; } } @@ -122,7 +122,7 @@ QByteArray finalArr = prefix + arr; finalArr = finalArr.mid(0, maxTermSize); - m_doc->addXattrPositionTerm(finalArr, m_position); + m_doc.addXattrPositionTerm(finalArr, m_position); m_position++; } diff --git a/src/file/basicindexingjob.cpp b/src/file/basicindexingjob.cpp --- a/src/file/basicindexingjob.cpp +++ b/src/file/basicindexingjob.cpp @@ -60,7 +60,7 @@ QString fileName = url.mid(url.lastIndexOf('/') + 1); - TermGenerator tg(&doc); + TermGenerator tg(doc); tg.indexFileNameText(fileName); tg.indexFileNameText(fileName, QByteArray("F")); tg.indexText(m_mimetype, QByteArray("M")); @@ -94,7 +94,7 @@ bool BasicIndexingJob::indexXAttr(const QString& url, Document& doc) { KFileMetaData::UserMetaData userMetaData(url); - TermGenerator tg(&doc); + TermGenerator tg(doc); QStringList tags = userMetaData.tags(); for (const QString& tag : tags) { diff --git a/src/file/extractor/result.cpp b/src/file/extractor/result.cpp --- a/src/file/extractor/result.cpp +++ b/src/file/extractor/result.cpp @@ -32,15 +32,15 @@ // In order to use it in a vector Result::Result() : ExtractionResult(QString(), QString()) - , m_termGen(nullptr) - , m_termGenForText(nullptr) + , m_termGen(m_doc) + , m_termGenForText(m_doc) { } Result::Result(const QString& url, const QString& mimetype, const Flags& flags) : KFileMetaData::ExtractionResult(url, mimetype, flags) - , m_termGen(nullptr) - , m_termGenForText(nullptr) + , m_termGen(m_doc) + , m_termGenForText(m_doc) { } @@ -131,11 +131,11 @@ { m_doc = doc; // All document metadata are indexed from position 1000 - m_termGen.setDocument(&m_doc); + m_termGen.setDocument(m_doc); m_termGen.setPosition(1000); // All document plain text starts from 10000. This is done to avoid // clashes with the term positions - m_termGenForText.setDocument(&m_doc); + m_termGenForText.setDocument(m_doc); m_termGenForText.setPosition(10000); }