fix the external index dialog to accept either xapian directory or recoll config directories
This commit is contained in:
parent
d3631b5ddf
commit
6b40f9b3f4
@ -49,10 +49,13 @@ using namespace std;
|
|||||||
#include "readfile.h"
|
#include "readfile.h"
|
||||||
#include "fstreewalk.h"
|
#include "fstreewalk.h"
|
||||||
|
|
||||||
|
// Static, logically const, RclConfig members are initialized once from the
|
||||||
|
// first object build during process initialization.
|
||||||
#ifndef RCL_INDEX_STRIPCHARS
|
#ifndef RCL_INDEX_STRIPCHARS
|
||||||
// We default to a case- and diacritics-less index for now
|
// We default to a case- and diacritics-less index for now
|
||||||
bool o_index_stripchars = true;
|
bool o_index_stripchars = true;
|
||||||
#endif
|
#endif
|
||||||
|
string RclConfig::o_localecharset;
|
||||||
|
|
||||||
bool ParamStale::needrecompute()
|
bool ParamStale::needrecompute()
|
||||||
{
|
{
|
||||||
@ -107,8 +110,6 @@ bool RclConfig::isDefaultConfig() const
|
|||||||
return !defaultconf.compare(specifiedconf);
|
return !defaultconf.compare(specifiedconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
string RclConfig::o_localecharset;
|
|
||||||
|
|
||||||
RclConfig::RclConfig(const string *argcnf)
|
RclConfig::RclConfig(const string *argcnf)
|
||||||
{
|
{
|
||||||
zeroMe();
|
zeroMe();
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
#include <qtextedit.h>
|
#include <qtextedit.h>
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
@ -445,6 +446,19 @@ void UIPrefsDialog::delExtraDbPB_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool samedir(const string& dir1, const string& dir2)
|
||||||
|
{
|
||||||
|
struct stat st1, st2;
|
||||||
|
if (stat(dir1.c_str(), &st1))
|
||||||
|
return false;
|
||||||
|
if (stat(dir2.c_str(), &st2))
|
||||||
|
return false;
|
||||||
|
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browse to add another index.
|
* Browse to add another index.
|
||||||
* We do a textual comparison to check for duplicates, except for
|
* We do a textual comparison to check for duplicates, except for
|
||||||
@ -453,13 +467,27 @@ void UIPrefsDialog::delExtraDbPB_clicked()
|
|||||||
void UIPrefsDialog::addExtraDbPB_clicked()
|
void UIPrefsDialog::addExtraDbPB_clicked()
|
||||||
{
|
{
|
||||||
QString input = myGetFileName(true,
|
QString input = myGetFileName(true,
|
||||||
tr("Select xapian index directory "
|
tr("Select recoll config directory or "
|
||||||
"(ie: /home/buddy/.recoll/xapiandb)"));
|
"xapian index directory "
|
||||||
|
"(e.g.: /home/me/.recoll or "
|
||||||
|
"/home/me/.recoll/xapiandb)"));
|
||||||
|
|
||||||
if (input.isEmpty())
|
if (input.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string dbdir = (const char *)input.toLocal8Bit();
|
string dbdir = (const char *)input.toLocal8Bit();
|
||||||
|
if (access(path_cat(dbdir, "recoll.conf").c_str(), 0) == 0) {
|
||||||
|
// Chosen dir is config dir.
|
||||||
|
RclConfig conf(&dbdir);
|
||||||
|
dbdir = conf.getDbDir();
|
||||||
|
if (dbdir.empty()) {
|
||||||
|
QMessageBox::warning(
|
||||||
|
0, "Recoll", tr("The selected directory looks like a Recoll "
|
||||||
|
"configuration directory but the configuration "
|
||||||
|
"could not be read"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
|
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
|
||||||
path_catslash(dbdir);
|
path_catslash(dbdir);
|
||||||
if (!Rcl::Db::testDbDir(dbdir)) {
|
if (!Rcl::Db::testDbDir(dbdir)) {
|
||||||
@ -467,42 +495,25 @@ void UIPrefsDialog::addExtraDbPB_clicked()
|
|||||||
tr("The selected directory does not appear to be a Xapian index"));
|
tr("The selected directory does not appear to be a Xapian index"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct stat st1, st2;
|
if (samedir(dbdir, theconfig->getDbDir())) {
|
||||||
stat(dbdir.c_str(), &st1);
|
|
||||||
string rcldbdir = theconfig->getDbDir();
|
|
||||||
stat(rcldbdir.c_str(), &st2);
|
|
||||||
path_catslash(rcldbdir);
|
|
||||||
|
|
||||||
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
|
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("This is the main/local index!"));
|
tr("This is the main/local index!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For some reason, finditem (which we used to use to detect duplicates
|
for (int i = 0; i < idxLV->count(); i++) {
|
||||||
// here) does not work anymore here: qt 4.6.3
|
QListWidgetItem *item = idxLV->item(i);
|
||||||
QList<QListWidgetItem *>items =
|
string existingdir = (const char *)item->text().toLocal8Bit();
|
||||||
idxLV->findItems (input, Qt::MatchFixedString|Qt::MatchCaseSensitive);
|
if (samedir(dbdir, existingdir)) {
|
||||||
if (!items.empty()) {
|
QMessageBox::warning(
|
||||||
QMessageBox::warning(0, "Recoll",
|
0, "Recoll", tr("The selected directory is already in the "
|
||||||
tr("The selected directory is already in the index list"));
|
"index list"));
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
string nv = (const char *)input.toLocal8Bit();
|
|
||||||
QListViewItemIterator it(idxLV);
|
|
||||||
while (it.current()) {
|
|
||||||
QCheckListItem *item = (QCheckListItem *)it.current();
|
|
||||||
string ov = (const char *)item->text().toLocal8Bit();
|
|
||||||
if (!ov.compare(nv)) {
|
|
||||||
QMessageBox::warning(0, "Recoll",
|
|
||||||
tr("The selected directory is already in the index list"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
QListWidgetItem *item = new QListWidgetItem(input, idxLV);
|
QListWidgetItem *item =
|
||||||
|
new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
|
||||||
item->setCheckState(Qt::Checked);
|
item->setCheckState(Qt::Checked);
|
||||||
idxLV->sortItems();
|
idxLV->sortItems();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,7 +112,11 @@ url = dc:identifier xesam:url
|
|||||||
# Section to define translations from extended file attribute names to
|
# Section to define translations from extended file attribute names to
|
||||||
# field names. xattr use must be enabled at compile time for this to be
|
# field names. xattr use must be enabled at compile time for this to be
|
||||||
# used. Enter translations as "xattrname = fieldname". Case matters.
|
# used. Enter translations as "xattrname = fieldname". Case matters.
|
||||||
|
# The values from the extended attributes will extend, not replace, the
|
||||||
|
# data found from equivalent fields inside the document. As an example, the
|
||||||
|
# following would map a quite plausible "tags" extended attribute into the
|
||||||
|
# "keywords" field.
|
||||||
|
tags = keywords
|
||||||
|
|
||||||
########################
|
########################
|
||||||
# Sections reserved for specific filters follow
|
# Sections reserved for specific filters follow
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user