*** empty log message ***
This commit is contained in:
parent
df78cd2d77
commit
d3e20ceeeb
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: confgui.cpp,v 1.1 2007-09-26 12:16:48 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: confgui.cpp,v 1.2 2007-09-27 15:47:25 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -23,35 +23,38 @@ static char rcsid[] = "@(#$Id: confgui.cpp,v 1.1 2007-09-26 12:16:48 dockes Exp
|
||||
#include "confgui.h"
|
||||
#include "smallut.h"
|
||||
#include "debuglog.h"
|
||||
#include "rcldb.h"
|
||||
|
||||
#include <list>
|
||||
using std::list;
|
||||
|
||||
namespace confgui {
|
||||
|
||||
const static int spacing = 3;
|
||||
const static int margin = 6;
|
||||
|
||||
void ConfParamW::setValue(const QString& value)
|
||||
{
|
||||
m_cflink.set(string((const char *)value.utf8()));
|
||||
m_cflink->set(string((const char *)value.utf8()));
|
||||
}
|
||||
|
||||
void ConfParamW::setValue(int value)
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%d", value);
|
||||
m_cflink.set(string(buf));
|
||||
m_cflink->set(string(buf));
|
||||
}
|
||||
void ConfParamW::setValue(bool value)
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%d", value);
|
||||
m_cflink.set(string(buf));
|
||||
m_cflink->set(string(buf));
|
||||
}
|
||||
|
||||
bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
||||
{
|
||||
m_hl = new QHBoxLayout(this);
|
||||
m_hl->setSpacing(6);
|
||||
m_hl->setSpacing(spacing);
|
||||
|
||||
QLabel *tl = new QLabel(this);
|
||||
tl->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
@ -67,8 +70,8 @@ bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink &cflink,
|
||||
#include <qframe.h>
|
||||
ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
int minvalue,
|
||||
@ -89,19 +92,27 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink &cflink,
|
||||
0, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
sb->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(sb);
|
||||
|
||||
QFrame *fr = new QFrame(this);
|
||||
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
QSizePolicy::Fixed,
|
||||
1, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
fr->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(fr);
|
||||
|
||||
|
||||
string s;
|
||||
m_cflink.get(s);
|
||||
m_cflink->get(s);
|
||||
sb->setValue(atoi(s.c_str()));
|
||||
|
||||
m_hl->addWidget(sb);
|
||||
|
||||
QObject::connect(sb, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(setValue(int)));
|
||||
}
|
||||
|
||||
ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt)
|
||||
: ConfParamW(parent, cflink)
|
||||
@ -112,7 +123,7 @@ ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink& cflink,
|
||||
// le->setMinimumSize( QSize( 200, 0 ) );
|
||||
|
||||
string s;
|
||||
m_cflink.get(s);
|
||||
m_cflink->get(s);
|
||||
le->setText(QString::fromUtf8(s.c_str()));
|
||||
le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
QSizePolicy::Fixed,
|
||||
@ -126,7 +137,7 @@ ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink& cflink,
|
||||
this, SLOT(setValue(const QString&)));
|
||||
}
|
||||
|
||||
ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
const QStringList &sl
|
||||
@ -139,7 +150,7 @@ ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink& cflink,
|
||||
cmb->insertStringList(sl);
|
||||
cmb->setEditable(false);
|
||||
string s;
|
||||
m_cflink.get(s);
|
||||
m_cflink->get(s);
|
||||
QString cs = QString::fromUtf8(s.c_str());
|
||||
for (int i = 0; i < cmb->count(); i++) {
|
||||
if (!cs.compare(cmb->text(i))) {
|
||||
@ -160,7 +171,7 @@ ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink& cflink,
|
||||
this, SLOT(setValue(const QString&)));
|
||||
}
|
||||
|
||||
ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt)
|
||||
: ConfParamW(parent, cflink)
|
||||
@ -170,24 +181,33 @@ ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink& cflink,
|
||||
QCheckBox *cb = new QCheckBox(this);
|
||||
|
||||
string s;
|
||||
m_cflink.get(s);
|
||||
m_cflink->get(s);
|
||||
cb->setChecked(stringToBool(s));
|
||||
cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
QSizePolicy::Fixed,
|
||||
0, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
cb->sizePolicy().hasHeightForWidth() ) );
|
||||
|
||||
m_hl->addWidget(cb);
|
||||
|
||||
QFrame *fr = new QFrame(this);
|
||||
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
QSizePolicy::Fixed,
|
||||
1, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
fr->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(fr);
|
||||
|
||||
QObject::connect(cb, SIGNAL(toggled(bool)),
|
||||
this, SLOT(setValue(bool)));
|
||||
}
|
||||
|
||||
ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt)
|
||||
: ConfParamW(parent, cflink)
|
||||
const QString& tltptxt,
|
||||
bool isdir
|
||||
)
|
||||
: ConfParamW(parent, cflink), m_isdir(isdir)
|
||||
{
|
||||
if (!createCommon(lbltxt, tltptxt))
|
||||
return;
|
||||
@ -213,7 +233,7 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink& cflink,
|
||||
|
||||
|
||||
string s;
|
||||
m_cflink.get(s);
|
||||
m_cflink->get(s);
|
||||
m_le->setText(QString::fromUtf8(s.c_str()));
|
||||
|
||||
QObject::connect(pb, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
||||
@ -223,23 +243,20 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink& cflink,
|
||||
|
||||
void ConfParamFNW::showBrowserDialog()
|
||||
{
|
||||
QString s = QFileDialog::getOpenFileName("",
|
||||
"",
|
||||
this,
|
||||
"open file dialog",
|
||||
"Choose a file");
|
||||
QString s = m_isdir ?
|
||||
QFileDialog::getExistingDirectory() : QFileDialog::getSaveFileName();
|
||||
if (!s.isEmpty())
|
||||
m_le->setText(s);
|
||||
}
|
||||
|
||||
ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt)
|
||||
: ConfParamW(parent, cflink)
|
||||
{
|
||||
// Can't use createCommon here cause we want the buttons below the label
|
||||
m_hl = new QHBoxLayout(this);
|
||||
m_hl->setSpacing(6);
|
||||
m_hl->setSpacing(spacing);
|
||||
|
||||
QVBoxLayout *vl1 = new QVBoxLayout();
|
||||
QHBoxLayout *hl1 = new QHBoxLayout();
|
||||
@ -256,7 +273,7 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink& cflink,
|
||||
vl1->addWidget(tl);
|
||||
|
||||
QPushButton *pbA = new QPushButton(this);
|
||||
pbA->setText(tr("Add"));
|
||||
pbA->setText(tr("+"));
|
||||
pbA->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
QSizePolicy::Fixed,
|
||||
0, // Horizontal stretch
|
||||
@ -264,7 +281,7 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink& cflink,
|
||||
pbA->sizePolicy().hasHeightForWidth() ) );
|
||||
hl1->addWidget(pbA);
|
||||
QPushButton *pbD = new QPushButton(this);
|
||||
pbD->setText(tr("Delete"));
|
||||
pbD->setText(tr("-"));
|
||||
pbD->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
QSizePolicy::Fixed,
|
||||
0, // Horizontal stretch
|
||||
@ -279,7 +296,7 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink& cflink,
|
||||
m_lb = new QListBox(this);
|
||||
|
||||
string s;
|
||||
m_cflink.get(s);
|
||||
m_cflink->get(s);
|
||||
list<string> ls;
|
||||
stringToStrings(s, ls);
|
||||
QStringList qls;
|
||||
@ -328,14 +345,13 @@ void ConfParamSLW::showInputDialog()
|
||||
|
||||
void ConfParamSLW::listToConf()
|
||||
{
|
||||
LOGDEB(("ConfParamSLW::listToConf()\n"));
|
||||
list<string> ls;
|
||||
for (unsigned int i = 0; i < m_lb->count(); i++) {
|
||||
ls.push_back((const char *)m_lb->text(i));
|
||||
}
|
||||
string s;
|
||||
stringsToString(ls, s);
|
||||
m_cflink.set(s);
|
||||
m_cflink->set(s);
|
||||
}
|
||||
|
||||
void ConfParamSLW::deleteSelected()
|
||||
@ -345,7 +361,6 @@ void ConfParamSLW::deleteSelected()
|
||||
didone = false;
|
||||
for (unsigned int i = 0; i < m_lb->count(); i++) {
|
||||
if (m_lb->isSelected(i)) {
|
||||
LOGDEB(("%d is selected\n", i));
|
||||
m_lb->removeItem(i);
|
||||
didone = true;
|
||||
break;
|
||||
@ -356,13 +371,9 @@ void ConfParamSLW::deleteSelected()
|
||||
}
|
||||
|
||||
// "Add entry" dialog for a file name list
|
||||
void ConfParamFNLW::showInputDialog()
|
||||
void ConfParamDNLW::showInputDialog()
|
||||
{
|
||||
QString s = QFileDialog::getOpenFileName("",
|
||||
"",
|
||||
this,
|
||||
"open file dialog",
|
||||
"Choose a file");
|
||||
QString s = QFileDialog::getExistingDirectory();
|
||||
if (!s.isEmpty()) {
|
||||
if (m_lb->findItem(s, Qt::ExactMatch) == 0) {
|
||||
m_lb->insertItem(s);
|
||||
@ -381,8 +392,7 @@ void ConfParamCSLW::showInputDialog()
|
||||
m_sl, // List
|
||||
0, // current
|
||||
false, // editable,
|
||||
&ok,
|
||||
this);
|
||||
&ok);
|
||||
if (ok && !s.isEmpty()) {
|
||||
if (m_lb->findItem(s, Qt::ExactMatch) == 0) {
|
||||
m_lb->insertItem(s);
|
||||
@ -392,4 +402,5 @@ void ConfParamCSLW::showInputDialog()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // Namespace confgui
|
||||
|
||||
|
||||
@ -1,37 +1,42 @@
|
||||
#ifndef _confgui_h_included_
|
||||
#define _confgui_h_included_
|
||||
/* @(#$Id: confgui.h,v 1.1 2007-09-26 12:16:48 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
/* @(#$Id: confgui.h,v 1.2 2007-09-27 15:47:25 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qwidget.h>
|
||||
|
||||
#include "refcntr.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
class QHBoxLayout;
|
||||
class QLineEdit;
|
||||
class QListBox;
|
||||
class RclConfig;
|
||||
|
||||
namespace confgui {
|
||||
|
||||
// A class to isolate the gui widget from the config storage mechanism
|
||||
class ConfLink {
|
||||
class ConfLinkRep {
|
||||
public:
|
||||
virtual bool set(const string& val) = 0;
|
||||
virtual bool get(string& val) = 0;
|
||||
};
|
||||
typedef RefCntr<ConfLinkRep> ConfLink;
|
||||
|
||||
// A widget to let the user change a configuration parameter
|
||||
// A widget to let the user change one configuration
|
||||
// parameter. Subclassed for specific parameter types
|
||||
class ConfParamW : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfParamW(QWidget *parent, ConfLink &cflink)
|
||||
ConfParamW(QWidget *parent, ConfLink cflink)
|
||||
: QWidget(parent), m_cflink(cflink)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
ConfLink& m_cflink;
|
||||
ConfLink m_cflink;
|
||||
QHBoxLayout *m_hl;
|
||||
virtual bool createCommon(const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
@ -44,9 +49,11 @@ namespace confgui {
|
||||
|
||||
|
||||
// Widgets for setting the different types of configuration parameters:
|
||||
|
||||
// Int
|
||||
class ConfParamIntW : public ConfParamW {
|
||||
public:
|
||||
ConfParamIntW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamIntW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
int minvalue = INT_MIN,
|
||||
@ -56,7 +63,7 @@ namespace confgui {
|
||||
// Arbitrary string
|
||||
class ConfParamStrW : public ConfParamW {
|
||||
public:
|
||||
ConfParamStrW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
};
|
||||
@ -64,35 +71,38 @@ namespace confgui {
|
||||
// Constrained string: choose from list
|
||||
class ConfParamCStrW : public ConfParamW {
|
||||
public:
|
||||
ConfParamCStrW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt, const QStringList& sl);
|
||||
};
|
||||
|
||||
// Boolean
|
||||
class ConfParamBoolW : public ConfParamW {
|
||||
public:
|
||||
ConfParamBoolW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
};
|
||||
|
||||
// File name
|
||||
class ConfParamFNW : public ConfParamW {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfParamFNW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
const QString& tltptxt, bool isdir = false);
|
||||
protected slots:
|
||||
void showBrowserDialog();
|
||||
private:
|
||||
protected:
|
||||
QLineEdit *m_le;
|
||||
bool m_isdir;
|
||||
};
|
||||
|
||||
// String list
|
||||
class ConfParamSLW : public ConfParamW {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfParamSLW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamSLW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
protected slots:
|
||||
@ -103,11 +113,11 @@ namespace confgui {
|
||||
void listToConf();
|
||||
};
|
||||
|
||||
// File/Dir name list
|
||||
class ConfParamFNLW : public ConfParamSLW {
|
||||
// Dir name list
|
||||
class ConfParamDNLW : public ConfParamSLW {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfParamFNLW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamDNLW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt)
|
||||
: ConfParamSLW(parent, cflink, lbltxt, tltptxt)
|
||||
@ -121,7 +131,7 @@ namespace confgui {
|
||||
class ConfParamCSLW : public ConfParamSLW {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfParamCSLW(QWidget *parent, ConfLink& cflink,
|
||||
ConfParamCSLW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
const QStringList& sl)
|
||||
@ -130,9 +140,8 @@ namespace confgui {
|
||||
}
|
||||
protected slots:
|
||||
virtual void showInputDialog();
|
||||
const QStringList &m_sl;
|
||||
const QStringList m_sl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* _confgui_h_included_ */
|
||||
|
||||
195
src/qtgui/confgui/confguiindex.cpp
Normal file
195
src/qtgui/confgui/confguiindex.cpp
Normal file
@ -0,0 +1,195 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.1 2007-09-27 15:47:25 dockes Exp $ (C) 2007 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <qlayout.h>
|
||||
|
||||
#include <list>
|
||||
using std::list;
|
||||
|
||||
#include "confgui.h"
|
||||
#include "confguiindex.h"
|
||||
#include "smallut.h"
|
||||
#include "debuglog.h"
|
||||
#include "rcldb.h"
|
||||
#include "conflinkrcl.h"
|
||||
#include "execmd.h"
|
||||
|
||||
namespace confgui {
|
||||
const static int spacing = 3;
|
||||
const static int margin = 6;
|
||||
|
||||
ConfTopPanelW::ConfTopPanelW(QWidget *parent, RclConfig *config)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
|
||||
vboxLayout->setSpacing(spacing);
|
||||
vboxLayout->setMargin(margin);
|
||||
|
||||
ConfLink lnktopdirs(new ConfLinkRclRep(config, "topdirs"));
|
||||
ConfParamDNLW *etopdirs = new
|
||||
ConfParamDNLW(this, lnktopdirs, tr("Top directories"),
|
||||
tr("The list of directories where recursive "
|
||||
"indexing starts. Default: your home."));
|
||||
vboxLayout->addWidget(etopdirs);
|
||||
|
||||
ConfLink lnkskp(new ConfLinkRclRep(config, "skippedPaths"));
|
||||
ConfParamSLW *eskp = new
|
||||
ConfParamSLW(this, lnkskp, tr("List of skipped paths"),
|
||||
tr("These are names of directories which indexing "
|
||||
"will not enter.<br> May contain wildcards. "
|
||||
"Must match "
|
||||
"the paths seen by the indexer (ie: if topdirs "
|
||||
"includes '/home/me' and '/home' is actually a link "
|
||||
"to '/usr/home', a correct skippedPath entry "
|
||||
"would be '/home/tmp*', not '/usr/home/tmp*')"));
|
||||
vboxLayout->addWidget(eskp);
|
||||
|
||||
list<string> cstemlangs = Rcl::Db::getStemmerNames();
|
||||
QStringList stemlangs;
|
||||
for (list<string>::const_iterator it = cstemlangs.begin();
|
||||
it != cstemlangs.end(); it++) {
|
||||
stemlangs.push_back(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
ConfLink lnkidxsl(new ConfLinkRclRep(config, "indexstemminglanguages"));
|
||||
ConfParamCSLW *eidxsl = new
|
||||
ConfParamCSLW(this, lnkidxsl, tr("Index stemming languages"),
|
||||
tr("The languages for which stemming expansion "
|
||||
"dictionaries will be built."), stemlangs);
|
||||
vboxLayout->addWidget(eidxsl);
|
||||
|
||||
ConfLink lnk4(new ConfLinkRclRep(config, "logfilename"));
|
||||
ConfParamFNW *e4 = new
|
||||
ConfParamFNW(this, lnk4, tr("Log file name"),
|
||||
tr("The file where the messages will be written. "
|
||||
"Use 'stderr' for terminal output"), false);
|
||||
vboxLayout->addWidget(e4);
|
||||
|
||||
ConfLink lnk1(new ConfLinkRclRep(config, "loglevel"));
|
||||
ConfParamIntW *e1 = new
|
||||
ConfParamIntW(this, lnk1, tr("Log verbosity level"),
|
||||
tr("This value adjusts the amount of "
|
||||
"messages, from only errors to a "
|
||||
"lot of debugging data."), 0, 6);
|
||||
vboxLayout->addWidget(e1);
|
||||
|
||||
ConfLink lnkidxflsh(new ConfLinkRclRep(config, "idxflushmb"));
|
||||
ConfParamIntW *eidxflsh = new
|
||||
ConfParamIntW(this, lnkidxflsh, tr("Index flush megabytes interval"),
|
||||
tr("This value adjust the amount of "
|
||||
"data which is indexed betweeen flushes to disk.<br>"
|
||||
"This helps control the indexer memory usage. "
|
||||
"Default 10MB "), 0, 1000);
|
||||
vboxLayout->addWidget(eidxflsh);
|
||||
|
||||
ConfLink lnkfsocc(new ConfLinkRclRep(config, "maxfsoccuppc"));
|
||||
ConfParamIntW *efsocc = new
|
||||
ConfParamIntW(this, lnkfsocc, tr("Max disk occupation (%)"),
|
||||
tr("This is the percentage of disk occupation where "
|
||||
"indexing will fail and stop (to avoid filling up "
|
||||
"your disk). <br>"
|
||||
"0 means no limit (this is the default)."), 0, 100);
|
||||
vboxLayout->addWidget(efsocc);
|
||||
|
||||
|
||||
ConfLink lnknaspl(new ConfLinkRclRep(config, "noaspell"));
|
||||
ConfParamBoolW *enaspl = new
|
||||
ConfParamBoolW(this, lnknaspl, tr("No aspell usage"),
|
||||
tr("Disables use of aspell to generate spelling "
|
||||
"approximation in the term explorer tool.<br> "
|
||||
"Useful is aspell is absent or does not work. "));
|
||||
vboxLayout->addWidget(enaspl);
|
||||
|
||||
ConfLink lnk2(new ConfLinkRclRep(config, "aspellLanguage"));
|
||||
ConfParamStrW *e2 = new
|
||||
ConfParamStrW(this, lnk2, tr("Aspell language"),
|
||||
tr("The language for the aspell dictionary. "
|
||||
"This should look like 'en' or 'fr' ...<br>"
|
||||
"If this value is not set, the NLS environment "
|
||||
"will be used to compute it, which usually works."
|
||||
"To get an idea of what is installed on your system, "
|
||||
"type 'aspell config' and look for .dat files inside "
|
||||
"the 'data-dir' directory. "));
|
||||
vboxLayout->addWidget(e2);
|
||||
|
||||
ConfLink lnkdbd(new ConfLinkRclRep(config, "dbdir"));
|
||||
ConfParamFNW *edbd = new
|
||||
ConfParamFNW(this, lnkdbd, tr("Database directory name"),
|
||||
tr("The name for a directory where to store the index<br>"
|
||||
"A non-absolute path is taken relative to the "
|
||||
" configuration directory. The default is 'xapiandb'."
|
||||
), true);
|
||||
vboxLayout->addWidget(edbd);
|
||||
|
||||
ConfLink lnkusfc(new ConfLinkRclRep(config, "usesystemfilecommand"));
|
||||
ConfParamBoolW *eusfc = new
|
||||
ConfParamBoolW(this, lnkusfc, tr("Use system's 'file' command"),
|
||||
tr("Use the system's 'file' command if internal "
|
||||
"mime type identification fails."));
|
||||
vboxLayout->addWidget(eusfc);
|
||||
}
|
||||
|
||||
ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
|
||||
vboxLayout->setSpacing(spacing);
|
||||
vboxLayout->setMargin(margin);
|
||||
|
||||
ConfLink lnkskn(new ConfLinkRclRep(config, "skippedNames"));
|
||||
ConfParamSLW *eskn = new
|
||||
ConfParamSLW(this, lnkskn, tr("List of skipped names"),
|
||||
tr("These are patterns for file or directory names which "
|
||||
"should not be indexed. "));
|
||||
vboxLayout->addWidget(eskn);
|
||||
|
||||
list<string> args;
|
||||
args.push_back("-l");
|
||||
ExecCmd ex;
|
||||
string icout;
|
||||
string cmd = "iconv";
|
||||
int status = ex.doexec(cmd, args, 0, &icout);
|
||||
if (status) {
|
||||
LOGERR(("Can't get list of charsets from 'iconv -l'"));
|
||||
}
|
||||
icout = neutchars(icout, ",");
|
||||
list<string> ccsets;
|
||||
stringToStrings(icout, ccsets);
|
||||
QStringList charsets;
|
||||
charsets.push_back("");
|
||||
for (list<string>::const_iterator it = ccsets.begin();
|
||||
it != ccsets.end(); it++) {
|
||||
charsets.push_back(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
|
||||
ConfLink lnk21(new ConfLinkRclRep(config, "defaultcharset"));
|
||||
ConfParamCStrW *e21 = new
|
||||
ConfParamCStrW(this, lnk21, tr("Default character set"),
|
||||
tr("This is the character set used for reading files "
|
||||
"which do not identify the character set "
|
||||
"internally, for example pure text files.<br>"
|
||||
"The default value is empty, "
|
||||
"and the value from the NLS environnement is used."
|
||||
), charsets);
|
||||
vboxLayout->addWidget(e21);
|
||||
|
||||
|
||||
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks"));
|
||||
ConfParamBoolW *e3 = new
|
||||
ConfParamBoolW(this, lnk3, tr("Follow symbolic links"),
|
||||
tr("Follow symbolic links while "
|
||||
"indexing. The default is no, "
|
||||
"to avoid duplicate indexing"));
|
||||
vboxLayout->addWidget(e3);
|
||||
|
||||
ConfLink lnkafln(new ConfLinkRclRep(config, "indexallfilenames"));
|
||||
ConfParamBoolW *eafln = new
|
||||
ConfParamBoolW(this, lnkafln, tr("Index all file names"),
|
||||
tr("Index the names of files for which the contents "
|
||||
"cannot be identified or processed (no or "
|
||||
"unsupported mime type). Default true"));
|
||||
vboxLayout->addWidget(eafln);
|
||||
}
|
||||
|
||||
|
||||
} // Namespace confgui
|
||||
23
src/qtgui/confgui/confguiindex.h
Normal file
23
src/qtgui/confgui/confguiindex.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef _confguiindex_h_included_
|
||||
#define _confguiindex_h_included_
|
||||
/* @(#$Id: confguiindex.h,v 1.1 2007-09-27 15:47:25 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
|
||||
#include <qwidget.h>
|
||||
|
||||
class RclConfig;
|
||||
|
||||
namespace confgui {
|
||||
// A panel with the top-level parameters (can't change in subdirs)
|
||||
class ConfTopPanelW : public QWidget {
|
||||
public:
|
||||
ConfTopPanelW(QWidget *parent, RclConfig *config);
|
||||
};
|
||||
|
||||
// A panel for the parameters that can be changed in subdirectories
|
||||
class ConfSubPanelW : public QWidget {
|
||||
public:
|
||||
ConfSubPanelW(QWidget *parent, RclConfig *config);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _confguiindex_h_included_ */
|
||||
48
src/qtgui/confgui/conflinkrcl.h
Normal file
48
src/qtgui/confgui/conflinkrcl.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef _CONFLINKRCL_H_INCLUDED_
|
||||
#define _CONFLINKRCL_H_INCLUDED_
|
||||
/* @(#$Id: conflinkrcl.h,v 1.1 2007-09-27 15:47:25 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include "confgui.h"
|
||||
#include "rclconfig.h"
|
||||
#include "debuglog.h"
|
||||
|
||||
namespace confgui {
|
||||
|
||||
class ConfLinkRclRep : public ConfLinkRep {
|
||||
public:
|
||||
ConfLinkRclRep(RclConfig *conf, const string& nm,
|
||||
const string& sk = "")
|
||||
: m_conf(conf), m_nm(nm), m_sk(sk)
|
||||
{
|
||||
}
|
||||
virtual ~ConfLinkRclRep() {}
|
||||
|
||||
virtual bool set(const string& val)
|
||||
{
|
||||
if (!m_conf)
|
||||
return false;
|
||||
LOGDEB(("Setting [%s] value to [%s]\n",
|
||||
m_nm.c_str(), val.c_str()));
|
||||
bool ret = m_conf->setConfParam(m_nm, val);
|
||||
if (!ret)
|
||||
LOGERR(("Value set failed\n"));
|
||||
return ret;
|
||||
}
|
||||
virtual bool get(string& val)
|
||||
{
|
||||
if (!m_conf)
|
||||
return false;
|
||||
bool ret = m_conf->getConfParam(m_nm, val);
|
||||
LOGDEB(("Got [%s] for [%s]\n",
|
||||
ret ? val.c_str() : "no value", m_nm.c_str()));
|
||||
return ret;
|
||||
}
|
||||
private:
|
||||
RclConfig *m_conf;
|
||||
const string m_nm;
|
||||
const string m_sk;
|
||||
};
|
||||
|
||||
} // Namespace confgui
|
||||
|
||||
#endif /* _CONFLINKRCL_H_INCLUDED_ */
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.1 2007-09-26 12:16:48 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.2 2007-09-27 15:47:25 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -21,8 +21,9 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.1 2007-09-26 12:16:48 dockes Exp $ (
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using std::string;
|
||||
using namespace std;
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@ -33,10 +34,14 @@ using std::string;
|
||||
#include <qthread.h>
|
||||
#include <qtimer.h>
|
||||
#include <qlayout.h>
|
||||
#include <qframe.h>
|
||||
|
||||
#include "pathut.h"
|
||||
#include "confgui.h"
|
||||
#include "confguiindex.h"
|
||||
#include "debuglog.h"
|
||||
#include "rclconfig.h"
|
||||
#include "execmd.h"
|
||||
#include "conflinkrcl.h"
|
||||
|
||||
using namespace confgui;
|
||||
|
||||
@ -62,7 +67,7 @@ Usage(void)
|
||||
exit((op_flags & OPT_h)==0);
|
||||
}
|
||||
|
||||
class ConfLinkNull : public ConfLink {
|
||||
class ConfLinkNullRep : public ConfLinkRep {
|
||||
public:
|
||||
virtual bool set(const string& val)
|
||||
{
|
||||
@ -72,12 +77,17 @@ class ConfLinkNull : public ConfLink {
|
||||
virtual bool get(string& val) {val = ""; return true;}
|
||||
};
|
||||
|
||||
static RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// fprintf(stderr, "Application created\n");
|
||||
string a_config;
|
||||
thisprog = argv[0];
|
||||
argc--; argv++;
|
||||
|
||||
@ -96,6 +106,15 @@ int main(int argc, char **argv)
|
||||
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
||||
DebugLog::setfilename("stderr");
|
||||
|
||||
string a_config = "tstconfdir";
|
||||
config = new RclConfig(&a_config);
|
||||
if (config == 0 || !config->ok()) {
|
||||
cerr << "Cant read configuration in: " << a_config << endl;
|
||||
exit(1);
|
||||
}
|
||||
cerr << "Working with configuration file in: " << config->getConfDir()
|
||||
<< endl;
|
||||
|
||||
// Translation file for Qt
|
||||
QTranslator qt( 0 );
|
||||
qt.load( QString( "qt_" ) + QTextCodec::locale(), "." );
|
||||
@ -113,59 +132,19 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
QWidget w;
|
||||
ConfLinkNull lnk;
|
||||
|
||||
QVBoxLayout *vboxLayout = new QVBoxLayout(&w);
|
||||
vboxLayout->setSpacing(6);
|
||||
vboxLayout->setMargin(11);
|
||||
|
||||
vboxLayout->addWidget(new ConfTopPanelW(&w, config));
|
||||
|
||||
ConfParamIntW *e1 = new ConfParamIntW(&w, lnk, "The text for the label",
|
||||
"The text for the tooltip");
|
||||
vboxLayout->addWidget(e1);
|
||||
QFrame *line2 = new QFrame(&w);
|
||||
line2->setFrameShape(QFrame::HLine);
|
||||
line2->setFrameShadow(QFrame::Sunken);
|
||||
vboxLayout->addWidget(line2);
|
||||
|
||||
ConfParamStrW *e2 = new ConfParamStrW(&w, lnk,
|
||||
"The text for the string label",
|
||||
"The text for the string tooltip");
|
||||
vboxLayout->addWidget(e2);
|
||||
|
||||
QStringList valuelist;
|
||||
valuelist.push_back("aone");
|
||||
valuelist.push_back("btwo");
|
||||
valuelist.push_back("cthree");
|
||||
valuelist.push_back("dfour");
|
||||
|
||||
ConfParamCStrW *e21 = new ConfParamCStrW(&w, lnk,
|
||||
"The text for the string label",
|
||||
"The text for the string tooltip",
|
||||
valuelist);
|
||||
vboxLayout->addWidget(e21);
|
||||
|
||||
|
||||
ConfParamBoolW *e3 = new ConfParamBoolW(&w, lnk,
|
||||
"The text for the Bool label",
|
||||
"The text for the Bool tooltip");
|
||||
vboxLayout->addWidget(e3);
|
||||
|
||||
ConfParamFNW *e4 = new ConfParamFNW(&w, lnk,
|
||||
"The text for the File Name label",
|
||||
"The text for the File Name tooltip");
|
||||
vboxLayout->addWidget(e4);
|
||||
|
||||
ConfParamSLW *e5 = new ConfParamSLW(&w, lnk,
|
||||
"The text for the String List label",
|
||||
"The text for the String List tooltip");
|
||||
vboxLayout->addWidget(e5);
|
||||
|
||||
ConfParamFNLW *e6 = new ConfParamFNLW(&w, lnk,
|
||||
"The text for the File List label",
|
||||
"The text for the File List tooltip");
|
||||
vboxLayout->addWidget(e6);
|
||||
|
||||
ConfParamCSLW *e7 = new ConfParamCSLW(&w, lnk,
|
||||
"The text for the File List label",
|
||||
"The text for the File List tooltip",
|
||||
valuelist);
|
||||
vboxLayout->addWidget(e7);
|
||||
vboxLayout->addWidget(new ConfSubPanelW(&w, config));
|
||||
|
||||
QSize size(0, 0);
|
||||
size = size.expandedTo(w.minimumSizeHint());
|
||||
|
||||
@ -5,7 +5,7 @@ CONFIG += qt warn_on thread release debug
|
||||
|
||||
HEADERS += confgui.h
|
||||
|
||||
SOURCES += main.cpp confgui.cpp
|
||||
SOURCES += main.cpp confgui.cpp confguiindex.cpp
|
||||
|
||||
#FORMS =
|
||||
|
||||
@ -15,9 +15,9 @@ unix {
|
||||
OBJECTS_DIR = .obj
|
||||
|
||||
DEFINES += RECOLL_DATADIR=\"/usr/local/share/recoll\"
|
||||
LIBS += ../../lib/librcl.a -lz
|
||||
LIBS += ../../lib/librcl.a -lxapian -liconv -lz
|
||||
|
||||
INCLUDEPATH += ../../common ../../utils
|
||||
INCLUDEPATH += ../../common ../../utils ../../rcldb
|
||||
#../index ../internfile ../query ../unac \
|
||||
# ../aspell ../rcldb
|
||||
POST_TARGETDEPS = ../../lib/librcl.a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user