*** empty log message ***
This commit is contained in:
parent
d3e20ceeeb
commit
2456f5a0a4
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: confgui.cpp,v 1.2 2007-09-27 15:47:25 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: confgui.cpp,v 1.3 2007-09-29 09:06:53 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -19,6 +19,7 @@ static char rcsid[] = "@(#$Id: confgui.cpp,v 1.2 2007-09-27 15:47:25 dockes Exp
|
||||
#include <qstringlist.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qframe.h>
|
||||
|
||||
#include "confgui.h"
|
||||
#include "smallut.h"
|
||||
@ -51,6 +52,11 @@ void ConfParamW::setValue(bool value)
|
||||
m_cflink->set(string(buf));
|
||||
}
|
||||
|
||||
void ConfParamW::loadValue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
||||
{
|
||||
m_hl = new QHBoxLayout(this);
|
||||
@ -70,7 +76,7 @@ bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
||||
|
||||
return true;
|
||||
}
|
||||
#include <qframe.h>
|
||||
|
||||
ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
@ -81,18 +87,17 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
||||
if (!createCommon(lbltxt, tltptxt))
|
||||
return;
|
||||
|
||||
|
||||
QSpinBox *sb = new QSpinBox(this);
|
||||
m_sb = new QSpinBox(this);
|
||||
// sb->setMinimum(minvalue);
|
||||
sb->setMinValue(minvalue);
|
||||
m_sb->setMinValue(minvalue);
|
||||
// sb->setMaximum(maxvalue);
|
||||
sb->setMaxValue(maxvalue);
|
||||
sb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
m_sb->setMaxValue(maxvalue);
|
||||
m_sb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
QSizePolicy::Fixed,
|
||||
0, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
sb->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(sb);
|
||||
m_sb->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(m_sb);
|
||||
|
||||
QFrame *fr = new QFrame(this);
|
||||
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
@ -103,13 +108,17 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
||||
m_hl->addWidget(fr);
|
||||
|
||||
|
||||
loadValue();
|
||||
|
||||
QObject::connect(m_sb, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(setValue(int)));
|
||||
}
|
||||
|
||||
void ConfParamIntW::loadValue()
|
||||
{
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
sb->setValue(atoi(s.c_str()));
|
||||
|
||||
|
||||
QObject::connect(sb, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(setValue(int)));
|
||||
m_sb->setValue(atoi(s.c_str()));
|
||||
}
|
||||
|
||||
ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||
@ -119,24 +128,30 @@ ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||
{
|
||||
if (!createCommon(lbltxt, tltptxt))
|
||||
return;
|
||||
QLineEdit *le = new QLineEdit(this);
|
||||
// le->setMinimumSize( QSize( 200, 0 ) );
|
||||
m_le = new QLineEdit(this);
|
||||
// m_le->setMinimumSize( QSize( 200, 0 ) );
|
||||
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
le->setText(QString::fromUtf8(s.c_str()));
|
||||
le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
loadValue();
|
||||
|
||||
m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
QSizePolicy::Fixed,
|
||||
1, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
le->sizePolicy().hasHeightForWidth() ) );
|
||||
m_le->sizePolicy().hasHeightForWidth() ) );
|
||||
|
||||
m_hl->addWidget(le);
|
||||
m_hl->addWidget(m_le);
|
||||
|
||||
QObject::connect(le, SIGNAL(textChanged(const QString&)),
|
||||
QObject::connect(m_le, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(setValue(const QString&)));
|
||||
}
|
||||
|
||||
void ConfParamStrW::loadValue()
|
||||
{
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
m_le->setText(QString::fromUtf8(s.c_str()));
|
||||
}
|
||||
|
||||
ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
@ -146,49 +161,55 @@ ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||
{
|
||||
if (!createCommon(lbltxt, tltptxt))
|
||||
return;
|
||||
QComboBox *cmb = new QComboBox(this);
|
||||
cmb->insertStringList(sl);
|
||||
cmb->setEditable(false);
|
||||
string 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))) {
|
||||
cmb->setCurrentItem(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_cmb = new QComboBox(this);
|
||||
m_cmb->insertStringList(sl);
|
||||
m_cmb->setEditable(false);
|
||||
|
||||
cmb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
loadValue();
|
||||
|
||||
m_cmb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
QSizePolicy::Fixed,
|
||||
1, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
cmb->sizePolicy().hasHeightForWidth() ) );
|
||||
m_cmb->sizePolicy().hasHeightForWidth() ) );
|
||||
|
||||
m_hl->addWidget(cmb);
|
||||
m_hl->addWidget(m_cmb);
|
||||
|
||||
QObject::connect(cmb, SIGNAL(activated(const QString&)),
|
||||
QObject::connect(m_cmb, SIGNAL(activated(const QString&)),
|
||||
this, SLOT(setValue(const QString&)));
|
||||
}
|
||||
|
||||
void ConfParamCStrW::loadValue()
|
||||
{
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
QString cs = QString::fromUtf8(s.c_str());
|
||||
for (int i = 0; i < m_cmb->count(); i++) {
|
||||
if (!cs.compare(m_cmb->text(i))) {
|
||||
m_cmb->setCurrentItem(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt)
|
||||
: ConfParamW(parent, cflink)
|
||||
{
|
||||
if (!createCommon(lbltxt, tltptxt))
|
||||
return;
|
||||
QCheckBox *cb = new QCheckBox(this);
|
||||
// No createCommon because the checkbox has a label
|
||||
m_hl = new QHBoxLayout(this);
|
||||
m_hl->setSpacing(spacing);
|
||||
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
cb->setChecked(stringToBool(s));
|
||||
cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
m_cb = new QCheckBox(lbltxt, this);
|
||||
|
||||
m_cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||
QSizePolicy::Fixed,
|
||||
0, // Horizontal stretch
|
||||
0, // Vertical stretch
|
||||
cb->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(cb);
|
||||
m_cb->sizePolicy().hasHeightForWidth() ) );
|
||||
QToolTip::add(m_cb, tltptxt);
|
||||
m_hl->addWidget(m_cb);
|
||||
|
||||
QFrame *fr = new QFrame(this);
|
||||
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
@ -198,10 +219,17 @@ ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||
fr->sizePolicy().hasHeightForWidth() ) );
|
||||
m_hl->addWidget(fr);
|
||||
|
||||
QObject::connect(cb, SIGNAL(toggled(bool)),
|
||||
QObject::connect(m_cb, SIGNAL(toggled(bool)),
|
||||
this, SLOT(setValue(bool)));
|
||||
}
|
||||
|
||||
void ConfParamBoolW::loadValue()
|
||||
{
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
m_cb->setChecked(stringToBool(s));
|
||||
}
|
||||
|
||||
ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt,
|
||||
@ -212,7 +240,6 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||
if (!createCommon(lbltxt, tltptxt))
|
||||
return;
|
||||
|
||||
|
||||
m_le = new QLineEdit(this);
|
||||
m_le->setMinimumSize(QSize(150, 0 ));
|
||||
m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||
@ -232,15 +259,18 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||
m_hl->addWidget(pb);
|
||||
|
||||
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
m_le->setText(QString::fromUtf8(s.c_str()));
|
||||
|
||||
QObject::connect(pb, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
||||
QObject::connect(m_le, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(setValue(const QString&)));
|
||||
}
|
||||
|
||||
void ConfParamFNW::loadValue()
|
||||
{
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
m_le->setText(QString::fromUtf8(s.c_str()));
|
||||
}
|
||||
|
||||
void ConfParamFNW::showBrowserDialog()
|
||||
{
|
||||
QString s = m_isdir ?
|
||||
@ -295,15 +325,7 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink,
|
||||
|
||||
m_lb = new QListBox(this);
|
||||
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
list<string> ls;
|
||||
stringToStrings(s, ls);
|
||||
QStringList qls;
|
||||
for (list<string>::const_iterator it = ls.begin(); it != ls.end(); it++) {
|
||||
qls.push_back(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
m_lb->insertStringList(qls);
|
||||
loadValue();
|
||||
|
||||
m_lb->setSelectionMode(QListBox::Extended);
|
||||
|
||||
@ -325,6 +347,20 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink,
|
||||
QObject::connect(pbD, SIGNAL(clicked()), this, SLOT(deleteSelected()));
|
||||
}
|
||||
|
||||
void ConfParamSLW::loadValue()
|
||||
{
|
||||
string s;
|
||||
m_cflink->get(s);
|
||||
list<string> ls;
|
||||
stringToStrings(s, ls);
|
||||
QStringList qls;
|
||||
for (list<string>::const_iterator it = ls.begin(); it != ls.end(); it++) {
|
||||
qls.push_back(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
m_lb->clear();
|
||||
m_lb->insertStringList(qls);
|
||||
}
|
||||
|
||||
void ConfParamSLW::showInputDialog()
|
||||
{
|
||||
bool ok;
|
||||
@ -361,6 +397,7 @@ void ConfParamSLW::deleteSelected()
|
||||
didone = false;
|
||||
for (unsigned int i = 0; i < m_lb->count(); i++) {
|
||||
if (m_lb->isSelected(i)) {
|
||||
emit entryDeleted(m_lb->text(i));
|
||||
m_lb->removeItem(i);
|
||||
didone = true;
|
||||
break;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#ifndef _confgui_h_included_
|
||||
#define _confgui_h_included_
|
||||
/* @(#$Id: confgui.h,v 1.2 2007-09-27 15:47:25 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
/* @(#$Id: confgui.h,v 1.3 2007-09-29 09:06:53 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -15,6 +15,9 @@ class QHBoxLayout;
|
||||
class QLineEdit;
|
||||
class QListBox;
|
||||
class RclConfig;
|
||||
class QSpinBox;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
|
||||
namespace confgui {
|
||||
|
||||
@ -26,6 +29,16 @@ namespace confgui {
|
||||
};
|
||||
typedef RefCntr<ConfLinkRep> ConfLink;
|
||||
|
||||
class ConfLinkNullRep : public ConfLinkRep {
|
||||
public:
|
||||
virtual bool set(const string&)
|
||||
{
|
||||
//fprintf(stderr, "Setting value to [%s]\n", val.c_str());
|
||||
return true;
|
||||
}
|
||||
virtual bool get(string& val) {val = ""; return true;}
|
||||
};
|
||||
|
||||
// A widget to let the user change one configuration
|
||||
// parameter. Subclassed for specific parameter types
|
||||
class ConfParamW : public QWidget {
|
||||
@ -35,9 +48,12 @@ namespace confgui {
|
||||
: QWidget(parent), m_cflink(cflink)
|
||||
{
|
||||
}
|
||||
virtual void loadValue() = 0;
|
||||
|
||||
protected:
|
||||
ConfLink m_cflink;
|
||||
ConfLink m_cflink;
|
||||
QHBoxLayout *m_hl;
|
||||
|
||||
virtual bool createCommon(const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
|
||||
@ -58,6 +74,9 @@ namespace confgui {
|
||||
const QString& tltptxt,
|
||||
int minvalue = INT_MIN,
|
||||
int maxvalue = INT_MAX);
|
||||
virtual void loadValue();
|
||||
protected:
|
||||
QSpinBox *m_sb;
|
||||
};
|
||||
|
||||
// Arbitrary string
|
||||
@ -66,6 +85,9 @@ namespace confgui {
|
||||
ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
virtual void loadValue();
|
||||
protected:
|
||||
QLineEdit *m_le;
|
||||
};
|
||||
|
||||
// Constrained string: choose from list
|
||||
@ -74,6 +96,9 @@ namespace confgui {
|
||||
ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt, const QStringList& sl);
|
||||
virtual void loadValue();
|
||||
protected:
|
||||
QComboBox *m_cmb;
|
||||
};
|
||||
|
||||
// Boolean
|
||||
@ -82,6 +107,9 @@ namespace confgui {
|
||||
ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
virtual void loadValue();
|
||||
protected:
|
||||
QCheckBox *m_cb;
|
||||
};
|
||||
|
||||
// File name
|
||||
@ -91,6 +119,7 @@ namespace confgui {
|
||||
ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt, bool isdir = false);
|
||||
virtual void loadValue();
|
||||
protected slots:
|
||||
void showBrowserDialog();
|
||||
protected:
|
||||
@ -105,12 +134,18 @@ namespace confgui {
|
||||
ConfParamSLW(QWidget *parent, ConfLink cflink,
|
||||
const QString& lbltxt,
|
||||
const QString& tltptxt);
|
||||
virtual void loadValue();
|
||||
QListBox *getListBox() {return m_lb;}
|
||||
|
||||
protected slots:
|
||||
virtual void showInputDialog();
|
||||
void deleteSelected();
|
||||
signals:
|
||||
void entryDeleted(QString);
|
||||
protected:
|
||||
QListBox *m_lb;
|
||||
void listToConf();
|
||||
|
||||
};
|
||||
|
||||
// Dir name list
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.1 2007-09-27 15:47:25 dockes Exp $ (C) 2007 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.2 2007-09-29 09:06:53 dockes Exp $ (C) 2007 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <qlayout.h>
|
||||
#include <qframe.h>
|
||||
#include <qwidget.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include <list>
|
||||
using std::list;
|
||||
@ -130,18 +135,58 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, RclConfig *config)
|
||||
}
|
||||
|
||||
ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent), m_config(config)
|
||||
{
|
||||
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
|
||||
vboxLayout->setSpacing(spacing);
|
||||
vboxLayout->setMargin(margin);
|
||||
|
||||
ConfLink lnkskn(new ConfLinkRclRep(config, "skippedNames"));
|
||||
ConfLink lnksubkeydirs(new ConfLinkNullRep());
|
||||
m_subdirs = new
|
||||
ConfParamDNLW(this, lnksubkeydirs,
|
||||
QObject::tr("Subdirectories with specific parameters"),
|
||||
QObject::tr("The list of subdirectories in the indexed "
|
||||
"hierarchy where some parameters need to be "
|
||||
"customised. "
|
||||
"Default: empty."));
|
||||
m_subdirs->getListBox()->setSelectionMode(QListBox::Single);
|
||||
connect(m_subdirs->getListBox(), SIGNAL(selectionChanged()),
|
||||
this, SLOT(subDirChanged()));
|
||||
connect(m_subdirs, SIGNAL(entryDeleted(QString)),
|
||||
this, SLOT(subDirDeleted(QString)));
|
||||
list<string> allkeydirs = config->getKeyDirs();
|
||||
QStringList qls;
|
||||
for (list<string>::const_iterator it = allkeydirs.begin();
|
||||
it != allkeydirs.end(); it++) {
|
||||
qls.push_back(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
m_subdirs->getListBox()->insertStringList(qls);
|
||||
|
||||
vboxLayout->addWidget(m_subdirs);
|
||||
|
||||
QLabel *explain = new QLabel(this);
|
||||
explain->setText(
|
||||
QObject::
|
||||
tr("<i>The following parameters are set either at the "
|
||||
"top level (no selection or empty line selected) "
|
||||
"or for the selected subdirectory. "
|
||||
"You can add / remove directories by clicking "
|
||||
"the +/- buttons."));
|
||||
vboxLayout->addWidget(explain);
|
||||
|
||||
QFrame *line2 = new QFrame(this);
|
||||
line2->setFrameShape(QFrame::HLine);
|
||||
line2->setFrameShadow(QFrame::Sunken);
|
||||
vboxLayout->addWidget(line2);
|
||||
|
||||
ConfLink lnkskn(new ConfLinkRclRep(config, "skippedNames", &m_sk));
|
||||
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. "));
|
||||
ConfParamSLW(this, lnkskn,
|
||||
QObject::tr("List of skipped names"),
|
||||
QObject::tr("These are patterns for file or directory "
|
||||
" names which should not be indexed."));
|
||||
vboxLayout->addWidget(eskn);
|
||||
m_widgets.push_back(eskn);
|
||||
|
||||
list<string> args;
|
||||
args.push_back("-l");
|
||||
@ -162,34 +207,78 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
|
||||
charsets.push_back(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
|
||||
ConfLink lnk21(new ConfLinkRclRep(config, "defaultcharset"));
|
||||
ConfLink lnk21(new ConfLinkRclRep(config, "defaultcharset", &m_sk));
|
||||
ConfParamCStrW *e21 = new
|
||||
ConfParamCStrW(this, lnk21, tr("Default character set"),
|
||||
tr("This is the character set used for reading files "
|
||||
ConfParamCStrW(this, lnk21,
|
||||
QObject::tr("Default character set"),
|
||||
QObject::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);
|
||||
m_widgets.push_back(e21);
|
||||
|
||||
|
||||
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks"));
|
||||
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks", &m_sk));
|
||||
ConfParamBoolW *e3 = new
|
||||
ConfParamBoolW(this, lnk3, tr("Follow symbolic links"),
|
||||
tr("Follow symbolic links while "
|
||||
ConfParamBoolW(this, lnk3,
|
||||
QObject::tr("Follow symbolic links"),
|
||||
QObject::tr("Follow symbolic links while "
|
||||
"indexing. The default is no, "
|
||||
"to avoid duplicate indexing"));
|
||||
vboxLayout->addWidget(e3);
|
||||
m_widgets.push_back(e3);
|
||||
|
||||
ConfLink lnkafln(new ConfLinkRclRep(config, "indexallfilenames"));
|
||||
ConfLink lnkafln(new ConfLinkRclRep(config, "indexallfilenames", &m_sk));
|
||||
ConfParamBoolW *eafln = new
|
||||
ConfParamBoolW(this, lnkafln, tr("Index all file names"),
|
||||
tr("Index the names of files for which the contents "
|
||||
ConfParamBoolW(this, lnkafln,
|
||||
QObject::tr("Index all file names"),
|
||||
QObject::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);
|
||||
m_widgets.push_back(eafln);
|
||||
}
|
||||
|
||||
void ConfSubPanelW::reloadAll()
|
||||
{
|
||||
for (list<ConfParamW*>::iterator it = m_widgets.begin();
|
||||
it != m_widgets.end(); it++) {
|
||||
(*it)->loadValue();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfSubPanelW::subDirChanged()
|
||||
{
|
||||
LOGDEB(("ConfSubPanelW::subDirChanged\n"));
|
||||
QListBoxItem *item = m_subdirs->getListBox()->selectedItem();
|
||||
if (item == 0) {
|
||||
m_sk = "";
|
||||
} else {
|
||||
m_sk = (const char *)item->text().utf8();
|
||||
}
|
||||
LOGDEB(("ConfSubPanelW::subDirChanged: now [%s]\n", m_sk.c_str()));
|
||||
reloadAll();
|
||||
}
|
||||
|
||||
void ConfSubPanelW::subDirDeleted(QString sbd)
|
||||
{
|
||||
LOGDEB(("ConfSubPanelW::subDirDeleted(%s)\n", (const char *)sbd.utf8()));
|
||||
if (sbd == "") {
|
||||
// Can't do this, have to reinsert it
|
||||
QTimer::singleShot(0, this, SLOT(restoreEmpty()));
|
||||
return;
|
||||
}
|
||||
// Have to delete all entries for submap
|
||||
m_config->setKeyDir((const char *)sbd.utf8());
|
||||
m_config->eraseKeyDir();
|
||||
}
|
||||
|
||||
void ConfSubPanelW::restoreEmpty()
|
||||
{
|
||||
LOGDEB(("ConfSubPanelW::restoreEmpty()\n"));
|
||||
m_subdirs->getListBox()->insertItem("", 0);
|
||||
}
|
||||
|
||||
} // Namespace confgui
|
||||
|
||||
@ -1,23 +1,64 @@
|
||||
#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 */
|
||||
/* @(#$Id: confguiindex.h,v 1.2 2007-09-29 09:06:53 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
|
||||
/**
|
||||
* Classes to handle the gui for the indexing configuration. These group
|
||||
* confgui elements, linked to configuration parameters, into panels.
|
||||
*/
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <qstring.h>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
using std::string;
|
||||
using std::list;
|
||||
|
||||
|
||||
class RclConfig;
|
||||
class ConfParamW;
|
||||
class ConfParamDNLW;
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A panel with the top-level parameters which can't be redefined in
|
||||
* subdirectoriess:
|
||||
*/
|
||||
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 {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfSubPanelW(QWidget *parent, RclConfig *config);
|
||||
|
||||
void setkeydir(const string& sk)
|
||||
{
|
||||
m_sk = sk;
|
||||
reloadAll();
|
||||
}
|
||||
void reloadAll();
|
||||
public slots:
|
||||
void subDirChanged();
|
||||
void subDirDeleted(QString);
|
||||
void restoreEmpty();
|
||||
private:
|
||||
string m_sk;
|
||||
ConfParamDNLW *m_subdirs;
|
||||
list<ConfParamW*> m_widgets;
|
||||
RclConfig *m_config;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // Namespace confgui
|
||||
|
||||
#endif /* _confguiindex_h_included_ */
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
#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 */
|
||||
/* @(#$Id: conflinkrcl.h,v 1.2 2007-09-29 09:06:53 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
/**
|
||||
* A Gui-to-Data link class for RclConfig
|
||||
* Has a subkey pointer member which makes it easy to change the
|
||||
* current subkey for a number at a time.
|
||||
*/
|
||||
#include "confgui.h"
|
||||
#include "rclconfig.h"
|
||||
#include "debuglog.h"
|
||||
@ -11,7 +16,7 @@ namespace confgui {
|
||||
class ConfLinkRclRep : public ConfLinkRep {
|
||||
public:
|
||||
ConfLinkRclRep(RclConfig *conf, const string& nm,
|
||||
const string& sk = "")
|
||||
string *sk = 0)
|
||||
: m_conf(conf), m_nm(nm), m_sk(sk)
|
||||
{
|
||||
}
|
||||
@ -21,8 +26,9 @@ public:
|
||||
{
|
||||
if (!m_conf)
|
||||
return false;
|
||||
LOGDEB(("Setting [%s] value to [%s]\n",
|
||||
LOGDEB1(("Setting [%s] value to [%s]\n",
|
||||
m_nm.c_str(), val.c_str()));
|
||||
m_conf->setKeyDir(m_sk ? *m_sk : "");
|
||||
bool ret = m_conf->setConfParam(m_nm, val);
|
||||
if (!ret)
|
||||
LOGERR(("Value set failed\n"));
|
||||
@ -32,15 +38,16 @@ public:
|
||||
{
|
||||
if (!m_conf)
|
||||
return false;
|
||||
m_conf->setKeyDir(m_sk ? *m_sk : "");
|
||||
bool ret = m_conf->getConfParam(m_nm, val);
|
||||
LOGDEB(("Got [%s] for [%s]\n",
|
||||
LOGDEB1(("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;
|
||||
RclConfig *m_conf;
|
||||
const string m_nm;
|
||||
const string *m_sk;
|
||||
};
|
||||
|
||||
} // Namespace confgui
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.2 2007-09-27 15:47:25 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.3 2007-09-29 09:06:53 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -27,14 +27,16 @@ using namespace std;
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qapplication.h>
|
||||
#include <qtranslator.h>
|
||||
|
||||
#include <qtextcodec.h>
|
||||
#include <qthread.h>
|
||||
#include <qtimer.h>
|
||||
#include <qlayout.h>
|
||||
#include <qframe.h>
|
||||
#include <qwidget.h>
|
||||
#include <qlabel.h>
|
||||
|
||||
#include "pathut.h"
|
||||
#include "confguiindex.h"
|
||||
@ -67,15 +69,6 @@ Usage(void)
|
||||
exit((op_flags & OPT_h)==0);
|
||||
}
|
||||
|
||||
class ConfLinkNullRep : public ConfLinkRep {
|
||||
public:
|
||||
virtual bool set(const string& val)
|
||||
{
|
||||
fprintf(stderr, "Setting value to [%s]\n", val.c_str());
|
||||
return true;
|
||||
}
|
||||
virtual bool get(string& val) {val = ""; return true;}
|
||||
};
|
||||
|
||||
static RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
@ -139,10 +132,10 @@ int main(int argc, char **argv)
|
||||
|
||||
vboxLayout->addWidget(new ConfTopPanelW(&w, config));
|
||||
|
||||
QFrame *line2 = new QFrame(&w);
|
||||
line2->setFrameShape(QFrame::HLine);
|
||||
line2->setFrameShadow(QFrame::Sunken);
|
||||
vboxLayout->addWidget(line2);
|
||||
QFrame *line1 = new QFrame(&w);
|
||||
line1->setFrameShape(QFrame::HLine);
|
||||
line1->setFrameShadow(QFrame::Sunken);
|
||||
vboxLayout->addWidget(line1);
|
||||
|
||||
vboxLayout->addWidget(new ConfSubPanelW(&w, config));
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ LANGUAGE = C++
|
||||
|
||||
CONFIG += qt warn_on thread release debug
|
||||
|
||||
HEADERS += confgui.h
|
||||
HEADERS += confgui.h confguiindex.h
|
||||
|
||||
SOURCES += main.cpp confgui.cpp confguiindex.cpp
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user