Add GUI preference to limit size of query history (or disable)
This commit is contained in:
parent
3aa64c390b
commit
8339559536
@ -28,14 +28,12 @@ using namespace Rcl;
|
|||||||
AdvSearchHist::AdvSearchHist()
|
AdvSearchHist::AdvSearchHist()
|
||||||
{
|
{
|
||||||
read();
|
read();
|
||||||
m_current = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdvSearchHist::~AdvSearchHist()
|
AdvSearchHist::~AdvSearchHist()
|
||||||
{
|
{
|
||||||
for (vector<std::shared_ptr<SearchData> >::iterator it = m_entries.begin();
|
for (auto& entry : m_entries) {
|
||||||
it != m_entries.end(); it++) {
|
entry.reset();
|
||||||
it->reset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +69,11 @@ bool AdvSearchHist::push(std::shared_ptr<SearchData> sd)
|
|||||||
m_current++;
|
m_current++;
|
||||||
|
|
||||||
string xml = sd->asXML();
|
string xml = sd->asXML();
|
||||||
g_dynconf->enterString(advSearchHistSk, xml, 100);
|
// dynconf interprets <= 0 as unlimited size, but we want 0 to
|
||||||
|
// disable saving history
|
||||||
|
if (prefs.historysize != 0) {
|
||||||
|
g_dynconf->enterString(advSearchHistSk, xml, prefs.historysize);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool read();
|
bool read();
|
||||||
|
|
||||||
int m_current;
|
int m_current{-1};
|
||||||
std::vector<std::shared_ptr<Rcl::SearchData> > m_entries;
|
std::vector<std::shared_ptr<Rcl::SearchData> > m_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,7 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.ssearchAutoPhraseThreshPC,
|
SETTING_RW(prefs.ssearchAutoPhraseThreshPC,
|
||||||
"/Recoll/prefs/ssearchAutoPhraseThreshPC", Double, 2.0);
|
"/Recoll/prefs/ssearchAutoPhraseThreshPC", Double, 2.0);
|
||||||
SETTING_RW(prefs.respagesize, "/Recoll/prefs/reslist/pagelen", Int, 8);
|
SETTING_RW(prefs.respagesize, "/Recoll/prefs/reslist/pagelen", Int, 8);
|
||||||
|
SETTING_RW(prefs.historysize, "/Recoll/prefs/historysize", Int, 0);
|
||||||
SETTING_RW(prefs.collapseDuplicates,
|
SETTING_RW(prefs.collapseDuplicates,
|
||||||
"/Recoll/prefs/reslist/collapseDuplicates", Bool, false);
|
"/Recoll/prefs/reslist/collapseDuplicates", Bool, false);
|
||||||
SETTING_RW(prefs.showResultsAsTable,
|
SETTING_RW(prefs.showResultsAsTable,
|
||||||
|
|||||||
@ -44,7 +44,8 @@ class PrefsPack {
|
|||||||
// toolbar+combobox or as a button group under simple search
|
// toolbar+combobox or as a button group under simple search
|
||||||
enum FilterCtlStyle {FCS_BT, FCS_CMB, FCS_MN};
|
enum FilterCtlStyle {FCS_BT, FCS_CMB, FCS_MN};
|
||||||
int filterCtlStyle;
|
int filterCtlStyle;
|
||||||
int respagesize;
|
int respagesize{8};
|
||||||
|
int historysize{0};
|
||||||
int maxhltextmbs;
|
int maxhltextmbs;
|
||||||
QString reslistfontfamily;
|
QString reslistfontfamily;
|
||||||
// Not saved in prefs for now. Computed from qt defaults and used to
|
// Not saved in prefs for now. Computed from qt defaults and used to
|
||||||
@ -73,7 +74,7 @@ class PrefsPack {
|
|||||||
int resArea; // Area for "results" toolbar
|
int resArea; // Area for "results" toolbar
|
||||||
bool ssearchTypSav; // Remember last search mode (else always
|
bool ssearchTypSav; // Remember last search mode (else always
|
||||||
// start with same)
|
// start with same)
|
||||||
int ssearchTyp;
|
int ssearchTyp{0};
|
||||||
// Use single app (default: xdg-open), instead of per-mime settings
|
// Use single app (default: xdg-open), instead of per-mime settings
|
||||||
bool useDesktopOpen;
|
bool useDesktopOpen;
|
||||||
// Remember sort state between invocations ?
|
// Remember sort state between invocations ?
|
||||||
@ -82,8 +83,8 @@ class PrefsPack {
|
|||||||
bool sortActive;
|
bool sortActive;
|
||||||
bool sortDesc;
|
bool sortDesc;
|
||||||
// Abstract preferences. Building abstracts can slow result display
|
// Abstract preferences. Building abstracts can slow result display
|
||||||
bool queryBuildAbstract;
|
bool queryBuildAbstract{true};
|
||||||
bool queryReplaceAbstract;
|
bool queryReplaceAbstract{false};
|
||||||
// Synthetized abstract length (chars) and word context size (words)
|
// Synthetized abstract length (chars) and word context size (words)
|
||||||
int syntAbsLen;
|
int syntAbsLen;
|
||||||
int syntAbsCtx;
|
int syntAbsCtx;
|
||||||
@ -93,7 +94,7 @@ class PrefsPack {
|
|||||||
int snipwMaxLength;
|
int snipwMaxLength;
|
||||||
// Snippets window sort by page (dflt: by weight)
|
// Snippets window sort by page (dflt: by weight)
|
||||||
bool snipwSortByPage;
|
bool snipwSortByPage;
|
||||||
bool startWithAdvSearchOpen;
|
bool startWithAdvSearchOpen{false};
|
||||||
// Try to display html if it exists in the internfile stack.
|
// Try to display html if it exists in the internfile stack.
|
||||||
bool previewHtml;
|
bool previewHtml;
|
||||||
bool previewActiveLinks;
|
bool previewActiveLinks;
|
||||||
@ -130,16 +131,16 @@ class PrefsPack {
|
|||||||
vector<int> restableColWidths;
|
vector<int> restableColWidths;
|
||||||
|
|
||||||
// Remembered term match mode
|
// Remembered term match mode
|
||||||
int termMatchType;
|
int termMatchType{0};
|
||||||
|
|
||||||
// Program version that wrote this. Not used for now, in prevision
|
// Program version that wrote this. Not used for now, in prevision
|
||||||
// of the case where we might need an incompatible change
|
// of the case where we might need an incompatible change
|
||||||
int rclVersion;
|
int rclVersion{1505};
|
||||||
// Suppress all noises
|
// Suppress all noises
|
||||||
bool noBeeps;
|
bool noBeeps;
|
||||||
|
|
||||||
bool showTrayIcon;
|
bool showTrayIcon{false};
|
||||||
bool closeToTray;
|
bool closeToTray{false};
|
||||||
|
|
||||||
int showTempFileWarning;
|
int showTempFileWarning;
|
||||||
|
|
||||||
@ -151,18 +152,6 @@ class PrefsPack {
|
|||||||
|
|
||||||
std::string stemlang();
|
std::string stemlang();
|
||||||
|
|
||||||
PrefsPack() :
|
|
||||||
respagesize(8),
|
|
||||||
reslistfontsize(10),
|
|
||||||
ssearchTyp(0),
|
|
||||||
queryBuildAbstract(true),
|
|
||||||
queryReplaceAbstract(false),
|
|
||||||
startWithAdvSearchOpen(false),
|
|
||||||
termMatchType(0),
|
|
||||||
rclVersion(1505),
|
|
||||||
showTrayIcon(false),
|
|
||||||
closeToTray(false)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Global preferences record */
|
/** Global preferences record */
|
||||||
|
|||||||
@ -364,8 +364,16 @@ void SSearch::startSimpleSearch()
|
|||||||
QString txt = currentText().trimmed();
|
QString txt = currentText().trimmed();
|
||||||
if (txt.isEmpty())
|
if (txt.isEmpty())
|
||||||
return;
|
return;
|
||||||
prefs.ssearchHistory.insert(0, txt);
|
if (prefs.historysize) {
|
||||||
prefs.ssearchHistory.removeDuplicates();
|
prefs.ssearchHistory.insert(0, txt);
|
||||||
|
prefs.ssearchHistory.removeDuplicates();
|
||||||
|
}
|
||||||
|
if (prefs.historysize >= 0) {
|
||||||
|
for (int i = (int)prefs.ssearchHistory.count();
|
||||||
|
i > prefs.historysize; i--) {
|
||||||
|
prefs.ssearchHistory.removeLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSearch::setPrefs()
|
void SSearch::setPrefs()
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="tLSTL">
|
<widget class="QLabel" name="tLSTL">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Style sheet</string>
|
<string>Application Qt style sheet</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -259,14 +259,37 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="noBeepsCB">
|
<layout class="QHBoxLayout">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>Suppress all beeps.</string>
|
<widget class="QLabel" name="hsLBL">
|
||||||
</property>
|
<property name="sizePolicy">
|
||||||
<property name="checked">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<bool>false</bool>
|
<horstretch>1</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
</widget>
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Limit the size of the search history. Use 0 to disable, -1 for unlimited.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Maximum size of search history (0: disable, -1: unlimited):</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="maxHistSizeSB">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="ssNoCompleteCB">
|
<widget class="QCheckBox" name="ssNoCompleteCB">
|
||||||
@ -338,6 +361,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="noBeepsCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Suppress all beeps.</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="spacer4">
|
<spacer name="spacer4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
@ -110,6 +110,7 @@ void UIPrefsDialog::setFromPrefs()
|
|||||||
|
|
||||||
// Entries per result page spinbox
|
// Entries per result page spinbox
|
||||||
pageLenSB->setValue(prefs.respagesize);
|
pageLenSB->setValue(prefs.respagesize);
|
||||||
|
maxHistSizeSB->setValue(prefs.historysize);
|
||||||
collapseDupsCB->setChecked(prefs.collapseDuplicates);
|
collapseDupsCB->setChecked(prefs.collapseDuplicates);
|
||||||
maxHLTSB->setValue(prefs.maxhltextmbs);
|
maxHLTSB->setValue(prefs.maxhltextmbs);
|
||||||
|
|
||||||
@ -294,6 +295,7 @@ void UIPrefsDialog::accept()
|
|||||||
m_mainWindow->setFilterCtlStyle(prefs.filterCtlStyle);
|
m_mainWindow->setFilterCtlStyle(prefs.filterCtlStyle);
|
||||||
|
|
||||||
prefs.respagesize = pageLenSB->value();
|
prefs.respagesize = pageLenSB->value();
|
||||||
|
prefs.historysize = maxHistSizeSB->value();
|
||||||
prefs.collapseDuplicates = collapseDupsCB->isChecked();
|
prefs.collapseDuplicates = collapseDupsCB->isChecked();
|
||||||
prefs.maxhltextmbs = maxHLTSB->value();
|
prefs.maxhltextmbs = maxHLTSB->value();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user