GUI: enable synonyms in preferences and query

This commit is contained in:
Jean-Francois Dockes 2015-11-21 12:52:21 +01:00
parent 183c6d312c
commit a724c76967
8 changed files with 124 additions and 3 deletions

View File

@ -202,6 +202,10 @@ void rwSettings(bool writing)
SETTING_RW(prefs.autoSuffsEnable,
"/Recoll/prefs/query/autoSuffsEnable", Bool, false);
SETTING_RW(prefs.synFileEnable,
"/Recoll/prefs/query/synFileEnable", Bool, false);
SETTING_RW(prefs.synFile, "/Recoll/prefs/query/synfile", String, "");
SETTING_RW(prefs.termMatchType, "/Recoll/prefs/query/termMatchType",
Int, 0);
// This is not really the current program version, just a value to

View File

@ -115,6 +115,9 @@ class PrefsPack {
// language entry.
QString autoSuffs;
bool autoSuffsEnable;
// Synonyms file
QString synFile;
bool synFileEnable;
QStringList restableFields;
vector<int> restableColWidths;

View File

@ -109,6 +109,8 @@
<addaction name="queryPrefsAction"/>
<addaction name="extIdxAction"/>
<addaction name="separator"/>
<addaction name="enbSynAction"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="helpMenu">
<property name="title">
@ -346,7 +348,7 @@
</action>
<action name="indexScheduleAction">
<property name="text">
<string>&amp;Indexing schedule</string>
<string>Indexing &amp;schedule</string>
</property>
<property name="name" stdset="0">
<cstring>indexScheduleAction</cstring>
@ -371,6 +373,20 @@
<cstring>extIdxAction</cstring>
</property>
</action>
<action name="enbSynAction">
<property name="text">
<string>Enable synonyms</string>
</property>
<property name="iconText">
<string>Enable synonyms</string>
</property>
<property name="name" stdset="0">
<cstring>enbSynAction</cstring>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</action>
<action name="toggleFullScreenAction">
<property name="text">
<string>&amp;Full Screen</string>

View File

@ -153,6 +153,9 @@ void RclMain::init()
// Set the focus to the search terms entry:
sSearch->queryText->setFocus();
enbSynAction->setDisabled(prefs.synFile.isEmpty());
enbSynAction->setChecked(prefs.synFileEnable);
// Stemming language menu
g_stringNoStem = tr("(no stemming)");
g_stringAllStem = tr("(all languages)");
@ -341,6 +344,8 @@ void RclMain::init()
this, SLOT(showUIPrefs()));
connect(extIdxAction, SIGNAL(triggered()),
this, SLOT(showExtIdxDialog()));
connect(enbSynAction, SIGNAL(toggled(bool)),
this, SLOT(setSynEnabled(bool)));
connect(toggleFullScreenAction, SIGNAL(triggered()),
this, SLOT(toggleFullScreen()));
@ -459,6 +464,13 @@ void RclMain::init()
periodictimer->start(1000);
}
void RclMain::setSynEnabled(bool on)
{
prefs.synFileEnable = on;
if (uiprefs)
uiprefs->synFileCB->setChecked(prefs.synFileEnable);
}
void RclMain::resultCount(int n)
{
actionSortByDateAsc->setEnabled(n>0);
@ -679,6 +691,17 @@ void RclMain::startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple)
return;
}
if (prefs.synFileEnable && !prefs.synFile.isEmpty()) {
string sf = (const char *)prefs.synFile.toLocal8Bit();
if (!rcldb->setSynGroupsFile(sf)) {
QMessageBox::warning(0, "Recoll",
tr("Can't set synonyms file (parse error?)"));
return;
}
} else {
rcldb->setSynGroupsFile("");
}
Rcl::Query *query = new Rcl::Query(rcldb);
query->setCollapseDuplicates(prefs.collapseDuplicates);
@ -1014,6 +1037,8 @@ void RclMain::setUIPrefs()
LOGDEB(("Recollmain::setUIPrefs\n"));
reslist->setFont();
sSearch->setPrefs();
enbSynAction->setDisabled(prefs.synFile.isEmpty());
enbSynAction->setChecked(prefs.synFileEnable);
}
void RclMain::enableNextPage(bool yesno)

View File

@ -130,6 +130,7 @@ public slots:
virtual void startManual(const string&);
virtual void showDocHistory();
virtual void showExtIdxDialog();
virtual void setSynEnabled(bool);
virtual void showUIPrefs();
virtual void showIndexConfig();
virtual void execIndexConfig();

View File

@ -778,6 +778,56 @@ May be slow for big documents.</string>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line3">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="textLabelSG">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Synonyms file</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="synFileCB">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="synFilePB">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer2">
<property name="orientation">

View File

@ -45,7 +45,6 @@
#include "recoll.h"
#include "guiutils.h"
#include "rcldb.h"
#include "rclconfig.h"
#include "pathut.h"
#include "uiprefs_w.h"
@ -73,6 +72,7 @@ void UIPrefsDialog::init()
connect(stylesheetPB, SIGNAL(clicked()),this, SLOT(showStylesheetDialog()));
connect(resetSSPB, SIGNAL(clicked()), this, SLOT(resetStylesheet()));
connect(snipCssPB, SIGNAL(clicked()),this, SLOT(showSnipCssDialog()));
connect(synFilePB, SIGNAL(clicked()),this, SLOT(showSynFileDialog()));
connect(resetSnipCssPB, SIGNAL(clicked()), this, SLOT(resetSnipCss()));
connect(idxLV, SIGNAL(itemSelectionChanged()),
@ -214,6 +214,15 @@ void UIPrefsDialog::setFromPrefs()
autoSuffsCB->setChecked(prefs.autoSuffsEnable);
autoSuffsLE->setText(prefs.autoSuffs);
synFileCB->setChecked(prefs.synFileEnable);
synFile = prefs.synFile;
if (synFile.isEmpty()) {
synFilePB->setText(tr("Choose"));
} else {
string nm = path_getsimple((const char *)synFile.toLocal8Bit());
synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
}
// Initialize the extra indexes listboxes
idxLV->clear();
for (list<string>::iterator it = prefs.allExtraDbs.begin();
@ -326,10 +335,12 @@ void UIPrefsDialog::accept()
prefs.syntAbsLen = syntlenSB->value();
prefs.syntAbsCtx = syntctxSB->value();
prefs.autoSuffsEnable = autoSuffsCB->isChecked();
prefs.autoSuffs = autoSuffsLE->text();
prefs.synFileEnable = synFileCB->isChecked();
prefs.synFile = synFile;
prefs.allExtraDbs.clear();
prefs.activeExtraDbs.clear();
for (int i = 0; i < idxLV->count(); i++) {
@ -441,6 +452,15 @@ void UIPrefsDialog::resetSnipCss()
snipCssPB->setText(tr("Choose"));
}
void UIPrefsDialog::showSynFileDialog()
{
synFile = myGetFileName(false, "Select synonyms file", true);
if (synFile.isEmpty())
return;
string nm = path_getsimple((const char *)synFile.toLocal8Bit());
synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
}
void UIPrefsDialog::resetReslistFont()
{
reslistFontFamily = "";

View File

@ -42,6 +42,7 @@ public:
int reslistFontSize;
QString qssFile;
QString snipCssFile;
QString synFile;
virtual void init();
@ -49,6 +50,7 @@ public slots:
virtual void showFontDialog();
virtual void resetReslistFont();
virtual void showStylesheetDialog();
virtual void showSynFileDialog();
virtual void showSnipCssDialog();
virtual void resetStylesheet();
virtual void resetSnipCss();