additional search databases
This commit is contained in:
+55
-1
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.5 2006-04-04 10:38:52 dockes Exp $ (C) 2005 Jean-Francois Dockes";
|
||||
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.6 2006-04-05 12:50:42 dockes Exp $ (C) 2005 Jean-Francois Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -24,8 +24,10 @@ static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.5 2006-04-04 10:38:52 dockes Exp
|
||||
#include "recoll.h"
|
||||
#include "guiutils.h"
|
||||
#include "pathut.h"
|
||||
#include "base64.h"
|
||||
|
||||
#include <qsettings.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
const static char *htmlbrowserlist =
|
||||
"opera konqueror firefox mozilla netscape";
|
||||
@@ -129,6 +131,58 @@ void rwSettings(bool writing)
|
||||
"/Recoll/prefs/query/buildAbstract", Bool, true);
|
||||
SETTING_RW(prefs.queryReplaceAbstract,
|
||||
"/Recoll/prefs/query/replaceAbstract", Bool, false);
|
||||
|
||||
QStringList qsl;
|
||||
if (writing) {
|
||||
for (list<string>::const_iterator it = prefs.allExtraDbs.begin();
|
||||
it != prefs.allExtraDbs.end(); it++) {
|
||||
string b64;
|
||||
base64_encode(*it, b64);
|
||||
qsl.push_back(QString::fromAscii(b64.c_str()));
|
||||
}
|
||||
settings.writeEntry("/Recoll/prefs/query/allExtraDbs", qsl);
|
||||
|
||||
qsl.clear();
|
||||
for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
|
||||
it != prefs.activeExtraDbs.end(); it++) {
|
||||
string b64;
|
||||
base64_encode(*it, b64);
|
||||
qsl.push_back(QString::fromAscii(b64.c_str()));
|
||||
}
|
||||
settings.writeEntry("/Recoll/prefs/query/activeExtraDbs", qsl);
|
||||
} else {
|
||||
qsl = settings.readListEntry("/Recoll/prefs/query/allExtraDbs");
|
||||
prefs.allExtraDbs.clear();
|
||||
for (QStringList::iterator it = qsl.begin(); it != qsl.end(); it++) {
|
||||
string dec;
|
||||
base64_decode((*it).ascii(), dec);
|
||||
prefs.allExtraDbs.push_back(dec);
|
||||
}
|
||||
|
||||
qsl = settings.readListEntry("/Recoll/prefs/query/activeExtraDbs");
|
||||
prefs.activeExtraDbs.clear();
|
||||
for (QStringList::iterator it = qsl.begin(); it != qsl.end(); it++) {
|
||||
string dec;
|
||||
base64_decode((*it).ascii(), dec);
|
||||
prefs.activeExtraDbs.push_back(dec);
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
{
|
||||
list<string>::const_iterator it;
|
||||
fprintf(stderr, "All extra Dbs:\n");
|
||||
for (it = prefs.allExtraDbs.begin();
|
||||
it != prefs.allExtraDbs.end(); it++) {
|
||||
fprintf(stderr, " [%s]\n", it->c_str());
|
||||
}
|
||||
fprintf(stderr, "Active extra Dbs:\n");
|
||||
for (it = prefs.activeExtraDbs.begin();
|
||||
it != prefs.activeExtraDbs.end(); it++) {
|
||||
fprintf(stderr, " [%s]\n", it->c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
+12
-1
@@ -17,7 +17,7 @@
|
||||
#ifndef _GUIUTILS_H_INCLUDED_
|
||||
#define _GUIUTILS_H_INCLUDED_
|
||||
/*
|
||||
* @(#$Id: guiutils.h,v 1.3 2006-03-29 17:31:55 dockes Exp $ (C) 2005 Jean-Francois Dockes
|
||||
* @(#$Id: guiutils.h,v 1.4 2006-04-05 12:50:42 dockes Exp $ (C) 2005 Jean-Francois Dockes
|
||||
* jean-francois.dockes@wanadoo.fr
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -37,8 +37,14 @@
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <qstring.h>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
#endif
|
||||
|
||||
/** Start a browser on the help document */
|
||||
extern bool startHelpBrowser(const string& url = "");
|
||||
|
||||
@@ -56,6 +62,11 @@ class PrefsPack {
|
||||
QString htmlBrowser;
|
||||
bool queryBuildAbstract;
|
||||
bool queryReplaceAbstract;
|
||||
// Extra query databases. This are encoded to base64 before storing
|
||||
// to the qt settings file to avoid any bin string/ charset conv issues
|
||||
list<string> allExtraDbs;
|
||||
list<string> activeExtraDbs;
|
||||
|
||||
PrefsPack() :
|
||||
showicons(true),
|
||||
respagesize(8),
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.39 2006-04-04 07:55:29 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.40 2006-04-05 12:50:42 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -90,6 +90,12 @@ bool maybeOpenDb(string &reason, bool force)
|
||||
qopts |= Rcl::Db::QO_REPLACE_ABSTRACT;
|
||||
if (force)
|
||||
rcldb->close();
|
||||
rcldb->rmQueryDb("");
|
||||
for (list<string>::const_iterator it = prefs.activeExtraDbs.begin();
|
||||
it != prefs.activeExtraDbs.end(); it++) {
|
||||
LOGDEB(("main: adding [%s]\n", it->c_str()));
|
||||
rcldb->addQueryDb(*it);
|
||||
}
|
||||
if (!rcldb->isopen() && !rcldb->open(dbdir, Rcl::Db::DbRO, qopts)) {
|
||||
reason = "Could not open database in " +
|
||||
dbdir + " wait for indexing to complete?";
|
||||
|
||||
+224
-3
@@ -8,8 +8,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>238</height>
|
||||
<width>533</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
@@ -84,7 +84,7 @@
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout6</cstring>
|
||||
<cstring>layout4</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
@@ -260,6 +260,220 @@ May be slow for big documents.</string>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>ExtraDb</cstring>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Extra Databases</string>
|
||||
</attribute>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout12</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>addExtraDbPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add database</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Select the recoll.conf file defining the database you want to add, then click Add Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>extraDbLE</cstring>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Select the recoll.conf file defining the database you want to add, then click Add Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>browseDbPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Select the recoll.conf file defining the database you want to add, then click Add Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout12</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout13</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel2_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>All extra databases</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>All known extra databases</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListBox">
|
||||
<property name="name">
|
||||
<cstring>allDbsLB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>Extended</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout11</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>addAADbPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>All ----></string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>addADbPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sel -----></string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>delADbPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><----- Sel</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>delAADbPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><----- All</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout14</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>textLabel3</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Active extra databases</string>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Extra databases that will be searched in addition to the main one</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListBox">
|
||||
<property name="name">
|
||||
<cstring>actDbsLB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>Extended</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
@@ -368,6 +582,13 @@ May be slow for big documents.</string>
|
||||
<slot>showFontDialog()</slot>
|
||||
<slot>resetReslistFont()</slot>
|
||||
<slot>showBrowserDialog()</slot>
|
||||
<slot>extraDbTextChanged( const QString & text )</slot>
|
||||
<slot>addAADbPB_clicked()</slot>
|
||||
<slot>addADbPB_clicked()</slot>
|
||||
<slot>delADbPB_clicked()</slot>
|
||||
<slot>delAADbPB_clicked()</slot>
|
||||
<slot>addExtraDbPB_clicked()</slot>
|
||||
<slot>browseDbPB_clicked()</slot>
|
||||
</slots>
|
||||
<functions>
|
||||
<function>init()</function>
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
** These will automatically be called by the form's constructor and
|
||||
** destructor.
|
||||
*****************************************************************************/
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
|
||||
#include "qfontdialog.h"
|
||||
#include "qfiledialog.h"
|
||||
@@ -33,6 +36,7 @@
|
||||
|
||||
#include "recoll.h"
|
||||
#include "guiutils.h"
|
||||
#include "rcldb.h"
|
||||
|
||||
void UIPrefsDialog::init()
|
||||
{
|
||||
@@ -82,10 +86,35 @@ void UIPrefsDialog::init()
|
||||
replAbsCB->setEnabled(false);
|
||||
}
|
||||
replAbsCB->setDown(prefs.queryReplaceAbstract);
|
||||
|
||||
// Initialize the extra databases listboxes
|
||||
QStringList ql;
|
||||
for (list<string>::iterator it = prefs.allExtraDbs.begin();
|
||||
it != prefs.allExtraDbs.end(); it++) {
|
||||
ql.append(QString::fromLocal8Bit(it->c_str()));
|
||||
}
|
||||
allDbsLB->insertStringList(ql);
|
||||
ql.clear();
|
||||
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
|
||||
it != prefs.activeExtraDbs.end(); it++) {
|
||||
ql.append(QString::fromLocal8Bit(it->c_str()));
|
||||
}
|
||||
actDbsLB->insertStringList(ql);
|
||||
ql.clear();
|
||||
|
||||
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
||||
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
||||
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
||||
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
|
||||
SLOT(extraDbTextChanged(const QString&)));
|
||||
connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked()));
|
||||
connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked()));
|
||||
connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked()));
|
||||
connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked()));
|
||||
connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked()));
|
||||
connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void UIPrefsDialog::accept()
|
||||
@@ -159,3 +188,106 @@ void UIPrefsDialog::showBrowserDialog()
|
||||
if (s)
|
||||
helpBrowserLE->setText(s);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
// External / extra search databases setup: this should modify to take
|
||||
// effect only when Ok is clicked. Currently modifs take effect as soon as
|
||||
// done in the Gui
|
||||
// Also needed: means to remove entry from 'all' list (del button? )
|
||||
|
||||
void UIPrefsDialog::extraDbTextChanged(const QString &text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
addExtraDbPB->setEnabled(false);
|
||||
} else {
|
||||
addExtraDbPB->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Add selected dbs to the active list
|
||||
void UIPrefsDialog::addADbPB_clicked()
|
||||
{
|
||||
for (unsigned int i = 0; i < allDbsLB->count();i++) {
|
||||
QListBoxItem *item = allDbsLB->item(i);
|
||||
if (item && item->isSelected()) {
|
||||
allDbsLB->setSelected(i, false);
|
||||
string dbname = (const char*)item->text().local8Bit();
|
||||
if (std::find(prefs.activeExtraDbs.begin(), prefs.activeExtraDbs.end(),
|
||||
dbname) == prefs.activeExtraDbs.end()) {
|
||||
actDbsLB->insertItem(item->text());
|
||||
prefs.activeExtraDbs.push_back(dbname);
|
||||
}
|
||||
}
|
||||
}
|
||||
actDbsLB->sort();
|
||||
}
|
||||
|
||||
void UIPrefsDialog::addAADbPB_clicked()
|
||||
{
|
||||
for (unsigned int i = 0; i < allDbsLB->count();i++) {
|
||||
allDbsLB->setSelected(i, true);
|
||||
}
|
||||
addADbPB_clicked();
|
||||
}
|
||||
|
||||
void UIPrefsDialog::delADbPB_clicked()
|
||||
{
|
||||
list<int> rmi;
|
||||
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
||||
QListBoxItem *item = actDbsLB->item(i);
|
||||
if (item && item->isSelected()) {
|
||||
string dbname = (const char*)item->text().local8Bit();
|
||||
list<string>::iterator sit;
|
||||
if ((sit = ::std::find(prefs.activeExtraDbs.begin(),
|
||||
prefs.activeExtraDbs.end(), dbname)) !=
|
||||
prefs.activeExtraDbs.end()) {
|
||||
prefs.activeExtraDbs.erase(sit);
|
||||
}
|
||||
rmi.push_front(i);
|
||||
}
|
||||
}
|
||||
for (list<int>::iterator ii = rmi.begin(); ii != rmi.end(); ii++) {
|
||||
actDbsLB->removeItem(*ii);
|
||||
}
|
||||
}
|
||||
|
||||
void UIPrefsDialog::delAADbPB_clicked()
|
||||
{
|
||||
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
|
||||
actDbsLB->setSelected(i, true);
|
||||
}
|
||||
delADbPB_clicked();
|
||||
}
|
||||
|
||||
void UIPrefsDialog::addExtraDbPB_clicked()
|
||||
{
|
||||
string dbdir = (const char *)extraDbLE->text().local8Bit();
|
||||
if (!Rcl::Db::testDbDir(dbdir)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("The selected directory does not appear to be a Xapian database"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (::std::find(prefs.allExtraDbs.begin(), prefs.allExtraDbs.end(),
|
||||
dbdir) != prefs.allExtraDbs.end()) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("The selected directory is already in the database list"));
|
||||
return;
|
||||
}
|
||||
prefs.allExtraDbs.push_back(dbdir);
|
||||
allDbsLB->insertItem(extraDbLE->text());
|
||||
allDbsLB->sort();
|
||||
}
|
||||
|
||||
void UIPrefsDialog::browseDbPB_clicked()
|
||||
{
|
||||
QFileDialog fdia;
|
||||
bool savedh = fdia.showHiddenFiles();
|
||||
fdia.setShowHiddenFiles(true);
|
||||
QString s = QFileDialog::getExistingDirectory("", this, 0,
|
||||
tr("Select directory holding xapian database (ie: /home/someone/.recoll/xapiandb)"));
|
||||
|
||||
fdia.setShowHiddenFiles(savedh);
|
||||
if (s)
|
||||
extraDbLE->setText(s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user