Query Fragments: handle config file errors + doc
This commit is contained in:
parent
b2370d953f
commit
7d54e147a0
7 changed files with 160 additions and 6 deletions
|
@ -1603,6 +1603,86 @@ MimeType=*/*
|
|||
|
||||
</sect2>
|
||||
|
||||
<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>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>Here follows an example:
|
||||
<programlisting>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<fragbuts version="1.0">
|
||||
|
||||
<radiobuttons>
|
||||
|
||||
<fragbut>
|
||||
<label>Include Web Results</label>
|
||||
<frag></frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>Exclude Web Results</label>
|
||||
<frag>-rclbes:BGL</frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>Only Web Results</label>
|
||||
<frag>rclbes:BGL</frag>
|
||||
</fragbut>
|
||||
|
||||
</radiobuttons>
|
||||
|
||||
<buttons>
|
||||
|
||||
<fragbut>
|
||||
<label>Year 2010</label>
|
||||
<frag>date:2010-01-01/2010-12-31</frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>My Great Directory Only</label>
|
||||
<frag>dir:/my/great/directory</frag>
|
||||
</fragbut>
|
||||
|
||||
</buttons>
|
||||
</fragbuts>
|
||||
</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>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>This feature is new in &RCL; 1.20, and will probably be
|
||||
refined depending on user feedback.</para>
|
||||
|
||||
</sect2>
|
||||
|
||||
|
||||
<sect2 id="RCL.SEARCH.GUI.COMPLEX">
|
||||
<title>Complex/advanced search</title>
|
||||
|
||||
|
@ -2135,6 +2215,21 @@ MimeType=*/*
|
|||
to the first page. These work even while the focus is in the
|
||||
search entry.</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara><title>Result table: moving the focus to the table</title>
|
||||
<para>You can use <keycap>Ctrl-r</keycap> to move the focus
|
||||
from the search entry to the table, and then use the arrow keys
|
||||
to change the current row. <keycap>Ctrl-Shift-s</keycap> returns to
|
||||
the search.</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara><title>Result table: open / preview</title>
|
||||
<para>With the focus in the result table, you can use
|
||||
<keycap>Ctrl-o</keycap> to open the document from the current
|
||||
row, <keycap>Ctrl-Shift-o</keycap> to open the document and close
|
||||
<command>recoll</command>, <keycap>Ctrl-d</keycap> to preview
|
||||
the document.</para>
|
||||
</formalpara>
|
||||
|
||||
<formalpara><title>Editing a new search while the focus is not
|
||||
in the search entry</title>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QtGui/QCheckBox>
|
||||
#include <QtGui/QRadioButton>
|
||||
#include <QtGui/QButtonGroup>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtXml/QXmlDefaultHandler>
|
||||
|
||||
#include "fragbuts.h"
|
||||
|
@ -113,6 +114,7 @@ bool FragButsParser::endElement(const QString & /* namespaceURI */,
|
|||
QCheckBox *but = new QCheckBox(label, parent);
|
||||
abut = but;
|
||||
}
|
||||
abut->setToolTip(currentText);
|
||||
buttons.push_back(FragButs::ButFrag(abut, frag));
|
||||
hl->addWidget(abut);
|
||||
} else if (qName == "buttons" || qName == "radiobuttons") {
|
||||
|
@ -125,12 +127,15 @@ bool FragButsParser::endElement(const QString & /* namespaceURI */,
|
|||
}
|
||||
|
||||
FragButs::FragButs(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent), m_ok(false)
|
||||
{
|
||||
string conf = path_cat(theconfig->getConfDir(), "fragbuts.xml");
|
||||
|
||||
string data, reason;
|
||||
if (!file_to_string(conf, data, &reason)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("%1 not found.").arg(
|
||||
QString::fromLocal8Bit(conf.c_str())));
|
||||
LOGERR(("Fragbuts:: can't read [%s]\n", conf.c_str()));
|
||||
return;
|
||||
}
|
||||
|
@ -142,6 +147,9 @@ FragButs::FragButs(QWidget* parent)
|
|||
QXmlInputSource xmlInputSource;
|
||||
xmlInputSource.setData(QString::fromUtf8(data.c_str()));
|
||||
if (!reader.parse(xmlInputSource)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("%1 could not be parsed.").arg(
|
||||
QString::fromLocal8Bit(conf.c_str())));
|
||||
LOGERR(("FragButs:: parse failed for [%s]\n", conf.c_str()));
|
||||
return;
|
||||
}
|
||||
|
@ -150,6 +158,8 @@ FragButs::FragButs(QWidget* parent)
|
|||
connect(it->button, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onButtonClicked(bool)));
|
||||
}
|
||||
setWindowTitle(tr("Fragment Buttons"));
|
||||
m_ok = true;
|
||||
}
|
||||
|
||||
FragButs::~FragButs()
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
};
|
||||
|
||||
void getfrags(std::vector<std::string>&);
|
||||
|
||||
bool ok() {return m_ok;}
|
||||
private slots:
|
||||
void onButtonClicked(bool);
|
||||
|
||||
|
@ -57,6 +57,7 @@ private:
|
|||
// Detect source file change
|
||||
time_t m_reftime;
|
||||
std::vector<ButFrag> m_buttons;
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1058,9 +1058,14 @@ void RclMain::showFragButs()
|
|||
{
|
||||
if (fragbuts == 0) {
|
||||
fragbuts = new FragButs(0);
|
||||
fragbuts->show();
|
||||
connect(fragbuts, SIGNAL(fragmentsChanged()),
|
||||
this, SLOT(onFragmentsChanged()));
|
||||
if (fragbuts->ok()) {
|
||||
fragbuts->show();
|
||||
connect(fragbuts, SIGNAL(fragmentsChanged()),
|
||||
this, SLOT(onFragmentsChanged()));
|
||||
} else {
|
||||
delete fragbuts;
|
||||
fragbuts = 0;
|
||||
}
|
||||
} else {
|
||||
// Close and reopen, in hope that makes us visible...
|
||||
fragbuts->close();
|
||||
|
|
|
@ -488,7 +488,7 @@ void ResTable::init()
|
|||
tableView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
new QShortcut(QKeySequence("Ctrl+o"), this, SLOT(menuEdit()));
|
||||
new QShortcut(QKeySequence("Ctrl+Shift+o"), this, SLOT(menuEditAndQuit()));
|
||||
new QShortcut(QKeySequence("Ctrl+p"), this, SLOT(menuPreview()));
|
||||
new QShortcut(QKeySequence("Ctrl+d"), this, SLOT(menuPreview()));
|
||||
connect(tableView, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||
this, SLOT(createPopupMenu(const QPoint&)));
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ ${INSTALL} -m 0644 python/recoll/recoll/rclconfig.py \
|
|||
|
||||
${INSTALL} -m 0444 \
|
||||
desktop/recollindex.desktop \
|
||||
sampleconf/fragbuts.xml \
|
||||
sampleconf/mimeconf \
|
||||
sampleconf/mimeview \
|
||||
sampleconf/recoll.conf \
|
||||
|
|
42
src/sampleconf/fragbuts.xml
Normal file
42
src/sampleconf/fragbuts.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<fragbuts version="1.0">
|
||||
|
||||
<radiobuttons>
|
||||
|
||||
<fragbut>
|
||||
<label>Include Web Results</label>
|
||||
<frag></frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>Exclude Web Results</label>
|
||||
<frag>-rclbes:BGL</frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>Only Web Results</label>
|
||||
<frag>rclbes:BGL</frag>
|
||||
</fragbut>
|
||||
|
||||
</radiobuttons>
|
||||
|
||||
<buttons>
|
||||
|
||||
<fragbut>
|
||||
<label>Year 2010</label>
|
||||
<frag>date:2010-01-01/2010-12-31</frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>c++ files</label>
|
||||
<frag>ext:cpp OR ext:cxx</frag>
|
||||
</fragbut>
|
||||
|
||||
<fragbut>
|
||||
<label>My Great Directory</label>
|
||||
<frag>dir:/my/great/directory</frag>
|
||||
</fragbut>
|
||||
|
||||
</buttons>
|
||||
|
||||
</fragbuts>
|
Loading…
Add table
Add a link
Reference in a new issue