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/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/recoll.conf sampleconf/recoll.qss \
sampleconf/recoll-dark.qss sampleconf/recoll-dark.css \
@ -656,7 +656,7 @@ desktop/recollindex.desktop \
index/rclmon.sh \
index/recollindex@.service \
index/recollindex.service \
sampleconf/fragbuts.xml \
sampleconf/fragment-buttons.xml \
sampleconf/fields \
sampleconf/recoll.conf \
sampleconf/mimeconf \

View File

@ -428,7 +428,7 @@ alink="#0000FF">
<div class="list-of-tables">
<p><b>List of Tables</b></p>
<dl>
<dt>3.1. <a href="#idm1478">Keyboard shortcuts</a></dt>
<dt>3.1. <a href="#idm1494">Keyboard shortcuts</a></dt>
</dl>
</div>
<div class="chapter">
@ -3538,75 +3538,109 @@ fs.inotify.max_user_watches=32768
<p>Selecting the <span class="guimenu">Tools</span>
<span class="guimenuitem">Query Fragments</span> menu
entry will open a window with radio- and check-buttons
which can be used to activate query language fragments
for filtering the current query. This can be useful if
you have frequent reusable selectors, for example,
filtering on alternate directories, or searching just one
category of files, not covered by the standard category
selectors.</p>
which can be used to filter the current query with
user-defined query language fragments. This can be useful
if you have frequent reusable selectors, not covered by
the standard category selectors, for example, filtering
on alternate directories, or searching just one category
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,
and defined by the contents of the <code class=
"filename">fragbuts.xml</code> file inside the
and defined by the contents of a XML text file, named
<code class="filename">fragment-buttons.xml</code> and
which will be looked for in the current index
configuration directory. The sample file distributed with
<span class="application">Recoll</span> (which you should
be able to find under <code class=
"filename">/usr/share/recoll/examples/fragbuts.xml</code>),
contains an example which filters the results from the
Web history.</p>
<span class="application">Recoll</span> contains a number
of example filters. This will be automatically copied to
the configuration directory if the file does not exist in
there (e.g. <code class=
"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>
<pre class="programlisting">
&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;!-- Actually useful: toggle Web queue results inclusion --&gt;
&lt;fragbut&gt;
&lt;fragbutton&gt;
&lt;label&gt;Include Web Results&lt;/label&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;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;frag&gt;rclbes:BGL&lt;/frag&gt;
&lt;/fragbut&gt;
&lt;/fragbutton&gt;
&lt;/radiobuttons&gt;
&lt;buttons&gt;
&lt;fragbut&gt;
&lt;fragbutton&gt;
&lt;label&gt;Example: Year 2010&lt;/label&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;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;frag&gt;dir:/my/great/directory&lt;/frag&gt;
&lt;/fragbut&gt;
&lt;/fragbutton&gt;
&lt;/buttons&gt;
&lt;/fragbuts&gt;
&lt;/fragbuttons&gt;
</pre>
<p>Each <code class="literal">radiobuttons</code> or
<code class="literal">buttons</code> section defines a
line of checkbuttons or radiobuttons inside the window.
Any number of buttons can be selected, but the
radiobuttons in a line are exclusive.</p>
<p>Each <code class="literal">fragbut</code> section
Any number of <code class="literal">buttons</code> can be
selected, but the <code class=
"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
fragment which will be added (as an AND filter) before
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 class="sect2">
<div class="titlepage">
@ -4083,7 +4117,7 @@ fs.inotify.max_user_watches=32768
<span class="guilabel">Shortcut</span> column, and type
the desired sequence.</p>
<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
shortcuts</b></p>
<div class="table-contents">
@ -4214,14 +4248,20 @@ fs.inotify.max_user_watches=32768
<td align="left">Ctrl+G</td>
</tr>
<tr>
<td align="left">Open the current document and
exit Recoll</td>
<td align="left">Ctrl+Shift+O</td>
<td align="left">Copy the text contained in the
selected document to the clipboard, then exit
recoll</td>
<td align="left">Ctrl+Alt+Shift+G</td>
</tr>
<tr>
<td align="left">Open the current document</td>
<td align="left">Ctrl+O</td>
</tr>
<tr>
<td align="left">Open the current document and
exit Recoll</td>
<td align="left">Ctrl+Alst+Shift+O</td>
</tr>
<tr>
<td align="left">Show a full preview for the
current document</td>

View File

@ -2507,82 +2507,96 @@ fs.inotify.max_user_watches=32768
<sect2 id="RCL.SEARCH.GUI.FRAGBUTS">
<title>The Query Fragments window</title>
<para>Selecting the <menuchoice><guimenu>Tools</guimenu>
<guimenuitem>Query Fragments</guimenuitem></menuchoice> menu
entry will open a window with radio- and check-buttons which
can be used to activate query language fragments for
filtering the current query. This can be useful if you have
frequent reusable selectors, for example, filtering on
alternate directories, or searching just one category of
files, not covered by the standard category
selectors.</para>
<para>Selecting the <menuchoice><guimenu>Tools</guimenu> <guimenuitem>Query
Fragments</guimenuitem></menuchoice> menu entry will open a window with radio- and
check-buttons which can be used to filter the current query with user-defined query language
fragments. This can be useful if you have frequent reusable selectors, not covered by the
standard category selectors, for example, filtering on alternate directories, or searching
just one category of files. In practise, the query fragments are joined to the current
query as an AND clause.</para>
<para>The contents of the window are entirely customizable, and
defined by the contents of the <filename>fragbuts.xml</filename>
file inside the configuration directory. The sample file
distributed with &RCL; (which you should be able to find under
<filename>/usr/share/recoll/examples/fragbuts.xml</filename>),
contains an example which filters the results from the Web
history.</para>
<para>The contents of the window are entirely customizable, and defined by the contents of a
XML text file, named <filename>fragment-buttons.xml</filename> and which will be looked
for in the current index configuration directory. The sample file distributed with &RCL;
contains a number of example filters. This will be automatically copied to the
configuration directory if the file does not exist in there
(e.g. <filename>~/.recoll/fragment-buttons.xml</filename> under Linux and Mac
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:
<programlisting><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<fragbuts version="1.0">
<fragbuttons version="1.0">
<radiobuttons>
<!-- Actually useful: toggle Web queue results inclusion -->
<fragbut>
<fragbutton>
<label>Include Web Results</label>
<frag></frag>
</fragbut>
</fragbutton>
<fragbut>
<fragbutton>
<label>Exclude Web Results</label>
<frag>-rclbes:BGL</frag>
</fragbut>
</fragbutton>
<fragbut>
<fragbutton>
<label>Only Web Results</label>
<frag>rclbes:BGL</frag>
</fragbut>
</fragbutton>
</radiobuttons>
<buttons>
<fragbut>
<fragbutton>
<label>Example: Year 2010</label>
<frag>date:2010-01-01/2010-12-31</frag>
</fragbut>
</fragbutton>
<fragbut>
<fragbutton>
<label>Example: c++ files</label>
<frag>ext:cpp OR ext:cxx</frag>
</fragbut>
</fragbutton>
<fragbut>
<fragbutton>
<label>Example: My Great Directory</label>
<frag>dir:/my/great/directory</frag>
</fragbut>
</fragbutton>
</buttons>
</fragbuts>
</fragbuttons>
]]></programlisting>
</para>
<para>Each <literal>radiobuttons</literal> or
<literal>buttons</literal> section defines a line of
checkbuttons or radiobuttons inside the window. Any number of
buttons can be selected, but the radiobuttons in a line are
exclusive.</para>
<para>Each <literal>radiobuttons</literal> or <literal>buttons</literal> section defines a
line of checkbuttons or radiobuttons inside the window. Any number
of <literal>buttons</literal> can be selected, but the <literal>radiobuttons</literal> in a
line are exclusive.</para>
<para>Each <literal>fragbut</literal> section defines the label
for a button, and the Query Language fragment which will be
added (as an AND filter) before performing the query if the
button is active.</para>
<para>Each <literal>fragbutton</literal> section defines the label
for a button, and the Query Language fragment which will be added (as an AND filter)
before performing the query if the 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>

View File

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

View File

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

View File

@ -171,7 +171,7 @@ copyrecoll()
mkdir -p $DESTDIR/Share/doc/webhelp
rsync -av $RCL/doc/user/webhelp/docs/* $DESTDIR/Share/doc/webhelp || exit 1
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/sampleconf/mimemap $DESTDIR/Share/examples
chkcp $RCL/windows/mimeview $DESTDIR/Share/examples