*** empty log message ***
This commit is contained in:
parent
d3e20ceeeb
commit
2456f5a0a4
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#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 <qstringlist.h>
|
||||||
#include <qlistbox.h>
|
#include <qlistbox.h>
|
||||||
#include <qcombobox.h>
|
#include <qcombobox.h>
|
||||||
|
#include <qframe.h>
|
||||||
|
|
||||||
#include "confgui.h"
|
#include "confgui.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
@ -51,6 +52,11 @@ void ConfParamW::setValue(bool value)
|
|||||||
m_cflink->set(string(buf));
|
m_cflink->set(string(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfParamW::loadValue()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
||||||
{
|
{
|
||||||
m_hl = new QHBoxLayout(this);
|
m_hl = new QHBoxLayout(this);
|
||||||
@ -70,7 +76,7 @@ bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#include <qframe.h>
|
|
||||||
ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt,
|
const QString& tltptxt,
|
||||||
@ -81,18 +87,17 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
|||||||
if (!createCommon(lbltxt, tltptxt))
|
if (!createCommon(lbltxt, tltptxt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_sb = new QSpinBox(this);
|
||||||
QSpinBox *sb = new QSpinBox(this);
|
|
||||||
// sb->setMinimum(minvalue);
|
// sb->setMinimum(minvalue);
|
||||||
sb->setMinValue(minvalue);
|
m_sb->setMinValue(minvalue);
|
||||||
// sb->setMaximum(maxvalue);
|
// sb->setMaximum(maxvalue);
|
||||||
sb->setMaxValue(maxvalue);
|
m_sb->setMaxValue(maxvalue);
|
||||||
sb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
m_sb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||||
QSizePolicy::Fixed,
|
QSizePolicy::Fixed,
|
||||||
0, // Horizontal stretch
|
0, // Horizontal stretch
|
||||||
0, // Vertical stretch
|
0, // Vertical stretch
|
||||||
sb->sizePolicy().hasHeightForWidth() ) );
|
m_sb->sizePolicy().hasHeightForWidth() ) );
|
||||||
m_hl->addWidget(sb);
|
m_hl->addWidget(m_sb);
|
||||||
|
|
||||||
QFrame *fr = new QFrame(this);
|
QFrame *fr = new QFrame(this);
|
||||||
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||||
@ -103,13 +108,17 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
|
|||||||
m_hl->addWidget(fr);
|
m_hl->addWidget(fr);
|
||||||
|
|
||||||
|
|
||||||
|
loadValue();
|
||||||
|
|
||||||
|
QObject::connect(m_sb, SIGNAL(valueChanged(int)),
|
||||||
|
this, SLOT(setValue(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfParamIntW::loadValue()
|
||||||
|
{
|
||||||
string s;
|
string s;
|
||||||
m_cflink->get(s);
|
m_cflink->get(s);
|
||||||
sb->setValue(atoi(s.c_str()));
|
m_sb->setValue(atoi(s.c_str()));
|
||||||
|
|
||||||
|
|
||||||
QObject::connect(sb, SIGNAL(valueChanged(int)),
|
|
||||||
this, SLOT(setValue(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
|
ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||||
@ -119,24 +128,30 @@ ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
|
|||||||
{
|
{
|
||||||
if (!createCommon(lbltxt, tltptxt))
|
if (!createCommon(lbltxt, tltptxt))
|
||||||
return;
|
return;
|
||||||
QLineEdit *le = new QLineEdit(this);
|
m_le = new QLineEdit(this);
|
||||||
// le->setMinimumSize( QSize( 200, 0 ) );
|
// m_le->setMinimumSize( QSize( 200, 0 ) );
|
||||||
|
|
||||||
string s;
|
loadValue();
|
||||||
m_cflink->get(s);
|
|
||||||
le->setText(QString::fromUtf8(s.c_str()));
|
m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||||
le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
|
||||||
QSizePolicy::Fixed,
|
QSizePolicy::Fixed,
|
||||||
1, // Horizontal stretch
|
1, // Horizontal stretch
|
||||||
0, // Vertical 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&)));
|
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,
|
ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt,
|
const QString& tltptxt,
|
||||||
@ -146,49 +161,55 @@ ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
|||||||
{
|
{
|
||||||
if (!createCommon(lbltxt, tltptxt))
|
if (!createCommon(lbltxt, tltptxt))
|
||||||
return;
|
return;
|
||||||
QComboBox *cmb = new QComboBox(this);
|
m_cmb = new QComboBox(this);
|
||||||
cmb->insertStringList(sl);
|
m_cmb->insertStringList(sl);
|
||||||
cmb->setEditable(false);
|
m_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cmb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
loadValue();
|
||||||
|
|
||||||
|
m_cmb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||||
QSizePolicy::Fixed,
|
QSizePolicy::Fixed,
|
||||||
1, // Horizontal stretch
|
1, // Horizontal stretch
|
||||||
0, // Vertical 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&)));
|
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,
|
ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt)
|
const QString& tltptxt)
|
||||||
: ConfParamW(parent, cflink)
|
: ConfParamW(parent, cflink)
|
||||||
{
|
{
|
||||||
if (!createCommon(lbltxt, tltptxt))
|
// No createCommon because the checkbox has a label
|
||||||
return;
|
m_hl = new QHBoxLayout(this);
|
||||||
QCheckBox *cb = new QCheckBox(this);
|
m_hl->setSpacing(spacing);
|
||||||
|
|
||||||
string s;
|
m_cb = new QCheckBox(lbltxt, this);
|
||||||
m_cflink->get(s);
|
|
||||||
cb->setChecked(stringToBool(s));
|
m_cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
||||||
cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
|
|
||||||
QSizePolicy::Fixed,
|
QSizePolicy::Fixed,
|
||||||
0, // Horizontal stretch
|
0, // Horizontal stretch
|
||||||
0, // Vertical stretch
|
0, // Vertical stretch
|
||||||
cb->sizePolicy().hasHeightForWidth() ) );
|
m_cb->sizePolicy().hasHeightForWidth() ) );
|
||||||
m_hl->addWidget(cb);
|
QToolTip::add(m_cb, tltptxt);
|
||||||
|
m_hl->addWidget(m_cb);
|
||||||
|
|
||||||
QFrame *fr = new QFrame(this);
|
QFrame *fr = new QFrame(this);
|
||||||
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||||
@ -198,10 +219,17 @@ ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
|||||||
fr->sizePolicy().hasHeightForWidth() ) );
|
fr->sizePolicy().hasHeightForWidth() ) );
|
||||||
m_hl->addWidget(fr);
|
m_hl->addWidget(fr);
|
||||||
|
|
||||||
QObject::connect(cb, SIGNAL(toggled(bool)),
|
QObject::connect(m_cb, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(setValue(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,
|
ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt,
|
const QString& tltptxt,
|
||||||
@ -212,7 +240,6 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
|||||||
if (!createCommon(lbltxt, tltptxt))
|
if (!createCommon(lbltxt, tltptxt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
m_le = new QLineEdit(this);
|
m_le = new QLineEdit(this);
|
||||||
m_le->setMinimumSize(QSize(150, 0 ));
|
m_le->setMinimumSize(QSize(150, 0 ));
|
||||||
m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
|
||||||
@ -232,15 +259,18 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
|
|||||||
m_hl->addWidget(pb);
|
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(pb, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
||||||
QObject::connect(m_le, SIGNAL(textChanged(const QString&)),
|
QObject::connect(m_le, SIGNAL(textChanged(const QString&)),
|
||||||
this, SLOT(setValue(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()
|
void ConfParamFNW::showBrowserDialog()
|
||||||
{
|
{
|
||||||
QString s = m_isdir ?
|
QString s = m_isdir ?
|
||||||
@ -295,15 +325,7 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink,
|
|||||||
|
|
||||||
m_lb = new QListBox(this);
|
m_lb = new QListBox(this);
|
||||||
|
|
||||||
string s;
|
loadValue();
|
||||||
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);
|
|
||||||
|
|
||||||
m_lb->setSelectionMode(QListBox::Extended);
|
m_lb->setSelectionMode(QListBox::Extended);
|
||||||
|
|
||||||
@ -325,6 +347,20 @@ ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink,
|
|||||||
QObject::connect(pbD, SIGNAL(clicked()), this, SLOT(deleteSelected()));
|
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()
|
void ConfParamSLW::showInputDialog()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
@ -361,6 +397,7 @@ void ConfParamSLW::deleteSelected()
|
|||||||
didone = false;
|
didone = false;
|
||||||
for (unsigned int i = 0; i < m_lb->count(); i++) {
|
for (unsigned int i = 0; i < m_lb->count(); i++) {
|
||||||
if (m_lb->isSelected(i)) {
|
if (m_lb->isSelected(i)) {
|
||||||
|
emit entryDeleted(m_lb->text(i));
|
||||||
m_lb->removeItem(i);
|
m_lb->removeItem(i);
|
||||||
didone = true;
|
didone = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _confgui_h_included_
|
#ifndef _confgui_h_included_
|
||||||
#define _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>
|
#include <string>
|
||||||
|
|
||||||
@ -15,6 +15,9 @@ class QHBoxLayout;
|
|||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QListBox;
|
class QListBox;
|
||||||
class RclConfig;
|
class RclConfig;
|
||||||
|
class QSpinBox;
|
||||||
|
class QComboBox;
|
||||||
|
class QCheckBox;
|
||||||
|
|
||||||
namespace confgui {
|
namespace confgui {
|
||||||
|
|
||||||
@ -26,6 +29,16 @@ namespace confgui {
|
|||||||
};
|
};
|
||||||
typedef RefCntr<ConfLinkRep> ConfLink;
|
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
|
// A widget to let the user change one configuration
|
||||||
// parameter. Subclassed for specific parameter types
|
// parameter. Subclassed for specific parameter types
|
||||||
class ConfParamW : public QWidget {
|
class ConfParamW : public QWidget {
|
||||||
@ -35,9 +48,12 @@ namespace confgui {
|
|||||||
: QWidget(parent), m_cflink(cflink)
|
: QWidget(parent), m_cflink(cflink)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
virtual void loadValue() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ConfLink m_cflink;
|
ConfLink m_cflink;
|
||||||
QHBoxLayout *m_hl;
|
QHBoxLayout *m_hl;
|
||||||
|
|
||||||
virtual bool createCommon(const QString& lbltxt,
|
virtual bool createCommon(const QString& lbltxt,
|
||||||
const QString& tltptxt);
|
const QString& tltptxt);
|
||||||
|
|
||||||
@ -58,6 +74,9 @@ namespace confgui {
|
|||||||
const QString& tltptxt,
|
const QString& tltptxt,
|
||||||
int minvalue = INT_MIN,
|
int minvalue = INT_MIN,
|
||||||
int maxvalue = INT_MAX);
|
int maxvalue = INT_MAX);
|
||||||
|
virtual void loadValue();
|
||||||
|
protected:
|
||||||
|
QSpinBox *m_sb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Arbitrary string
|
// Arbitrary string
|
||||||
@ -66,6 +85,9 @@ namespace confgui {
|
|||||||
ConfParamStrW(QWidget *parent, ConfLink cflink,
|
ConfParamStrW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt);
|
const QString& tltptxt);
|
||||||
|
virtual void loadValue();
|
||||||
|
protected:
|
||||||
|
QLineEdit *m_le;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Constrained string: choose from list
|
// Constrained string: choose from list
|
||||||
@ -74,6 +96,9 @@ namespace confgui {
|
|||||||
ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
ConfParamCStrW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt, const QStringList& sl);
|
const QString& tltptxt, const QStringList& sl);
|
||||||
|
virtual void loadValue();
|
||||||
|
protected:
|
||||||
|
QComboBox *m_cmb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Boolean
|
// Boolean
|
||||||
@ -82,6 +107,9 @@ namespace confgui {
|
|||||||
ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
ConfParamBoolW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt);
|
const QString& tltptxt);
|
||||||
|
virtual void loadValue();
|
||||||
|
protected:
|
||||||
|
QCheckBox *m_cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// File name
|
// File name
|
||||||
@ -91,6 +119,7 @@ namespace confgui {
|
|||||||
ConfParamFNW(QWidget *parent, ConfLink cflink,
|
ConfParamFNW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt, bool isdir = false);
|
const QString& tltptxt, bool isdir = false);
|
||||||
|
virtual void loadValue();
|
||||||
protected slots:
|
protected slots:
|
||||||
void showBrowserDialog();
|
void showBrowserDialog();
|
||||||
protected:
|
protected:
|
||||||
@ -105,12 +134,18 @@ namespace confgui {
|
|||||||
ConfParamSLW(QWidget *parent, ConfLink cflink,
|
ConfParamSLW(QWidget *parent, ConfLink cflink,
|
||||||
const QString& lbltxt,
|
const QString& lbltxt,
|
||||||
const QString& tltptxt);
|
const QString& tltptxt);
|
||||||
|
virtual void loadValue();
|
||||||
|
QListBox *getListBox() {return m_lb;}
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void showInputDialog();
|
virtual void showInputDialog();
|
||||||
void deleteSelected();
|
void deleteSelected();
|
||||||
|
signals:
|
||||||
|
void entryDeleted(QString);
|
||||||
protected:
|
protected:
|
||||||
QListBox *m_lb;
|
QListBox *m_lb;
|
||||||
void listToConf();
|
void listToConf();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dir name list
|
// Dir name list
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
|
|
||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qlistbox.h>
|
||||||
|
#include <qtimer.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
using std::list;
|
using std::list;
|
||||||
@ -130,18 +135,58 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, RclConfig *config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
|
ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
|
||||||
: QWidget(parent)
|
: QWidget(parent), m_config(config)
|
||||||
{
|
{
|
||||||
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
|
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
|
||||||
vboxLayout->setSpacing(spacing);
|
vboxLayout->setSpacing(spacing);
|
||||||
vboxLayout->setMargin(margin);
|
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 *eskn = new
|
||||||
ConfParamSLW(this, lnkskn, tr("List of skipped names"),
|
ConfParamSLW(this, lnkskn,
|
||||||
tr("These are patterns for file or directory names which "
|
QObject::tr("List of skipped names"),
|
||||||
"should not be indexed. "));
|
QObject::tr("These are patterns for file or directory "
|
||||||
|
" names which should not be indexed."));
|
||||||
vboxLayout->addWidget(eskn);
|
vboxLayout->addWidget(eskn);
|
||||||
|
m_widgets.push_back(eskn);
|
||||||
|
|
||||||
list<string> args;
|
list<string> args;
|
||||||
args.push_back("-l");
|
args.push_back("-l");
|
||||||
@ -162,34 +207,78 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
|
|||||||
charsets.push_back(QString::fromUtf8(it->c_str()));
|
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 *e21 = new
|
||||||
ConfParamCStrW(this, lnk21, tr("Default character set"),
|
ConfParamCStrW(this, lnk21,
|
||||||
tr("This is the character set used for reading files "
|
QObject::tr("Default character set"),
|
||||||
|
QObject::tr("This is the character set used for reading files "
|
||||||
"which do not identify the character set "
|
"which do not identify the character set "
|
||||||
"internally, for example pure text files.<br>"
|
"internally, for example pure text files.<br>"
|
||||||
"The default value is empty, "
|
"The default value is empty, "
|
||||||
"and the value from the NLS environnement is used."
|
"and the value from the NLS environnement is used."
|
||||||
), charsets);
|
), charsets);
|
||||||
vboxLayout->addWidget(e21);
|
vboxLayout->addWidget(e21);
|
||||||
|
m_widgets.push_back(e21);
|
||||||
|
|
||||||
|
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks", &m_sk));
|
||||||
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks"));
|
|
||||||
ConfParamBoolW *e3 = new
|
ConfParamBoolW *e3 = new
|
||||||
ConfParamBoolW(this, lnk3, tr("Follow symbolic links"),
|
ConfParamBoolW(this, lnk3,
|
||||||
tr("Follow symbolic links while "
|
QObject::tr("Follow symbolic links"),
|
||||||
|
QObject::tr("Follow symbolic links while "
|
||||||
"indexing. The default is no, "
|
"indexing. The default is no, "
|
||||||
"to avoid duplicate indexing"));
|
"to avoid duplicate indexing"));
|
||||||
vboxLayout->addWidget(e3);
|
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 *eafln = new
|
||||||
ConfParamBoolW(this, lnkafln, tr("Index all file names"),
|
ConfParamBoolW(this, lnkafln,
|
||||||
tr("Index the names of files for which the contents "
|
QObject::tr("Index all file names"),
|
||||||
|
QObject::tr("Index the names of files for which the contents "
|
||||||
"cannot be identified or processed (no or "
|
"cannot be identified or processed (no or "
|
||||||
"unsupported mime type). Default true"));
|
"unsupported mime type). Default true"));
|
||||||
vboxLayout->addWidget(eafln);
|
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
|
} // Namespace confgui
|
||||||
|
|||||||
@ -1,23 +1,64 @@
|
|||||||
#ifndef _confguiindex_h_included_
|
#ifndef _confguiindex_h_included_
|
||||||
#define _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 <qwidget.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
using std::string;
|
||||||
|
using std::list;
|
||||||
|
|
||||||
|
|
||||||
class RclConfig;
|
class RclConfig;
|
||||||
|
class ConfParamW;
|
||||||
|
class ConfParamDNLW;
|
||||||
|
|
||||||
namespace confgui {
|
namespace confgui {
|
||||||
// A panel with the top-level parameters (can't change in subdirs)
|
|
||||||
|
/**
|
||||||
|
* A panel with the top-level parameters which can't be redefined in
|
||||||
|
* subdirectoriess:
|
||||||
|
*/
|
||||||
class ConfTopPanelW : public QWidget {
|
class ConfTopPanelW : public QWidget {
|
||||||
public:
|
public:
|
||||||
ConfTopPanelW(QWidget *parent, RclConfig *config);
|
ConfTopPanelW(QWidget *parent, RclConfig *config);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A panel for the parameters that can be changed in subdirectories
|
|
||||||
|
/**
|
||||||
|
* A panel for the parameters that can be changed in subdirectories:
|
||||||
|
*/
|
||||||
class ConfSubPanelW : public QWidget {
|
class ConfSubPanelW : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ConfSubPanelW(QWidget *parent, RclConfig *config);
|
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_ */
|
#endif /* _confguiindex_h_included_ */
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
#ifndef _CONFLINKRCL_H_INCLUDED_
|
#ifndef _CONFLINKRCL_H_INCLUDED_
|
||||||
#define _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 "confgui.h"
|
||||||
#include "rclconfig.h"
|
#include "rclconfig.h"
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
@ -11,7 +16,7 @@ namespace confgui {
|
|||||||
class ConfLinkRclRep : public ConfLinkRep {
|
class ConfLinkRclRep : public ConfLinkRep {
|
||||||
public:
|
public:
|
||||||
ConfLinkRclRep(RclConfig *conf, const string& nm,
|
ConfLinkRclRep(RclConfig *conf, const string& nm,
|
||||||
const string& sk = "")
|
string *sk = 0)
|
||||||
: m_conf(conf), m_nm(nm), m_sk(sk)
|
: m_conf(conf), m_nm(nm), m_sk(sk)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -21,8 +26,9 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_conf)
|
if (!m_conf)
|
||||||
return false;
|
return false;
|
||||||
LOGDEB(("Setting [%s] value to [%s]\n",
|
LOGDEB1(("Setting [%s] value to [%s]\n",
|
||||||
m_nm.c_str(), val.c_str()));
|
m_nm.c_str(), val.c_str()));
|
||||||
|
m_conf->setKeyDir(m_sk ? *m_sk : "");
|
||||||
bool ret = m_conf->setConfParam(m_nm, val);
|
bool ret = m_conf->setConfParam(m_nm, val);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
LOGERR(("Value set failed\n"));
|
LOGERR(("Value set failed\n"));
|
||||||
@ -32,15 +38,16 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_conf)
|
if (!m_conf)
|
||||||
return false;
|
return false;
|
||||||
|
m_conf->setKeyDir(m_sk ? *m_sk : "");
|
||||||
bool ret = m_conf->getConfParam(m_nm, val);
|
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()));
|
ret ? val.c_str() : "no value", m_nm.c_str()));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
RclConfig *m_conf;
|
RclConfig *m_conf;
|
||||||
const string m_nm;
|
const string m_nm;
|
||||||
const string m_sk;
|
const string *m_sk;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace confgui
|
} // Namespace confgui
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -27,14 +27,16 @@ using namespace std;
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qtranslator.h>
|
#include <qtranslator.h>
|
||||||
|
|
||||||
#include <qtextcodec.h>
|
#include <qtextcodec.h>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
#include <qframe.h>
|
#include <qframe.h>
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "confguiindex.h"
|
#include "confguiindex.h"
|
||||||
@ -67,15 +69,6 @@ Usage(void)
|
|||||||
exit((op_flags & OPT_h)==0);
|
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;
|
static RclConfig *config;
|
||||||
RclConfig *RclConfig::getMainConfig()
|
RclConfig *RclConfig::getMainConfig()
|
||||||
@ -139,10 +132,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
vboxLayout->addWidget(new ConfTopPanelW(&w, config));
|
vboxLayout->addWidget(new ConfTopPanelW(&w, config));
|
||||||
|
|
||||||
QFrame *line2 = new QFrame(&w);
|
QFrame *line1 = new QFrame(&w);
|
||||||
line2->setFrameShape(QFrame::HLine);
|
line1->setFrameShape(QFrame::HLine);
|
||||||
line2->setFrameShadow(QFrame::Sunken);
|
line1->setFrameShadow(QFrame::Sunken);
|
||||||
vboxLayout->addWidget(line2);
|
vboxLayout->addWidget(line1);
|
||||||
|
|
||||||
vboxLayout->addWidget(new ConfSubPanelW(&w, config));
|
vboxLayout->addWidget(new ConfSubPanelW(&w, config));
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ LANGUAGE = C++
|
|||||||
|
|
||||||
CONFIG += qt warn_on thread release debug
|
CONFIG += qt warn_on thread release debug
|
||||||
|
|
||||||
HEADERS += confgui.h
|
HEADERS += confgui.h confguiindex.h
|
||||||
|
|
||||||
SOURCES += main.cpp confgui.cpp confguiindex.cpp
|
SOURCES += main.cpp confgui.cpp confguiindex.cpp
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user