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