diff options
Diffstat (limited to 'common/mail/fulltextindexer.cpp')
-rw-r--r-- | common/mail/fulltextindexer.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/common/mail/fulltextindexer.cpp b/common/mail/fulltextindexer.cpp new file mode 100644 index 0000000..a980752 --- /dev/null +++ b/common/mail/fulltextindexer.cpp | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #include "fulltextindexer.h" | ||
20 | |||
21 | #include "typeindex.h" | ||
22 | #include "fulltextindex.h" | ||
23 | #include "log.h" | ||
24 | #include "utils.h" | ||
25 | |||
26 | using namespace Sink; | ||
27 | using namespace Sink::ApplicationDomain; | ||
28 | |||
29 | |||
30 | void FulltextIndexer::add(const ApplicationDomain::ApplicationDomainType &entity) | ||
31 | { | ||
32 | if (!index) { | ||
33 | index.reset(new FulltextIndex{mResourceInstanceIdentifier, Storage::DataStore::ReadWrite}); | ||
34 | } | ||
35 | index->add(entity.identifier(), entity.getProperty("index").value<QList<QPair<QString, QString>>>()); | ||
36 | } | ||
37 | |||
38 | void FulltextIndexer::remove(const ApplicationDomain::ApplicationDomainType &entity) | ||
39 | { | ||
40 | if (!index) { | ||
41 | index.reset(new FulltextIndex{mResourceInstanceIdentifier, Storage::DataStore::ReadWrite}); | ||
42 | } | ||
43 | index->remove(entity.identifier()); | ||
44 | } | ||
45 | |||
46 | void FulltextIndexer::commitTransaction() | ||
47 | { | ||
48 | if (index) { | ||
49 | index->commitTransaction(); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | void FulltextIndexer::abortTransaction() | ||
54 | { | ||
55 | if (index) { | ||
56 | index->abortTransaction(); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | QMap<QByteArray, int> FulltextIndexer::databases() | ||
61 | { | ||
62 | return {}; | ||
63 | } | ||
64 | |||