This commit is contained in:
Jean-Francois Dockes
2018-10-12 12:06:21 +02:00
151 changed files with 10323 additions and 3194 deletions
+6 -4
View File
@@ -79,10 +79,12 @@ bool AdvSearchHist::read()
{
if (!g_dynconf)
return false;
list<string> lxml = g_dynconf->getStringList(advSearchHistSk);
for (list<string>::const_iterator it = lxml.begin(); it != lxml.end();
it++) {
// getStringEntries() return the entries in order (lower key
// first), but we want most recent first, so revert
vector<string> lxml =
g_dynconf->getStringEntries<vector>(advSearchHistSk);
for (auto it = lxml.rbegin(); it != lxml.rend(); it++) {
std::shared_ptr<SearchData> sd = xmlToSearchData(*it);
if (sd)
m_entries.push_back(sd);
+21 -21
View File
@@ -316,19 +316,17 @@ void rwSettings(bool writing)
// as they are likely to depend on RECOLL_CONFDIR.
if (writing) {
g_dynconf->eraseAll(allEdbsSk);
for (list<string>::const_iterator it = prefs.allExtraDbs.begin();
it != prefs.allExtraDbs.end(); it++) {
g_dynconf->enterString(allEdbsSk, *it);
for (const auto& dbdir : prefs.allExtraDbs) {
g_dynconf->enterString(allEdbsSk, dbdir);
}
g_dynconf->eraseAll(actEdbsSk);
for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) {
g_dynconf->enterString(actEdbsSk, *it);
for (const auto& dbdir : prefs.activeExtraDbs) {
g_dynconf->enterString(actEdbsSk, dbdir);
}
} else {
prefs.allExtraDbs = g_dynconf->getStringList(allEdbsSk);
prefs.allExtraDbs = g_dynconf->getStringEntries<vector>(allEdbsSk);
const char *cp;
if ((cp = getenv("RECOLL_EXTRA_DBS")) != 0) {
vector<string> dbl;
@@ -337,17 +335,18 @@ void rwSettings(bool writing)
dit++) {
string dbdir = path_canon(*dit);
path_catslash(dbdir);
if (std::find(prefs.allExtraDbs.begin(),
prefs.allExtraDbs.end(), dbdir) !=
if (std::find(prefs.allExtraDbs.begin(),
prefs.allExtraDbs.end(), dbdir) !=
prefs.allExtraDbs.end())
continue;
bool stripped;
if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
LOGERR("Not a xapian index: [" << (dbdir) << "]\n" );
LOGERR("Not a xapian index: [" << dbdir << "]\n");
continue;
}
if (stripped != o_index_stripchars) {
LOGERR("Incompatible character stripping: [" << (dbdir) << "]\n" );
LOGERR("Incompatible character stripping: [" << dbdir <<
"]\n");
continue;
}
prefs.allExtraDbs.push_back(dbdir);
@@ -355,16 +354,17 @@ void rwSettings(bool writing)
}
// Get the remembered "active external indexes":
prefs.activeExtraDbs = g_dynconf->getStringList(actEdbsSk);
prefs.activeExtraDbs = g_dynconf->getStringEntries<vector>(actEdbsSk);
// Clean up the list: remove directories which are not
// actually there: useful for removable volumes.
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end();) {
for (auto it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end();) {
bool stripped;
if (!Rcl::Db::testDbDir(*it, &stripped) ||
stripped != o_index_stripchars) {
LOGINFO("Not a Xapian index or char stripping differs: [" << *it << "]\n" );
LOGINFO("Not a Xapian index or char stripping differs: [" <<
*it << "]\n");
it = prefs.activeExtraDbs.erase(it);
} else {
it++;
@@ -418,14 +418,14 @@ void rwSettings(bool writing)
while (prefs.asearchSubdirHist.size() > 20)
prefs.asearchSubdirHist.pop_back();
g_dynconf->eraseAll(asbdSk);
for (QStringList::iterator it = prefs.asearchSubdirHist.begin();
it != prefs.asearchSubdirHist.end(); it++) {
g_dynconf->enterString(asbdSk, (const char *)((*it).toUtf8()));
for (const auto& qdbd : prefs.asearchSubdirHist) {
g_dynconf->enterString(asbdSk, qs2utf8s(qdbd));
}
} else {
list<string> tl = g_dynconf->getStringList(asbdSk);
for (list<string>::iterator it = tl.begin(); it != tl.end(); it++)
prefs.asearchSubdirHist.push_front(QString::fromUtf8(it->c_str()));
vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk);
for (const auto& dbd: tl) {
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
}
}
if (!writing)
havereadsettings = true;
+2 -2
View File
@@ -99,8 +99,8 @@ class PrefsPack {
bool showResultsAsTable;
// Extra query indexes. This are stored in the history file, not qt prefs
list<string> allExtraDbs;
list<string> activeExtraDbs;
vector<string> allExtraDbs;
vector<string> activeExtraDbs;
// Advanced search subdir restriction: we don't activate the last value
// but just remember previously entered values
QStringList asearchSubdirHist;
Binary file not shown.
+1132 -447
View File
File diff suppressed because it is too large Load Diff
+10 -12
View File
@@ -42,6 +42,7 @@
#include "guiutils.h"
#include "smallut.h"
#include "readfile.h"
#include "uncomp.h"
#include "recollq.h"
@@ -52,10 +53,11 @@ static vector<TempFile> o_tempfiles;
/* Keep an array of temporary files for deletion at exit. It happens that we
erase some of them before exiting (ie: when closing a preview tab), we don't
reuse the array holes for now */
void rememberTempFile(TempFile temp)
TempFile *rememberTempFile(TempFile temp)
{
std::unique_lock<std::mutex> locker(thetempfileslock);
o_tempfiles.push_back(temp);
return &o_tempfiles.back();
}
void forgetTempFile(string &fn)
@@ -63,10 +65,9 @@ void forgetTempFile(string &fn)
if (fn.empty())
return;
std::unique_lock<std::mutex> locker(thetempfileslock);
for (vector<TempFile>::iterator it = o_tempfiles.begin();
it != o_tempfiles.end(); it++) {
if ((*it) && !fn.compare((*it)->filename())) {
it->reset();
for (auto& entry : o_tempfiles) {
if (entry.ok() && !fn.compare(entry.filename())) {
entry = TempFile();
}
}
fn.erase();
@@ -76,11 +77,10 @@ void deleteAllTempFiles()
{
std::unique_lock<std::mutex> locker(thetempfileslock);
o_tempfiles.clear();
Uncomp::clearcache();
}
Rcl::Db *rcldb;
int recollNeedsExit;
RclMain *mainWindow;
@@ -101,10 +101,9 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
if (force)
rcldb->close();
rcldb->rmQueryDb("");
for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) {
LOGDEB("main: adding [" << *it << "]\n" );
rcldb->addQueryDb(*it);
for (const auto& dbdir : prefs.activeExtraDbs) {
LOGDEB("main: adding [" << dbdir << "]\n");
rcldb->addQueryDb(dbdir);
}
Rcl::Db::OpenError error;
if (!rcldb->isopen() && !rcldb->open(Rcl::Db::DbRO, &error)) {
@@ -151,7 +150,6 @@ static void recollCleanup()
deleteZ(theconfig);
deleteAllTempFiles();
LOGDEB2("recollCleanup: done\n" );
}
+5 -8
View File
@@ -832,15 +832,15 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
// an ipath, create it.
if (fn.empty() || !idoc.ipath.empty()) {
TempFile temp = lthr.tmpimg;
if (temp) {
if (temp.ok()) {
LOGDEB1("Preview: load: got temp file from internfile\n");
} else if (!FileInterner::idocToFile(temp, string(),
theconfig, idoc)) {
temp.reset(); // just in case.
temp = TempFile(); // just in case.
}
if (temp) {
if (temp.ok()) {
rememberTempFile(temp);
fn = temp->filename();
fn = temp.filename();
editor->m_tmpfilename = fn;
} else {
editor->m_tmpfilename.erase();
@@ -876,10 +876,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
// Enter document in document history
string udi;
if (idoc.getmeta(Rcl::Doc::keyudi, &udi)) {
historyEnterDoc(g_dynconf, udi);
}
historyEnterDoc(rcldb, g_dynconf, idoc);
editor->setFocus();
emit(previewExposed(this, m_searchId, docnum));
+8 -8
View File
@@ -86,7 +86,7 @@ void RclMain::periodic100()
bool exited = m_idxproc->maybereap(&status);
if (exited) {
QString reasonmsg;
if (m_idxreasontmp) {
if (m_idxreasontmp && m_idxreasontmp->ok()) {
string reasons;
file_to_string(m_idxreasontmp->filename(), reasons);
if (!reasons.empty()) {
@@ -227,11 +227,11 @@ bool RclMain::checkIdxPaths()
// re-enabled by the indexing status check
void RclMain::toggleIndexing()
{
if (!m_idxreasontmp) {
if (!m_idxreasontmp || !m_idxreasontmp->ok()) {
// We just store the pointer and let the tempfile cleaner deal
// with delete on exiting
m_idxreasontmp = new TempFileInternal(".txt");
rememberTempFile(TempFile(m_idxreasontmp));
TempFile temp(".txt");
m_idxreasontmp = rememberTempFile(temp);
}
switch (m_indexerState) {
@@ -281,7 +281,7 @@ void RclMain::toggleIndexing()
return;
}
vector<string> args{"-c", theconfig->getConfDir()};
if (m_idxreasontmp) {
if (m_idxreasontmp && m_idxreasontmp->ok()) {
args.push_back("-R");
args.push_back(m_idxreasontmp->filename());
}
@@ -377,7 +377,7 @@ void RclMain::rebuildIndex()
}
vector<string> args{"-c", theconfig->getConfDir(), "-z"};
if (m_idxreasontmp) {
if (m_idxreasontmp && m_idxreasontmp->ok()) {
args.push_back("-R");
args.push_back(m_idxreasontmp->filename());
}
@@ -458,7 +458,7 @@ void RclMain::specialIndex()
return;
vector<string> args{"-c", theconfig->getConfDir()};
if (m_idxreasontmp) {
if (m_idxreasontmp && m_idxreasontmp->ok()) {
args.push_back("-R");
args.push_back(m_idxreasontmp->filename());
}
@@ -521,7 +521,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
vector<string> paths;
if (Rcl::docsToPaths(docs, paths)) {
vector<string> args{"-c", theconfig->getConfDir(), "-e", "-i"};
if (m_idxreasontmp) {
if (m_idxreasontmp && m_idxreasontmp->ok()) {
args.push_back("-R");
args.push_back(m_idxreasontmp->filename());
}
+1 -1
View File
@@ -80,7 +80,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
}
// We can only run indexing on the main index (dbidx 0)
bool ismainidx = rcldb->whatDbIdx(doc) == 0;
bool ismainidx = rcldb->fromMainIndex(doc);
// Indexer already running?
bool ixnotact = (m_indexerState == IXST_NOTRUNNING);
+9 -7
View File
@@ -310,10 +310,12 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
}
}
bool enterHistory = false;
// Can't remember what enterHistory was actually for. Set it to
// true always for now
bool enterHistory = true;
bool istempfile = false;
LOGDEB("RclMain::startNV: groksipath " << groksipath << " wantsf " <<
LOGDEB("StartNativeViewer: groksipath " << groksipath << " wantsf " <<
wantsfile << " wantsparentf " << wantsparentfile << "\n");
// If the command wants a file but this is not a file url, or
@@ -332,7 +334,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
enterHistory = true;
istempfile = true;
rememberTempFile(temp);
fn = temp->filename();
fn = temp.filename();
url = path_pathtofileurl(fn);
}
@@ -354,10 +356,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
return;
}
}
if (temp) {
if (temp.ok()) {
istempfile = true;
rememberTempFile(temp);
fn = temp->filename();
fn = temp.filename();
url = path_pathtofileurl(fn);
}
}
@@ -451,8 +453,8 @@ void RclMain::execViewer(const map<string, string>& subs, bool enterHistory,
stb->showMessage(msg, 10000);
}
if (!enterHistory)
historyEnterDoc(g_dynconf, doc.meta[Rcl::Doc::keyudi]);
if (enterHistory)
historyEnterDoc(rcldb, g_dynconf, doc);
// Do the zeitgeist thing
zg_send_event(ZGSEND_OPEN, doc);
+1 -1
View File
@@ -204,7 +204,7 @@ private:
vector<ExecCmd*> m_viewers;
ExecCmd *m_idxproc{0}; // Indexing process
bool m_idxkilled{false}; // Killed my process
TempFileInternal *m_idxreasontmp{nullptr};
TempFile *m_idxreasontmp{nullptr};
map<QString, QAction*> m_stemLangToId;
vector<string> m_catgbutvec;
int m_catgbutvecidx{0};
+1 -1
View File
@@ -36,7 +36,7 @@ bool getStemLangs(vector<string>& langs);
extern RclConfig *theconfig;
extern void rememberTempFile(TempFile);
extern TempFile *rememberTempFile(TempFile);
extern void forgetTempFile(string &fn);
extern void deleteAllTempFiles();
+15 -4
View File
@@ -362,19 +362,30 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const
LOGDEB2("RecollModel::data: row " << index.row() << " col " <<
index.column() << " role " << role << "\n");
if (!m_source || role != Qt::DisplayRole || !index.isValid() ||
index.column() >= int(m_fields.size())) {
return QVariant();
index.column() >= int(m_fields.size())) {
return QVariant();
}
Rcl::Doc doc;
if (!m_source->getDoc(index.row(), doc)) {
return QVariant();
return QVariant();
}
string colname = m_fields[index.column()];
string data = m_getters[index.column()](colname, doc);
// Special case url, because it may not be utf-8. URL-encode in this case.
if (!colname.compare("url")) {
int ecnt;
string data1;
if (!transcode(data, data1, "UTF-8", "UTF-8", &ecnt) || ecnt > 0) {
data = url_encode(data);
}
}
list<string> lr;
g_hiliter.plaintorich(m_getters[index.column()](colname, doc), lr, m_hdata);
g_hiliter.plaintorich(data, lr, m_hdata);
return QString::fromUtf8(lr.front().c_str());
}
+4 -4
View File
@@ -32,6 +32,7 @@
#include <qevent.h>
#include <QTimer>
#include <QCompleter>
#include <QAbstractItemView>
#include "log.h"
#include "guiutils.h"
@@ -300,9 +301,8 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
sdata->setMaxExpand(maxexp);
}
for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) {
xml << " <EX>" << base64_encode(*it) << "</EX>";
for (const auto& dbdir : prefs.activeExtraDbs) {
xml << " <EX>" << base64_encode(dbdir) << "</EX>";
}
xml << "</SD>\n";
@@ -710,7 +710,7 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
LOGDEB2("SSearch::eventFilter: target " << (target) << " (" << (queryText->lineEdit()) << ") type " << (eventTypeToStr(event->type())) << "\n" );
#endif
if (target == queryText->view()) {
if (target == (QObject*)(queryText->view())) {
if (event->type() == QEvent::Hide) {
// List was closed. If we were displaying completions, need
// to reset state.
+8 -12
View File
@@ -231,22 +231,18 @@ void UIPrefsDialog::setFromPrefs()
// Initialize the extra indexes listboxes
idxLV->clear();
for (list<string>::iterator it = prefs.allExtraDbs.begin();
it != prefs.allExtraDbs.end(); it++) {
for (const auto& dbdir : prefs.allExtraDbs) {
QListWidgetItem *item =
new QListWidgetItem(QString::fromLocal8Bit(it->c_str()),
idxLV);
new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
if (item)
item->setCheckState(Qt::Unchecked);
}
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) {
QList<QListWidgetItem *>items =
idxLV->findItems (QString::fromLocal8Bit(it->c_str()),
Qt::MatchFixedString|Qt::MatchCaseSensitive);
for (QList<QListWidgetItem *>::iterator it = items.begin();
it != items.end(); it++) {
(*it)->setCheckState(Qt::Checked);
for (const auto& dbdir : prefs.activeExtraDbs) {
auto items =
idxLV->findItems (QString::fromLocal8Bit(dbdir.c_str()),
Qt::MatchFixedString|Qt::MatchCaseSensitive);
for (auto& entry : items) {
entry->setCheckState(Qt::Checked);
}
}
idxLV->sortItems();
+6 -51
View File
@@ -21,17 +21,6 @@
#include <memory>
#include <unordered_map>
#ifdef _WIN32
#define USING_STD_REGEX
#endif
#ifndef USING_STD_REGEX
#include <sys/types.h>
#include <regex.h>
#else
#include <regex>
#endif
#include <QDebug>
#include <QSettings>
#include <QCloseEvent>
@@ -43,10 +32,11 @@
#include "recoll.h"
#include "webcache.h"
#include "beaglequeuecache.h"
#include "webstore.h"
#include "circache.h"
#include "conftree.h"
#include "rclmain_w.h"
#include "smallut.h"
using namespace std;
@@ -62,7 +52,7 @@ public:
class WebcacheModelInternal {
public:
std::shared_ptr<BeagleQueueCache> cache;
std::shared_ptr<WebStore> cache;
vector<CEnt> all;
vector<CEnt> disp;
};
@@ -81,7 +71,7 @@ WebcacheModel::~WebcacheModel()
void WebcacheModel::reload()
{
m->cache =
std::shared_ptr<BeagleQueueCache>(new BeagleQueueCache(theconfig));
std::shared_ptr<WebStore>(new WebStore(theconfig));
m->all.clear();
m->disp.clear();
@@ -158,21 +148,8 @@ QVariant WebcacheModel::data(const QModelIndex& index, int role) const
return QVariant();
}
/* We now read the data on init */
#if 0
string sdic;
if (!m->cache->cc()->get(m->disp[row].udi, sdic)) {
return QVariant();
}
ConfSimple dic(sdic);
//ostringstream os; dic.write(os); cerr << "DIC: " << os.str() << endl;
string mime, url;
dic.get("mimetype", mime);
dic.get("url", url);
#else
const string& mime = m->disp[row].mimetype;
const string& url = m->disp[row].url;
#endif
switch (index.column()) {
case 0: return QVariant(QString::fromUtf8(mime.c_str()));
@@ -181,35 +158,13 @@ QVariant WebcacheModel::data(const QModelIndex& index, int role) const
}
}
#ifndef USING_STD_REGEX
#define M_regexec(A,B,C,D,E) regexec(&(A),B,C,D,E)
#else
#define M_regexec(A,B,C,D,E) (!regex_match(B,A))
#endif
void WebcacheModel::setSearchFilter(const QString& _txt)
{
string txt = qs2utf8s(_txt);
#ifndef USING_STD_REGEX
regex_t exp;
if (regcomp(&exp, txt.c_str(), REG_NOSUB|REG_EXTENDED)) {
//qDebug() << "regcomp failed for " << _txt;
return;
}
#else
basic_regex<char> exp;
try {
exp = basic_regex<char>(txt, std::regex_constants::nosubs |
std::regex_constants::extended);
} catch(...) {
return;
}
#endif
SimpleRegexp re(qs2utf8s(_txt), SimpleRegexp::SRE_NOSUB);
m->disp.clear();
for (unsigned int i = 0; i < m->all.size(); i++) {
if (!M_regexec(exp, m->all[i].url.c_str(), 0, 0, 0)) {
if (re(m->all[i].url)) {
m->disp.push_back(m->all[i]);
} else {
//qDebug() << "match failed. exp" << _txt << "data" <<