1 | /* |
---|---|
2 | This file is part of the KDE Baloo project. |
3 | SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.1-or-later |
6 | */ |
7 | |
8 | #include "document.h" |
9 | |
10 | using namespace Baloo; |
11 | |
12 | Document::Document() = default; |
13 | |
14 | void Document::addTerm(const QByteArray& term) |
15 | { |
16 | Q_ASSERT(!term.isEmpty()); |
17 | // This adds "term" without position data if it does not exist, otherwise it is a noop |
18 | m_terms[term]; |
19 | } |
20 | |
21 | void Document::addPositionTerm(const QByteArray& term, int position) |
22 | { |
23 | Q_ASSERT(!term.isEmpty()); |
24 | TermData& td = m_terms[term]; |
25 | td.positions.append(t: position); |
26 | } |
27 | |
28 | void Document::addXattrPositionTerm(const QByteArray& term, int position) |
29 | { |
30 | Q_ASSERT(!term.isEmpty()); |
31 | TermData& td = m_xattrTerms[term]; |
32 | td.positions.append(t: position); |
33 | } |
34 | |
35 | void Document::addXattrTerm(const QByteArray& term) |
36 | { |
37 | Q_ASSERT(!term.isEmpty()); |
38 | m_xattrTerms[term]; |
39 | } |
40 | |
41 | void Document::addFileNamePositionTerm(const QByteArray& term, int position) |
42 | { |
43 | Q_ASSERT(!term.isEmpty()); |
44 | TermData& td = m_fileNameTerms[term]; |
45 | td.positions.append(t: position); |
46 | } |
47 | |
48 | void Document::addFileNameTerm(const QByteArray& term) |
49 | { |
50 | Q_ASSERT(!term.isEmpty()); |
51 | m_fileNameTerms[term]; |
52 | } |
53 | |
54 | quint64 Document::id() const |
55 | { |
56 | return m_id; |
57 | } |
58 | |
59 | void Document::setId(quint64 id) |
60 | { |
61 | Q_ASSERT(id); |
62 | m_id = id; |
63 | } |
64 | |
65 | quint64 Document::parentId() const |
66 | { |
67 | return m_parentId; |
68 | } |
69 | |
70 | void Document::setParentId(quint64 parentId) |
71 | { |
72 | Q_ASSERT(parentId); |
73 | m_parentId = parentId; |
74 | } |
75 | |
76 | void Document::setUrl(const QByteArray& url) |
77 | { |
78 | Q_ASSERT(!url.isEmpty()); |
79 | m_url = url; |
80 | } |
81 | |
82 | QByteArray Document::url() const |
83 | { |
84 | return m_url; |
85 | } |
86 | |
87 | bool Document::contentIndexing() const |
88 | { |
89 | return m_contentIndexing; |
90 | } |
91 | |
92 | void Document::setContentIndexing(bool val) |
93 | { |
94 | m_contentIndexing = val; |
95 | } |
96 | |
97 | void Document::setData(const QByteArray& data) |
98 | { |
99 | m_data = data; |
100 | } |
101 |