File indexing completed on 2024-05-12 05:11:18

0001 /*
0002  * This file is part of the KDE Akonadi Search Project
0003  * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006  *
0007  */
0008 
0009 #pragma once
0010 
0011 #include "search_core_export.h"
0012 #include "searchstore.h"
0013 
0014 #include <QExplicitlySharedDataPointer>
0015 
0016 namespace Akonadi
0017 {
0018 namespace Search
0019 {
0020 class SearchStore;
0021 class Result;
0022 
0023 class Q_DECL_HIDDEN ResultIteratorPrivate : public QSharedData
0024 {
0025 public:
0026     ResultIteratorPrivate()
0027     {
0028     }
0029 
0030     ~ResultIteratorPrivate()
0031     {
0032         if (store) {
0033             store->close(queryId);
0034         }
0035     }
0036 
0037     int queryId = 0;
0038     SearchStore *store = nullptr;
0039 };
0040 
0041 /** Result iterator. */
0042 class AKONADI_SEARCH_CORE_EXPORT ResultIterator
0043 {
0044 public:
0045     ResultIterator();
0046     ResultIterator(const ResultIterator &rhs);
0047     ~ResultIterator();
0048 
0049     ResultIterator &operator=(const ResultIterator &other);
0050 
0051     // internal
0052     ResultIterator(int id, SearchStore *store);
0053 
0054     bool next();
0055 
0056     [[nodiscard]] QByteArray id() const;
0057     [[nodiscard]] QUrl url() const;
0058 
0059     [[nodiscard]] QString text() const;
0060     [[nodiscard]] QString icon() const;
0061 
0062 private:
0063     QExplicitlySharedDataPointer<ResultIteratorPrivate> d;
0064 };
0065 }
0066 }