BibleTime
btsearchsyntaxhelpdialog.cpp
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
14 
15 #include <QColor>
16 #include <QDesktopServices>
17 #include <QDialogButtonBox>
18 #include <QFont>
19 #include <QPalette>
20 #include <QTextBrowser>
21 #include <QVBoxLayout>
22 #include "../../util/btconnect.h"
23 #include "../messagedialog.h"
24 
25 
26 class QUrl;
27 
28 namespace Search {
29 
31  : QDialog(parent, wflags)
32 {
33  resize(550, 340);
34 
35  QVBoxLayout *l = new QVBoxLayout;
36 
37  m_textBrowser = new QTextBrowser(this);
38  QFont font = m_textBrowser->font();
39  font.setPointSize(font.pointSize()+2);
40  m_textBrowser->setFont(font);
41  m_textBrowser->setOpenLinks(false);
42  BT_CONNECT(m_textBrowser, &QTextBrowser::anchorClicked,
43  [this](QUrl const & url) {
44  if (url.scheme().isEmpty()) {
45  if (auto fragment = url.fragment(); !fragment.isEmpty())
46  m_textBrowser->scrollToAnchor(std::move(fragment));
47  } else {
48  QDesktopServices::openUrl(url);
49  }
50  });
51  l->addWidget(m_textBrowser);
52 
53  m_buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
54  BT_CONNECT(m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
55  l->addWidget(m_buttons);
56 
57  setLayout(l);
58 
59  retranslateUi();
60 }
61 
63  QString theTitle(tr("Search Syntax Help"));
64  setWindowTitle(theTitle);
65 
66  m_textBrowser->setHtml(
67  QStringLiteral(
68  "<html><head><title>%1</title>"
69  "<style type=\"text/css\">"
70  "body{"
71  "background-color:%2;"
72  "color:%3"
73  "}h3{"
74  "font-weight:bold;"
75  "text-align:center"
76  "}a{"
77  "text-decoration:underline"
78  "}a:link{"
79  "color:%4"
80  "}a:visited{"
81  "color:%5"
82  "}h1 a{"
83  "font-size:medium"
84  "}table{"
85  "margin-left:2em;"
86  "border-collapse:collapse"
87  "}td{"
88  "padding:0.2em 0.3em;"
89  "border:3px solid %6;"
90  "color:%7;"
91  "background-color:%8;"
92  "}ul#links{"
93  "list-style-type:none"
94  "}"
95  "</style></head><body>"
96  "<p>%9</p>"
97  "<p><ul id='links'>"
98  "<li><a href='#allsome'>%10</a></li>"
99  "<li><a href='#grouping'>%11</a></li>"
100  "<li><a href='#wildcards'>%12</a></li>"
101  "<li><a href='#fields'>%13</a></li>"
102  "<li><a href='#lucene'>%14</a></li>"
103  "</ul></p>"
104  "<h1><a name='allsome'>%15</a></h1>"
105  "<p>%16</p>"
106  "<p><table>"
107  "<tr><td><code>%17</code></td><td>%18</td></tr>"
108  "<tr><td><code>%19</code></td><td>%20</td></tr>"
109  "<tr><td><code>%21</code></td><td>%22</td></tr>"
110  "<tr><td><code>%23</code></td><td>%24</td></tr>"
111  "</table></p>"
112  "<h1><a name='grouping'>%25</a></h1>"
113  "<p>%26</p>"
114  "<p><table>"
115  "<tr><td><code>%27</code></td><td>%28</td></tr>"
116  "<tr><td><code>%29</code></td><td>%30</td></tr>"
117  "<tr><td><code>%31</code></td><td>%32</td></tr>"
118  "</table></p>"
119  "<h1><a name='wildcards'>%33</a></h1>"
120  "<p>%34</p>"
121  "<p><table>"
122  "<tr><td><code>%35</code></td><td>%36</td></tr>"
123  "<tr><td><code>%37</code></td><td>%38</td></tr>"
124  "<tr><td><code>%39</code></td><td>%40</td></tr>"
125  "<tr><td><code>%41</code></td><td>%42</td></tr>"
126  "</table></p>"
127  "<h1><a name='fields'>%43</a></h1>"
128  "<p>"
129  "%44<br/>"
130  "<table>"
131  "<tr><td><code>heading:</code></td><td>%45</td></tr>"
132  "<tr><td><code>footnote:</code></td><td>%46</td></tr>"
133  "<tr><td><code>strong:</code></td><td>%47</td></tr>"
134  "<tr><td><code>morph:</code></td><td>%48</td></tr>"
135  "</table>"
136  "</p>"
137  "<p>"
138  "%49<br/>"
139  "<table>"
140  "<tr><td><code>%50</code></td><td>%51</td></tr>"
141  "<tr><td><code>%52</code></td><td>%53</td></tr>"
142  "<tr><td><code>%54</code></td><td>%55</td></tr>"
143  "<tr><td><code>%56</code></td><td>%57</td></tr>"
144  "</table>"
145  "</p>"
146  "<h1><a name='lucene'>%58</a></h1>"
147  "<p>%59</p>"
148  "</body></html>"
149  )
150  .arg(theTitle,
151  palette().color(QPalette::Window).name(),
152  palette().color(QPalette::WindowText).name(),
153  palette().color(QPalette::Link).name(),
154  palette().color(QPalette::LinkVisited).name(),
155  palette().color(QPalette::WindowText).name(),
156  palette().color(QPalette::Text).name(),
157  palette().color(QPalette::Base).name(), // %8
158  tr("This help is mainly for 'Full syntax' option. 'All words' and "
159  "'Some words' options have more limited syntax; "
160  "<a href=\"#%1\">wildcards</a> and <a href=\"#%2\">text "
161  "fields</a> are supported for them. Some other syntax features "
162  "may give strange or wrong results with All words/Some words.")
163  .arg(QStringLiteral("wildcards"), QStringLiteral("fields")),
164  tr("Which words to find"), // %10
165  tr("Grouping and order"),
166  tr("Wildcards (partial words)"),
167  tr("Text fields (different parts of text)"),
168  tr("Other syntax features"),
169  tr("Which words to find"), // %15
170  tr("Search terms are separated by spaces. <code>AND</code> "
171  "(all words), <code>OR</code> (some words) and "
172  "<code>NOT</code> (not the following word) can be added "
173  "between the words. If none is added explicitly "
174  "<code>OR</code> is used automatically. <code>+word</code> "
175  "means the word must be in the results, <code>-word</code> "
176  "means it must not be in the results.",
177  "Do not translate \"AND\", \"OR\" or \"NOT\"."),
178  tr("jesus AND god", "Do not translate \"AND\"."),
179  tr("Finds verses with both 'Jesus' and 'God'"),
180  tr("jesus OR god", "Do not translate \"OR\"."),
181  tr("Finds verses with 'Jesus' or 'God' or both"), // %20
182  tr("jesus NOT god", "Do not translate \"NOT\"."),
183  tr("Finds verses with 'Jesus' but with no 'God'"),
184  tr("+jesus -god"),
185  tr("Finds verses with 'Jesus' but with no 'God'"),
186  tr("Grouping and order"), // %25
187  tr("Words can be grouped with <strong>parenthesis</strong>. Strict"
188  " word order can be defined with <strong>quotes</strong>."),
189  tr("(a AND b) OR c", "Do not translate \"AND\" or \"OR\"."),
190  tr("Finds verses with both 'a' AND 'b', and verses with 'c'"),
191  tr("\"says lord\""),
192  tr("Finds e.g. '...Isaiah says, \"Lord...' but not '...says the "
193  "LORD'"), // %30
194  tr("\"says the lord\""),
195  tr("Finds all verses with 'says the LORD'"),
196  tr("Wildcards (partial words)"),
197  tr("<code>*</code> matches any sequence of 0 or more "
198  "characters, while <code>?</code> matches any single "
199  "character. A wildcard can not be used in the beginning of a "
200  "word."),
201  tr("a*"), // %35
202  tr("All words beginning with 'a'"),
203  tr("a*a"),
204  tr("'Assyria', 'aroma', 'abba' etc."),
205  tr("a?"),
206  tr("'at' and 'an'"), // %40
207  tr("a??a"),
208  tr("'abba', 'area', 'Asia' etc."),
209  tr("Text fields (different parts of text)"),
210  tr("Available text fields:" ),
211  tr("Searches headings"), // %45
212  tr("Searches footnotes"),
213  tr("Searches Strong's numbers"),
214  tr("Searches morphology codes"),
215  tr("Examples:"),
216  tr("heading:Jesus", "Do not translate \"heading:\"."), // %50
217  tr("Finds headings with 'Jesus'"),
218  tr("footnote:Jesus AND footnote:said",
219  "Do not translate \"footnote:\" or \"AND\"."),
220  tr("Finds footnotes with 'Jesus' and 'said'"),
221  tr("strong:G846", "Do not translate \"strong:\"."),
222  tr("Finds verses with Strong's Greek number 846"), // %55
223  tr("morph:\"N-NSF\"", "Do not translate \"morph:\"."),
224  tr("Finds verses with morphology code 'N-NSF'"),
225  tr("Other syntax features"),
226  tr("BibleTime uses the CLucene search engine. You can read more "
227  "on the <a href=\"%1\">lucene syntax web page</a> (in external "
228  "browser).")
229  .arg(QStringLiteral("http://lucene.apache.org/java/1_4_3/"
230  "queryparsersyntax.html"))
231  ));
232 
234 }
235 
236 } // namespace Search
#define BT_CONNECT(...)
Definition: btconnect.h:20
BtSearchSyntaxHelpDialog(QWidget *parent=nullptr, Qt::WindowFlags wflags=Qt::Dialog)
void prepareDialogBox(QDialogButtonBox *box)