GUI: the size of the restable column widths prefs list doubled each time the dialog was opened. It was properly reset in most cases, but some use schemes would result in monster sizes being saved to the prefs
This commit is contained in:
parent
a619922ba1
commit
49949ca5b3
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005 Jean-Francois Dockes
|
/* Copyright (C) 2005-2019 Jean-Francois Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -53,13 +53,13 @@ PrefsPack prefs;
|
|||||||
// Using the same macro to read/write a setting. insurance against typing
|
// Using the same macro to read/write a setting. insurance against typing
|
||||||
// mistakes
|
// mistakes
|
||||||
#define PARS(X) (X)
|
#define PARS(X) (X)
|
||||||
#define SETTING_RW(var, nm, tp, def) \
|
#define SETTING_RW(var, nm, tp, def) \
|
||||||
if (writing) { \
|
if (writing) { \
|
||||||
settings.setValue(nm , var); \
|
settings.setValue(nm , var); \
|
||||||
} else { \
|
} else { \
|
||||||
var = settings.value(nm, def).to##tp \
|
var = settings.value(nm, def).to##tp \
|
||||||
(); \
|
(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saving and restoring user preferences. These are stored in a global
|
* Saving and restoring user preferences. These are stored in a global
|
||||||
@ -87,7 +87,7 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.ssearchTypSav, "/Recoll/prefs/ssearchTypSav", Bool, 0);
|
SETTING_RW(prefs.ssearchTypSav, "/Recoll/prefs/ssearchTypSav", Bool, 0);
|
||||||
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
|
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
|
||||||
SETTING_RW(prefs.startWithAdvSearchOpen,
|
SETTING_RW(prefs.startWithAdvSearchOpen,
|
||||||
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
|
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
|
||||||
SETTING_RW(prefs.previewHtml, "/Recoll/prefs/previewHtml", Bool, true);
|
SETTING_RW(prefs.previewHtml, "/Recoll/prefs/previewHtml", Bool, true);
|
||||||
SETTING_RW(prefs.previewActiveLinks,
|
SETTING_RW(prefs.previewActiveLinks,
|
||||||
"/Recoll/prefs/previewActiveLinks", Bool, false);
|
"/Recoll/prefs/previewActiveLinks", Bool, false);
|
||||||
@ -99,17 +99,17 @@ void rwSettings(bool writing)
|
|||||||
if (prefs.advSearchClauses.size() > maxclauselistsize) {
|
if (prefs.advSearchClauses.size() > maxclauselistsize) {
|
||||||
prefs.advSearchClauses.resize(maxclauselistsize);
|
prefs.advSearchClauses.resize(maxclauselistsize);
|
||||||
}
|
}
|
||||||
for (auto clause : prefs.advSearchClauses) {
|
for (auto clause : prefs.advSearchClauses) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf, "%d ", clause);
|
sprintf(buf, "%d ", clause);
|
||||||
advSearchClauses += QString::fromUtf8(buf);
|
advSearchClauses += QString::fromUtf8(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString ascdflt;
|
QString ascdflt;
|
||||||
SETTING_RW(advSearchClauses,"/Recoll/prefs/adv/clauseList", String, ascdflt);
|
SETTING_RW(advSearchClauses,"/Recoll/prefs/adv/clauseList", String, ascdflt);
|
||||||
if (!writing) {
|
if (!writing) {
|
||||||
vector<string> clauses;
|
vector<string> clauses;
|
||||||
stringToStrings(qs2utf8s(advSearchClauses), clauses);
|
stringToStrings(qs2utf8s(advSearchClauses), clauses);
|
||||||
// There was a long-lurking bug where the clause list was
|
// There was a long-lurking bug where the clause list was
|
||||||
// growing to absurd sizes. The prefs.advSearchClauses clear()
|
// growing to absurd sizes. The prefs.advSearchClauses clear()
|
||||||
// call was missing (ok with the now false initial assumption
|
// call was missing (ok with the now false initial assumption
|
||||||
@ -122,29 +122,29 @@ void rwSettings(bool writing)
|
|||||||
}
|
}
|
||||||
prefs.advSearchClauses.clear();
|
prefs.advSearchClauses.clear();
|
||||||
prefs.advSearchClauses.reserve(clauses.size());
|
prefs.advSearchClauses.reserve(clauses.size());
|
||||||
for (auto clause : clauses) {
|
for (auto clause : clauses) {
|
||||||
prefs.advSearchClauses.push_back(atoi(clause.c_str()));
|
prefs.advSearchClauses.push_back(atoi(clause.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTING_RW(prefs.ssearchNoComplete,
|
SETTING_RW(prefs.ssearchNoComplete,
|
||||||
"/Recoll/prefs/ssearch/noComplete", Bool, false);
|
"/Recoll/prefs/ssearch/noComplete", Bool, false);
|
||||||
SETTING_RW(prefs.ssearchStartOnComplete,
|
SETTING_RW(prefs.ssearchStartOnComplete,
|
||||||
"/Recoll/prefs/ssearch/startOnComplete", Bool, true);
|
"/Recoll/prefs/ssearch/startOnComplete", Bool, true);
|
||||||
SETTING_RW(prefs.filterCtlStyle, "/Recoll/prefs/filterCtlStyle", Int, 0);
|
SETTING_RW(prefs.filterCtlStyle, "/Recoll/prefs/filterCtlStyle", Int, 0);
|
||||||
SETTING_RW(prefs.ssearchAutoPhrase,
|
SETTING_RW(prefs.ssearchAutoPhrase,
|
||||||
"/Recoll/prefs/ssearchAutoPhrase", Bool, true);
|
"/Recoll/prefs/ssearchAutoPhrase", Bool, true);
|
||||||
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.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,
|
||||||
"/Recoll/prefs/showResultsAsTable", Bool, false);
|
"/Recoll/prefs/showResultsAsTable", Bool, false);
|
||||||
SETTING_RW(prefs.maxhltextmbs, "/Recoll/prefs/preview/maxhltextmbs", Int, 3);
|
SETTING_RW(prefs.maxhltextmbs, "/Recoll/prefs/preview/maxhltextmbs", Int, 3);
|
||||||
|
|
||||||
SETTING_RW(prefs.previewPlainPre,
|
SETTING_RW(prefs.previewPlainPre,
|
||||||
"/Recoll/prefs/preview/plainPre", Int, PrefsPack::PP_PREWRAP);
|
"/Recoll/prefs/preview/plainPre", Int, PrefsPack::PP_PREWRAP);
|
||||||
|
|
||||||
// History: used to be able to only set a bare color name. Can now
|
// History: used to be able to only set a bare color name. Can now
|
||||||
// set any CSS style. Hack on ':' presence to keep compat with old
|
// set any CSS style. Hack on ':' presence to keep compat with old
|
||||||
@ -152,7 +152,7 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.qtermstyle, "/Recoll/prefs/qtermcolor", String,
|
SETTING_RW(prefs.qtermstyle, "/Recoll/prefs/qtermcolor", String,
|
||||||
"color: blue");
|
"color: blue");
|
||||||
if (!writing && prefs.qtermstyle == "")
|
if (!writing && prefs.qtermstyle == "")
|
||||||
prefs.qtermstyle = "color: blue";
|
prefs.qtermstyle = "color: blue";
|
||||||
{ // histo compatibility hack
|
{ // histo compatibility hack
|
||||||
int colon = prefs.qtermstyle.indexOf(":");
|
int colon = prefs.qtermstyle.indexOf(":");
|
||||||
int semi = prefs.qtermstyle.indexOf(";");
|
int semi = prefs.qtermstyle.indexOf(";");
|
||||||
@ -165,140 +165,141 @@ void rwSettings(bool writing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SETTING_RW(prefs.reslistdateformat, "/Recoll/prefs/reslist/dateformat",
|
SETTING_RW(prefs.reslistdateformat, "/Recoll/prefs/reslist/dateformat",
|
||||||
String," %Y-%m-%d %H:%M:%S %z");
|
String," %Y-%m-%d %H:%M:%S %z");
|
||||||
if (!writing && prefs.reslistdateformat == "")
|
if (!writing && prefs.reslistdateformat == "")
|
||||||
prefs.reslistdateformat = " %Y-%m-%d %H:%M:%S %z";
|
prefs.reslistdateformat = " %Y-%m-%d %H:%M:%S %z";
|
||||||
prefs.creslistdateformat = (const char*)prefs.reslistdateformat.toUtf8();
|
prefs.creslistdateformat = (const char*)prefs.reslistdateformat.toUtf8();
|
||||||
|
|
||||||
SETTING_RW(prefs.reslistfontfamily, "/Recoll/prefs/reslist/fontFamily",
|
SETTING_RW(prefs.reslistfontfamily, "/Recoll/prefs/reslist/fontFamily",
|
||||||
String, "");
|
String, "");
|
||||||
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int,
|
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int,
|
||||||
10);
|
10);
|
||||||
|
|
||||||
QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
|
QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
|
||||||
if (writing) {
|
if (writing) {
|
||||||
if (prefs.reslistformat.compare(rlfDflt)) {
|
if (prefs.reslistformat.compare(rlfDflt)) {
|
||||||
settings.setValue("/Recoll/prefs/reslist/format",
|
settings.setValue("/Recoll/prefs/reslist/format",
|
||||||
prefs.reslistformat);
|
prefs.reslistformat);
|
||||||
} else {
|
} else {
|
||||||
settings.remove("/Recoll/prefs/reslist/format");
|
settings.remove("/Recoll/prefs/reslist/format");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prefs.reslistformat =
|
prefs.reslistformat =
|
||||||
settings.value("/Recoll/prefs/reslist/format", rlfDflt).toString();
|
settings.value("/Recoll/prefs/reslist/format", rlfDflt).toString();
|
||||||
prefs.creslistformat = qs2utf8s(prefs.reslistformat);
|
prefs.creslistformat = qs2utf8s(prefs.reslistformat);
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
|
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
|
||||||
String, "");
|
String, "");
|
||||||
SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
|
SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
|
||||||
SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
|
SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
|
||||||
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
||||||
"english");
|
"english");
|
||||||
SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen",
|
SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen",
|
||||||
Bool, true);
|
Bool, true);
|
||||||
|
|
||||||
SETTING_RW(prefs.keepSort,
|
SETTING_RW(prefs.keepSort,
|
||||||
"/Recoll/prefs/keepSort", Bool, false);
|
"/Recoll/prefs/keepSort", Bool, false);
|
||||||
SETTING_RW(prefs.sortField, "/Recoll/prefs/sortField", String, "");
|
SETTING_RW(prefs.sortField, "/Recoll/prefs/sortField", String, "");
|
||||||
SETTING_RW(prefs.sortActive,
|
SETTING_RW(prefs.sortActive,
|
||||||
"/Recoll/prefs/sortActive", Bool, false);
|
"/Recoll/prefs/sortActive", Bool, false);
|
||||||
SETTING_RW(prefs.sortDesc,
|
SETTING_RW(prefs.sortDesc,
|
||||||
"/Recoll/prefs/query/sortDesc", Bool, 0);
|
"/Recoll/prefs/query/sortDesc", Bool, 0);
|
||||||
if (!writing) {
|
if (!writing) {
|
||||||
// Handle transition from older prefs which did not store sortColumn
|
// Handle transition from older prefs which did not store sortColumn
|
||||||
// (Active always meant sort by date).
|
// (Active always meant sort by date).
|
||||||
if (prefs.sortActive && prefs.sortField.isNull())
|
if (prefs.sortActive && prefs.sortField.isNull())
|
||||||
prefs.sortField = "mtime";
|
prefs.sortField = "mtime";
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTING_RW(prefs.queryBuildAbstract,
|
SETTING_RW(prefs.queryBuildAbstract,
|
||||||
"/Recoll/prefs/query/buildAbstract", Bool, true);
|
"/Recoll/prefs/query/buildAbstract", Bool, true);
|
||||||
SETTING_RW(prefs.queryReplaceAbstract,
|
SETTING_RW(prefs.queryReplaceAbstract,
|
||||||
"/Recoll/prefs/query/replaceAbstract", Bool, false);
|
"/Recoll/prefs/query/replaceAbstract", Bool, false);
|
||||||
SETTING_RW(prefs.syntAbsLen, "/Recoll/prefs/query/syntAbsLen",
|
SETTING_RW(prefs.syntAbsLen, "/Recoll/prefs/query/syntAbsLen",
|
||||||
Int, 250);
|
Int, 250);
|
||||||
SETTING_RW(prefs.syntAbsCtx, "/Recoll/prefs/query/syntAbsCtx",
|
SETTING_RW(prefs.syntAbsCtx, "/Recoll/prefs/query/syntAbsCtx",
|
||||||
Int, 4);
|
Int, 4);
|
||||||
// Abstract snippet separator
|
// Abstract snippet separator
|
||||||
SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"…");
|
SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"…");
|
||||||
if (!writing && prefs.abssep == "")
|
if (!writing && prefs.abssep == "")
|
||||||
prefs.abssep = "…";
|
prefs.abssep = "…";
|
||||||
SETTING_RW(prefs.snipwMaxLength, "/Recoll/prefs/snipwin/maxlen", Int, 1000);
|
SETTING_RW(prefs.snipwMaxLength, "/Recoll/prefs/snipwin/maxlen", Int, 1000);
|
||||||
SETTING_RW(prefs.snipwSortByPage,"/Recoll/prefs/snipwin/bypage", Bool, false);
|
SETTING_RW(prefs.snipwSortByPage,"/Recoll/prefs/snipwin/bypage", Bool, false);
|
||||||
|
|
||||||
SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
|
SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
|
||||||
SETTING_RW(prefs.autoSuffsEnable,
|
SETTING_RW(prefs.autoSuffsEnable,
|
||||||
"/Recoll/prefs/query/autoSuffsEnable", Bool, false);
|
"/Recoll/prefs/query/autoSuffsEnable", Bool, false);
|
||||||
|
|
||||||
SETTING_RW(prefs.synFileEnable,
|
SETTING_RW(prefs.synFileEnable,
|
||||||
"/Recoll/prefs/query/synFileEnable", Bool, false);
|
"/Recoll/prefs/query/synFileEnable", Bool, false);
|
||||||
SETTING_RW(prefs.synFile, "/Recoll/prefs/query/synfile", String, "");
|
SETTING_RW(prefs.synFile, "/Recoll/prefs/query/synfile", String, "");
|
||||||
|
|
||||||
SETTING_RW(prefs.termMatchType, "/Recoll/prefs/query/termMatchType",
|
SETTING_RW(prefs.termMatchType, "/Recoll/prefs/query/termMatchType",
|
||||||
Int, 0);
|
Int, 0);
|
||||||
// This is not really the current program version, just a value to
|
// This is not really the current program version, just a value to
|
||||||
// be used in case we have incompatible changes one day
|
// be used in case we have incompatible changes one day
|
||||||
SETTING_RW(prefs.rclVersion, "/Recoll/prefs/rclVersion", Int, 1009);
|
SETTING_RW(prefs.rclVersion, "/Recoll/prefs/rclVersion", Int, 1009);
|
||||||
|
|
||||||
// Ssearch combobox history list
|
// Ssearch combobox history list
|
||||||
if (writing) {
|
if (writing) {
|
||||||
settings.setValue("/Recoll/prefs/query/ssearchHistory",
|
settings.setValue("/Recoll/prefs/query/ssearchHistory",
|
||||||
prefs.ssearchHistory);
|
prefs.ssearchHistory);
|
||||||
} else {
|
} else {
|
||||||
prefs.ssearchHistory =
|
prefs.ssearchHistory =
|
||||||
settings.value("/Recoll/prefs/query/ssearchHistory").toStringList();
|
settings.value("/Recoll/prefs/query/ssearchHistory").toStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignored file types (advanced search)
|
// Ignored file types (advanced search)
|
||||||
if (writing) {
|
if (writing) {
|
||||||
settings.setValue("/Recoll/prefs/query/asearchIgnFilTyps",
|
settings.setValue("/Recoll/prefs/query/asearchIgnFilTyps",
|
||||||
prefs.asearchIgnFilTyps);
|
prefs.asearchIgnFilTyps);
|
||||||
} else {
|
} else {
|
||||||
prefs.asearchIgnFilTyps =
|
prefs.asearchIgnFilTyps =
|
||||||
settings.value("/Recoll/prefs/query/asearchIgnFilTyps").toStringList();
|
settings.value("/Recoll/prefs/query/asearchIgnFilTyps").toStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Field list for the restable
|
// Field list for the restable
|
||||||
if (writing) {
|
if (writing) {
|
||||||
settings.setValue("/Recoll/prefs/query/restableFields",
|
settings.setValue("/Recoll/prefs/query/restableFields",
|
||||||
prefs.restableFields);
|
prefs.restableFields);
|
||||||
} else {
|
} else {
|
||||||
prefs.restableFields =
|
prefs.restableFields =
|
||||||
settings.value("/Recoll/prefs/query/restableFields").toStringList();
|
settings.value("/Recoll/prefs/query/restableFields").toStringList();
|
||||||
if (prefs.restableFields.empty()) {
|
if (prefs.restableFields.empty()) {
|
||||||
prefs.restableFields.push_back("date");
|
prefs.restableFields.push_back("date");
|
||||||
prefs.restableFields.push_back("title");
|
prefs.restableFields.push_back("title");
|
||||||
prefs.restableFields.push_back("filename");
|
prefs.restableFields.push_back("filename");
|
||||||
prefs.restableFields.push_back("author");
|
prefs.restableFields.push_back("author");
|
||||||
prefs.restableFields.push_back("url");
|
prefs.restableFields.push_back("url");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// restable col widths
|
// restable col widths
|
||||||
QString rtcw;
|
QString rtcw;
|
||||||
if (writing) {
|
if (writing) {
|
||||||
for (vector<int>::iterator it = prefs.restableColWidths.begin();
|
for (vector<int>::iterator it = prefs.restableColWidths.begin();
|
||||||
it != prefs.restableColWidths.end(); it++) {
|
it != prefs.restableColWidths.end(); it++) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf, "%d ", *it);
|
sprintf(buf, "%d ", *it);
|
||||||
rtcw += QString::fromUtf8(buf);
|
rtcw += QString::fromUtf8(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SETTING_RW(rtcw, "/Recoll/prefs/query/restableWidths", String,
|
SETTING_RW(rtcw, "/Recoll/prefs/query/restableWidths", String,
|
||||||
"83 253 132 172 130 ");
|
"83 253 132 172 130 ");
|
||||||
if (!writing) {
|
if (!writing) {
|
||||||
vector<string> widths;
|
prefs.restableColWidths.clear();
|
||||||
stringToStrings((const char *)rtcw.toUtf8(), widths);
|
vector<string> widths;
|
||||||
for (vector<string>::iterator it = widths.begin();
|
stringToStrings((const char *)rtcw.toUtf8(), widths);
|
||||||
it != widths.end(); it++) {
|
for (vector<string>::iterator it = widths.begin();
|
||||||
prefs.restableColWidths.push_back(atoi(it->c_str()));
|
it != widths.end(); it++) {
|
||||||
}
|
prefs.restableColWidths.push_back(atoi(it->c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
|
SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
|
||||||
Bool, false);
|
Bool, false);
|
||||||
SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
|
SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
|
||||||
SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);
|
SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);
|
||||||
SETTING_RW(prefs.showTempFileWarning, "Recoll/prefs/showTempFileWarning",
|
SETTING_RW(prefs.showTempFileWarning, "Recoll/prefs/showTempFileWarning",
|
||||||
@ -317,64 +318,64 @@ void rwSettings(bool writing)
|
|||||||
// This are stored inside the dynamic configuration file (aka: history),
|
// This are stored inside the dynamic configuration file (aka: history),
|
||||||
// as they are likely to depend on RECOLL_CONFDIR.
|
// as they are likely to depend on RECOLL_CONFDIR.
|
||||||
if (writing) {
|
if (writing) {
|
||||||
g_dynconf->eraseAll(allEdbsSk);
|
g_dynconf->eraseAll(allEdbsSk);
|
||||||
for (const auto& dbdir : prefs.allExtraDbs) {
|
for (const auto& dbdir : prefs.allExtraDbs) {
|
||||||
g_dynconf->enterString(allEdbsSk, dbdir);
|
g_dynconf->enterString(allEdbsSk, dbdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_dynconf->eraseAll(actEdbsSk);
|
g_dynconf->eraseAll(actEdbsSk);
|
||||||
for (const auto& dbdir : prefs.activeExtraDbs) {
|
for (const auto& dbdir : prefs.activeExtraDbs) {
|
||||||
g_dynconf->enterString(actEdbsSk, dbdir);
|
g_dynconf->enterString(actEdbsSk, dbdir);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prefs.allExtraDbs = g_dynconf->getStringEntries<vector>(allEdbsSk);
|
prefs.allExtraDbs = g_dynconf->getStringEntries<vector>(allEdbsSk);
|
||||||
const char *cp;
|
const char *cp;
|
||||||
if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
|
if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
|
||||||
vector<string> dbl;
|
vector<string> dbl;
|
||||||
stringToTokens(cp, dbl, ":");
|
stringToTokens(cp, dbl, ":");
|
||||||
for (vector<string>::iterator dit = dbl.begin(); dit != dbl.end();
|
for (vector<string>::iterator dit = dbl.begin(); dit != dbl.end();
|
||||||
dit++) {
|
dit++) {
|
||||||
string dbdir = path_canon(*dit);
|
string dbdir = path_canon(*dit);
|
||||||
path_catslash(dbdir);
|
path_catslash(dbdir);
|
||||||
if (std::find(prefs.allExtraDbs.begin(),
|
if (std::find(prefs.allExtraDbs.begin(),
|
||||||
prefs.allExtraDbs.end(), dbdir) !=
|
prefs.allExtraDbs.end(), dbdir) !=
|
||||||
prefs.allExtraDbs.end())
|
prefs.allExtraDbs.end())
|
||||||
continue;
|
continue;
|
||||||
bool stripped;
|
bool stripped;
|
||||||
if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
|
if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
|
||||||
LOGERR("Not a xapian index: [" << dbdir << "]\n");
|
LOGERR("Not a xapian index: [" << dbdir << "]\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (stripped != o_index_stripchars) {
|
if (stripped != o_index_stripchars) {
|
||||||
LOGERR("Incompatible character stripping: [" << dbdir <<
|
LOGERR("Incompatible character stripping: [" << dbdir <<
|
||||||
"]\n");
|
"]\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prefs.allExtraDbs.push_back(dbdir);
|
prefs.allExtraDbs.push_back(dbdir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the remembered "active external indexes":
|
// Get the remembered "active external indexes":
|
||||||
prefs.activeExtraDbs = g_dynconf->getStringEntries<vector>(actEdbsSk);
|
prefs.activeExtraDbs = g_dynconf->getStringEntries<vector>(actEdbsSk);
|
||||||
|
|
||||||
// Clean up the list: remove directories which are not
|
// Clean up the list: remove directories which are not
|
||||||
// actually there: useful for removable volumes.
|
// actually there: useful for removable volumes.
|
||||||
for (auto it = prefs.activeExtraDbs.begin();
|
for (auto it = prefs.activeExtraDbs.begin();
|
||||||
it != prefs.activeExtraDbs.end();) {
|
it != prefs.activeExtraDbs.end();) {
|
||||||
bool stripped;
|
bool stripped;
|
||||||
if (!Rcl::Db::testDbDir(*it, &stripped) ||
|
if (!Rcl::Db::testDbDir(*it, &stripped) ||
|
||||||
stripped != o_index_stripchars) {
|
stripped != o_index_stripchars) {
|
||||||
LOGINFO("Not a Xapian index or char stripping differs: [" <<
|
LOGINFO("Not a Xapian index or char stripping differs: [" <<
|
||||||
*it << "]\n");
|
*it << "]\n");
|
||||||
it = prefs.activeExtraDbs.erase(it);
|
it = prefs.activeExtraDbs.erase(it);
|
||||||
} else {
|
} else {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get active db directives from the environment. This can only add to
|
// Get active db directives from the environment. This can only add to
|
||||||
// the remembered and cleaned up list
|
// the remembered and cleaned up list
|
||||||
const char *cp4Act;
|
const char *cp4Act;
|
||||||
if ((cp4Act = getenv("RECOLL_ACTIVE_EXTRA_DBS")) != 0) {
|
if ((cp4Act = getenv("RECOLL_ACTIVE_EXTRA_DBS")) != 0) {
|
||||||
vector<string> dbl;
|
vector<string> dbl;
|
||||||
@ -387,9 +388,9 @@ void rwSettings(bool writing)
|
|||||||
prefs.activeExtraDbs.end(), dbdir) !=
|
prefs.activeExtraDbs.end(), dbdir) !=
|
||||||
prefs.activeExtraDbs.end())
|
prefs.activeExtraDbs.end())
|
||||||
continue;
|
continue;
|
||||||
bool strpd;
|
bool strpd;
|
||||||
if (!Rcl::Db::testDbDir(dbdir, &strpd) ||
|
if (!Rcl::Db::testDbDir(dbdir, &strpd) ||
|
||||||
strpd != o_index_stripchars) {
|
strpd != o_index_stripchars) {
|
||||||
LOGERR("Not a Xapian dir or diff. char stripping: [" << (dbdir) << "]\n" );
|
LOGERR("Not a Xapian dir or diff. char stripping: [" << (dbdir) << "]\n" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -400,33 +401,33 @@ void rwSettings(bool writing)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
list<string>::const_iterator it;
|
list<string>::const_iterator it;
|
||||||
fprintf(stderr, "All extra Dbs:\n");
|
fprintf(stderr, "All extra Dbs:\n");
|
||||||
for (it = prefs.allExtraDbs.begin();
|
for (it = prefs.allExtraDbs.begin();
|
||||||
it != prefs.allExtraDbs.end(); it++) {
|
it != prefs.allExtraDbs.end(); it++) {
|
||||||
fprintf(stderr, " [%s]\n", it->c_str());
|
fprintf(stderr, " [%s]\n", it->c_str());
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Active extra Dbs:\n");
|
fprintf(stderr, "Active extra Dbs:\n");
|
||||||
for (it = prefs.activeExtraDbs.begin();
|
for (it = prefs.activeExtraDbs.begin();
|
||||||
it != prefs.activeExtraDbs.end(); it++) {
|
it != prefs.activeExtraDbs.end(); it++) {
|
||||||
fprintf(stderr, " [%s]\n", it->c_str());
|
fprintf(stderr, " [%s]\n", it->c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const string asbdSk = "asearchSbd";
|
const string asbdSk = "asearchSbd";
|
||||||
if (writing) {
|
if (writing) {
|
||||||
while (prefs.asearchSubdirHist.size() > 20)
|
while (prefs.asearchSubdirHist.size() > 20)
|
||||||
prefs.asearchSubdirHist.pop_back();
|
prefs.asearchSubdirHist.pop_back();
|
||||||
g_dynconf->eraseAll(asbdSk);
|
g_dynconf->eraseAll(asbdSk);
|
||||||
for (const auto& qdbd : prefs.asearchSubdirHist) {
|
for (const auto& qdbd : prefs.asearchSubdirHist) {
|
||||||
g_dynconf->enterString(asbdSk, qs2utf8s(qdbd));
|
g_dynconf->enterString(asbdSk, qs2utf8s(qdbd));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk);
|
vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk);
|
||||||
for (const auto& dbd: tl) {
|
for (const auto& dbd: tl) {
|
||||||
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
|
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!writing)
|
if (!writing)
|
||||||
@ -437,10 +438,10 @@ string PrefsPack::stemlang()
|
|||||||
{
|
{
|
||||||
string stemLang(qs2utf8s(prefs.queryStemLang));
|
string stemLang(qs2utf8s(prefs.queryStemLang));
|
||||||
if (stemLang == "ALL") {
|
if (stemLang == "ALL") {
|
||||||
if (theconfig)
|
if (theconfig)
|
||||||
theconfig->getConfParam("indexstemminglanguages", stemLang);
|
theconfig->getConfParam("indexstemminglanguages", stemLang);
|
||||||
else
|
else
|
||||||
stemLang = "";
|
stemLang = "";
|
||||||
}
|
}
|
||||||
return stemLang;
|
return stemLang;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user