Renamed the fragment buttons config file from fragbuts.xml to fragment-buttons.xml

This commit is contained in:
Jean-Francois Dockes 2021-08-30 10:11:22 +02:00
parent aae1f07a9f
commit 275a1210e0
6 changed files with 170 additions and 117 deletions

View File

@ -567,7 +567,7 @@ python/samples/recollgui/rclmain.ui \
python/samples/recollq.py \ python/samples/recollq.py \
python/samples/recollqsd.py \ python/samples/recollqsd.py \
\ \
sampleconf/fields sampleconf/fragbuts.xml sampleconf/mimeconf \ sampleconf/fields sampleconf/fragment-buttons.xml sampleconf/mimeconf \
sampleconf/mimemap sampleconf/mimeview sampleconf/mimeview.mac \ sampleconf/mimemap sampleconf/mimeview sampleconf/mimeview.mac \
sampleconf/recoll.conf sampleconf/recoll.qss \ sampleconf/recoll.conf sampleconf/recoll.qss \
sampleconf/recoll-dark.qss sampleconf/recoll-dark.css \ sampleconf/recoll-dark.qss sampleconf/recoll-dark.css \
@ -656,7 +656,7 @@ desktop/recollindex.desktop \
index/rclmon.sh \ index/rclmon.sh \
index/recollindex@.service \ index/recollindex@.service \
index/recollindex.service \ index/recollindex.service \
sampleconf/fragbuts.xml \ sampleconf/fragment-buttons.xml \
sampleconf/fields \ sampleconf/fields \
sampleconf/recoll.conf \ sampleconf/recoll.conf \
sampleconf/mimeconf \ sampleconf/mimeconf \

View File

@ -428,7 +428,7 @@ alink="#0000FF">
<div class="list-of-tables"> <div class="list-of-tables">
<p><b>List of Tables</b></p> <p><b>List of Tables</b></p>
<dl> <dl>
<dt>3.1. <a href="#idm1478">Keyboard shortcuts</a></dt> <dt>3.1. <a href="#idm1494">Keyboard shortcuts</a></dt>
</dl> </dl>
</div> </div>
<div class="chapter"> <div class="chapter">
@ -3538,75 +3538,109 @@ fs.inotify.max_user_watches=32768
<p>Selecting the <span class="guimenu">Tools</span> <p>Selecting the <span class="guimenu">Tools</span>
<span class="guimenuitem">Query Fragments</span> menu <span class="guimenuitem">Query Fragments</span> menu
entry will open a window with radio- and check-buttons entry will open a window with radio- and check-buttons
which can be used to activate query language fragments which can be used to filter the current query with
for filtering the current query. This can be useful if user-defined query language fragments. This can be useful
you have frequent reusable selectors, for example, if you have frequent reusable selectors, not covered by
filtering on alternate directories, or searching just one the standard category selectors, for example, filtering
category of files, not covered by the standard category on alternate directories, or searching just one category
selectors.</p> of files. In practise, the query fragments are joined to
the current query as an AND clause.</p>
<p>The contents of the window are entirely customizable, <p>The contents of the window are entirely customizable,
and defined by the contents of the <code class= and defined by the contents of a XML text file, named
"filename">fragbuts.xml</code> file inside the <code class="filename">fragment-buttons.xml</code> and
which will be looked for in the current index
configuration directory. The sample file distributed with configuration directory. The sample file distributed with
<span class="application">Recoll</span> (which you should <span class="application">Recoll</span> contains a number
be able to find under <code class= of example filters. This will be automatically copied to
"filename">/usr/share/recoll/examples/fragbuts.xml</code>), the configuration directory if the file does not exist in
contains an example which filters the results from the there (e.g. <code class=
Web history.</p> "filename">~/.recoll/fragment-buttons.xml</code> under
Linux and Mac OS, <code class=
"filename">$HOME/AppData/Local/Recoll</code> for
Windows). Editing the copy will allow you to configure
the tool for your needs .</p>
<div class="note" style=
"margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>The <code class=
"filename">fragment-buttons.xml</code> file was named
<code class="filename">fragbuts.xml</code> up to
<span class="application">Recoll</span> version 1.31.0.
This was deemed too close to offensive for native
English speakers, so that the file was renamed. An
existing <code class="filename">fragbuts.xml</code>
will still be used if <code class=
"filename">fragment-buttons.xml</code> does not exist.
No automatic renaming will be performed.</p>
</div>
<p>Here follows an example:</p> <p>Here follows an example:</p>
<pre class="programlisting"> <pre class="programlisting">
&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;fragbuts version="1.0"&gt; &lt;fragbuttons version="1.0"&gt;
&lt;radiobuttons&gt; &lt;radiobuttons&gt;
&lt;!-- Actually useful: toggle Web queue results inclusion --&gt; &lt;!-- Actually useful: toggle Web queue results inclusion --&gt;
&lt;fragbut&gt; &lt;fragbutton&gt;
&lt;label&gt;Include Web Results&lt;/label&gt; &lt;label&gt;Include Web Results&lt;/label&gt;
&lt;frag&gt;&lt;/frag&gt; &lt;frag&gt;&lt;/frag&gt;
&lt;/fragbut&gt; &lt;/fragbutton&gt;
&lt;fragbut&gt; &lt;fragbutton&gt;
&lt;label&gt;Exclude Web Results&lt;/label&gt; &lt;label&gt;Exclude Web Results&lt;/label&gt;
&lt;frag&gt;-rclbes:BGL&lt;/frag&gt; &lt;frag&gt;-rclbes:BGL&lt;/frag&gt;
&lt;/fragbut&gt; &lt;/fragbutton&gt;
&lt;fragbut&gt; &lt;fragbutton&gt;
&lt;label&gt;Only Web Results&lt;/label&gt; &lt;label&gt;Only Web Results&lt;/label&gt;
&lt;frag&gt;rclbes:BGL&lt;/frag&gt; &lt;frag&gt;rclbes:BGL&lt;/frag&gt;
&lt;/fragbut&gt; &lt;/fragbutton&gt;
&lt;/radiobuttons&gt; &lt;/radiobuttons&gt;
&lt;buttons&gt; &lt;buttons&gt;
&lt;fragbut&gt; &lt;fragbutton&gt;
&lt;label&gt;Example: Year 2010&lt;/label&gt; &lt;label&gt;Example: Year 2010&lt;/label&gt;
&lt;frag&gt;date:2010-01-01/2010-12-31&lt;/frag&gt; &lt;frag&gt;date:2010-01-01/2010-12-31&lt;/frag&gt;
&lt;/fragbut&gt; &lt;/fragbutton&gt;
&lt;fragbut&gt; &lt;fragbutton&gt;
&lt;label&gt;Example: c++ files&lt;/label&gt; &lt;label&gt;Example: c++ files&lt;/label&gt;
&lt;frag&gt;ext:cpp OR ext:cxx&lt;/frag&gt; &lt;frag&gt;ext:cpp OR ext:cxx&lt;/frag&gt;
&lt;/fragbut&gt; &lt;/fragbutton&gt;
&lt;fragbut&gt; &lt;fragbutton&gt;
&lt;label&gt;Example: My Great Directory&lt;/label&gt; &lt;label&gt;Example: My Great Directory&lt;/label&gt;
&lt;frag&gt;dir:/my/great/directory&lt;/frag&gt; &lt;frag&gt;dir:/my/great/directory&lt;/frag&gt;
&lt;/fragbut&gt; &lt;/fragbutton&gt;
&lt;/buttons&gt; &lt;/buttons&gt;
&lt;/fragbuts&gt; &lt;/fragbuttons&gt;
</pre> </pre>
<p>Each <code class="literal">radiobuttons</code> or <p>Each <code class="literal">radiobuttons</code> or
<code class="literal">buttons</code> section defines a <code class="literal">buttons</code> section defines a
line of checkbuttons or radiobuttons inside the window. line of checkbuttons or radiobuttons inside the window.
Any number of buttons can be selected, but the Any number of <code class="literal">buttons</code> can be
radiobuttons in a line are exclusive.</p> selected, but the <code class=
<p>Each <code class="literal">fragbut</code> section "literal">radiobuttons</code> in a line are
exclusive.</p>
<p>Each <code class="literal">fragbutton</code> section
defines the label for a button, and the Query Language defines the label for a button, and the Query Language
fragment which will be added (as an AND filter) before fragment which will be added (as an AND filter) before
performing the query if the button is active.</p> performing the query if the button is active.</p>
<p>The only thing that you need to know about XML for
editing this file is that any opening tag like <em class=
"replaceable"><code>&lt;label&gt;</code></em> needs to be
matched by a closing tag after the value: <em class=
"replaceable"><code>&lt;/label&gt;</code></em>.</p>
<p>You will normally edit the file with a regular text
editor, like, e.g. <span class=
"command"><strong>vi</strong></span> or <span class=
"command"><strong>notepad</strong></span>.
Double-clicking the file in a file manager may not work,
because this usually opens it in a WEB browser, which
will not let you modify the contents.</p>
</div> </div>
<div class="sect2"> <div class="sect2">
<div class="titlepage"> <div class="titlepage">
@ -4083,7 +4117,7 @@ fs.inotify.max_user_watches=32768
<span class="guilabel">Shortcut</span> column, and type <span class="guilabel">Shortcut</span> column, and type
the desired sequence.</p> the desired sequence.</p>
<div class="table"> <div class="table">
<a name="idm1478" id="idm1478"></a> <a name="idm1494" id="idm1494"></a>
<p class="title"><b>Table&nbsp;3.1.&nbsp;Keyboard <p class="title"><b>Table&nbsp;3.1.&nbsp;Keyboard
shortcuts</b></p> shortcuts</b></p>
<div class="table-contents"> <div class="table-contents">
@ -4214,14 +4248,20 @@ fs.inotify.max_user_watches=32768
<td align="left">Ctrl+G</td> <td align="left">Ctrl+G</td>
</tr> </tr>
<tr> <tr>
<td align="left">Open the current document and <td align="left">Copy the text contained in the
exit Recoll</td> selected document to the clipboard, then exit
<td align="left">Ctrl+Shift+O</td> recoll</td>
<td align="left">Ctrl+Alt+Shift+G</td>
</tr> </tr>
<tr> <tr>
<td align="left">Open the current document</td> <td align="left">Open the current document</td>
<td align="left">Ctrl+O</td> <td align="left">Ctrl+O</td>
</tr> </tr>
<tr>
<td align="left">Open the current document and
exit Recoll</td>
<td align="left">Ctrl+Alst+Shift+O</td>
</tr>
<tr> <tr>
<td align="left">Show a full preview for the <td align="left">Show a full preview for the
current document</td> current document</td>

View File

@ -2507,82 +2507,96 @@ fs.inotify.max_user_watches=32768
<sect2 id="RCL.SEARCH.GUI.FRAGBUTS"> <sect2 id="RCL.SEARCH.GUI.FRAGBUTS">
<title>The Query Fragments window</title> <title>The Query Fragments window</title>
<para>Selecting the <menuchoice><guimenu>Tools</guimenu> <para>Selecting the <menuchoice><guimenu>Tools</guimenu> <guimenuitem>Query
<guimenuitem>Query Fragments</guimenuitem></menuchoice> menu Fragments</guimenuitem></menuchoice> menu entry will open a window with radio- and
entry will open a window with radio- and check-buttons which check-buttons which can be used to filter the current query with user-defined query language
can be used to activate query language fragments for fragments. This can be useful if you have frequent reusable selectors, not covered by the
filtering the current query. This can be useful if you have standard category selectors, for example, filtering on alternate directories, or searching
frequent reusable selectors, for example, filtering on just one category of files. In practise, the query fragments are joined to the current
alternate directories, or searching just one category of query as an AND clause.</para>
files, not covered by the standard category
selectors.</para>
<para>The contents of the window are entirely customizable, and <para>The contents of the window are entirely customizable, and defined by the contents of a
defined by the contents of the <filename>fragbuts.xml</filename> XML text file, named <filename>fragment-buttons.xml</filename> and which will be looked
file inside the configuration directory. The sample file for in the current index configuration directory. The sample file distributed with &RCL;
distributed with &RCL; (which you should be able to find under contains a number of example filters. This will be automatically copied to the
<filename>/usr/share/recoll/examples/fragbuts.xml</filename>), configuration directory if the file does not exist in there
contains an example which filters the results from the Web (e.g. <filename>~/.recoll/fragment-buttons.xml</filename> under Linux and Mac
history.</para> OS, <filename>$HOME/AppData/Local/Recoll</filename> for Windows). Editing the copy will
allow you to configure the tool for your needs .</para>
<note><para>
The <filename>fragment-buttons.xml</filename> file was
named <filename>fragbuts.xml</filename> up to &RCL; version 1.31.0. This was deemed too
close to offensive for native English speakers, so that the file was renamed. An
existing <filename>fragbuts.xml</filename> will still be used
if <filename>fragment-buttons.xml</filename> does not exist. No automatic renaming will be
performed.</para>
</note>
<para>Here follows an example: <para>Here follows an example:
<programlisting><![CDATA[ <programlisting><![CDATA[
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<fragbuts version="1.0"> <fragbuttons version="1.0">
<radiobuttons> <radiobuttons>
<!-- Actually useful: toggle Web queue results inclusion --> <!-- Actually useful: toggle Web queue results inclusion -->
<fragbut> <fragbutton>
<label>Include Web Results</label> <label>Include Web Results</label>
<frag></frag> <frag></frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Exclude Web Results</label> <label>Exclude Web Results</label>
<frag>-rclbes:BGL</frag> <frag>-rclbes:BGL</frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Only Web Results</label> <label>Only Web Results</label>
<frag>rclbes:BGL</frag> <frag>rclbes:BGL</frag>
</fragbut> </fragbutton>
</radiobuttons> </radiobuttons>
<buttons> <buttons>
<fragbut> <fragbutton>
<label>Example: Year 2010</label> <label>Example: Year 2010</label>
<frag>date:2010-01-01/2010-12-31</frag> <frag>date:2010-01-01/2010-12-31</frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Example: c++ files</label> <label>Example: c++ files</label>
<frag>ext:cpp OR ext:cxx</frag> <frag>ext:cpp OR ext:cxx</frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Example: My Great Directory</label> <label>Example: My Great Directory</label>
<frag>dir:/my/great/directory</frag> <frag>dir:/my/great/directory</frag>
</fragbut> </fragbutton>
</buttons> </buttons>
</fragbuts> </fragbuttons>
]]></programlisting> ]]></programlisting>
</para> </para>
<para>Each <literal>radiobuttons</literal> or <para>Each <literal>radiobuttons</literal> or <literal>buttons</literal> section defines a
<literal>buttons</literal> section defines a line of line of checkbuttons or radiobuttons inside the window. Any number
checkbuttons or radiobuttons inside the window. Any number of of <literal>buttons</literal> can be selected, but the <literal>radiobuttons</literal> in a
buttons can be selected, but the radiobuttons in a line are line are exclusive.</para>
exclusive.</para>
<para>Each <literal>fragbut</literal> section defines the label <para>Each <literal>fragbutton</literal> section defines the label
for a button, and the Query Language fragment which will be for a button, and the Query Language fragment which will be added (as an AND filter)
added (as an AND filter) before performing the query if the before performing the query if the button is active.</para>
button is active.</para>
<para>The only thing that you need to know about XML for editing this file is that any
opening tag like <replaceable>&lt;label&gt;</replaceable> needs to be matched by a closing
tag after the value: <replaceable>&lt;/label&gt;</replaceable>.</para>
<para>You will normally edit the file with a regular text editor, like,
e.g. <command>vi</command> or <command>notepad</command>. Double-clicking the file in a
file manager may not work, because this usually opens it in a WEB browser, which will not
let you modify the contents.</para>
</sect2> </sect2>

View File

@ -59,8 +59,8 @@ public:
radio = true; radio = true;
bg = new QButtonGroup(parent); bg = new QButtonGroup(parent);
hl = new QHBoxLayout(); hl = new QHBoxLayout();
} else if (nm == "label" || nm == "frag" || nm == "fragbuts" || } else if (nm == "label" || nm == "frag" || nm == "fragbuts" || nm == "fragbuttons" ||
nm == "fragbut") { nm == "fragbut" || nm == "fragbutton") {
} else { } else {
QMessageBox::warning( QMessageBox::warning(
0, "Recoll", QString("Bad element name: [%1]").arg(nm.c_str())); 0, "Recoll", QString("Bad element name: [%1]").arg(nm.c_str()));
@ -73,7 +73,7 @@ public:
label = u8s2qs(currentText); label = u8s2qs(currentText);
} else if (nm == "frag") { } else if (nm == "frag") {
frag = currentText; frag = currentText;
} else if (nm == "fragbut") { } else if (nm == "fragbut" || nm == "fragbutton") {
string slab = qs2utf8s(label); string slab = qs2utf8s(label);
trimstring(slab, " \t\n\t"); trimstring(slab, " \t\n\t");
label = u8s2qs(slab.c_str()); label = u8s2qs(slab.c_str());
@ -94,7 +94,7 @@ public:
} else if (nm == "buttons" || nm == "radiobuttons") { } else if (nm == "buttons" || nm == "radiobuttons") {
vl->addLayout(hl); vl->addLayout(hl);
hl = 0; hl = 0;
} else if (nm == "fragbuts") { } else if (nm == "fragbuts" || nm == "fragbuttons") {
vlw->addLayout(vl); vlw->addLayout(vl);
} else { } else {
QMessageBox::warning( QMessageBox::warning(
@ -125,32 +125,32 @@ private:
FragButs::FragButs(QWidget* parent) FragButs::FragButs(QWidget* parent)
: QWidget(parent), m_reftime(0), m_ok(false) : QWidget(parent), m_reftime(0), m_ok(false)
{ {
m_fn = path_cat(theconfig->getConfDir(), "fragbuts.xml"); m_fn = path_cat(theconfig->getConfDir(), "fragment-buttons.xml");
string data, reason; string data, reason;
if (!path_exists(m_fn)) { if (!path_exists(m_fn)) {
// config does not exist: try to create it from sample // Try the older name
string src = path_cat(theconfig->getDatadir(), "examples"); m_fn = path_cat(theconfig->getConfDir(), "fragbuts.xml");
src = path_cat(src, "fragbuts.xml"); if (!path_exists(m_fn)) {
copyfile(src.c_str(), m_fn.c_str(), reason); // No configuration file yet: create it from the sample file
string src = path_cat(theconfig->getDatadir(), "examples");
src = path_cat(src, "fragment-buttons.xml");
m_fn = path_cat(theconfig->getConfDir(), "fragment-buttons.xml");
copyfile(src.c_str(), m_fn.c_str(), reason);
}
} }
if (!file_to_string(m_fn, data, &reason)) { if (!file_to_string(m_fn, data, &reason)) {
QMessageBox::warning( QMessageBox::warning(0, "Recoll", tr("%1 not found.").arg(path2qs(m_fn)));
0, "Recoll", tr("%1 not found.").arg(path2qs(m_fn)));
LOGERR("Fragbuts:: can't read [" << m_fn << "]\n"); LOGERR("Fragbuts:: can't read [" << m_fn << "]\n");
return; return;
} }
FragButsParser parser(data, this, m_buttons); FragButsParser parser(data, this, m_buttons);
if (!parser.Parse()) { if (!parser.Parse()) {
QMessageBox::warning( QMessageBox::warning(0, "Recoll", tr("%1:\n %2").arg(path2qs(m_fn))
0, "Recoll", tr("%1:\n %2").arg(path2qs(m_fn)) .arg(u8s2qs(parser.getReason())));
.arg(u8s2qs(parser.getReason())));
return; return;
} }
for (vector<ButFrag>::iterator it = m_buttons.begin(); for (auto& entry : m_buttons) {
it != m_buttons.end(); it++) { connect(entry.button, SIGNAL(clicked(bool)), this, SLOT(onButtonClicked(bool)));
connect(it->button, SIGNAL(clicked(bool)),
this, SLOT(onButtonClicked(bool)));
} }
setWindowTitle(tr("Query Fragments")); setWindowTitle(tr("Query Fragments"));
isStale(&m_reftime); isStale(&m_reftime);
@ -179,11 +179,10 @@ void FragButs::onButtonClicked(bool on)
void FragButs::getfrags(std::vector<std::string>& frags) void FragButs::getfrags(std::vector<std::string>& frags)
{ {
for (vector<ButFrag>::iterator it = m_buttons.begin(); for (auto &entry : m_buttons) {
it != m_buttons.end(); it++) { if (entry.button->isChecked() && !entry.fragment.empty()) {
if (it->button->isChecked() && !it->fragment.empty()) { LOGDEB("FragButs: fragment [" << entry.fragment << "]\n" );
LOGDEB("FragButs: fragment [" << (it->fragment) << "]\n" ); frags.push_back(entry.fragment);
frags.push_back(it->fragment);
} }
} }
} }

View File

@ -5,53 +5,53 @@
before execution. before execution.
--> -->
<fragbuts version="1.0"> <fragbuttons version="1.0">
<radiobuttons> <radiobuttons>
<!-- Actually useful: toggle WEB queue results inclusion --> <!-- Actually useful: toggle WEB queue results inclusion -->
<fragbut> <fragbutton>
<label>Include Web Results</label> <label>Include Web Results</label>
<frag></frag> <frag></frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Exclude Web Results</label> <label>Exclude Web Results</label>
<frag>-rclbes:BGL</frag> <frag>-rclbes:BGL</frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Only Web Results</label> <label>Only Web Results</label>
<frag>rclbes:BGL</frag> <frag>rclbes:BGL</frag>
</fragbut> </fragbutton>
</radiobuttons> </radiobuttons>
<buttons> <buttons>
<fragbut> <fragbutton>
<label>Example: Year 2010</label> <label>Example: Year 2010</label>
<frag>date:2010-01-01/2010-12-31</frag> <frag>date:2010-01-01/2010-12-31</frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Example: c++ files</label> <label>Example: c++ files</label>
<frag>ext:cpp OR ext:cxx</frag> <frag>ext:cpp OR ext:cxx</frag>
</fragbut> </fragbutton>
<fragbut> <fragbutton>
<label>Example: My Great Directory</label> <label>Example: My Great Directory</label>
<frag>dir:/my/great/directory</frag> <frag>dir:/my/great/directory</frag>
</fragbut> </fragbutton>
</buttons> </buttons>
<buttons> <buttons>
<fragbut> <fragbutton>
<label>Check the manual (Query Fragments Window section) for explanations</label> <label>Check the manual (Query Fragments Window section) for explanations</label>
<frag></frag> <frag></frag>
</fragbut> </fragbutton>
</buttons> </buttons>
</fragbuts> </fragbuttons>

View File

@ -171,7 +171,7 @@ copyrecoll()
mkdir -p $DESTDIR/Share/doc/webhelp mkdir -p $DESTDIR/Share/doc/webhelp
rsync -av $RCL/doc/user/webhelp/docs/* $DESTDIR/Share/doc/webhelp || exit 1 rsync -av $RCL/doc/user/webhelp/docs/* $DESTDIR/Share/doc/webhelp || exit 1
chkcp $RCL/sampleconf/fields $DESTDIR/Share/examples chkcp $RCL/sampleconf/fields $DESTDIR/Share/examples
chkcp $RCL/sampleconf/fragbuts.xml $DESTDIR/Share/examples chkcp $RCL/sampleconf/fragment-buttons.xml $DESTDIR/Share/examples
chkcp $RCL/windows/mimeconf $DESTDIR/Share/examples chkcp $RCL/windows/mimeconf $DESTDIR/Share/examples
chkcp $RCL/sampleconf/mimemap $DESTDIR/Share/examples chkcp $RCL/sampleconf/mimemap $DESTDIR/Share/examples
chkcp $RCL/windows/mimeview $DESTDIR/Share/examples chkcp $RCL/windows/mimeview $DESTDIR/Share/examples