MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / indexNote

Method indexNote

utilities/noteindexer.cpp:45–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44
45void NoteIndexer::indexNote(qint32 lid) {
46 NoteTable ntable(db);
47 Note n;
48 ntable.get(n, lid,false,false);
49
50 if (n.title.isSet()) {
51 QLOG_DEBUG() << "Indexing note: " << n.title;
52 }
53
54 QString content = "";
55 if (n.content.isSet())
56 content = n.content;
57
58
59 // Start looking through the note
60 qint32 startPos =content.indexOf(QChar('<'));
61 qint32 endPos = content.indexOf(QChar('>'),startPos)+1;
62 content.remove(startPos,endPos-startPos);
63
64 // Remove encrypted text
65 while (content.contains("<en-crypt")) {
66 startPos = content.indexOf("<en-crypt");
67 endPos = content.indexOf("</en-crypt>") + 11;
68 content = content.mid(0,startPos)+content.mid(endPos);
69 }
70
71 // Remove any XML tags
72 while (content.contains(QChar('<'))) {
73 startPos = content.indexOf(QChar('<'));
74 endPos = content.indexOf(QChar('>'),startPos)+1;
75 content.remove(startPos,endPos-startPos);
76 };
77
78 // Get the content as an HTML doc.
79 QTextDocument textDocument;
80 textDocument.setHtml(content);
81 QString title = "";
82 if (n.title.isSet())
83 title = n.title;
84 content = textDocument.toPlainText() + " " + title;
85 this->addTextIndex(lid, content);
86}
87
88
89void NoteIndexer::addTextIndex(int lid, QString content) {

Callers

nothing calls this directly

Calls 5

addTextIndexMethod · 0.95
removeMethod · 0.80
getMethod · 0.45
isSetMethod · 0.45
setHtmlMethod · 0.45

Tested by

no test coverage detected