File indexing completed on 2024-04-21 03:51:41

0001 /*
0002     This file is part of the KDE Baloo project.
0003     SPDX-FileCopyrightText: 2014-2015 Vishesh Handa <vhanda@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef BALOO_TERMGENERATOR_H
0009 #define BALOO_TERMGENERATOR_H
0010 
0011 #include <QByteArray>
0012 #include <QString>
0013 #include "engine_export.h"
0014 #include "document.h"
0015 
0016 namespace Baloo {
0017 
0018 class BALOO_ENGINE_EXPORT TermGenerator
0019 {
0020 public:
0021     explicit TermGenerator(Document& doc);
0022 
0023     void setDocument(Document& doc) {
0024         m_doc = doc;
0025     }
0026 
0027     void indexText(const QString& text);
0028     void indexText(const QString& text, const QByteArray& prefix);
0029 
0030     void indexXattrText(const QString& text, const QByteArray& prefix);
0031     void indexFileNameText(const QString& text);
0032 
0033     void setPosition(int position);
0034     int position() const;
0035 
0036     static QByteArrayList termList(const QString& text);
0037 
0038     // Trim all terms to this size
0039     const static int maxTermSize = 25;
0040 private:
0041     Document& m_doc;
0042     int m_position;
0043 };
0044 }
0045 
0046 #endif // BALOO_TERMGENERATOR_H