Line data Source code
1 : #ifndef SEARCHFEEDITEM_H
2 : #define SEARCHFEEDITEM_H
3 :
4 : #include "LisvelFeedItem.h"
5 :
6 : #include <QObject>
7 :
8 : #include "ListModel.h"
9 :
10 : /*!
11 : \brief A pseudo-feed containing search results.
12 :
13 : Created to display search results.
14 :
15 : Search results are relevance-ordered using FTS5's BM25 ranking, with
16 : matching terms highlighted using <mark> tags.
17 :
18 : Search can be scoped to:
19 : - Global (all feeds) - default
20 : - A specific feed (by feed_id)
21 : - A folder (all feeds within the folder)
22 : */
23 : class SearchFeedItem : public LisvelFeedItem
24 : {
25 : Q_OBJECT
26 : public:
27 : /*!
28 : \brief Search scope enumeration.
29 : */
30 : enum class Scope {
31 : Global, //!< Search all feeds (default)
32 : Feed, //!< Search within a specific feed
33 : Folder //!< Search within all feeds in a folder
34 : };
35 :
36 : explicit SearchFeedItem(ListModel *feedList);
37 :
38 : /*!
39 : \brief Sets the search query and clears any existing results.
40 : \param query The FTS5 search query string.
41 : */
42 : void setSearchQuery(const QString& query);
43 :
44 : /*!
45 : \brief Sets the search scope.
46 : \param scope The scope (Global, Feed, or Folder).
47 : \param scopeId The feed ID or folder ID when scope is Feed or Folder.
48 : */
49 : void setScope(Scope scope, qint64 scopeId = -1);
50 :
51 : /*!
52 : \return The current search query.
53 : */
54 0 : Q_INVOKABLE QString getSearchQuery() const { return searchQuery; }
55 :
56 : /*!
57 : \return True if a search query is set.
58 : */
59 : bool hasSearchQuery() const { return !searchQuery.isEmpty(); }
60 :
61 : /*!
62 : \return The current search scope.
63 : */
64 : Scope getScope() const { return searchScope; }
65 :
66 : /*!
67 : \return The scope ID (feed or folder ID).
68 : */
69 : qint64 getScopeId() const { return scopeId; }
70 :
71 : // Search doesn't support bookmarks (relevance-ordered, not chronological).
72 : virtual bool canBookmark(qint64 bookmarkID, bool allowBackward) override;
73 : virtual bool bookmarksEnabled() const override;
74 :
75 : private:
76 : QString searchQuery;
77 : Scope searchScope;
78 : qint64 scopeId;
79 : };
80 :
81 : #endif // SEARCHFEEDITEM_H
|