*** empty log message ***

This commit is contained in:
dockes 2007-10-09 11:08:17 +00:00
parent 0271de6d43
commit c800954fc7
6 changed files with 109 additions and 76 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: confgui.cpp,v 1.6 2007-10-07 20:22:55 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: confgui.cpp,v 1.7 2007-10-09 11:08:17 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <stdio.h>
@ -64,7 +64,7 @@ using std::list;
namespace confgui {
const static int spacing = 3;
const static int spacing = 4;
const static int margin = 6;
void ConfParamW::setValue(const QString& value)
@ -98,7 +98,6 @@ bool ConfParamW::createCommon(const QString& lbltxt, const QString& tltptxt)
tl->sizePolicy().hasHeightForWidth() ) );
tl->setText(lbltxt);
QToolTip::add(tl, tltptxt);
/* qt4 tl->setProperty("toolTip", tltptxt);*/
m_hl->addWidget(tl);
@ -134,7 +133,6 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
m_hl->addWidget(fr);
loadValue();
QObject::connect(m_sb, SIGNAL(valueChanged(int)),
this, SLOT(setValue(int)));
}
@ -154,17 +152,14 @@ ConfParamStrW::ConfParamStrW(QWidget *parent, ConfLink cflink,
if (!createCommon(lbltxt, tltptxt))
return;
m_le = new QLineEdit(this);
loadValue();
m_le->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Fixed,
1, // Horizontal stretch
0, // Vertical stretch
m_le->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_le);
loadValue();
QObject::connect(m_le, SIGNAL(textChanged(const QString&)),
this, SLOT(setValue(const QString&)));
}
@ -239,6 +234,7 @@ ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
fr->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(fr);
loadValue();
QObject::connect(m_cb, SIGNAL(toggled(bool)),
this, SLOT(setValue(bool)));
}
@ -278,7 +274,7 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
pb->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(pb);
loadValue();
QObject::connect(pb, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
QObject::connect(m_le, SIGNAL(textChanged(const QString&)),
this, SLOT(setValue(const QString&)));

View File

@ -1,6 +1,6 @@
#ifndef _confgui_h_included_
#define _confgui_h_included_
/* @(#$Id: confgui.h,v 1.4 2007-10-01 06:35:31 dockes Exp $ (C) 2007 J.F.Dockes */
/* @(#$Id: confgui.h,v 1.5 2007-10-09 11:08:17 dockes Exp $ (C) 2007 J.F.Dockes */
#include <string>
@ -22,7 +22,6 @@ using std::string;
class QHBOXLAYOUT;
class QLineEdit;
class QLISTBOX;
class RclConfig;
class QSpinBox;
class QComboBox;
class QCheckBox;

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.4 2007-10-07 20:22:55 dockes Exp $ (C) 2007 J.F.Dockes";
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.5 2007-10-09 11:08:17 dockes Exp $ (C) 2007 J.F.Dockes";
#endif
#include <qglobal.h>
@ -40,6 +40,8 @@ static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.4 2007-10-07 20:22:55 dockes
#include <qlabel.h>
#include QLISTBOX_INCLUDE
#include <qtimer.h>
#include <qmessagebox.h>
#include <qgroupbox.h>
#include <list>
using std::list;
@ -51,12 +53,41 @@ using std::list;
#include "rcldb.h"
#include "conflinkrcl.h"
#include "execmd.h"
#include "rclconfig.h"
namespace confgui {
const static int spacing = 3;
const static int spacing = 6;
const static int margin = 6;
ConfTopPanelW::ConfTopPanelW(QWidget *parent, RclConfig *config)
ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config)
: QTABDIALOG(parent), m_rclconf(config)
{
setOkButton();
setCancelButton();
if ((m_conf = m_rclconf->cloneMainConfig()) == 0)
return;
m_conf->holdWrites(true);
addTab(new ConfTopPanelW(this, m_conf), QObject::tr("Global parameters"));
addTab(new ConfSubPanelW(this, m_conf), QObject::tr("Local parameters"));
connect(this, SIGNAL(applyButtonPressed()), this, SLOT(acceptChanges()));
}
void ConfIndexW::acceptChanges()
{
LOGDEB(("ConfIndexW::acceptChanges()\n"));
if (m_conf) {
if (!m_conf->holdWrites(false)) {
QMessageBox::critical(0, "Recoll",
tr("Can't write configuration file"));
}
delete m_conf;
m_conf = 0;
// Update in-memory config
m_rclconf->updateMainConfig();
}
}
ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
: QWidget(parent)
{
QVBOXLAYOUT *vboxLayout = new QVBOXLAYOUT(this);
@ -166,7 +197,7 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, RclConfig *config)
vboxLayout->addWidget(eusfc);
}
ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
: QWidget(parent), m_config(config)
{
QVBOXLAYOUT *vboxLayout = new QVBOXLAYOUT(this);
@ -185,14 +216,13 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
this, SLOT(subDirChanged()));
connect(m_subdirs, SIGNAL(entryDeleted(QString)),
this, SLOT(subDirDeleted(QString)));
list<string> allkeydirs = config->getKeyDirs();
list<string> allkeydirs = config->getSubKeys();
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);
@ -211,13 +241,15 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
line2->setFrameShadow(QFRAME::Sunken);
vboxLayout->addWidget(line2);
m_groupbox = new QGroupBox(this);
QVBoxLayout *vgbox = new QVBoxLayout;
ConfLink lnkskn(new ConfLinkRclRep(config, "skippedNames", &m_sk));
ConfParamSLW *eskn = new
ConfParamSLW(this, lnkskn,
ConfParamSLW(m_groupbox, 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);
vgbox->addWidget(eskn);
m_widgets.push_back(eskn);
list<string> args;
@ -241,7 +273,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
ConfLink lnk21(new ConfLinkRclRep(config, "defaultcharset", &m_sk));
ConfParamCStrW *e21 = new
ConfParamCStrW(this, lnk21,
ConfParamCStrW(m_groupbox, lnk21,
QObject::tr("Default character set"),
QObject::tr("This is the character set used for reading files "
"which do not identify the character set "
@ -249,28 +281,31 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, RclConfig *config)
"The default value is empty, "
"and the value from the NLS environnement is used."
), charsets);
vboxLayout->addWidget(e21);
vgbox->addWidget(e21);
m_widgets.push_back(e21);
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks", &m_sk));
ConfParamBoolW *e3 = new
ConfParamBoolW(this, lnk3,
ConfParamBoolW(m_groupbox, lnk3,
QObject::tr("Follow symbolic links"),
QObject::tr("Follow symbolic links while "
"indexing. The default is no, "
"to avoid duplicate indexing"));
vboxLayout->addWidget(e3);
vgbox->addWidget(e3);
m_widgets.push_back(e3);
ConfLink lnkafln(new ConfLinkRclRep(config, "indexallfilenames", &m_sk));
ConfParamBoolW *eafln = new
ConfParamBoolW(this, lnkafln,
ConfParamBoolW(m_groupbox, 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);
vgbox->addWidget(eafln);
m_widgets.push_back(eafln);
m_groupbox->setLayout(vgbox);
vboxLayout->addWidget(m_groupbox);
subDirChanged();
}
void ConfSubPanelW::reloadAll()
@ -287,8 +322,10 @@ void ConfSubPanelW::subDirChanged()
QLISTBOXITEM *item = m_subdirs->getListBox()->selectedItem();
if (item == 0) {
m_sk = "";
m_groupbox->setTitle(tr("Global"));
} else {
m_sk = (const char *)item->text().utf8();
m_groupbox->setTitle(item->text());
}
LOGDEB(("ConfSubPanelW::subDirChanged: now [%s]\n", m_sk.c_str()));
reloadAll();
@ -303,8 +340,7 @@ void ConfSubPanelW::subDirDeleted(QString sbd)
return;
}
// Have to delete all entries for submap
m_config->setKeyDir((const char *)sbd.utf8());
m_config->eraseKeyDir();
m_config->eraseKey((const char *)sbd.utf8());
}
void ConfSubPanelW::restoreEmpty()

View File

@ -1,6 +1,6 @@
#ifndef _confguiindex_h_included_
#define _confguiindex_h_included_
/* @(#$Id: confguiindex.h,v 1.2 2007-09-29 09:06:53 dockes Exp $ (C) 2007 J.F.Dockes */
/* @(#$Id: confguiindex.h,v 1.3 2007-10-09 11:08:17 dockes Exp $ (C) 2007 J.F.Dockes */
/**
* Classes to handle the gui for the indexing configuration. These group
@ -9,26 +9,45 @@
#include <qwidget.h>
#include <qstring.h>
#if QT_VERSION < 0x040000
#include <qtabdialog.h>
#define QTABDIALOG QTabDialog
#else // Qt4 ->
#include <Q3TabDialog>
#define QTABDIALOG Q3TabDialog
#endif // QT 3/4
#include <string>
#include <list>
using std::string;
using std::list;
class ConfNull;
class RclConfig;
class ConfParamW;
class ConfParamDNLW;
class QGroupBox;
namespace confgui {
class ConfIndexW : public QTABDIALOG {
Q_OBJECT
public:
ConfIndexW(QWidget *parent, RclConfig *config);
public slots:
void acceptChanges();
private:
RclConfig *m_rclconf;
ConfNull *m_conf;
};
/**
* A panel with the top-level parameters which can't be redefined in
* subdirectoriess:
*/
class ConfTopPanelW : public QWidget {
public:
ConfTopPanelW(QWidget *parent, RclConfig *config);
ConfTopPanelW(QWidget *parent, ConfNull *config);
};
@ -38,15 +57,9 @@ public:
class ConfSubPanelW : public QWidget {
Q_OBJECT
public:
ConfSubPanelW(QWidget *parent, RclConfig *config);
ConfSubPanelW(QWidget *parent, ConfNull *config);
void setkeydir(const string& sk)
{
m_sk = sk;
reloadAll();
}
void reloadAll();
public slots:
private slots:
void subDirChanged();
void subDirDeleted(QString);
void restoreEmpty();
@ -54,11 +67,12 @@ private:
string m_sk;
ConfParamDNLW *m_subdirs;
list<ConfParamW*> m_widgets;
RclConfig *m_config;
ConfNull *m_config;
QGroupBox *m_groupbox;
void reloadAll();
};
} // Namespace confgui
#endif /* _confguiindex_h_included_ */

View File

@ -1,21 +1,21 @@
#ifndef _CONFLINKRCL_H_INCLUDED_
#define _CONFLINKRCL_H_INCLUDED_
/* @(#$Id: conflinkrcl.h,v 1.2 2007-09-29 09:06:53 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: conflinkrcl.h,v 1.3 2007-10-09 11:08:17 dockes Exp $ (C) 2004 J.F.Dockes */
/**
* A Gui-to-Data link class for RclConfig
* A Gui-to-Data link class for ConfTree
* 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 "conftree.h"
#include "debuglog.h"
namespace confgui {
class ConfLinkRclRep : public ConfLinkRep {
public:
ConfLinkRclRep(RclConfig *conf, const string& nm,
ConfLinkRclRep(ConfNull *conf, const string& nm,
string *sk = 0)
: m_conf(conf), m_nm(nm), m_sk(sk)
{
@ -26,10 +26,8 @@ public:
{
if (!m_conf)
return false;
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);
LOGDEB1(("Setting [%s] value to [%s]\n", m_nm.c_str(), val.c_str()));
bool ret = m_conf->set(m_nm, val, m_sk?*m_sk:"");
if (!ret)
LOGERR(("Value set failed\n"));
return ret;
@ -38,14 +36,14 @@ public:
{
if (!m_conf)
return false;
m_conf->setKeyDir(m_sk ? *m_sk : "");
bool ret = m_conf->getConfParam(m_nm, val);
LOGDEB1(("Got [%s] for [%s]\n",
ret ? val.c_str() : "no value", m_nm.c_str()));
bool ret = m_conf->get(m_nm, val, m_sk?*m_sk:"");
LOGDEB1(("ConfLinkRcl::get: [%s] sk [%s] -> [%s]\n",
m_nm.c_str(), m_sk?m_sk->c_str():"",
ret ? val.c_str() : "no value"));
return ret;
}
private:
RclConfig *m_conf;
ConfNull *m_conf;
const string m_nm;
const string *m_sk;
};

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.4 2007-10-01 06:35:31 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: main.cpp,v 1.5 2007-10-09 11:08:17 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -28,26 +28,31 @@ using namespace std;
#include <unistd.h>
#include <qglobal.h>
#include <qobject.h>
#if QT_VERSION < 0x040000
#define QFRAME_INCLUDE <qframe.h>
#define QFILEDIALOG_INCLUDE <qfiledialog.h>
#define QLISTBOX_INCLUDE <qlistbox.h>
#include <qtabdialog.h>
#define QFILEDIALOG QFileDialog
#define QFRAME QFrame
#define QHBOXLAYOUT QHBoxLayout
#define QLISTBOX QListBox
#define QLISTBOXITEM QListBoxItem
#define QVBOXLAYOUT QVBoxLayout
#else
#define QTABDIALOG QTabDialog
#else // Qt4 ->
#include <Q3HBoxLayout>
#include <Q3VBoxLayout>
#include <Q3TabDialog>
#include <QFrame>
#define QFRAME_INCLUDE <q3frame.h>
#include <QFileDialog>
#define QFILEDIALOG_INCLUDE <q3filedialog.h>
#define QLISTBOX_INCLUDE <q3listbox.h>
#define QFILEDIALOG Q3FileDialog
@ -56,7 +61,8 @@ using namespace std;
#define QLISTBOX Q3ListBox
#define QLISTBOXITEM Q3ListBoxItem
#define QVBOXLAYOUT Q3VBoxLayout
#endif
#define QTABDIALOG Q3TabDialog
#endif // QT 3/4
#include <qobject.h>
#include <qapplication.h>
@ -153,23 +159,7 @@ int main(int argc, char **argv)
app.installTranslator( &translator );
// fprintf(stderr, "Translations installed\n");
QWidget w;
QVBOXLAYOUT *vboxLayout = new QVBOXLAYOUT(&w);
vboxLayout->setSpacing(6);
vboxLayout->setMargin(11);
vboxLayout->addWidget(new ConfTopPanelW(&w, config));
QFRAME *line1 = new QFRAME(&w);
line1->setFrameShape(QFRAME::HLine);
line1->setFrameShadow(QFRAME::Sunken);
vboxLayout->addWidget(line1);
vboxLayout->addWidget(new ConfSubPanelW(&w, config));
ConfIndexW w(0, config);
QSize size(0, 0);
size = size.expandedTo(w.minimumSizeHint());
w.resize(size);