compiles cleanly without qt3_support. Needs more testing

This commit is contained in:
Jean-Francois Dockes 2010-12-04 15:26:13 +01:00
parent 1f11387d52
commit a29e380227
19 changed files with 463 additions and 591 deletions

View File

@ -62,7 +62,8 @@ static map<QString,QString> cat_rtranslations;
void AdvSearch::init() void AdvSearch::init()
{ {
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.COMPLEX"); HelpClient::installMap((const char *)objectName().toUtf8(),
"RCL.SEARCH.COMPLEX");
this->installEventFilter(this); this->installEventFilter(this);
@ -86,8 +87,8 @@ void AdvSearch::init()
connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause())); connect(addClausePB, SIGNAL(clicked()), this, SLOT(addClause()));
connect(delClausePB, SIGNAL(clicked()), this, SLOT(delClause())); connect(delClausePB, SIGNAL(clicked()), this, SLOT(delClause()));
conjunctCMB->insertItem(tr("All clauses")); conjunctCMB->insertItem(1, tr("All clauses"));
conjunctCMB->insertItem(tr("Any clause")); conjunctCMB->insertItem(2, tr("Any clause"));
// Create preconfigured clauses // Create preconfigured clauses
for (unsigned int i = 0; i < iclausescnt; i++) { for (unsigned int i = 0; i < iclausescnt; i++) {
@ -116,7 +117,7 @@ void AdvSearch::init()
restrictCtCB->setChecked(m_ignByCats); restrictCtCB->setChecked(m_ignByCats);
fillFileTypes(); fillFileTypes();
subtreeCMB->insertStringList(prefs.asearchSubdirHist); subtreeCMB->insertItems(0, prefs.asearchSubdirHist);
subtreeCMB->setEditText(""); subtreeCMB->setEditText("");
// The clauseline frame is needed to force designer to accept a // The clauseline frame is needed to force designer to accept a
@ -151,7 +152,7 @@ bool AdvSearch::eventFilter(QObject *, QEvent *event)
if (event->type() == QEvent::KeyPress || if (event->type() == QEvent::KeyPress ||
event->type() == QEvent::ShortcutOverride) { event->type() == QEvent::ShortcutOverride) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event); QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_Q && (ke->state() & Qt::ControlButton)) { if (ke->key() == Qt::Key_Q && (ke->modifiers() & Qt::ControlModifier)) {
recollNeedsExit = 1; recollNeedsExit = 1;
return true; return true;
} }
@ -165,7 +166,7 @@ void AdvSearch::saveCnf()
prefs.advSearchClauses.clear(); prefs.advSearchClauses.clear();
for (std::list<SearchClauseW *>::iterator cit = m_clauseWins.begin(); for (std::list<SearchClauseW *>::iterator cit = m_clauseWins.begin();
cit != m_clauseWins.end(); cit++) { cit != m_clauseWins.end(); cit++) {
prefs.advSearchClauses.push_back((*cit)->sTpCMB->currentItem()); prefs.advSearchClauses.push_back((*cit)->sTpCMB->currentIndex());
} }
} }
@ -290,7 +291,7 @@ void AdvSearch::fillFileTypes()
for (list<string>::iterator it = types.begin(); for (list<string>::iterator it = types.begin();
it != types.end(); it++) { it != types.end(); it++) {
QString qs = QString::fromUtf8(it->c_str()); QString qs = QString::fromUtf8(it->c_str());
if (m_ignTypes.findIndex(qs) < 0) if (m_ignTypes.indexOf(qs) < 0)
ql.append(qs); ql.append(qs);
} }
} else { } else {
@ -306,7 +307,7 @@ void AdvSearch::fillFileTypes()
} else { } else {
cat = QString::fromUtf8(it->c_str()); cat = QString::fromUtf8(it->c_str());
} }
if (m_ignTypes.findIndex(cat) < 0) if (m_ignTypes.indexOf(cat) < 0)
ql.append(cat); ql.append(cat);
} }
} }
@ -324,7 +325,7 @@ void AdvSearch::saveFileTypes()
using namespace Rcl; using namespace Rcl;
void AdvSearch::runSearch() void AdvSearch::runSearch()
{ {
RefCntr<SearchData> sdata(new SearchData(conjunctCMB->currentItem() == 0 ? RefCntr<SearchData> sdata(new SearchData(conjunctCMB->currentIndex() == 0 ?
SCLT_AND : SCLT_OR)); SCLT_AND : SCLT_OR));
bool hasclause = false; bool hasclause = false;
@ -339,17 +340,17 @@ void AdvSearch::runSearch()
if (!hasclause) if (!hasclause)
return; return;
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) { if (restrictFtCB->isChecked() && noFiltypsLB->count() > 0) {
for (int i = 0; i < yesFiltypsLB->count(); i++) { for (int i = 0; i < yesFiltypsLB->count(); i++) {
if (restrictCtCB->isOn()) { if (restrictCtCB->isChecked()) {
QString qcat = yesFiltypsLB->item(i)->text(); QString qcat = yesFiltypsLB->item(i)->text();
map<QString,QString>::const_iterator qit; map<QString,QString>::const_iterator qit;
string cat; string cat;
if ((qit = cat_rtranslations.find(qcat)) != if ((qit = cat_rtranslations.find(qcat)) !=
cat_rtranslations.end()) { cat_rtranslations.end()) {
cat = (const char *)qit->second.utf8(); cat = (const char *)qit->second.toUtf8();
} else { } else {
cat = (const char *)qcat.utf8(); cat = (const char *)qcat.toUtf8();
} }
list<string> types; list<string> types;
rclconfig->getMimeCatTypes(cat, types); rclconfig->getMimeCatTypes(cat, types);
@ -359,19 +360,19 @@ void AdvSearch::runSearch()
} }
} else { } else {
sdata->addFiletype((const char *) sdata->addFiletype((const char *)
yesFiltypsLB->item(i)->text().utf8()); yesFiltypsLB->item(i)->text().toUtf8());
} }
} }
} }
if (!subtreeCMB->currentText().isEmpty()) { if (!subtreeCMB->currentText().isEmpty()) {
QString current = subtreeCMB->currentText(); QString current = subtreeCMB->currentText();
sdata->setTopdir((const char*)subtreeCMB->currentText().utf8()); sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8());
// Keep history list clean and sorted. Maybe there would be a // Keep history list clean and sorted. Maybe there would be a
// simpler way to do this // simpler way to do this
list<QString> entries; list<QString> entries;
for (int i = 0; i < subtreeCMB->count(); i++) { for (int i = 0; i < subtreeCMB->count(); i++) {
entries.push_back(subtreeCMB->text(i)); entries.push_back(subtreeCMB->itemText(i));
} }
entries.push_back(subtreeCMB->currentText()); entries.push_back(subtreeCMB->currentText());
entries.sort(); entries.sort();
@ -379,12 +380,12 @@ void AdvSearch::runSearch()
subtreeCMB->clear(); subtreeCMB->clear();
for (list<QString>::iterator it = entries.begin(); for (list<QString>::iterator it = entries.begin();
it != entries.end(); it++) { it != entries.end(); it++) {
subtreeCMB->insertItem(*it); subtreeCMB->addItem(*it);
} }
subtreeCMB->setCurrentText(current); subtreeCMB->setCurrentIndex(subtreeCMB->findText(current));
prefs.asearchSubdirHist.clear(); prefs.asearchSubdirHist.clear();
for (int index = 0; index < subtreeCMB->count(); index++) for (int index = 0; index < subtreeCMB->count(); index++)
prefs.asearchSubdirHist.push_back(subtreeCMB->text(index)); prefs.asearchSubdirHist.push_back(subtreeCMB->itemText(index));
} }
saveCnf(); saveCnf();

View File

@ -6,37 +6,11 @@ static char rcsid[] = "@(#$Id: confgui.cpp,v 1.9 2008-05-21 07:21:37 dockes Exp
#include <stdlib.h> #include <stdlib.h>
#include <qglobal.h> #include <qglobal.h>
#if QT_VERSION < 0x040000 #include <QHBoxLayout>
#define QFRAME_INCLUDE <qframe.h> #include <QVBoxLayout>
#define QFILEDIALOG_INCLUDE <qfiledialog.h>
#define QLISTBOX_INCLUDE <qlistbox.h>
#define QFILEDIALOG QFileDialog
#define QFRAME QFrame
#define QHBOXLAYOUT QHBoxLayout
#define QLISTBOX QListBox
#define QLISTBOXITEM QListBoxItem
#define QLBEXACTMATCH Qt::ExactMatch
#define QVBOXLAYOUT QVBoxLayout
#else
#include <Q3HBoxLayout>
#include <Q3VBoxLayout>
#include <QFrame> #include <QFrame>
#define QFRAME_INCLUDE <q3frame.h>
#include <QFileDialog> #include <QFileDialog>
#define QFILEDIALOG_INCLUDE <q3filedialog.h> #include <QListWidget>
#define QLISTBOX_INCLUDE <q3listbox.h>
#define QFILEDIALOG Q3FileDialog
#define QFRAME Q3Frame
#define QHBOXLAYOUT Q3HBoxLayout
#define QLISTBOX Q3ListBox
#define QLISTBOXITEM Q3ListBoxItem
#define QLBEXACTMATCH Q3ListBox::ExactMatch
#define QVBOXLAYOUT Q3VBoxLayout
#endif
#include <qobject.h> #include <qobject.h>
#include <qlayout.h> #include <qlayout.h>
@ -47,13 +21,10 @@ static char rcsid[] = "@(#$Id: confgui.cpp,v 1.9 2008-05-21 07:21:37 dockes Exp
#include <qtooltip.h> #include <qtooltip.h>
#include <qlineedit.h> #include <qlineedit.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include QFILEDIALOG_INCLUDE
#include <qinputdialog.h> #include <qinputdialog.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qstringlist.h> #include <qstringlist.h>
#include QLISTBOX_INCLUDE
#include <qcombobox.h> #include <qcombobox.h>
#include QFRAME_INCLUDE
#include "confgui.h" #include "confgui.h"
#include "smallut.h" #include "smallut.h"
@ -65,15 +36,15 @@ using std::list;
namespace confgui { namespace confgui {
const static int spacing = 4; const static int spacing = 2;
const static int margin = 6; const static int margin = 2;
void ConfParamW::setValue(const QString& value) void ConfParamW::setValue(const QString& value)
{ {
if (m_fsencoding) if (m_fsencoding)
m_cflink->set(string((const char *)value.local8Bit())); m_cflink->set(string((const char *)value.toLocal8Bit()));
else else
m_cflink->set(string((const char *)value.utf8())); m_cflink->set(string((const char *)value.toUtf8()));
} }
void ConfParamW::setValue(int value) void ConfParamW::setValue(int value)
@ -89,19 +60,26 @@ void ConfParamW::setValue(bool value)
m_cflink->set(string(buf)); m_cflink->set(string(buf));
} }
void setSzPol(QWidget *w, QSizePolicy::Policy hpol,
QSizePolicy::Policy vpol,
int hstretch, int vstretch)
{
QSizePolicy policy(hpol, vpol);
policy.setHorizontalStretch(hstretch);
policy.setVerticalStretch(vstretch);
policy.setHeightForWidth(w->sizePolicy().hasHeightForWidth());
w->setSizePolicy(policy);
}
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);
m_hl->setSpacing(spacing); m_hl->setSpacing(spacing);
QLabel *tl = new QLabel(this); QLabel *tl = new QLabel(this);
tl->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(tl, QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0);
QSizePolicy::Fixed,
0, // Horizontal stretch
0, // Vertical stretch
tl->sizePolicy().hasHeightForWidth() ) );
tl->setText(lbltxt); tl->setText(lbltxt);
QToolTip::add(tl, tltptxt); tl->setToolTip(tltptxt);
m_hl->addWidget(tl); m_hl->addWidget(tl);
@ -120,21 +98,13 @@ ConfParamIntW::ConfParamIntW(QWidget *parent, ConfLink cflink,
return; return;
m_sb = new QSpinBox(this); m_sb = new QSpinBox(this);
m_sb->setMinValue(minvalue); m_sb->setMinimum(minvalue);
m_sb->setMaxValue(maxvalue); m_sb->setMaximum(maxvalue);
m_sb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, setSzPol(m_sb, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
QSizePolicy::Fixed,
0, // Horizontal stretch
0, // Vertical stretch
m_sb->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_sb); m_hl->addWidget(m_sb);
QFRAME *fr = new QFRAME(this); QFrame *fr = new QFrame(this);
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(fr, QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0);
QSizePolicy::Fixed,
1, // Horizontal stretch
0, // Vertical stretch
fr->sizePolicy().hasHeightForWidth() ) );
m_hl->addWidget(fr); m_hl->addWidget(fr);
loadValue(); loadValue();
@ -158,12 +128,10 @@ ConfParamStrW::ConfParamStrW(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->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(m_le, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
QSizePolicy::Fixed,
1, // Horizontal stretch
0, // Vertical stretch
m_le->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_le); m_hl->addWidget(m_le);
loadValue(); loadValue();
@ -190,14 +158,12 @@ ConfParamCStrW::ConfParamCStrW(QWidget *parent, ConfLink cflink,
{ {
if (!createCommon(lbltxt, tltptxt)) if (!createCommon(lbltxt, tltptxt))
return; return;
m_cmb = new QComboBox(false, this); m_cmb = new QComboBox(this);
m_cmb->insertStringList(sl); m_cmb->setEditable(FALSE);
// m_cmb->setEditable(false); m_cmb->insertItems(0, sl);
m_cmb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
QSizePolicy::Fixed, setSzPol(m_cmb, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
1, // Horizontal stretch
0, // Vertical stretch
m_cmb->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_cmb); m_hl->addWidget(m_cmb);
loadValue(); loadValue();
@ -216,8 +182,8 @@ void ConfParamCStrW::loadValue()
cs = QString::fromUtf8(s.c_str()); cs = QString::fromUtf8(s.c_str());
for (int i = 0; i < m_cmb->count(); i++) { for (int i = 0; i < m_cmb->count(); i++) {
if (!cs.compare(m_cmb->text(i))) { if (!cs.compare(m_cmb->itemText(i))) {
m_cmb->setCurrentItem(i); m_cmb->setCurrentIndex(i);
break; break;
} }
} }
@ -229,29 +195,20 @@ ConfParamBoolW::ConfParamBoolW(QWidget *parent, ConfLink cflink,
: ConfParamW(parent, cflink) : ConfParamW(parent, cflink)
{ {
// No createCommon because the checkbox has a label // No createCommon because the checkbox has a label
m_hl = new QHBOXLAYOUT(this); m_hl = new QHBoxLayout(this);
m_hl->setSpacing(spacing); m_hl->setSpacing(spacing);
m_cb = new QCheckBox(lbltxt, this); m_cb = new QCheckBox(lbltxt, this);
m_cb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, setSzPol(m_cb, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
QSizePolicy::Fixed, m_cb->setToolTip(tltptxt);
0, // Horizontal stretch
0, // Vertical stretch
m_cb->sizePolicy().hasHeightForWidth()));
QToolTip::add(m_cb, tltptxt);
m_hl->addWidget(m_cb); m_hl->addWidget(m_cb);
QFRAME *fr = new QFRAME(this); QFrame *fr = new QFrame(this);
fr->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(fr, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
QSizePolicy::Fixed,
1, // Horizontal stretch
0, // Vertical stretch
fr->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(fr); m_hl->addWidget(fr);
loadValue(); loadValue();
QObject::connect(m_cb, SIGNAL(toggled(bool)), QObject::connect(m_cb, SIGNAL(toggled(bool)), this, SLOT(setValue(bool)));
this, SLOT(setValue(bool)));
} }
void ConfParamBoolW::loadValue() void ConfParamBoolW::loadValue()
@ -272,22 +229,14 @@ ConfParamFNW::ConfParamFNW(QWidget *parent, ConfLink cflink,
return; return;
m_fsencoding = true; m_fsencoding = true;
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, setSzPol(m_le, QSizePolicy::Preferred, QSizePolicy::Fixed, 1, 0);
QSizePolicy::Fixed,
1, // Horizontal stretch
0, // Vertical stretch
m_le->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_le); m_hl->addWidget(m_le);
m_pb = new QPushButton(this); m_pb = new QPushButton(this);
m_pb->setText(tr("Browse")); setSzPol(m_pb, QSizePolicy::Fixed, QSizePolicy::Fixed, 1, 0);
m_pb->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
QSizePolicy::Fixed,
0, // Horizontal stretch
0, // Vertical stretch
m_pb->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_pb); m_hl->addWidget(m_pb);
loadValue(); loadValue();
@ -306,68 +255,56 @@ void ConfParamFNW::loadValue()
void ConfParamFNW::showBrowserDialog() void ConfParamFNW::showBrowserDialog()
{ {
QString s = m_isdir ? QString s = m_isdir ?
QFILEDIALOG::getExistingDirectory() : QFILEDIALOG::getSaveFileName(); QFileDialog::getExistingDirectory() : QFileDialog::getSaveFileName();
if (!s.isEmpty()) if (!s.isEmpty())
m_le->setText(s); m_le->setText(s);
} }
class SmallerListWidget: public QListWidget
{
public:
SmallerListWidget(QWidget *parent)
: QListWidget(parent) {}
virtual QSize sizeHint() {return QSize(150, 40);}
};
ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink, ConfParamSLW::ConfParamSLW(QWidget *parent, ConfLink cflink,
const QString& lbltxt, const QString& lbltxt,
const QString& tltptxt) const QString& tltptxt)
: ConfParamW(parent, cflink) : ConfParamW(parent, cflink)
{ {
// Can't use createCommon here cause we want the buttons below the label // Can't use createCommon here cause we want the buttons below the label
m_hl = new QHBOXLAYOUT(this); m_hl = new QHBoxLayout(this);
m_hl->setSpacing(spacing); m_hl->setSpacing(spacing);
QVBOXLAYOUT *vl1 = new QVBOXLAYOUT(); QVBoxLayout *vl1 = new QVBoxLayout();
QHBOXLAYOUT *hl1 = new QHBOXLAYOUT(); QHBoxLayout *hl1 = new QHBoxLayout();
QLabel *tl = new QLabel(this); QLabel *tl = new QLabel(this);
tl->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(tl, QSizePolicy::Preferred, QSizePolicy::Fixed, 0, 0);
QSizePolicy::Fixed,
0, // Horizontal stretch
0, // Vertical stretch
tl->sizePolicy().hasHeightForWidth()));
tl->setText(lbltxt); tl->setText(lbltxt);
QToolTip::add(tl, tltptxt); tl->setToolTip(tltptxt);
vl1->addWidget(tl); vl1->addWidget(tl);
QPushButton *pbA = new QPushButton(this); QPushButton *pbA = new QPushButton(this);
pbA->setText(tr("+")); pbA->setText(tr("+"));
pbA->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, setSzPol(pbA, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
QSizePolicy::Fixed,
0, // Horizontal stretch
0, // Vertical stretch
pbA->sizePolicy().hasHeightForWidth()));
hl1->addWidget(pbA); hl1->addWidget(pbA);
QPushButton *pbD = new QPushButton(this); QPushButton *pbD = new QPushButton(this);
setSzPol(pbD, QSizePolicy::Fixed, QSizePolicy::Fixed, 0, 0);
pbD->setText(tr("-")); pbD->setText(tr("-"));
pbD->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
QSizePolicy::Fixed,
0, // Horizontal stretch
0, // Vertical stretch
pbD->sizePolicy().hasHeightForWidth()));
hl1->addWidget(pbD); hl1->addWidget(pbD);
vl1->addLayout(hl1); vl1->addLayout(hl1);
m_hl->addLayout(vl1); m_hl->addLayout(vl1);
m_lb = new QLISTBOX(this); m_lb = new SmallerListWidget(this);
m_lb->setSelectionMode(QLISTBOX::Extended); m_lb->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_lb->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(m_lb, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 1);
QSizePolicy::Preferred,
1, // Horizontal stretch
1, // Vertical stretch
m_lb->sizePolicy().hasHeightForWidth()));
m_hl->addWidget(m_lb); m_hl->addWidget(m_lb);
this->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(this, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 1);
QSizePolicy::Preferred,
1, // Horizontal stretch
1, // Vertical stretch
this->sizePolicy().hasHeightForWidth()));
loadValue(); loadValue();
QObject::connect(pbA, SIGNAL(clicked()), this, SLOT(showInputDialog())); QObject::connect(pbA, SIGNAL(clicked()), this, SLOT(showInputDialog()));
QObject::connect(pbD, SIGNAL(clicked()), this, SLOT(deleteSelected())); QObject::connect(pbD, SIGNAL(clicked()), this, SLOT(deleteSelected()));
@ -387,22 +324,25 @@ void ConfParamSLW::loadValue()
qls.push_back(QString::fromUtf8(it->c_str())); qls.push_back(QString::fromUtf8(it->c_str()));
} }
m_lb->clear(); m_lb->clear();
m_lb->insertStringList(qls); m_lb->insertItems(0, qls);
} }
void ConfParamSLW::showInputDialog() void ConfParamSLW::showInputDialog()
{ {
bool ok; bool ok;
QString s = QInputDialog::getText("", // Caption QString s = QInputDialog::getText (this,
"", // Label "", // title
QLineEdit::Normal, // Mode "", // label,
QString::null, // text QLineEdit::Normal, // EchoMode mode
&ok, "", // const QString & text
this); &ok);
if (ok && !s.isEmpty()) { if (ok && !s.isEmpty()) {
if (m_lb->findItem(s, QLBEXACTMATCH) == 0) { QList<QListWidgetItem *>items =
m_lb->insertItem(s); m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
m_lb->sort(); if (items.empty()) {
m_lb->insertItem(0, s);
m_lb->sortItems();
listToConf(); listToConf();
} }
} }
@ -411,14 +351,15 @@ void ConfParamSLW::showInputDialog()
void ConfParamSLW::listToConf() void ConfParamSLW::listToConf()
{ {
list<string> ls; list<string> ls;
for (unsigned int i = 0; i < m_lb->count(); i++) { for (int i = 0; i < m_lb->count(); i++) {
// General parameters are encoded as utf-8. File names as // General parameters are encoded as utf-8. File names as
// local8bit There is no hope for 8bit file names anyway // local8bit There is no hope for 8bit file names anyway
// except for luck: the original encoding is unknown. // except for luck: the original encoding is unknown.
QString text = m_lb->item(i)->text();
if (m_fsencoding) if (m_fsencoding)
ls.push_back((const char *)(m_lb->text(i).local8Bit())); ls.push_back((const char *)(text.toLocal8Bit()));
else else
ls.push_back((const char *)(m_lb->text(i).utf8())); ls.push_back((const char *)(text.toUtf8()));
} }
string s; string s;
stringsToString(ls, s); stringsToString(ls, s);
@ -430,10 +371,11 @@ void ConfParamSLW::deleteSelected()
bool didone; bool didone;
do { do {
didone = false; didone = false;
for (unsigned int i = 0; i < m_lb->count(); i++) { for (int i = 0; i < m_lb->count(); i++) {
if (m_lb->isSelected(i)) { if (m_lb->item(i)->isSelected()) {
emit entryDeleted(m_lb->text(i)); emit entryDeleted(m_lb->item(i)->text());
m_lb->removeItem(i); QListWidgetItem *item = m_lb->takeItem(i);
delete item;
didone = true; didone = true;
break; break;
} }
@ -445,14 +387,18 @@ void ConfParamSLW::deleteSelected()
// "Add entry" dialog for a file name list // "Add entry" dialog for a file name list
void ConfParamDNLW::showInputDialog() void ConfParamDNLW::showInputDialog()
{ {
QString s = QFILEDIALOG::getExistingDirectory(); QString s = QFileDialog::getExistingDirectory();
if (!s.isEmpty()) { if (!s.isEmpty()) {
if (m_lb->findItem(s, QLBEXACTMATCH) == 0) { QList<QListWidgetItem *>items =
m_lb->insertItem(s); m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
m_lb->sort(); if (items.empty()) {
QLISTBOXITEM *item = m_lb->findItem(s, QLBEXACTMATCH); m_lb->insertItem(0, s);
if (m_lb->selectionMode() == QLISTBOX::Single && item) m_lb->sortItems();
m_lb->setSelected(item, true); QList<QListWidgetItem *>items =
m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
if (m_lb->selectionMode() == QAbstractItemView::SingleSelection &&
!items.empty())
(*items.begin())->setSelected(TRUE);
listToConf(); listToConf();
} }
} }
@ -462,16 +408,20 @@ void ConfParamDNLW::showInputDialog()
void ConfParamCSLW::showInputDialog() void ConfParamCSLW::showInputDialog()
{ {
bool ok; bool ok;
QString s = QInputDialog::getItem("", // Caption QString s = QInputDialog::getItem (this, // parent
"", // Label "", // title
m_sl, // List "", // label,
0, // current m_sl, // items,
false, // editable, 0, // current = 0
&ok); FALSE, // editable = true,
&ok);
if (ok && !s.isEmpty()) { if (ok && !s.isEmpty()) {
if (m_lb->findItem(s, QLBEXACTMATCH) == 0) { QList<QListWidgetItem *>items =
m_lb->insertItem(s); m_lb->findItems(s, Qt::MatchFixedString|Qt::MatchCaseSensitive);
m_lb->sort(); if (items.empty()) {
m_lb->insertItem(0, s);
m_lb->sortItems();
listToConf(); listToConf();
} }
} }

View File

@ -27,21 +27,14 @@
#include <qglobal.h> #include <qglobal.h>
#include <qstring.h> #include <qstring.h>
#include <qwidget.h> #include <qwidget.h>
#if QT_VERSION < 0x040000
#define QHBOXLAYOUT QHBoxLayout
#define QLISTBOX QListBox
#else
#define QHBOXLAYOUT Q3HBoxLayout
#define QLISTBOX Q3ListBox
#endif
#include "refcntr.h" #include "refcntr.h"
using std::string; using std::string;
class QHBOXLAYOUT; class QHBoxLayout;
class QLineEdit; class QLineEdit;
class QLISTBOX; class QListWidget;
class QSpinBox; class QSpinBox;
class QComboBox; class QComboBox;
class QCheckBox; class QCheckBox;
@ -84,7 +77,7 @@ namespace confgui {
virtual void setFsEncoding(bool onoff) {m_fsencoding = onoff;} virtual void setFsEncoding(bool onoff) {m_fsencoding = onoff;}
protected: protected:
ConfLink m_cflink; ConfLink m_cflink;
QHBOXLAYOUT *m_hl; QHBoxLayout *m_hl;
// File names are encoded as local8bit in the config files. Other // File names are encoded as local8bit in the config files. Other
// are encoded as utf-8 // are encoded as utf-8
bool m_fsencoding; bool m_fsencoding;
@ -192,7 +185,7 @@ namespace confgui {
const QString& lbltxt, const QString& lbltxt,
const QString& tltptxt); const QString& tltptxt);
virtual void loadValue(); virtual void loadValue();
QLISTBOX *getListBox() {return m_lb;} QListWidget *getListBox() {return m_lb;}
public slots: public slots:
virtual void setEnabled(bool i) {if(m_lb) ((QWidget*)m_lb)->setEnabled(i);} virtual void setEnabled(bool i) {if(m_lb) ((QWidget*)m_lb)->setEnabled(i);}
@ -202,7 +195,7 @@ namespace confgui {
signals: signals:
void entryDeleted(QString); void entryDeleted(QString);
protected: protected:
QLISTBOX *m_lb; QListWidget *m_lb;
void listToConf(); void listToConf();
}; };
@ -237,6 +230,10 @@ namespace confgui {
protected: protected:
const QStringList m_sl; const QStringList m_sl;
}; };
extern void setSzPol(QWidget *w, QSizePolicy::Policy hpol,
QSizePolicy::Policy vpol,
int hstretch, int vstretch);
} }
#endif /* _confgui_h_included_ */ #endif /* _confgui_h_included_ */

View File

@ -3,49 +3,18 @@ static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.13 2008-09-30 12:38:29 docke
#endif #endif
#include <qglobal.h> #include <qglobal.h>
#if QT_VERSION < 0x040000 #include <QHBoxLayout>
#define QFRAME_INCLUDE <qframe.h> #include <QVBoxLayout>
#define QFILEDIALOG_INCLUDE <qfiledialog.h> #include <QGroupBox>
#define QLISTBOX_INCLUDE <qlistbox.h>
#define QFILEDIALOG QFileDialog
#define QFRAME QFrame
#define QHBOXLAYOUT QHBoxLayout
#define QLISTBOX QListBox
#define QLISTBOXITEM QListBoxItem
#define QLBEXACTMATCH Qt::ExactMatch
#define QVBOXLAYOUT QVBoxLayout
#define QGROUPBOX QGroupBox
#include <qgroupbox.h>
#else
#include <Q3HBoxLayout>
#include <Q3VBoxLayout>
#include <Q3GroupBox>
#include <QFrame> #include <QFrame>
#define QFRAME_INCLUDE <q3frame.h>
#include <QFileDialog> #include <QFileDialog>
#define QFILEDIALOG_INCLUDE <q3filedialog.h>
#define QLISTBOX_INCLUDE <q3listbox.h>
#define QFILEDIALOG Q3FileDialog
#define QFRAME Q3Frame
#define QHBOXLAYOUT Q3HBoxLayout
#define QLISTBOX Q3ListBox
#define QLISTBOXITEM Q3ListBoxItem
#define QLBEXACTMATCH Q3ListBox::ExactMatch
#define QVBOXLAYOUT Q3VBoxLayout
#define QGROUPBOX Q3GroupBox
#endif
#include <qlayout.h> #include <qlayout.h>
#include QFRAME_INCLUDE
#include <qwidget.h> #include <qwidget.h>
#include <qlabel.h> #include <qlabel.h>
#include QLISTBOX_INCLUDE
#include <qtimer.h> #include <qtimer.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include <QListWidget>
#include <list> #include <list>
using std::list; using std::list;
@ -62,20 +31,28 @@ using std::list;
#include "rclconfig.h" #include "rclconfig.h"
namespace confgui { namespace confgui {
const static int spacing = 6; const static int spacing = 3;
const static int margin = 6; const static int margin = 3;
ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config) ConfIndexW::ConfIndexW(QWidget *parent, RclConfig *config)
: QTABDIALOG(parent), m_rclconf(config) : QDialog(parent), m_rclconf(config)
{ {
setCaption(QString::fromLocal8Bit(config->getConfDir().c_str())); setWindowTitle(QString::fromLocal8Bit(config->getConfDir().c_str()));
setOkButton(); tabWidget = new QTabWidget;
setCancelButton();
reloadPanels(); reloadPanels();
resize(QSize(600, 500).expandedTo(minimumSizeHint()));
connect(this, SIGNAL(applyButtonPressed()), this, SLOT(acceptChanges())); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
connect(this, SIGNAL(cancelButtonPressed()), this, SLOT(rejectChanges())); | QDialogButtonBox::Cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(tabWidget);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
resize(QSize(600, 450).expandedTo(minimumSizeHint()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(rejectChanges()));
} }
void ConfIndexW::acceptChanges() void ConfIndexW::acceptChanges()
@ -101,6 +78,7 @@ void ConfIndexW::acceptChanges()
startIndexingAfterConfig = 0; startIndexingAfterConfig = 0;
start_indexing(true); start_indexing(true);
} }
hide();
} }
void ConfIndexW::rejectChanges() void ConfIndexW::rejectChanges()
@ -110,6 +88,7 @@ void ConfIndexW::rejectChanges()
delete m_conf; delete m_conf;
m_conf = 0; m_conf = 0;
QTimer::singleShot(0, this, SLOT(reloadPanels())); QTimer::singleShot(0, this, SLOT(reloadPanels()));
hide();
} }
void ConfIndexW::reloadPanels() void ConfIndexW::reloadPanels()
@ -117,31 +96,26 @@ void ConfIndexW::reloadPanels()
if ((m_conf = m_rclconf->cloneMainConfig()) == 0) if ((m_conf = m_rclconf->cloneMainConfig()) == 0)
return; return;
m_conf->holdWrites(true); m_conf->holdWrites(true);
for (list<QWidget *>::iterator it = m_widgets.begin(); tabWidget->clear();
it != m_widgets.end(); it++) {
removePage(*it);
delete *it;
}
m_widgets.clear(); m_widgets.clear();
QWidget *w = new ConfTopPanelW(this, m_conf); QWidget *w = new ConfTopPanelW(this, m_conf);
m_widgets.push_back(w); m_widgets.push_back(w);
addTab(w, QObject::tr("Global parameters")); tabWidget->addTab(w, QObject::tr("Global parameters"));
w = new ConfSubPanelW(this, m_conf); w = new ConfSubPanelW(this, m_conf);
m_widgets.push_back(w); m_widgets.push_back(w);
addTab(w, QObject::tr("Local parameters")); tabWidget->addTab(w, QObject::tr("Local parameters"));
w = new ConfBeaglePanelW(this, m_conf); w = new ConfBeaglePanelW(this, m_conf);
m_widgets.push_back(w); m_widgets.push_back(w);
addTab(w, QObject::tr("Beagle web history")); tabWidget->addTab(w, QObject::tr("Beagle web history"));
} }
ConfBeaglePanelW::ConfBeaglePanelW(QWidget *parent, ConfNull *config) ConfBeaglePanelW::ConfBeaglePanelW(QWidget *parent, ConfNull *config)
: QWidget(parent) : QWidget(parent)
{ {
QVBOXLAYOUT *vboxLayout = new QVBOXLAYOUT(this); QVBoxLayout *vboxLayout = new QVBoxLayout(this);
vboxLayout->setSpacing(spacing); vboxLayout->setSpacing(spacing);
vboxLayout->setMargin(margin); vboxLayout->setMargin(margin);
@ -161,7 +135,7 @@ ConfBeaglePanelW::ConfBeaglePanelW(QWidget *parent, ConfNull *config)
"for visited web pages.<br>" "for visited web pages.<br>"
"A non-absolute path is taken relative to the " "A non-absolute path is taken relative to the "
"configuration directory."), true); "configuration directory."), true);
cp2->setEnabled(cp1->m_cb->isOn()); cp2->setEnabled(cp1->m_cb->isChecked());
connect(cp1->m_cb, SIGNAL(toggled(bool)), cp2, SLOT(setEnabled(bool))); connect(cp1->m_cb, SIGNAL(toggled(bool)), cp2, SLOT(setEnabled(bool)));
vboxLayout->addWidget(cp2); vboxLayout->addWidget(cp2);
@ -170,7 +144,7 @@ ConfBeaglePanelW::ConfBeaglePanelW(QWidget *parent, ConfNull *config)
new ConfParamIntW(this, lnk3, tr("Max. size for the web cache (MB)"), new ConfParamIntW(this, lnk3, tr("Max. size for the web cache (MB)"),
tr("Entries will be recycled once the size is reached"), tr("Entries will be recycled once the size is reached"),
-1, 1000); -1, 1000);
cp3->setEnabled(cp1->m_cb->isOn()); cp3->setEnabled(cp1->m_cb->isChecked());
connect(cp1->m_cb, SIGNAL(toggled(bool)), cp3, SLOT(setEnabled(bool))); connect(cp1->m_cb, SIGNAL(toggled(bool)), cp3, SLOT(setEnabled(bool)));
vboxLayout->addWidget(cp3); vboxLayout->addWidget(cp3);
vboxLayout->insertStretch(-1); vboxLayout->insertStretch(-1);
@ -188,11 +162,8 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
ConfParamDNLW(this, lnktopdirs, tr("Top directories"), ConfParamDNLW(this, lnktopdirs, tr("Top directories"),
tr("The list of directories where recursive " tr("The list of directories where recursive "
"indexing starts. Default: your home.")); "indexing starts. Default: your home."));
#if QT_VERSION < 0x040000 setSzPol(etopdirs, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 3);
gl1->addMultiCellWidget(etopdirs, 0, 0, 0, 1);
#else
gl1->addWidget(etopdirs, 0, 0, 1, 2); gl1->addWidget(etopdirs, 0, 0, 1, 2);
#endif
ConfLink lnkskp(new ConfLinkRclRep(config, "skippedPaths")); ConfLink lnkskp(new ConfLinkRclRep(config, "skippedPaths"));
ConfParamSLW *eskp = new ConfParamSLW *eskp = new
@ -205,11 +176,8 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
"to '/usr/home', a correct skippedPath entry " "to '/usr/home', a correct skippedPath entry "
"would be '/home/me/tmp*', not '/usr/home/me/tmp*')")); "would be '/home/me/tmp*', not '/usr/home/me/tmp*')"));
eskp->setFsEncoding(true); eskp->setFsEncoding(true);
#if QT_VERSION < 0x040000 setSzPol(eskp, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 3);
gl1->addMultiCellWidget(eskp, 1, 1, 0, 1);
#else
gl1->addWidget(eskp, 1, 0, 1, 2); gl1->addWidget(eskp, 1, 0, 1, 2);
#endif
list<string> cstemlangs = Rcl::Db::getStemmerNames(); list<string> cstemlangs = Rcl::Db::getStemmerNames();
QStringList stemlangs; QStringList stemlangs;
@ -222,22 +190,15 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
ConfParamCSLW(this, lnkidxsl, tr("Stemming languages"), ConfParamCSLW(this, lnkidxsl, tr("Stemming languages"),
tr("The languages for which stemming expansion<br>" tr("The languages for which stemming expansion<br>"
"dictionaries will be built."), stemlangs); "dictionaries will be built."), stemlangs);
#if QT_VERSION < 0x040000 setSzPol(eidxsl, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 1);
gl1->addMultiCellWidget(eidxsl, 2, 2, 0, 1);
#else
gl1->addWidget(eidxsl, 2, 0, 1, 2); gl1->addWidget(eidxsl, 2, 0, 1, 2);
#endif
ConfLink lnk4(new ConfLinkRclRep(config, "logfilename")); ConfLink lnk4(new ConfLinkRclRep(config, "logfilename"));
ConfParamFNW *e4 = new ConfParamFNW *e4 = new
ConfParamFNW(this, lnk4, tr("Log file name"), ConfParamFNW(this, lnk4, tr("Log file name"),
tr("The file where the messages will be written.<br>" tr("The file where the messages will be written.<br>"
"Use 'stderr' for terminal output"), false); "Use 'stderr' for terminal output"), false);
#if QT_VERSION < 0x040000
gl1->addMultiCellWidget(e4, 3, 3, 0, 1);
#else
gl1->addWidget(e4, 3, 0, 1, 2); gl1->addWidget(e4, 3, 0, 1, 2);
#endif
QWidget *w = 0; QWidget *w = 0;
@ -289,7 +250,7 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
"To get an idea of what is installed on your system, " "To get an idea of what is installed on your system, "
"type 'aspell config' and look for .dat files inside " "type 'aspell config' and look for .dat files inside "
"the 'data-dir' directory. ")); "the 'data-dir' directory. "));
cpaspl->setEnabled(!cpasp->m_cb->isOn()); cpaspl->setEnabled(!cpasp->m_cb->isChecked());
connect(cpasp->m_cb, SIGNAL(toggled(bool)), cpaspl,SLOT(setDisabled(bool))); connect(cpasp->m_cb, SIGNAL(toggled(bool)), cpaspl,SLOT(setDisabled(bool)));
gl1->addWidget(cpaspl, 6, 1); gl1->addWidget(cpaspl, 6, 1);
@ -300,17 +261,13 @@ ConfTopPanelW::ConfTopPanelW(QWidget *parent, ConfNull *config)
"A non-absolute path is taken relative to the " "A non-absolute path is taken relative to the "
" configuration directory. The default is 'xapiandb'." " configuration directory. The default is 'xapiandb'."
), true); ), true);
#if QT_VERSION < 0x040000
gl1->addMultiCellWidget(edbd, 7, 7, 0, 1);
#else
gl1->addWidget(edbd, 7, 0, 1, 2); gl1->addWidget(edbd, 7, 0, 1, 2);
#endif
} }
ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config) ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
: QWidget(parent), m_config(config) : 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);
@ -321,9 +278,11 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
QObject::tr("The list of subdirectories in the indexed " QObject::tr("The list of subdirectories in the indexed "
"hierarchy <br>where some parameters need " "hierarchy <br>where some parameters need "
"to be redefined. Default: empty.")); "to be redefined. Default: empty."));
m_subdirs->getListBox()->setSelectionMode(QLISTBOX::Single); m_subdirs->getListBox()->setSelectionMode(QAbstractItemView::SingleSelection);
connect(m_subdirs->getListBox(), SIGNAL(selectionChanged()), connect(m_subdirs->getListBox(),
this, SLOT(subDirChanged())); SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this,
SLOT(subDirChanged(QListWidgetItem *, QListWidgetItem *)));
connect(m_subdirs, SIGNAL(entryDeleted(QString)), connect(m_subdirs, SIGNAL(entryDeleted(QString)),
this, SLOT(subDirDeleted(QString))); this, SLOT(subDirDeleted(QString)));
list<string> allkeydirs = config->getSubKeys(); list<string> allkeydirs = config->getSubKeys();
@ -332,12 +291,12 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
it != allkeydirs.end(); it++) { it != allkeydirs.end(); it++) {
qls.push_back(QString::fromUtf8(it->c_str())); qls.push_back(QString::fromUtf8(it->c_str()));
} }
m_subdirs->getListBox()->insertStringList(qls); m_subdirs->getListBox()->insertItems(0, qls);
vboxLayout->addWidget(m_subdirs); vboxLayout->addWidget(m_subdirs);
QFRAME *line2 = new QFRAME(this); QFrame *line2 = new QFrame(this);
line2->setFrameShape(QFRAME::HLine); line2->setFrameShape(QFrame::HLine);
line2->setFrameShadow(QFRAME::Sunken); line2->setFrameShadow(QFrame::Sunken);
vboxLayout->addWidget(line2); vboxLayout->addWidget(line2);
QLabel *explain = new QLabel(this); QLabel *explain = new QLabel(this);
@ -352,31 +311,22 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
vboxLayout->addWidget(explain); vboxLayout->addWidget(explain);
m_groupbox = new QGROUPBOX(1, Qt::Horizontal, this); m_groupbox = new QGroupBox(this);
m_groupbox->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, setSzPol(m_groupbox, QSizePolicy::Preferred, QSizePolicy::Preferred, 1, 3);
QSizePolicy::Preferred,
1, // Horizontal stretch
3, // Vertical stretch
m_groupbox->sizePolicy().hasHeightForWidth()));
QWidget *w = new QWidget(m_groupbox); QGridLayout *gl1 = new QGridLayout(m_groupbox);
QGridLayout *gl1 = new QGridLayout(w);
gl1->setSpacing(spacing); gl1->setSpacing(spacing);
gl1->setMargin(margin); gl1->setMargin(margin);
ConfLink lnkskn(new ConfLinkRclRep(config, "skippedNames", &m_sk)); ConfLink lnkskn(new ConfLinkRclRep(config, "skippedNames", &m_sk));
ConfParamSLW *eskn = new ConfParamSLW *eskn = new
ConfParamSLW(w, lnkskn, ConfParamSLW(m_groupbox, lnkskn,
QObject::tr("Skipped names"), QObject::tr("Skipped names"),
QObject::tr("These are patterns for file or directory " QObject::tr("These are patterns for file or directory "
" names which should not be indexed.")); " names which should not be indexed."));
eskn->setFsEncoding(true); eskn->setFsEncoding(true);
m_widgets.push_back(eskn); m_widgets.push_back(eskn);
#if QT_VERSION < 0x040000
gl1->addMultiCellWidget(eskn, 0, 0, 0, 1);
#else
gl1->addWidget(eskn, 0, 0, 1, 2); gl1->addWidget(eskn, 0, 0, 1, 2);
#endif
list<string> args; list<string> args;
args.push_back("-l"); args.push_back("-l");
@ -399,7 +349,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
ConfLink lnk21(new ConfLinkRclRep(config, "defaultcharset", &m_sk)); ConfLink lnk21(new ConfLinkRclRep(config, "defaultcharset", &m_sk));
ConfParamCStrW *e21 = new ConfParamCStrW *e21 = new
ConfParamCStrW(w, lnk21, ConfParamCStrW(m_groupbox, lnk21,
QObject::tr("Default character set"), QObject::tr("Default character set"),
QObject::tr("This is the character set used for reading files " 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 "
@ -408,15 +358,11 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
"and the value from the NLS environnement is used." "and the value from the NLS environnement is used."
), charsets); ), charsets);
m_widgets.push_back(e21); m_widgets.push_back(e21);
#if QT_VERSION < 0x040000
gl1->addMultiCellWidget(e21, 1, 1, 0, 1);
#else
gl1->addWidget(e21, 1, 0, 1, 2); gl1->addWidget(e21, 1, 0, 1, 2);
#endif
ConfLink lnk3(new ConfLinkRclRep(config, "followLinks", &m_sk)); ConfLink lnk3(new ConfLinkRclRep(config, "followLinks", &m_sk));
ConfParamBoolW *e3 = new ConfParamBoolW *e3 = new
ConfParamBoolW(w, lnk3, ConfParamBoolW(m_groupbox, lnk3,
QObject::tr("Follow symbolic links"), QObject::tr("Follow symbolic links"),
QObject::tr("Follow symbolic links while " QObject::tr("Follow symbolic links while "
"indexing. The default is no, " "indexing. The default is no, "
@ -426,7 +372,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
ConfLink lnkafln(new ConfLinkRclRep(config, "indexallfilenames", &m_sk)); ConfLink lnkafln(new ConfLinkRclRep(config, "indexallfilenames", &m_sk));
ConfParamBoolW *eafln = new ConfParamBoolW *eafln = new
ConfParamBoolW(w, lnkafln, ConfParamBoolW(m_groupbox, lnkafln,
QObject::tr("Index all file names"), QObject::tr("Index all file names"),
QObject::tr("Index the names of files for which the contents " 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 "
@ -436,7 +382,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
ConfLink lnkzfmaxkbs(new ConfLinkRclRep(config, "compressedfilemaxkbs")); ConfLink lnkzfmaxkbs(new ConfLinkRclRep(config, "compressedfilemaxkbs"));
ConfParamIntW *ezfmaxkbs = new ConfParamIntW *ezfmaxkbs = new
ConfParamIntW(w, lnkzfmaxkbs, ConfParamIntW(m_groupbox, lnkzfmaxkbs,
tr("Max. compressed file size (KB)"), tr("Max. compressed file size (KB)"),
tr("This value sets a threshold beyond which compressed" tr("This value sets a threshold beyond which compressed"
"files will not be processed. Set to -1 for no " "files will not be processed. Set to -1 for no "
@ -447,7 +393,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
ConfLink lnktxtmaxmbs(new ConfLinkRclRep(config, "textfilemaxmbs")); ConfLink lnktxtmaxmbs(new ConfLinkRclRep(config, "textfilemaxmbs"));
ConfParamIntW *etxtmaxmbs = new ConfParamIntW *etxtmaxmbs = new
ConfParamIntW(w, lnktxtmaxmbs, ConfParamIntW(m_groupbox, lnktxtmaxmbs,
tr("Max. text file size (MB)"), tr("Max. text file size (MB)"),
tr("This value sets a threshold beyond which text " tr("This value sets a threshold beyond which text "
"files will not be processed. Set to -1 for no " "files will not be processed. Set to -1 for no "
@ -459,7 +405,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
ConfLink lnktxtpagekbs(new ConfLinkRclRep(config, "textfilepagekbs")); ConfLink lnktxtpagekbs(new ConfLinkRclRep(config, "textfilepagekbs"));
ConfParamIntW *etxtpagekbs = new ConfParamIntW *etxtpagekbs = new
ConfParamIntW(w, lnktxtpagekbs, ConfParamIntW(m_groupbox, lnktxtpagekbs,
tr("Text file page size (KB)"), tr("Text file page size (KB)"),
tr("If this value is set (not equal to -1), text " tr("If this value is set (not equal to -1), text "
"files will be split in chunks of this size for " "files will be split in chunks of this size for "
@ -471,7 +417,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
ConfLink lnkfiltmaxsecs(new ConfLinkRclRep(config, "filtermaxseconds")); ConfLink lnkfiltmaxsecs(new ConfLinkRclRep(config, "filtermaxseconds"));
ConfParamIntW *efiltmaxsecs = new ConfParamIntW *efiltmaxsecs = new
ConfParamIntW(w, lnkfiltmaxsecs, ConfParamIntW(m_groupbox, lnkfiltmaxsecs,
tr("Max. filter exec. time (S)"), tr("Max. filter exec. time (S)"),
tr("External filters working longer than this will be " tr("External filters working longer than this will be "
"aborted. This is for the rare case (ie: postscript) " "aborted. This is for the rare case (ie: postscript) "
@ -482,7 +428,7 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
gl1->addWidget(efiltmaxsecs, 4, 1); gl1->addWidget(efiltmaxsecs, 4, 1);
vboxLayout->addWidget(m_groupbox); vboxLayout->addWidget(m_groupbox);
subDirChanged(); subDirChanged(0, 0);
} }
void ConfSubPanelW::reloadAll() void ConfSubPanelW::reloadAll()
@ -493,16 +439,16 @@ void ConfSubPanelW::reloadAll()
} }
} }
void ConfSubPanelW::subDirChanged() void ConfSubPanelW::subDirChanged(QListWidgetItem *current, QListWidgetItem *)
{ {
LOGDEB(("ConfSubPanelW::subDirChanged\n")); LOGDEB(("ConfSubPanelW::subDirChanged\n"));
QLISTBOXITEM *item = m_subdirs->getListBox()->selectedItem();
if (item == 0 || item->text() == "") { if (current == 0 || current->text() == "") {
m_sk = ""; m_sk = "";
m_groupbox->setTitle(tr("Global")); m_groupbox->setTitle(tr("Global"));
} else { } else {
m_sk = (const char *)item->text().utf8(); m_sk = (const char *) current->text().toUtf8();
m_groupbox->setTitle(item->text()); m_groupbox->setTitle(current->text());
} }
LOGDEB(("ConfSubPanelW::subDirChanged: now [%s]\n", m_sk.c_str())); LOGDEB(("ConfSubPanelW::subDirChanged: now [%s]\n", m_sk.c_str()));
reloadAll(); reloadAll();
@ -510,20 +456,20 @@ void ConfSubPanelW::subDirChanged()
void ConfSubPanelW::subDirDeleted(QString sbd) void ConfSubPanelW::subDirDeleted(QString sbd)
{ {
LOGDEB(("ConfSubPanelW::subDirDeleted(%s)\n", (const char *)sbd.utf8())); LOGDEB(("ConfSubPanelW::subDirDeleted(%s)\n", (const char *)sbd.toUtf8()));
if (sbd == "") { if (sbd == "") {
// Can't do this, have to reinsert it // Can't do this, have to reinsert it
QTimer::singleShot(0, this, SLOT(restoreEmpty())); QTimer::singleShot(0, this, SLOT(restoreEmpty()));
return; return;
} }
// Have to delete all entries for submap // Have to delete all entries for submap
m_config->eraseKey((const char *)sbd.utf8()); m_config->eraseKey((const char *)sbd.toUtf8());
} }
void ConfSubPanelW::restoreEmpty() void ConfSubPanelW::restoreEmpty()
{ {
LOGDEB(("ConfSubPanelW::restoreEmpty()\n")); LOGDEB(("ConfSubPanelW::restoreEmpty()\n"));
m_subdirs->getListBox()->insertItem("", 0); m_subdirs->getListBox()->insertItem(0, "");
} }
} // Namespace confgui } // Namespace confgui

View File

@ -7,17 +7,13 @@
* confgui elements, linked to configuration parameters, into panels. * confgui elements, linked to configuration parameters, into panels.
*/ */
#include <qwidget.h> #include <QWidget>
#include <qstring.h> #include <QString>
#if QT_VERSION < 0x040000 #include <QGroupBox>
#include <qgroupbox.h> #include <QDialog>
#include <qtabdialog.h> #include <QDialogButtonBox>
#define QTABDIALOG QTabDialog #include <QTabWidget>
#else // Qt4 -> #include <QListWidgetItem>
#include <Q3GroupBox>
#include <Q3TabDialog>
#define QTABDIALOG Q3TabDialog
#endif // QT 3/4
#include <string> #include <string>
#include <list> #include <list>
@ -31,7 +27,7 @@ class ConfParamDNLW;
namespace confgui { namespace confgui {
class ConfIndexW : public QTABDIALOG { class ConfIndexW : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
ConfIndexW(QWidget *parent, RclConfig *config); ConfIndexW(QWidget *parent, RclConfig *config);
@ -43,6 +39,8 @@ private:
RclConfig *m_rclconf; RclConfig *m_rclconf;
ConfNull *m_conf; ConfNull *m_conf;
list<QWidget *> m_widgets; list<QWidget *> m_widgets;
QTabWidget *tabWidget;
QDialogButtonBox *buttonBox;
}; };
/** /**
@ -64,7 +62,7 @@ public:
ConfSubPanelW(QWidget *parent, ConfNull *config); ConfSubPanelW(QWidget *parent, ConfNull *config);
private slots: private slots:
void subDirChanged(); void subDirChanged(QListWidgetItem *, QListWidgetItem *);
void subDirDeleted(QString); void subDirDeleted(QString);
void restoreEmpty(); void restoreEmpty();
private: private:
@ -72,11 +70,7 @@ private:
ConfParamDNLW *m_subdirs; ConfParamDNLW *m_subdirs;
list<ConfParamW*> m_widgets; list<ConfParamW*> m_widgets;
ConfNull *m_config; ConfNull *m_config;
#if QT_VERSION < 0x040000
QGroupBox *m_groupbox; QGroupBox *m_groupbox;
#else
Q3GroupBox *m_groupbox;
#endif
void reloadAll(); void reloadAll();
}; };

View File

@ -208,7 +208,7 @@ int main(int argc, char **argv)
question += *argv++; question += *argv++;
} }
// Translation file for Qt TOBEDONE ? // Translation file for Qt
QString slang = QLocale::system().name().left(2); QString slang = QLocale::system().name().left(2);
QTranslator qt(0); QTranslator qt(0);
qt.load(QString("qt_") + slang, "." ); qt.load(QString("qt_") + slang, "." );

View File

@ -86,7 +86,7 @@ public:
virtual string startMatch() virtual string startMatch()
{ {
return string("<span style='color: ") return string("<span style='color: ")
+ string((const char *)(prefs.qtermcolor.utf8())) + string((const char *)(prefs.qtermcolor.toUtf8()))
+ string(";font-weight: bold;") + string(";font-weight: bold;")
+ string("'>"); + string("'>");
} }
@ -110,9 +110,10 @@ public:
}; };
PreviewTextEdit::PreviewTextEdit(QWidget* parent,const char* name, Preview *pv) PreviewTextEdit::PreviewTextEdit(QWidget* parent,const char* name, Preview *pv)
: QTextEdit(parent, name), m_preview(pv), m_dspflds(false) : QTextEdit(parent), m_preview(pv), m_dspflds(false)
{ {
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
setObjectName(name);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(createPopupMenu(const QPoint&))); this, SLOT(createPopupMenu(const QPoint&)));
m_plaintorich = new PlainToRichQtPreview(); m_plaintorich = new PlainToRichQtPreview();
@ -125,44 +126,39 @@ PreviewTextEdit::~PreviewTextEdit()
void Preview::init() void Preview::init()
{ {
setName("Preview"); setObjectName("Preview");
setSizePolicy( QSizePolicy((QSizePolicy::SizeType)5, QVBoxLayout* previewLayout = new QVBoxLayout(this);
(QSizePolicy::SizeType)5, 0, 0,
sizePolicy().hasHeightForWidth()));
QVBoxLayout* previewLayout =
new QVBoxLayout( this, 4, 6, "previewLayout");
pvTab = new QTabWidget(this, "pvTab"); pvTab = new QTabWidget(this);
// Create the first tab. Should be possible to use addEditorTab // Create the first tab. Should be possible to use addEditorTab
// but this causes a pb with the sizeing // but this causes a pb with the sizeing
QWidget *unnamed = new QWidget(pvTab, "unnamed"); QWidget *unnamed = new QWidget(pvTab);
QVBoxLayout *unnamedLayout = QVBoxLayout *unnamedLayout = new QVBoxLayout(unnamed);
new QVBoxLayout(unnamed, 0, 6, "unnamedLayout");
PreviewTextEdit *pvEdit = new PreviewTextEdit(unnamed, "pvEdit", this); PreviewTextEdit *pvEdit = new PreviewTextEdit(unnamed, "pvEdit", this);
pvEdit->setReadOnly(TRUE); pvEdit->setReadOnly(TRUE);
pvEdit->setUndoRedoEnabled(FALSE); pvEdit->setUndoRedoEnabled(FALSE);
unnamedLayout->addWidget(pvEdit); unnamedLayout->addWidget(pvEdit);
pvTab->insertTab(unnamed, QString::fromLatin1("")); pvTab->addTab(unnamed, "");
previewLayout->addWidget(pvTab); previewLayout->addWidget(pvTab);
// Create the buttons and entry field // Create the buttons and entry field
QHBoxLayout *layout3 = new QHBoxLayout(0, 0, 6, "layout3"); QHBoxLayout *layout3 = new QHBoxLayout(0);
searchLabel = new QLabel(this, "searchLabel"); searchLabel = new QLabel(this);
layout3->addWidget(searchLabel); layout3->addWidget(searchLabel);
searchTextLine = new QLineEdit(this, "searchTextLine"); searchTextLine = new QLineEdit(this);
layout3->addWidget(searchTextLine); layout3->addWidget(searchTextLine);
nextButton = new QPushButton(this, "nextButton"); nextButton = new QPushButton(this);
nextButton->setEnabled(TRUE); nextButton->setEnabled(TRUE);
layout3->addWidget(nextButton); layout3->addWidget(nextButton);
prevButton = new QPushButton(this, "prevButton"); prevButton = new QPushButton(this);
prevButton->setEnabled(TRUE); prevButton->setEnabled(TRUE);
layout3->addWidget(prevButton); layout3->addWidget(prevButton);
clearPB = new QPushButton(this, "clearPB"); clearPB = new QPushButton(this);
clearPB->setEnabled(FALSE); clearPB->setEnabled(FALSE);
layout3->addWidget(clearPB); layout3->addWidget(clearPB);
matchCheck = new QCheckBox(this, "matchCheck"); matchCheck = new QCheckBox(this);
layout3->addWidget(matchCheck); layout3->addWidget(matchCheck);
previewLayout->addLayout(layout3); previewLayout->addLayout(layout3);
@ -182,7 +178,8 @@ void Preview::init()
pvTab->setCornerWidget(bt); pvTab->setCornerWidget(bt);
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.PREVIEW"); HelpClient::installMap((const char *)objectName().toUtf8(),
"RCL.SEARCH.PREVIEW");
// signals and slots connections // signals and slots connections
connect(searchTextLine, SIGNAL(textChanged(const QString&)), connect(searchTextLine, SIGNAL(textChanged(const QString&)),
@ -201,7 +198,7 @@ void Preview::init()
resize(prefs.pvwidth, prefs.pvheight); resize(prefs.pvwidth, prefs.pvheight);
} }
m_loading = false; m_loading = false;
currentChanged(pvTab->currentPage()); currentChanged(pvTab->currentWidget());
m_justCreated = true; m_justCreated = true;
m_haveAnchors = false; m_haveAnchors = false;
m_curAnchor = 1; m_curAnchor = 1;
@ -243,31 +240,31 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
PreviewTextEdit *edit = currentEditor(); PreviewTextEdit *edit = currentEditor();
QKeyEvent *keyEvent = (QKeyEvent *)event; QKeyEvent *keyEvent = (QKeyEvent *)event;
if (keyEvent->key() == Qt::Key_Q && if (keyEvent->key() == Qt::Key_Q &&
(keyEvent->state() & Qt::ControlButton)) { (keyEvent->modifiers() & Qt::ControlModifier)) {
recollNeedsExit = 1; recollNeedsExit = 1;
return true; return true;
} else if (keyEvent->key() == Qt::Key_Escape) { } else if (keyEvent->key() == Qt::Key_Escape) {
close(); close();
return true; return true;
} else if (keyEvent->key() == Qt::Key_Down && } else if (keyEvent->key() == Qt::Key_Down &&
(keyEvent->state() & Qt::ShiftButton)) { (keyEvent->modifiers() & Qt::ShiftModifier)) {
LOGDEB2(("Preview::eventFilter: got Shift-Up\n")); LOGDEB2(("Preview::eventFilter: got Shift-Up\n"));
if (edit) if (edit)
emit(showNext(this, m_searchId, edit->m_data.docnum)); emit(showNext(this, m_searchId, edit->m_data.docnum));
return true; return true;
} else if (keyEvent->key() == Qt::Key_Up && } else if (keyEvent->key() == Qt::Key_Up &&
(keyEvent->state() & Qt::ShiftButton)) { (keyEvent->modifiers() & Qt::ShiftModifier)) {
LOGDEB2(("Preview::eventFilter: got Shift-Down\n")); LOGDEB2(("Preview::eventFilter: got Shift-Down\n"));
if (edit) if (edit)
emit(showPrev(this, m_searchId, edit->m_data.docnum)); emit(showPrev(this, m_searchId, edit->m_data.docnum));
return true; return true;
} else if (keyEvent->key() == Qt::Key_W && } else if (keyEvent->key() == Qt::Key_W &&
(keyEvent->state() & Qt::ControlButton)) { (keyEvent->modifiers() & Qt::ControlModifier)) {
LOGDEB2(("Preview::eventFilter: got ^W\n")); LOGDEB2(("Preview::eventFilter: got ^W\n"));
closeCurrentTab(); closeCurrentTab();
return true; return true;
} else if (keyEvent->key() == Qt::Key_P && } else if (keyEvent->key() == Qt::Key_P &&
(keyEvent->state() & Qt::ControlButton)) { (keyEvent->modifiers() & Qt::ControlModifier)) {
LOGDEB2(("Preview::eventFilter: got ^P\n")); LOGDEB2(("Preview::eventFilter: got ^P\n"));
emit(printCurrentPreviewRequest()); emit(printCurrentPreviewRequest());
return true; return true;
@ -293,7 +290,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
value += edit->verticalScrollBar()->pageStep(); value += edit->verticalScrollBar()->pageStep();
edit->verticalScrollBar()->setValue(value); edit->verticalScrollBar()->setValue(value);
return true; return true;
} else if (keyEvent->key() == Qt::Key_BackSpace) { } else if (keyEvent->key() == Qt::Key_Backspace) {
LOGDEB2(("Preview::eventFilter: got Backspace\n")); LOGDEB2(("Preview::eventFilter: got Backspace\n"));
int value = edit->verticalScrollBar()->value(); int value = edit->verticalScrollBar()->value();
value -= edit->verticalScrollBar()->pageStep(); value -= edit->verticalScrollBar()->pageStep();
@ -326,10 +323,10 @@ void Preview::searchTextLine_textChanged(const QString & text)
PreviewTextEdit *Preview::currentEditor() PreviewTextEdit *Preview::currentEditor()
{ {
LOGDEB2(("Preview::currentEditor()\n")); LOGDEB2(("Preview::currentEditor()\n"));
QWidget *tw = pvTab->currentPage(); QWidget *tw = pvTab->currentWidget();
PreviewTextEdit *edit = 0; PreviewTextEdit *edit = 0;
if (tw) { if (tw) {
edit = dynamic_cast<PreviewTextEdit*>(tw->child("pvEdit")); edit = tw->findChild<PreviewTextEdit*>("pvEdit");
} }
return edit; return edit;
} }
@ -342,7 +339,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
bool wordOnly) bool wordOnly)
{ {
LOGDEB(("Preview::doSearch: text [%s] txtlen %d next %d rev %d word %d\n", LOGDEB(("Preview::doSearch: text [%s] txtlen %d next %d rev %d word %d\n",
(const char *)_text.utf8(), _text.length(), int(next), (const char *)_text.toUtf8(), _text.length(), int(next),
int(reverse), int(wordOnly))); int(reverse), int(wordOnly)));
QString text = _text; QString text = _text;
@ -372,7 +369,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
LOGDEB(("m_curAnchor: %d\n", m_curAnchor)); LOGDEB(("m_curAnchor: %d\n", m_curAnchor));
QString aname = QString aname =
QString::fromUtf8(edit->m_plaintorich->termAnchorName(m_curAnchor).c_str()); QString::fromUtf8(edit->m_plaintorich->termAnchorName(m_curAnchor).c_str());
LOGDEB(("Calling scrollToAnchor(%s)\n", (const char *)aname.utf8())); LOGDEB(("Calling scrollToAnchor(%s)\n", (const char *)aname.toUtf8()));
edit->scrollToAnchor(aname); edit->scrollToAnchor(aname);
// Position the cursor approximately at the anchor (top of // Position the cursor approximately at the anchor (top of
// viewport) so that searches start from here // viewport) so that searches start from here
@ -445,7 +442,7 @@ void Preview::currentChanged(QWidget * tw)
{ {
LOGDEB2(("PreviewTextEdit::currentChanged\n")); LOGDEB2(("PreviewTextEdit::currentChanged\n"));
PreviewTextEdit *edit = PreviewTextEdit *edit =
dynamic_cast<PreviewTextEdit*>(tw->child("pvEdit")); tw->findChild<PreviewTextEdit*>("pvEdit");
m_currentW = tw; m_currentW = tw;
LOGDEB1(("Preview::currentChanged(). Editor: %p\n", edit)); LOGDEB1(("Preview::currentChanged(). Editor: %p\n", edit));
@ -454,9 +451,6 @@ void Preview::currentChanged(QWidget * tw)
return; return;
} }
edit->setFocus(); edit->setFocus();
// Connect doubleclick but cleanup first just in case this was
// already connected.
disconnect(edit, SIGNAL(doubleClicked(int, int)), this, 0);
// Disconnect the print signal and reconnect it to the current editor // Disconnect the print signal and reconnect it to the current editor
LOGDEB(("Disconnecting reconnecting print signal\n")); LOGDEB(("Disconnecting reconnecting print signal\n"));
disconnect(this, SIGNAL(printCurrentPreviewRequest()), 0, 0); disconnect(this, SIGNAL(printCurrentPreviewRequest()), 0, 0);
@ -475,10 +469,7 @@ void Preview::closeCurrentTab()
return; return;
} }
if (pvTab->count() > 1) { if (pvTab->count() > 1) {
QWidget *tw = pvTab->currentPage(); pvTab->removeTab(pvTab->currentIndex());
if (!tw)
return;
pvTab->removePage(tw);
} else { } else {
close(); close();
} }
@ -488,13 +479,13 @@ PreviewTextEdit *Preview::addEditorTab()
{ {
LOGDEB1(("PreviewTextEdit::addEditorTab()\n")); LOGDEB1(("PreviewTextEdit::addEditorTab()\n"));
QWidget *anon = new QWidget((QWidget *)pvTab); QWidget *anon = new QWidget((QWidget *)pvTab);
QVBoxLayout *anonLayout = new QVBoxLayout(anon, 1, 1, "anonLayout"); QVBoxLayout *anonLayout = new QVBoxLayout(anon);
PreviewTextEdit *editor = new PreviewTextEdit(anon, "pvEdit", this); PreviewTextEdit *editor = new PreviewTextEdit(anon, "pvEdit", this);
editor->setReadOnly(TRUE); editor->setReadOnly(TRUE);
editor->setUndoRedoEnabled(FALSE ); editor->setUndoRedoEnabled(FALSE );
anonLayout->addWidget(editor); anonLayout->addWidget(editor);
pvTab->addTab(anon, "Tab"); pvTab->addTab(anon, "Tab");
pvTab->showPage(anon); pvTab->setCurrentIndex(pvTab->count() -1);
return editor; return editor;
} }
@ -513,8 +504,8 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
if (title.length() > 20) { if (title.length() > 20) {
title = title.left(10) + "..." + title.right(10); title = title.left(10) + "..." + title.right(10);
} }
QWidget *w = pvTab->currentPage(); int curidx = pvTab->currentIndex();
pvTab->changeTab(w, title); pvTab->setTabText(curidx, title);
char datebuf[100]; char datebuf[100];
datebuf[0] = 0; datebuf[0] = 0;
@ -531,7 +522,8 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
tiptxt += doc.mimetype + " " + string(datebuf) + "\n"; tiptxt += doc.mimetype + " " + string(datebuf) + "\n";
if (meta_it != doc.meta.end() && !meta_it->second.empty()) if (meta_it != doc.meta.end() && !meta_it->second.empty())
tiptxt += meta_it->second + "\n"; tiptxt += meta_it->second + "\n";
pvTab->setTabToolTip(w,QString::fromUtf8(tiptxt.c_str(), tiptxt.length())); pvTab->setTabToolTip(curidx,
QString::fromUtf8(tiptxt.c_str(), tiptxt.length()));
PreviewTextEdit *e = currentEditor(); PreviewTextEdit *e = currentEditor();
if (e) { if (e) {
@ -549,11 +541,11 @@ bool Preview::makeDocCurrent(const Rcl::Doc& doc, int docnum, bool sametab)
for (int i = 0; i < pvTab->count(); i++) { for (int i = 0; i < pvTab->count(); i++) {
QWidget *tw = pvTab->widget(i); QWidget *tw = pvTab->widget(i);
if (tw) { if (tw) {
PreviewTextEdit *edit = PreviewTextEdit *edit =
dynamic_cast<PreviewTextEdit*>(tw->child("pvEdit")); tw->findChild<PreviewTextEdit*>("pvEdit");
if (edit && !edit->m_data.url.compare(doc.url) && if (edit && !edit->m_data.url.compare(doc.url) &&
!edit->m_data.ipath.compare(doc.ipath)) { !edit->m_data.ipath.compare(doc.ipath)) {
pvTab->showPage(tw); pvTab->setCurrentIndex(i);
return true; return true;
} }
} }
@ -790,8 +782,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
// while still inserting at bottom // while still inserting at bottom
list<QString> qrichlst; list<QString> qrichlst;
PreviewTextEdit *editor = currentEditor(); PreviewTextEdit *editor = currentEditor();
editor->setText(""); editor->setHtml("");
editor->setTextFormat(Qt::RichText);
editor->m_data.format = Qt::RichText; editor->m_data.format = Qt::RichText;
bool inputishtml = !fdoc.mimetype.compare("text/html"); bool inputishtml = !fdoc.mimetype.compare("text/html");
@ -865,7 +856,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
if (inputishtml) { if (inputishtml) {
qrichlst.push_back(qr); qrichlst.push_back(qr);
} else { } else {
editor->setTextFormat(Qt::PlainText); editor->setPlainText("");
editor->m_data.format = Qt::PlainText; editor->m_data.format = Qt::PlainText;
for (int pos = 0; pos < (int)qr.length(); pos += l) { for (int pos = 0; pos < (int)qr.length(); pos += l) {
l = MIN(CHUNKL, qr.length() - pos); l = MIN(CHUNKL, qr.length() - pos);
@ -917,7 +908,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
if (m_haveAnchors) { if (m_haveAnchors) {
QString aname = QString aname =
QString::fromUtf8(editor->m_plaintorich->termAnchorName(1).c_str()); QString::fromUtf8(editor->m_plaintorich->termAnchorName(1).c_str());
LOGDEB2(("Call movetoanchor(%s)\n", (const char *)aname.utf8())); LOGDEB2(("Call movetoanchor(%s)\n", (const char *)aname.toUtf8()));
editor->scrollToAnchor(aname); editor->scrollToAnchor(aname);
// Position the cursor approximately at the anchor (top of // Position the cursor approximately at the anchor (top of
// viewport) so that searches start from here // viewport) so that searches start from here
@ -932,9 +923,6 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
if (udit != idoc.meta.end()) if (udit != idoc.meta.end())
historyEnterDoc(g_dynconf, udit->second); historyEnterDoc(g_dynconf, udit->second);
// Switch format back to plaintext so that selections generate plain text
editor->setTextFormat(Qt::PlainText);
editor->setFocus(); editor->setFocus();
emit(previewExposed(this, m_searchId, docnum)); emit(previewExposed(this, m_searchId, docnum));
LOGDEB(("LoadFileInCurrentTab: returning true\n")); LOGDEB(("LoadFileInCurrentTab: returning true\n"));
@ -961,15 +949,16 @@ void PreviewTextEdit::toggleFields()
// If currently displaying fields, switch to body text // If currently displaying fields, switch to body text
if (m_dspflds) { if (m_dspflds) {
setTextFormat(m_data.format); if (m_data.format == Qt::PlainText)
setText(m_data.richtxt); setPlainText(m_data.richtxt);
else
setHtml(m_data.richtxt);
m_dspflds = false; m_dspflds = false;
return; return;
} }
// Else display fields // Else display fields
m_dspflds = true; m_dspflds = true;
setTextFormat(Qt::RichText);
QString txt = "<html><head></head><body>\n"; QString txt = "<html><head></head><body>\n";
txt += "<b>" + QString::fromLocal8Bit(m_data.url.c_str()); txt += "<b>" + QString::fromLocal8Bit(m_data.url.c_str());
if (!m_data.ipath.empty()) if (!m_data.ipath.empty())
@ -983,15 +972,15 @@ void PreviewTextEdit::toggleFields()
+ "</dd>\n"; + "</dd>\n";
} }
txt += "</dl></body></html>"; txt += "</dl></body></html>";
setText(txt); setHtml(txt);
} }
void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event) void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event)
{ {
LOGDEB2(("PreviewTextEdit::mouseDoubleClickEvent\n")); LOGDEB2(("PreviewTextEdit::mouseDoubleClickEvent\n"));
QTextEdit::mouseDoubleClickEvent(event); QTextEdit::mouseDoubleClickEvent(event);
if (hasSelectedText() && m_preview) if (textCursor().hasSelection() && m_preview)
m_preview->emitWordSelect(selectedText()); m_preview->emitWordSelect(textCursor().selectedText());
} }
void PreviewTextEdit::print() void PreviewTextEdit::print()

View File

@ -34,8 +34,8 @@ void HelpClient::installMap(string wname, string section)
helpmap[wname] = section; helpmap[wname] = section;
} }
HelpClient::HelpClient(QObject *parent, const char *name) HelpClient::HelpClient(QObject *parent, const char *)
: QObject(parent, name) : QObject(parent)
{ {
parent->installEventFilter(this); parent->installEventFilter(this);
} }
@ -52,7 +52,7 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event)
QWidget *widget = static_cast<QWidget *>(obj)->focusWidget(); QWidget *widget = static_cast<QWidget *>(obj)->focusWidget();
map<string, string>::iterator it = helpmap.end(); map<string, string>::iterator it = helpmap.end();
while (widget) { while (widget) {
it = helpmap.find(widget->name()); it = helpmap.find((const char *)widget->objectName().toUtf8());
if (it != helpmap.end()) if (it != helpmap.end())
break; break;
widget = widget->parentWidget(); widget = widget->parentWidget();

View File

@ -35,7 +35,6 @@ using std::pair;
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qfiledialog.h> #include <qfiledialog.h>
#include <qshortcut.h> #include <qshortcut.h>
#include <qtabwidget.h> #include <qtabwidget.h>
#include <qtimer.h> #include <qtimer.h>
#include <qstatusbar.h> #include <qstatusbar.h>
@ -49,9 +48,10 @@ using std::pair;
#include <qaction.h> #include <qaction.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qimage.h> #include <qimage.h>
#include <qiconset.h>
#include <qapplication.h> #include <qapplication.h>
#include <qcursor.h> #include <qcursor.h>
#include <qevent.h>
#include "recoll.h" #include "recoll.h"
#include "debuglog.h" #include "debuglog.h"
#include "mimehandler.h" #include "mimehandler.h"
@ -104,7 +104,7 @@ void RclMain::init()
(void)statusBar(); (void)statusBar();
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.SIMPLE"); HelpClient::installMap((const char *)this->objectName().toUtf8(), "RCL.SEARCH.SIMPLE");
// Set the focus to the search terms entry: // Set the focus to the search terms entry:
sSearch->queryText->setFocus(); sSearch->queryText->setFocus();
@ -118,9 +118,9 @@ void RclMain::init()
// Stemming language menu // Stemming language menu
g_stringNoStem = tr("(no stemming)"); g_stringNoStem = tr("(no stemming)");
g_stringAllStem = tr("(all languages)"); g_stringAllStem = tr("(all languages)");
m_idNoStem = preferencesMenu->insertItem(g_stringNoStem); m_idNoStem = preferencesMenu->addAction(g_stringNoStem);
m_stemLangToId[g_stringNoStem] = m_idNoStem; m_stemLangToId[g_stringNoStem] = m_idNoStem;
m_idAllStem = preferencesMenu->insertItem(g_stringAllStem); m_idAllStem = preferencesMenu->addAction(g_stringAllStem);
m_stemLangToId[g_stringAllStem] = m_idAllStem; m_stemLangToId[g_stringAllStem] = m_idAllStem;
// Can't get the stemming languages from the db at this stage as // Can't get the stemming languages from the db at this stage as
@ -135,18 +135,18 @@ void RclMain::init()
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("error retrieving stemming languages")); tr("error retrieving stemming languages"));
} }
int curid = prefs.queryStemLang == "ALL" ? m_idAllStem : m_idNoStem; QAction *curid = prefs.queryStemLang == "ALL" ? m_idAllStem : m_idNoStem;
int id; QAction *id;
for (list<string>::const_iterator it = langs.begin(); for (list<string>::const_iterator it = langs.begin();
it != langs.end(); it++) { it != langs.end(); it++) {
QString qlang = QString::fromAscii(it->c_str(), it->length()); QString qlang = QString::fromAscii(it->c_str(), it->length());
id = preferencesMenu->insertItem(qlang); id = preferencesMenu->addAction(qlang);
m_stemLangToId[qlang] = id; m_stemLangToId[qlang] = id;
if (prefs.queryStemLang == qlang) { if (prefs.queryStemLang == qlang) {
curid = id; curid = id;
} }
} }
preferencesMenu->setItemChecked(curid, true); curid->setChecked(true);
// A shortcut to get the focus back to the search entry. // A shortcut to get the focus back to the search entry.
QKeySequence seq("Ctrl+Shift+s"); QKeySequence seq("Ctrl+Shift+s");
@ -158,8 +158,9 @@ void RclMain::init()
QComboBox *catgCMB = 0; QComboBox *catgCMB = 0;
if (prefs.catgToolBar) { if (prefs.catgToolBar) {
QToolBar *catgToolBar = new QToolBar(this); QToolBar *catgToolBar = new QToolBar(this);
catgCMB = new QComboBox(FALSE, catgToolBar, "catCMB"); catgCMB = new QComboBox(catgToolBar);
catgCMB->insertItem(tr("All")); catgCMB->setEditable(FALSE);
catgCMB->addItem(tr("All"));
catgToolBar->setObjectName(QString::fromUtf8("catgToolBar")); catgToolBar->setObjectName(QString::fromUtf8("catgToolBar"));
catgCMB->setToolTip(tr("Document category filter")); catgCMB->setToolTip(tr("Document category filter"));
catgToolBar->addWidget(catgCMB); catgToolBar->addWidget(catgCMB);
@ -185,9 +186,9 @@ void RclMain::init()
QRadioButton *but = new QRadioButton(catgBGRP); QRadioButton *but = new QRadioButton(catgBGRP);
QString catgnm = QString::fromUtf8(it->c_str(), it->length()); QString catgnm = QString::fromUtf8(it->c_str(), it->length());
m_catgbutvec.push_back(*it); m_catgbutvec.push_back(*it);
but->setText(tr(catgnm)); but->setText(tr(catgnm.toUtf8()));
if (prefs.catgToolBar && catgCMB) if (prefs.catgToolBar && catgCMB)
catgCMB->insertItem(tr(catgnm)); catgCMB->addItem(tr(catgnm.toUtf8()));
bgrphbox->addWidget(but); bgrphbox->addWidget(but);
bgrp->addButton(but, bgrpid++); bgrp->addButton(but, bgrpid++);
} }
@ -200,8 +201,8 @@ void RclMain::init()
this, SLOT(startSearch(RefCntr<Rcl::SearchData>))); this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
sSearch->queryText->installEventFilter(this); sSearch->queryText->installEventFilter(this);
connect(preferencesMenu, SIGNAL(activated(int)), connect(preferencesMenu, SIGNAL(triggered(QAction*)),
this, SLOT(setStemLang(int))); this, SLOT(setStemLang(QAction*)));
connect(preferencesMenu, SIGNAL(aboutToShow()), connect(preferencesMenu, SIGNAL(aboutToShow()),
this, SLOT(adjustPrefsMenu())); this, SLOT(adjustPrefsMenu()));
// signals and slots connections // signals and slots connections
@ -332,13 +333,13 @@ void RclMain::focusToSearch()
sSearch->queryText->setFocus(Qt::ShortcutFocusReason); sSearch->queryText->setFocus(Qt::ShortcutFocusReason);
} }
void RclMain::setStemLang(int id) void RclMain::setStemLang(QAction *id)
{ {
LOGDEB(("RclMain::setStemLang(%d)\n", id)); LOGDEB(("RclMain::setStemLang(%d)\n", id));
// Check that the menu entry is for a stemming language change // Check that the menu entry is for a stemming language change
// (might also be "show prefs" etc. // (might also be "show prefs" etc.
bool isLangId = false; bool isLangId = false;
for (map<QString, int>::const_iterator it = m_stemLangToId.begin(); for (map<QString, QAction*>::const_iterator it = m_stemLangToId.begin();
it != m_stemLangToId.end(); it++) { it != m_stemLangToId.end(); it++) {
if (id == it->second) if (id == it->second)
isLangId = true; isLangId = true;
@ -347,11 +348,11 @@ void RclMain::setStemLang(int id)
return; return;
// Set the "checked" item state for lang entries // Set the "checked" item state for lang entries
for (map<QString, int>::const_iterator it = m_stemLangToId.begin(); for (map<QString, QAction*>::const_iterator it = m_stemLangToId.begin();
it != m_stemLangToId.end(); it++) { it != m_stemLangToId.end(); it++) {
preferencesMenu->setItemChecked(it->second, false); (it->second)->setChecked(false);
} }
preferencesMenu->setItemChecked(id, true); id->setChecked(true);
// Retrieve language value (also handle special cases), set prefs, // Retrieve language value (also handle special cases), set prefs,
// notify that we changed // notify that we changed
@ -361,11 +362,11 @@ void RclMain::setStemLang(int id)
} else if (id == m_idAllStem) { } else if (id == m_idAllStem) {
lang = "ALL"; lang = "ALL";
} else { } else {
lang = preferencesMenu->text(id); lang = id->text();
} }
prefs.queryStemLang = lang; prefs.queryStemLang = lang;
LOGDEB(("RclMain::setStemLang(%d): lang [%s]\n", LOGDEB(("RclMain::setStemLang(%d): lang [%s]\n",
id, (const char *)prefs.queryStemLang.ascii())); id, (const char *)prefs.queryStemLang.toAscii()));
rwSettings(true); rwSettings(true);
emit stemLangChanged(lang); emit stemLangChanged(lang);
} }
@ -373,23 +374,23 @@ void RclMain::setStemLang(int id)
// Set the checked stemming language item before showing the prefs menu // Set the checked stemming language item before showing the prefs menu
void RclMain::setStemLang(const QString& lang) void RclMain::setStemLang(const QString& lang)
{ {
LOGDEB(("RclMain::setStemLang(%s)\n", (const char *)lang.ascii())); LOGDEB(("RclMain::setStemLang(%s)\n", (const char *)lang.toAscii()));
int id; QAction *id;
if (lang == "") { if (lang == "") {
id = m_idNoStem; id = m_idNoStem;
} else if (lang == "ALL") { } else if (lang == "ALL") {
id = m_idAllStem; id = m_idAllStem;
} else { } else {
map<QString, int>::iterator it = m_stemLangToId.find(lang); map<QString, QAction*>::iterator it = m_stemLangToId.find(lang);
if (it == m_stemLangToId.end()) if (it == m_stemLangToId.end())
return; return;
id = it->second; id = it->second;
} }
for (map<QString, int>::const_iterator it = m_stemLangToId.begin(); for (map<QString, QAction*>::const_iterator it = m_stemLangToId.begin();
it != m_stemLangToId.end(); it++) { it != m_stemLangToId.end(); it++) {
preferencesMenu->setItemChecked(it->second, false); (it->second)->setChecked(false);
} }
preferencesMenu->setItemChecked(id, true); id->setChecked(true);
} }
// Prefs menu about to show // Prefs menu about to show
@ -422,7 +423,7 @@ void RclMain::fileExit()
prefs.mainwidth = width(); prefs.mainwidth = width();
prefs.mainheight = height(); prefs.mainheight = height();
} }
prefs.ssearchTyp = sSearch->searchTypCMB->currentItem(); prefs.ssearchTyp = sSearch->searchTypCMB->currentIndex();
if (asearchform) if (asearchform)
delete asearchform; delete asearchform;
// We'd prefer to do this in the exit handler, but it's apparently to late // We'd prefer to do this in the exit handler, but it's apparently to late
@ -463,14 +464,14 @@ void RclMain::periodic100()
// and check this / restart query in DocSeqDb() ?) // and check this / restart query in DocSeqDb() ?)
string reason; string reason;
maybeOpenDb(reason, 1); maybeOpenDb(reason, 1);
periodictimer->changeInterval(1000); periodictimer->setInterval(1000);
} }
} else { } else {
// Indexing is running // Indexing is running
m_idxStatusAck = false; m_idxStatusAck = false;
fileToggleIndexingAction->setText(tr("Stop &Indexing")); fileToggleIndexingAction->setText(tr("Stop &Indexing"));
fileToggleIndexingAction->setEnabled(TRUE); fileToggleIndexingAction->setEnabled(TRUE);
periodictimer->changeInterval(100); periodictimer->setInterval(100);
// The toggle thing is for the status to flash // The toggle thing is for the status to flash
if (toggle < 9) { if (toggle < 9) {
QString msg = tr("Indexing in progress: "); QString msg = tr("Indexing in progress: ");
@ -498,9 +499,9 @@ void RclMain::periodic100()
mf = url_encode(status.fn, 0); mf = url_encode(status.fn, 0);
} }
msg += QString::fromUtf8(mf.c_str()); msg += QString::fromUtf8(mf.c_str());
statusBar()->message(msg, 4000); statusBar()->showMessage(msg, 4000);
} else if (toggle == 9) { } else if (toggle == 9) {
statusBar()->message(""); statusBar()->showMessage("");
} }
if (++toggle >= 10) if (++toggle >= 10)
toggle = 0; toggle = 0;
@ -517,11 +518,11 @@ void RclMain::toggleIndexing()
if (idxthread_getStatus() == IDXTS_NULL) { if (idxthread_getStatus() == IDXTS_NULL) {
// Indexing was in progress, stop it // Indexing was in progress, stop it
stop_indexing(); stop_indexing();
periodictimer->changeInterval(1000); periodictimer->setInterval(1000);
fileToggleIndexingAction->setText(tr("Update &Index")); fileToggleIndexingAction->setText(tr("Update &Index"));
} else { } else {
start_indexing(false); start_indexing(false);
periodictimer->changeInterval(100); periodictimer->setInterval(100);
fileToggleIndexingAction->setText(tr("Stop &Indexing")); fileToggleIndexingAction->setText(tr("Stop &Indexing"));
} }
fileToggleIndexingAction->setEnabled(FALSE); fileToggleIndexingAction->setEnabled(FALSE);
@ -543,7 +544,7 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
resList->resetList(); resList->resetList();
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
string stemLang = (const char *)prefs.queryStemLang.ascii(); string stemLang = (const char *)prefs.queryStemLang.toAscii();
if (stemLang == "ALL") { if (stemLang == "ALL") {
rclconfig->getConfParam("indexstemminglanguages", stemLang); rclconfig->getConfParam("indexstemminglanguages", stemLang);
} }
@ -561,7 +562,7 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
curPreview = 0; curPreview = 0;
DocSequenceDb *src = DocSequenceDb *src =
new DocSequenceDb(RefCntr<Rcl::Query>(query), new DocSequenceDb(RefCntr<Rcl::Query>(query),
string(tr("Query results").utf8()), sdata); string(tr("Query results").toUtf8()), sdata);
src->setAbstractParams(prefs.queryBuildAbstract, src->setAbstractParams(prefs.queryBuildAbstract,
prefs.queryReplaceAbstract); prefs.queryReplaceAbstract);
@ -656,7 +657,7 @@ void RclMain::showExtIdxDialog()
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
uiprefs->close(); uiprefs->close();
} }
uiprefs->tabWidget->setCurrentPage(2); uiprefs->tabWidget->setCurrentIndex(2);
uiprefs->show(); uiprefs->show();
} }
@ -711,7 +712,7 @@ void RclMain::startPreview(int docnum, int mod)
return; return;
} }
if (mod & Qt::ShiftButton) { if (mod & Qt::ShiftModifier) {
// User wants new preview window // User wants new preview window
curPreview = 0; curPreview = 0;
} }
@ -736,7 +737,7 @@ void RclMain::startPreview(int docnum, int mod)
this, SLOT(previewPrevInTab(Preview *, int, int))); this, SLOT(previewPrevInTab(Preview *, int, int)));
connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)), connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)),
this, SLOT(previewExposed(Preview *, int, int))); this, SLOT(previewExposed(Preview *, int, int)));
curPreview->setCaption(resList->getDescription()); curPreview->setWindowTitle(resList->getDescription());
curPreview->show(); curPreview->show();
} }
curPreview->makeDocCurrent(doc, docnum); curPreview->makeDocCurrent(doc, docnum);
@ -833,8 +834,8 @@ void RclMain::previewExposed(Preview *, int sid, int docnum)
static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r"; static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r";
void RclMain::ssearchAddTerm(QString term) void RclMain::ssearchAddTerm(QString term)
{ {
LOGDEB(("RclMain::ssearchAddTerm: [%s]\n", (const char *)term.utf8())); LOGDEB(("RclMain::ssearchAddTerm: [%s]\n", (const char *)term.toUtf8()));
string t = (const char *)term.utf8(); string t = (const char *)term.toUtf8();
string::size_type pos = t.find_last_not_of(punct); string::size_type pos = t.find_last_not_of(punct);
if (pos == string::npos) if (pos == string::npos)
return; return;
@ -861,11 +862,11 @@ void RclMain::saveDocToFile(int docnum)
return; return;
} }
QString s = QString s =
QFileDialog::getSaveFileName(path_home().c_str(), QFileDialog::getSaveFileName(this, //parent
"", this, tr("Save file"), // caption
tr("Save file dialog"), QString::fromLocal8Bit(path_home().c_str()) //dir
tr("Choose a file name to save under")); );
string tofile((const char *)s.local8Bit()); string tofile((const char *)s.toLocal8Bit());
TempFile temp; // not used TempFile temp; // not used
if (!FileInterner::idocToFile(temp, tofile, rclconfig, doc)) { if (!FileInterner::idocToFile(temp, tofile, rclconfig, doc)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
@ -1107,7 +1108,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
transcode(ncmd, prcmd, fcharset, "UTF-8"); transcode(ncmd, prcmd, fcharset, "UTF-8");
QString msg = tr("Executing: [") + QString msg = tr("Executing: [") +
QString::fromUtf8(prcmd.c_str()) + "]"; QString::fromUtf8(prcmd.c_str()) + "]";
stb->message(msg, 5000); stb->showMessage(msg, 5000);
} }
if (!istempfile) if (!istempfile)
@ -1182,14 +1183,14 @@ void RclMain::showDocHistory()
// Construct a bogus SearchData structure // Construct a bogus SearchData structure
RefCntr<Rcl::SearchData>searchdata = RefCntr<Rcl::SearchData>searchdata =
RefCntr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND)); RefCntr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND));
searchdata->setDescription((const char *)tr("History data").utf8()); searchdata->setDescription((const char *)tr("History data").toUtf8());
// If you change the title, also change it in eraseDocHistory() // If you change the title, also change it in eraseDocHistory()
DocSequenceHistory *src = DocSequenceHistory *src =
new DocSequenceHistory(rcldb, g_dynconf, new DocSequenceHistory(rcldb, g_dynconf,
string(tr("Document history").utf8())); string(tr("Document history").toUtf8()));
src->setDescription((const char *)tr("History data").utf8()); src->setDescription((const char *)tr("History data").toUtf8());
resList->setDocSource(RefCntr<DocSequence>(src)); resList->setDocSource(RefCntr<DocSequence>(src));
} }
@ -1269,7 +1270,8 @@ bool RclMain::eventFilter(QObject *, QEvent *event)
// filtered by the search entry to mean "select all line". We prefer to // filtered by the search entry to mean "select all line". We prefer to
// keep it for the action as it's easy to find another combination to // keep it for the action as it's easy to find another combination to
// select all (ie: home, then shift-end) // select all (ie: home, then shift-end)
if (ke->key() == Qt::Key_Home && (ke->state() & Qt::ShiftButton)) { if (ke->key() == Qt::Key_Home &&
(ke->modifiers() & Qt::ShiftModifier)) {
// Shift-Home -> first page of results // Shift-Home -> first page of results
resList->resultPageFirst(); resList->resultPageFirst();
return true; return true;

View File

@ -90,7 +90,7 @@ public slots:
virtual void resetSearch(); virtual void resetSearch();
virtual void eraseDocHistory(); virtual void eraseDocHistory();
// Callback for setting the stemming language through the prefs menu // Callback for setting the stemming language through the prefs menu
virtual void setStemLang(int id); virtual void setStemLang(QAction *id);
// Prefs menu about to show, set the checked lang entry // Prefs menu about to show, set the checked lang entry
virtual void adjustPrefsMenu(); virtual void adjustPrefsMenu();
virtual void catgFilter(int); virtual void catgFilter(int);
@ -115,10 +115,10 @@ private:
vector<TempFile> m_tempfiles; vector<TempFile> m_tempfiles;
vector<ExecCmd*> m_viewers; vector<ExecCmd*> m_viewers;
map<QString, int> m_stemLangToId; map<QString, QAction*> m_stemLangToId;
vector<string> m_catgbutvec; vector<string> m_catgbutvec;
int m_idNoStem; QAction * m_idNoStem;
int m_idAllStem; QAction * m_idAllStem;
bool m_idxStatusAck; // Did we act on last status? bool m_idxStatusAck; // Did we act on last status?
virtual void init(); virtual void init();

View File

@ -86,5 +86,3 @@ TRANSLATIONS = \
../qtgui/i18n/recoll_uk.ts \ ../qtgui/i18n/recoll_uk.ts \
../qtgui/i18n/recoll_xx.ts \ ../qtgui/i18n/recoll_xx.ts \
QT += qt3support

View File

@ -20,6 +20,7 @@ static char rcsid[] = "@(#$Id: reslist.cpp,v 1.52 2008-12-17 15:12:08 dockes Exp
#include <qimage.h> #include <qimage.h>
#include <qclipboard.h> #include <qclipboard.h>
#include <qscrollbar.h> #include <qscrollbar.h>
#include <QTextBlock>
#ifndef __APPLE__ #ifndef __APPLE__
#include <qx11info_x11.h> #include <qx11info_x11.h>
#endif #endif
@ -111,7 +112,7 @@ bool QtGuiResListPager::append(const string& data, int docnum,
string QtGuiResListPager::trans(const string& in) string QtGuiResListPager::trans(const string& in)
{ {
return string((const char*)ResList::tr(in.c_str()).utf8()); return string((const char*)ResList::tr(in.c_str()).toUtf8());
} }
string QtGuiResListPager::detailsLink() string QtGuiResListPager::detailsLink()
@ -188,7 +189,7 @@ public:
virtual ~PlainToRichQtReslist() {} virtual ~PlainToRichQtReslist() {}
virtual string startMatch() { virtual string startMatch() {
return string("<span style='color: ") return string("<span style='color: ")
+ string((const char *)prefs.qtermcolor.ascii()) + string("'>"); + string((const char *)prefs.qtermcolor.toAscii()) + string("'>");
} }
virtual string endMatch() {return string("</span>");} virtual string endMatch() {return string("</span>");}
}; };
@ -197,10 +198,12 @@ static PlainToRichQtReslist g_hiliter;
///////////////////////////////////// /////////////////////////////////////
ResList::ResList(QWidget* parent, const char* name) ResList::ResList(QWidget* parent, const char* name)
: QTextBrowser(parent, name) : QTextBrowser(parent)
{ {
if (!name) if (!name)
setName("resList"); setObjectName("resList");
else
setObjectName(name);
setReadOnly(TRUE); setReadOnly(TRUE);
setUndoRedoEnabled(FALSE); setUndoRedoEnabled(FALSE);
setOpenLinks(FALSE); setOpenLinks(FALSE);
@ -209,7 +212,8 @@ ResList::ResList(QWidget* parent, const char* name)
setTabChangesFocus(true); setTabChangesFocus(true);
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.RESLIST"); HelpClient::installMap((const char *)this->objectName().toAscii(),
"RCL.SEARCH.RESLIST");
// signals and slots connections // signals and slots connections
connect(this, SIGNAL(anchorClicked(const QUrl &)), connect(this, SIGNAL(anchorClicked(const QUrl &)),
@ -282,7 +286,7 @@ void ResList::setDocSource()
} else { } else {
if (m_filtspecs.isNotNull()) { if (m_filtspecs.isNotNull()) {
string title = m_baseDocSource->title() + " (" + string title = m_baseDocSource->title() + " (" +
string((const char*)tr("filtered").utf8()) + ")"; string((const char*)tr("filtered").toUtf8()) + ")";
m_docSource = m_docSource =
RefCntr<DocSequence>(new DocSeqFiltered(m_docSource,m_filtspecs, RefCntr<DocSequence>(new DocSeqFiltered(m_docSource,m_filtspecs,
title)); title));
@ -291,7 +295,7 @@ void ResList::setDocSource()
if (m_sortspecs.isNotNull()) { if (m_sortspecs.isNotNull()) {
string title = m_baseDocSource->title() + " (" + string title = m_baseDocSource->title() + " (" +
string((const char *)tr("sorted").utf8()) + ")"; string((const char *)tr("sorted").toUtf8()) + ")";
m_docSource = RefCntr<DocSequence>(new DocSeqSorted(m_docSource, m_docSource = RefCntr<DocSequence>(new DocSeqSorted(m_docSource,
m_sortspecs, m_sortspecs,
title)); title));
@ -334,7 +338,7 @@ bool ResList::displayingHistory()
{ {
// We want to reset the displayed history if it is currently // We want to reset the displayed history if it is currently
// shown. Using the title value is an ugly hack // shown. Using the title value is an ugly hack
string htstring = string((const char *)tr("Document history").utf8()); string htstring = string((const char *)tr("Document history").toUtf8());
if (m_docSource.isNull() || m_docSource->title().empty()) if (m_docSource.isNull() || m_docSource->title().empty())
return false; return false;
return m_docSource->title().find(htstring) == 0; return m_docSource->title().find(htstring) == 0;
@ -342,7 +346,7 @@ bool ResList::displayingHistory()
void ResList::languageChange() void ResList::languageChange()
{ {
setCaption(tr("Result list")); setWindowTitle(tr("Result list"));
} }
bool ResList::getTerms(vector<string>& terms, bool ResList::getTerms(vector<string>& terms,
@ -449,13 +453,13 @@ bool ResList::getDoc(int docnum, Rcl::Doc &doc)
void ResList::keyPressEvent(QKeyEvent * e) void ResList::keyPressEvent(QKeyEvent * e)
{ {
if (e->key() == Qt::Key_Q && (e->state() & Qt::ControlButton)) { if (e->key() == Qt::Key_Q && (e->modifiers() & Qt::ControlModifier)) {
recollNeedsExit = 1; recollNeedsExit = 1;
return; return;
} else if (e->key() == Qt::Key_Prior || e->key() == Qt::Key_Backspace) { } else if (e->key() == Qt::Key_PageUp || e->key() == Qt::Key_Backspace) {
resPageUpOrBack(); resPageUpOrBack();
return; return;
} else if (e->key() == Qt::Key_Next || e->key() == Qt::Key_Space) { } else if (e->key() == Qt::Key_PageDown || e->key() == Qt::Key_Space) {
resPageDownOrNext(); resPageDownOrNext();
return; return;
} }
@ -465,11 +469,11 @@ void ResList::keyPressEvent(QKeyEvent * e)
void ResList::mouseReleaseEvent(QMouseEvent *e) void ResList::mouseReleaseEvent(QMouseEvent *e)
{ {
m_lstClckMod = 0; m_lstClckMod = 0;
if (e->state() & Qt::ControlButton) { if (e->modifiers() & Qt::ControlModifier) {
m_lstClckMod |= Qt::ControlButton; m_lstClckMod |= Qt::ControlModifier;
} }
if (e->state() & Qt::ShiftButton) { if (e->modifiers() & Qt::ShiftModifier) {
m_lstClckMod |= Qt::ShiftButton; m_lstClckMod |= Qt::ShiftModifier;
} }
QTextBrowser::mouseReleaseEvent(e); QTextBrowser::mouseReleaseEvent(e);
} }
@ -495,7 +499,7 @@ void ResList::highlighted(const QString& )
void ResList::resPageUpOrBack() void ResList::resPageUpOrBack()
{ {
int vpos = verticalScrollBar()->value(); int vpos = verticalScrollBar()->value();
moveCursor(QTextBrowser::MovePgUp, false); verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
if (vpos == verticalScrollBar()->value()) if (vpos == verticalScrollBar()->value())
resultPageBack(); resultPageBack();
} }
@ -503,7 +507,7 @@ void ResList::resPageUpOrBack()
void ResList::resPageDownOrNext() void ResList::resPageDownOrNext()
{ {
int vpos = verticalScrollBar()->value(); int vpos = verticalScrollBar()->value();
moveCursor(QTextBrowser::MovePgDown, false); verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
LOGDEB(("ResList::resPageDownOrNext: vpos before %d, after %d\n", LOGDEB(("ResList::resPageDownOrNext: vpos before %d, after %d\n",
vpos, verticalScrollBar()->value())); vpos, verticalScrollBar()->value()));
if (vpos == verticalScrollBar()->value()) if (vpos == verticalScrollBar()->value())
@ -530,7 +534,7 @@ void ResList::resultPageFirst()
void ResList::append(const QString &text) void ResList::append(const QString &text)
{ {
LOGDEB2(("QtGuiReslistPager::appendQString : %s\n", LOGDEB2(("QtGuiReslistPager::appendQString : %s\n",
(const char*)text.utf8())); (const char*)text.toUtf8()));
QTextBrowser::append(text); QTextBrowser::append(text);
} }
@ -605,16 +609,17 @@ void ResList::previewExposed(int docnum)
void ResList::mouseDoubleClickEvent(QMouseEvent *event) void ResList::mouseDoubleClickEvent(QMouseEvent *event)
{ {
QTextBrowser::mouseDoubleClickEvent(event); QTextBrowser::mouseDoubleClickEvent(event);
if (hasSelectedText()) if (textCursor().hasSelection())
emit(wordSelect(selectedText())); emit(wordSelect(textCursor().selectedText()));
} }
void ResList::linkWasClicked(const QUrl &url) void ResList::linkWasClicked(const QUrl &url)
{ {
QString s = url.toString(); QString s = url.toString();
LOGDEB(("ResList::linkWasClicked: [%s]\n", s.ascii())); const char *ascurl = s.toAscii();
int i = atoi(s.ascii()+1) -1; LOGDEB(("ResList::linkWasClicked: [%s]\n", ascurl));
int what = s.ascii()[0]; int i = atoi(ascurl+1) - 1;
int what = ascurl[0];
switch (what) { switch (what) {
case 'H': case 'H':
emit headerClicked(); emit headerClicked();

View File

@ -9,6 +9,7 @@ using std::list;
#endif #endif
#include <qtextbrowser.h> #include <qtextbrowser.h>
#include <QTextCursor>
#include "docseq.h" #include "docseq.h"
#include "sortseq.h" #include "sortseq.h"
@ -77,7 +78,7 @@ class ResList : public QTextBrowser
virtual void setFilterParams(const DocSeqFiltSpec &spec); virtual void setFilterParams(const DocSeqFiltSpec &spec);
virtual void highlighted(const QString& link); virtual void highlighted(const QString& link);
virtual void createPopupMenu(const QPoint& pos); virtual void createPopupMenu(const QPoint& pos);
signals: signals:
void nextPageAvailable(bool); void nextPageAvailable(bool);
void prevPageAvailable(bool); void prevPageAvailable(bool);

View File

@ -36,14 +36,15 @@ static char rcsid[] = "@(#$Id: searchclause_w.cpp,v 1.4 2006-12-04 06:19:11 dock
SearchClauseW::SearchClauseW(QWidget* parent) SearchClauseW::SearchClauseW(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
QHBoxLayout* hLayout = new QHBoxLayout(this, 0, 3); QHBoxLayout* hLayout = new QHBoxLayout(this);
sTpCMB = new QComboBox(FALSE, this, "sTpCMB"); sTpCMB = new QComboBox(this);
sTpCMB->setEditable(false);
hLayout->addWidget(sTpCMB); hLayout->addWidget(sTpCMB);
proxSlackSB = new QSpinBox(this, "proxSlackSB"); proxSlackSB = new QSpinBox(this);
hLayout->addWidget(proxSlackSB); hLayout->addWidget(proxSlackSB);
wordsLE = new QLineEdit(this, "wordsLE"); wordsLE = new QLineEdit(this);
wordsLE->setMinimumSize(QSize(250, 0)); wordsLE->setMinimumSize(QSize(250, 0));
hLayout->addWidget(wordsLE); hLayout->addWidget(wordsLE);
@ -67,22 +68,21 @@ SearchClauseW::~SearchClauseW()
*/ */
void SearchClauseW::languageChange() void SearchClauseW::languageChange()
{ {
setCaption(tr("SearchClauseW"));
sTpCMB->clear(); sTpCMB->clear();
sTpCMB->insertItem(tr("Any of these")); // 0 sTpCMB->addItem(tr("Any of these")); // 0
sTpCMB->insertItem(tr("All of these")); //1 sTpCMB->addItem(tr("All of these")); //1
sTpCMB->insertItem(tr("None of these"));//2 sTpCMB->addItem(tr("None of these"));//2
sTpCMB->insertItem(tr("This phrase"));//3 sTpCMB->addItem(tr("This phrase"));//3
sTpCMB->insertItem(tr("Terms in proximity"));//4 sTpCMB->addItem(tr("Terms in proximity"));//4
sTpCMB->insertItem(tr("File name matching"));//5 sTpCMB->addItem(tr("File name matching"));//5
// sTpCMB->insertItem(tr("Complex clause"));//6 // sTpCMB->insertItem(tr("Complex clause"));//6
// Ensure that the spinbox will be enabled/disabled depending on // Ensure that the spinbox will be enabled/disabled depending on
// combobox state // combobox state
tpChange(0); tpChange(0);
QToolTip::add(sTpCMB, tr("Select the type of query that will be performed with the words")); sTpCMB->setToolTip(tr("Select the type of query that will be performed with the words"));
QToolTip::add(proxSlackSB, tr("Number of additional words that may be interspersed with the chosen ones")); proxSlackSB->setToolTip(tr("Number of additional words that may be interspersed with the chosen ones"));
} }
using namespace Rcl; using namespace Rcl;
@ -93,26 +93,26 @@ SearchClauseW::getClause()
{ {
if (wordsLE->text().isEmpty()) if (wordsLE->text().isEmpty())
return 0; return 0;
switch (sTpCMB->currentItem()) { switch (sTpCMB->currentIndex()) {
case 0: case 0:
return new SearchDataClauseSimple(SCLT_OR, return new SearchDataClauseSimple(SCLT_OR,
(const char *)wordsLE->text().utf8()); (const char *)wordsLE->text().toUtf8());
case 1: case 1:
return new SearchDataClauseSimple(SCLT_AND, return new SearchDataClauseSimple(SCLT_AND,
(const char *)wordsLE->text().utf8()); (const char *)wordsLE->text().toUtf8());
case 2: case 2:
return new SearchDataClauseSimple(SCLT_EXCL, return new SearchDataClauseSimple(SCLT_EXCL,
(const char *)wordsLE->text().utf8()); (const char *)wordsLE->text().toUtf8());
case 3: case 3:
return new SearchDataClauseDist(SCLT_PHRASE, return new SearchDataClauseDist(SCLT_PHRASE,
(const char *)wordsLE->text().utf8(), (const char *)wordsLE->text().toUtf8(),
proxSlackSB->value()); proxSlackSB->value());
case 4: case 4:
return new SearchDataClauseDist(SCLT_NEAR, return new SearchDataClauseDist(SCLT_NEAR,
(const char *)wordsLE->text().utf8(), (const char *)wordsLE->text().toUtf8(),
proxSlackSB->value()); proxSlackSB->value());
case 5: case 5:
return new SearchDataClauseFilename((const char *)wordsLE->text().utf8()); return new SearchDataClauseFilename((const char *)wordsLE->text().toUtf8());
case 6: case 6:
default: default:
return 0; return 0;
@ -124,8 +124,8 @@ void SearchClauseW::tpChange(int index)
{ {
if (index < 0 || index > 5) if (index < 0 || index > 5)
return; return;
if (sTpCMB->currentItem() != index) if (sTpCMB->currentIndex() != index)
sTpCMB->setCurrentItem(index); sTpCMB->setCurrentIndex(index);
switch (index) { switch (index) {
case 3: case 3:
case 4: case 4:

View File

@ -56,17 +56,18 @@ void SortForm::init()
v = spec & (0xf & ~(1<<3)); v = spec & (0xf & ~(1<<3));
d = spec & (1 << 3); d = spec & (1 << 3);
spec >>= 4; spec >>= 4;
fldCMB1->setCurrentItem(v < 3 ? v : 0); fldCMB1->setCurrentIndex(v < 3 ? v : 0);
descCB1->setChecked(d != 0 ? true : false); descCB1->setChecked(d != 0 ? true : false);
v = spec & (0xf & ~(1<<3)); v = spec & (0xf & ~(1<<3));
d = spec & (1 << 3); d = spec & (1 << 3);
spec >>= 4; spec >>= 4;
fldCMB2->setCurrentItem(v < 3 ? v : 0); fldCMB2->setCurrentIndex(v < 3 ? v : 0);
descCB2->setChecked(d !=0 ? true : false); descCB2->setChecked(d !=0 ? true : false);
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.SORT"); HelpClient::installMap((const char *)this->objectName().toUtf8(),
"RCL.SEARCH.SORT");
// signals and slots connections // signals and slots connections
connect(applyPB, SIGNAL(clicked()), this, SLOT(apply())); connect(applyPB, SIGNAL(clicked()), this, SLOT(apply()));
@ -106,7 +107,7 @@ void SortForm::setData()
spec.sortdepth = 0; spec.sortdepth = 0;
} else { } else {
bool desc = descCB1->isChecked(); bool desc = descCB1->isChecked();
switch (fldCMB1->currentItem()) { switch (fldCMB1->currentIndex()) {
case 1: case 1:
spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, desc?true:false); spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, desc?true:false);
break; break;
@ -116,7 +117,7 @@ void SortForm::setData()
} }
desc = descCB2->isChecked(); desc = descCB2->isChecked();
switch (fldCMB2->currentItem()) { switch (fldCMB2->currentIndex()) {
case 1: case 1:
spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, desc?true:false); spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, desc?true:false);
break; break;
@ -129,10 +130,10 @@ void SortForm::setData()
// Save data to prefs; // Save data to prefs;
prefs.sortDepth = spec.sortdepth; prefs.sortDepth = spec.sortdepth;
unsigned int spec = 0, v, d; unsigned int spec = 0, v, d;
v = fldCMB1->currentItem() & 0x7; v = fldCMB1->currentIndex() & 0x7;
d = descCB1->isChecked() ? 8 : 0; d = descCB1->isChecked() ? 8 : 0;
spec |= (d|v); spec |= (d|v);
v = fldCMB2->currentItem() & 0x7; v = fldCMB2->currentIndex() & 0x7;
d = descCB2->isChecked() ? 8 : 0; d = descCB2->isChecked() ? 8 : 0;
spec |= (d|v) << 4; spec |= (d|v) << 4;
prefs.sortSpec = (int) spec; prefs.sortSpec = (int) spec;

View File

@ -48,20 +48,20 @@ static char rcsid[] = "@(#$Id: spell_w.cpp,v 1.11 2007-02-19 16:28:05 dockes Exp
void SpellW::init() void SpellW::init()
{ {
// Don't change the order, or fix the rest of the code... // Don't change the order, or fix the rest of the code...
/*0*/expTypeCMB->insertItem(tr("Wildcards")); /*0*/expTypeCMB->addItem(tr("Wildcards"));
/*1*/expTypeCMB->insertItem(tr("Regexp")); /*1*/expTypeCMB->addItem(tr("Regexp"));
/*2*/expTypeCMB->insertItem(tr("Stem expansion")); /*2*/expTypeCMB->addItem(tr("Stem expansion"));
#ifdef RCL_USE_ASPELL #ifdef RCL_USE_ASPELL
bool noaspell = false; bool noaspell = false;
rclconfig->getConfParam("noaspell", &noaspell); rclconfig->getConfParam("noaspell", &noaspell);
if (!noaspell) if (!noaspell)
/*3*/expTypeCMB->insertItem(tr("Spelling/Phonetic")); /*3*/expTypeCMB->addItem(tr("Spelling/Phonetic"));
#endif #endif
int typ = prefs.termMatchType; int typ = prefs.termMatchType;
if (typ < 0 || typ > expTypeCMB->count()) if (typ < 0 || typ > expTypeCMB->count())
typ = 0; typ = 0;
expTypeCMB->setCurrentItem(typ); expTypeCMB->setCurrentIndex(typ);
// Stemming language combobox // Stemming language combobox
stemLangCMB->clear(); stemLangCMB->clear();
@ -73,12 +73,13 @@ void SpellW::init()
for (list<string>::const_iterator it = langs.begin(); for (list<string>::const_iterator it = langs.begin();
it != langs.end(); it++) { it != langs.end(); it++) {
stemLangCMB-> stemLangCMB->
insertItem(QString::fromAscii(it->c_str(), it->length())); addItem(QString::fromAscii(it->c_str(), it->length()));
} }
stemLangCMB->setEnabled(expTypeCMB->currentItem()==2); stemLangCMB->setEnabled(expTypeCMB->currentIndex()==2);
(void)new HelpClient(this); (void)new HelpClient(this);
HelpClient::installMap(this->name(), "RCL.SEARCH.TERMEXPLORER"); HelpClient::installMap((const char *)this->objectName().toUtf8(),
"RCL.SEARCH.TERMEXPLORER");
// signals and slots connections // signals and slots connections
connect(baseWordLE, SIGNAL(textChanged(const QString&)), connect(baseWordLE, SIGNAL(textChanged(const QString&)),
@ -116,25 +117,25 @@ void SpellW::doExpand()
return; return;
} }
string expr = string((const char *)baseWordLE->text().utf8()); string expr = string((const char *)baseWordLE->text().toUtf8());
list<string> suggs; list<string> suggs;
prefs.termMatchType = expTypeCMB->currentItem(); prefs.termMatchType = expTypeCMB->currentIndex();
Rcl::Db::MatchType mt = Rcl::Db::ET_WILD; Rcl::Db::MatchType mt = Rcl::Db::ET_WILD;
switch(expTypeCMB->currentItem()) { switch(expTypeCMB->currentIndex()) {
case 0: mt = Rcl::Db::ET_WILD; break; case 0: mt = Rcl::Db::ET_WILD; break;
case 1:mt = Rcl::Db::ET_REGEXP; break; case 1:mt = Rcl::Db::ET_REGEXP; break;
case 2:mt = Rcl::Db::ET_STEM; break; case 2:mt = Rcl::Db::ET_STEM; break;
} }
Rcl::TermMatchResult res; Rcl::TermMatchResult res;
switch (expTypeCMB->currentItem()) { switch (expTypeCMB->currentIndex()) {
case 0: case 0:
case 1: case 1:
case 2: case 2:
{ {
string l_stemlang = stemLangCMB->currentText().ascii(); string l_stemlang = (const char*)stemLangCMB->currentText().toAscii();
if (!rcldb->termMatch(mt, l_stemlang, expr, res, 200)) { if (!rcldb->termMatch(mt, l_stemlang, expr, res, 200)) {
LOGERR(("SpellW::doExpand:rcldb::termMatch failed\n")); LOGERR(("SpellW::doExpand:rcldb::termMatch failed\n"));

View File

@ -40,12 +40,12 @@ static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.26 2008-12-05 11:09:31 dockes E
void SSearch::init() void SSearch::init()
{ {
// See enum above and keep in order ! // See enum above and keep in order !
searchTypCMB->insertItem(tr("Any term")); searchTypCMB->addItem(tr("Any term"));
searchTypCMB->insertItem(tr("All terms")); searchTypCMB->addItem(tr("All terms"));
searchTypCMB->insertItem(tr("File name")); searchTypCMB->addItem(tr("File name"));
searchTypCMB->insertItem(tr("Query language")); searchTypCMB->addItem(tr("Query language"));
queryText->insertStringList(prefs.ssearchHistory); queryText->addItems(prefs.ssearchHistory);
queryText->setEditText(""); queryText->setEditText("");
connect(queryText->lineEdit(), SIGNAL(returnPressed()), connect(queryText->lineEdit(), SIGNAL(returnPressed()),
this, SLOT(startSimpleSearch())); this, SLOT(startSimpleSearch()));
@ -77,14 +77,16 @@ void SSearch::searchTypeChanged(int typ)
LOGDEB(("Search type now %d\n", typ)); LOGDEB(("Search type now %d\n", typ));
// Adjust context help // Adjust context help
if (typ == SST_LANG) if (typ == SST_LANG)
HelpClient::installMap(this->name(), "RCL.SEARCH.LANG"); HelpClient::installMap((const char *)this->objectName().toUtf8(),
"RCL.SEARCH.LANG");
else else
HelpClient::installMap(this->name(), "RCL.SEARCH.SIMPLE"); HelpClient::installMap((const char *)this->objectName().toUtf8(),
"RCL.SEARCH.SIMPLE");
// Also fix tooltips // Also fix tooltips
switch (typ) { switch (typ) {
case SST_LANG: case SST_LANG:
QToolTip::add(queryText, queryText->setToolTip(tr(
"Enter query language expression. Cheat sheet:<br>\n" "Enter query language expression. Cheat sheet:<br>\n"
"<i>term1 term2</i> : 'term1' and 'term2' in any field.<br>\n" "<i>term1 term2</i> : 'term1' and 'term2' in any field.<br>\n"
"<i>field:term1</i> : 'term1' in field 'field'.<br>\n" "<i>field:term1</i> : 'term1' in field 'field'.<br>\n"
@ -97,16 +99,17 @@ void SSearch::searchTypeChanged(int typ)
"<i>\"term1 term2\"</i> : phrase (must occur exactly). Possible modifiers:<br>\n" "<i>\"term1 term2\"</i> : phrase (must occur exactly). Possible modifiers:<br>\n"
"<i>\"term1 term2\"p</i> : unordered proximity search with default distance.<br>\n" "<i>\"term1 term2\"p</i> : unordered proximity search with default distance.<br>\n"
"Use <b>Show Query</b> link when in doubt about result and see manual (&lt;F1>) for more detail.\n" "Use <b>Show Query</b> link when in doubt about result and see manual (&lt;F1>) for more detail.\n"
); ));
break; break;
case SST_FNM: case SST_FNM:
QToolTip::add(queryText, "Enter file name wildcard expression."); queryText->setToolTip(tr("Enter file name wildcard expression."));
break; break;
case SST_ANY: case SST_ANY:
case SST_ALL: case SST_ALL:
default: default:
QToolTip::add(queryText, queryText->setToolTip(tr(
"Enter search terms here. Type ESC SPC for completions of current term."); "Enter search terms here. Type ESC SPC for completions of current term."
));
} }
} }
@ -115,20 +118,20 @@ void SSearch::startSimpleSearch()
if (queryText->currentText().length() == 0) if (queryText->currentText().length() == 0)
return; return;
string u8 = (const char *)queryText->currentText().utf8(); string u8 = (const char *)queryText->currentText().toUtf8();
LOGDEB(("SSearch::startSimpleSearch: [%s]\n", u8.c_str())); LOGDEB(("SSearch::startSimpleSearch: [%s]\n", u8.c_str()));
trimstring(u8); trimstring(u8);
if (u8.length() == 0) if (u8.length() == 0)
return; return;
SSearchType tp = (SSearchType)searchTypCMB->currentItem(); SSearchType tp = (SSearchType)searchTypCMB->currentIndex();
Rcl::SearchData *sdata = 0; Rcl::SearchData *sdata = 0;
if (tp == SST_LANG) { if (tp == SST_LANG) {
string reason; string reason;
if (prefs.autoSuffsEnable) if (prefs.autoSuffsEnable)
sdata = wasaStringToRcl(u8, reason, (const char *)prefs.autoSuffs.utf8()); sdata = wasaStringToRcl(u8, reason, (const char *)prefs.autoSuffs.toUtf8());
else else
sdata = wasaStringToRcl(u8, reason); sdata = wasaStringToRcl(u8, reason);
if (sdata == 0) { if (sdata == 0) {
@ -180,42 +183,25 @@ void SSearch::startSimpleSearch()
// Search terms history // Search terms history
// Need to remove any previous occurence of the search entry from // We want to have the new text at the top and any older identical
// the listbox list, The qt listbox doesn't do lru correctly (if // entry to be erased. There is no standard qt policy to do this ?
// already in the list the new entry would remain at it's place, // So do it by hand.
// not jump at the top as it should
LOGDEB3(("Querytext list count %d\n", queryText->count()));
// Have to save current text, this will change while we clean up the list
QString txt = queryText->currentText(); QString txt = queryText->currentText();
bool changed; int index = queryText->findText(txt);
do { if (index > 0)
changed = false; queryText->removeItem(index);
for (int index = 0; index < queryText->count(); index++) {
LOGDEB3(("Querytext[%d] = [%s]\n", index,
(const char *)(queryText->text(index).utf8())));
if (queryText->text(index).length() == 0 ||
QString::compare(queryText->text(index), txt) == 0) {
LOGDEB3(("Querytext removing at %d [%s] [%s]\n", index,
(const char *)(queryText->text(index).utf8()),
(const char *)(txt.utf8())));
queryText->removeItem(index);
changed = true;
break;
}
}
} while (changed);
// The combobox is set for no insertion, insert here: // The combobox is set for no insertion, insert here:
queryText->insertItem(txt, 0); queryText->insertItem(0, txt);
queryText->setCurrentItem(0); queryText->setCurrentIndex(0);
// Save the current state of the listbox list to the prefs (will // Save the current state of the listbox list to the prefs (will
// go to disk) // go to disk)
prefs.ssearchHistory.clear(); prefs.ssearchHistory.clear();
for (int index = 0; index < queryText->count(); index++) { for (int index = 0; index < queryText->count(); index++) {
prefs.ssearchHistory.push_back(queryText->text(index)); prefs.ssearchHistory.push_back(queryText->itemText(index));
} }
RefCntr<Rcl::SearchData> rsdata(sdata); RefCntr<Rcl::SearchData> rsdata(sdata);
emit startSearch(rsdata); emit startSearch(rsdata);
} }
@ -232,7 +218,7 @@ bool SSearch::hasSearchString()
void SSearch::setAnyTermMode() void SSearch::setAnyTermMode()
{ {
searchTypCMB->setCurrentItem(SST_ANY); searchTypCMB->setCurrentIndex(SST_ANY);
} }
// Complete last word in input by querying db for all possible terms. // Complete last word in input by querying db for all possible terms.
@ -240,13 +226,13 @@ void SSearch::completion()
{ {
if (!rcldb) if (!rcldb)
return; return;
if (searchTypCMB->currentItem() == SST_FNM) { if (searchTypCMB->currentIndex() == SST_FNM) {
// Filename: no completion // Filename: no completion
QApplication::beep(); QApplication::beep();
return; return;
} }
// Extract last word in text // Extract last word in text
string txt = (const char *)queryText->currentText().utf8(); string txt = (const char *)queryText->currentText().toUtf8();
string::size_type cs = txt.find_last_of(" "); string::size_type cs = txt.find_last_of(" ");
if (cs == string::npos) if (cs == string::npos)
cs = 0; cs = 0;
@ -262,7 +248,7 @@ void SSearch::completion()
// Query database // Query database
const int max = 100; const int max = 100;
Rcl::TermMatchResult tmres; Rcl::TermMatchResult tmres;
string stemLang = (const char *)prefs.queryStemLang.ascii(); string stemLang = (const char *)prefs.queryStemLang.toAscii();
if (stemLang == "ALL") { if (stemLang == "ALL") {
rclconfig->getConfParam("indexstemminglanguages", stemLang); rclconfig->getConfParam("indexstemminglanguages", stemLang);
} }
@ -288,15 +274,15 @@ void SSearch::completion()
it != tmres.entries.end(); it++) { it != tmres.entries.end(); it++) {
lst.push_back(QString::fromUtf8(it->term.c_str())); lst.push_back(QString::fromUtf8(it->term.c_str()));
} }
res = QInputDialog::getItem(tr("Completions"), res = QInputDialog::getItem (this, tr("Completions"),
tr("Select an item:"), lst, 0, tr("Select an item:"),
FALSE, &ok, this); lst, 0, false, &ok);
} }
// Insert result // Insert result
if (ok) { if (ok) {
txt.erase(cs); txt.erase(cs);
txt.append(res.utf8()); txt.append((const char *)res.toUtf8());
queryText->setEditText(QString::fromUtf8(txt.c_str())); queryText->setEditText(QString::fromUtf8(txt.c_str()));
} else { } else {
return; return;

View File

@ -122,8 +122,8 @@ void UIPrefsDialog::setFromPrefs()
// Stemming language combobox // Stemming language combobox
stemLangCMB->clear(); stemLangCMB->clear();
stemLangCMB->insertItem(g_stringNoStem); stemLangCMB->addItem(g_stringNoStem);
stemLangCMB->insertItem(g_stringAllStem); stemLangCMB->addItem(g_stringAllStem);
list<string> langs; list<string> langs;
if (!getStemLangs(langs)) { if (!getStemLangs(langs)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
@ -133,12 +133,13 @@ void UIPrefsDialog::setFromPrefs()
for (list<string>::const_iterator it = langs.begin(); for (list<string>::const_iterator it = langs.begin();
it != langs.end(); it++) { it != langs.end(); it++) {
stemLangCMB-> stemLangCMB->
insertItem(QString::fromAscii(it->c_str(), it->length())); addItem(QString::fromAscii(it->c_str(), it->length()));
if (cur == 0 && !strcmp(prefs.queryStemLang.ascii(), it->c_str())) { if (cur == 0 && !strcmp((const char*)prefs.queryStemLang.toAscii(),
it->c_str())) {
cur = stemLangCMB->count(); cur = stemLangCMB->count();
} }
} }
stemLangCMB->setCurrentItem(cur); stemLangCMB->setCurrentIndex(cur);
autoPhraseCB->setChecked(prefs.ssearchAutoPhrase); autoPhraseCB->setChecked(prefs.ssearchAutoPhrase);
@ -183,16 +184,16 @@ void UIPrefsDialog::accept()
prefs.qtermcolor = qtermColorLE->text(); prefs.qtermcolor = qtermColorLE->text();
prefs.reslistfontfamily = reslistFontFamily; prefs.reslistfontfamily = reslistFontFamily;
prefs.reslistfontsize = reslistFontSize; prefs.reslistfontsize = reslistFontSize;
prefs.reslistformat = rlfTE->text(); prefs.reslistformat = rlfTE->toPlainText();
if (prefs.reslistformat.stripWhiteSpace().isEmpty()) { if (prefs.reslistformat.trimmed().isEmpty()) {
prefs.reslistformat = prefs.dfltResListFormat; prefs.reslistformat = prefs.dfltResListFormat;
rlfTE->setPlainText(prefs.reslistformat); rlfTE->setPlainText(prefs.reslistformat);
} }
prefs.creslistformat = (const char*)prefs.reslistformat.utf8(); prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
if (stemLangCMB->currentItem() == 0) { if (stemLangCMB->currentIndex() == 0) {
prefs.queryStemLang = ""; prefs.queryStemLang = "";
} else if (stemLangCMB->currentItem() == 1) { } else if (stemLangCMB->currentIndex() == 1) {
prefs.queryStemLang = "ALL"; prefs.queryStemLang = "ALL";
} else { } else {
prefs.queryStemLang = stemLangCMB->currentText(); prefs.queryStemLang = stemLangCMB->currentText();
@ -220,10 +221,10 @@ void UIPrefsDialog::accept()
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i); QListWidgetItem *item = idxLV->item(i);
if (item) { if (item) {
prefs.allExtraDbs.push_back((const char *)item->text().local8Bit()); prefs.allExtraDbs.push_back((const char *)item->text().toLocal8Bit());
if (item->checkState() == Qt::Checked) { if (item->checkState() == Qt::Checked) {
prefs.activeExtraDbs.push_back((const char *) prefs.activeExtraDbs.push_back((const char *)
item->text().local8Bit()); item->text().toLocal8Bit());
} }
} }
} }
@ -250,13 +251,13 @@ void UIPrefsDialog::setStemLang(const QString& lang)
cur = 1; cur = 1;
} else { } else {
for (int i = 1; i < stemLangCMB->count(); i++) { for (int i = 1; i < stemLangCMB->count(); i++) {
if (lang == stemLangCMB->text(i)) { if (lang == stemLangCMB->itemText(i)) {
cur = i; cur = i;
break; break;
} }
} }
} }
stemLangCMB->setCurrentItem(cur); stemLangCMB->setCurrentIndex(cur);
} }
void UIPrefsDialog::showFontDialog() void UIPrefsDialog::showFontDialog()
@ -366,7 +367,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
return; return;
lastdir = input; lastdir = input;
string dbdir = (const char *)input.local8Bit(); string dbdir = (const char *)input.toLocal8Bit();
LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str())); LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
path_catslash(dbdir); path_catslash(dbdir);
if (!Rcl::Db::testDbDir(dbdir)) { if (!Rcl::Db::testDbDir(dbdir)) {
@ -396,11 +397,11 @@ void UIPrefsDialog::addExtraDbPB_clicked()
return; return;
} }
#if 0 #if 0
string nv = (const char *)input.local8Bit(); string nv = (const char *)input.toLocal8Bit();
QListViewItemIterator it(idxLV); QListViewItemIterator it(idxLV);
while (it.current()) { while (it.current()) {
QCheckListItem *item = (QCheckListItem *)it.current(); QCheckListItem *item = (QCheckListItem *)it.current();
string ov = (const char *)item->text().local8Bit(); string ov = (const char *)item->text().toLocal8Bit();
if (!ov.compare(nv)) { if (!ov.compare(nv)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("The selected directory is already in the index list")); tr("The selected directory is already in the index list"));

View File

@ -99,7 +99,7 @@ void ViewAction::editActions()
QTableWidgetItem *item0 = actionsLV->item(row, 0); QTableWidgetItem *item0 = actionsLV->item(row, 0);
if (!item0->isSelected()) if (!item0->isSelected())
continue; continue;
mtypes.push_back((const char *)item0->text().local8Bit()); mtypes.push_back((const char *)item0->text().toLocal8Bit());
QTableWidgetItem *item1 = actionsLV->item(row, 1); QTableWidgetItem *item1 = actionsLV->item(row, 1);
QString action = item1->text(); QString action = item1->text();
if (action0.isEmpty()) { if (action0.isEmpty()) {
@ -122,13 +122,13 @@ void ViewAction::editActions()
return; return;
bool ok; bool ok;
QString newaction = QInputDialog::getText("Recoll", "Edit action:", QString newaction = QInputDialog::getText(this, "Recoll", "Edit action:",
QLineEdit::Normal, QLineEdit::Normal,
action0, &ok, this); action0, &ok);
if (!ok || newaction.isEmpty() ) if (!ok || newaction.isEmpty() )
return; return;
string sact = (const char *)newaction.local8Bit(); string sact = (const char *)newaction.toLocal8Bit();
for (list<string>::const_iterator it = mtypes.begin(); for (list<string>::const_iterator it = mtypes.begin();
it != mtypes.end(); it++) { it != mtypes.end(); it++) {
rclconfig->setMimeViewerDef(*it, sact); rclconfig->setMimeViewerDef(*it, sact);