File indexing completed on 2024-05-12 15:51:17
0001 // SPDX-FileCopyrightText: 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0002 // SPDX-License-Identifier: LGPL-2.1-only or LGPL-3.0-only or LicenseRef-KDE-Accepted-LGPL 0003 0004 #pragma once 0005 0006 #include <QObject> 0007 #include <QSet> 0008 #include <QString> 0009 0010 class ContentQuery; 0011 /** 0012 * \brief Class to handle the search. 0013 * 0014 * This class can be extended to handle other search engines, 0015 * such as baloo and the file system content lister. 0016 * 0017 * By default it only searches the KFileMetaData available to it. 0018 */ 0019 class ContentListerBase : public QObject 0020 { 0021 Q_OBJECT 0022 public: 0023 explicit ContentListerBase(QObject *parent = nullptr); 0024 ~ContentListerBase() override; 0025 0026 /** 0027 * \brief Start a search. 0028 * @param queries List of ContentQueries that the search should be limited to. 0029 */ 0030 Q_SLOT virtual void startSearch(const QList<ContentQuery *> &queries); 0031 0032 /** 0033 * \brief Fires when a matching file is found. 0034 */ 0035 Q_SIGNAL void fileFound(const QString &filePath, const QVariantMap &metadata); 0036 /** 0037 * \brief Fires when the search was completed. 0038 */ 0039 Q_SIGNAL void searchCompleted(); 0040 0041 /** 0042 * @return the available metadata for the filepath so that it can be searched. 0043 */ 0044 static QVariantMap metaDataForFile(const QString &file); 0045 0046 protected: 0047 friend class ContentList; 0048 QSet<QString> knownFiles; 0049 };