|
a/src/qtgui/spell_w.cpp |
|
b/src/qtgui/spell_w.cpp |
|
... |
|
... |
20 |
|
20 |
|
21 |
#include <algorithm>
|
21 |
#include <algorithm>
|
22 |
#include <list>
|
22 |
#include <list>
|
23 |
#include <map>
|
23 |
#include <map>
|
24 |
#include <string>
|
24 |
#include <string>
|
25 |
using std::list;
|
|
|
26 |
using std::multimap;
|
|
|
27 |
using std::string;
|
|
|
28 |
|
25 |
|
29 |
#include <qmessagebox.h>
|
26 |
#include <qmessagebox.h>
|
30 |
#include <qpushbutton.h>
|
27 |
#include <qpushbutton.h>
|
31 |
#include <qlabel.h>
|
28 |
#include <qlabel.h>
|
32 |
#include <qlineedit.h>
|
29 |
#include <qlineedit.h>
|
|
... |
|
... |
50 |
#include "execmd.h"
|
47 |
#include "execmd.h"
|
51 |
|
48 |
|
52 |
#ifdef RCL_USE_ASPELL
|
49 |
#ifdef RCL_USE_ASPELL
|
53 |
#include "rclaspell.h"
|
50 |
#include "rclaspell.h"
|
54 |
#endif
|
51 |
#endif
|
|
|
52 |
|
|
|
53 |
using std::list;
|
|
|
54 |
using std::multimap;
|
|
|
55 |
using std::string;
|
55 |
|
56 |
|
56 |
void SpellW::init()
|
57 |
void SpellW::init()
|
57 |
{
|
58 |
{
|
58 |
m_c2t.clear();
|
59 |
m_c2t.clear();
|
59 |
expTypeCMB->addItem(tr("Wildcards"));
|
60 |
expTypeCMB->addItem(tr("Wildcards"));
|
|
... |
|
... |
71 |
}
|
72 |
}
|
72 |
#endif
|
73 |
#endif
|
73 |
expTypeCMB->addItem(tr("Show index statistics"));
|
74 |
expTypeCMB->addItem(tr("Show index statistics"));
|
74 |
m_c2t.push_back(TYPECMB_STATS);
|
75 |
m_c2t.push_back(TYPECMB_STATS);
|
75 |
|
76 |
|
76 |
int typ = prefs.termMatchType;
|
|
|
77 |
vector<comboboxchoice>::const_iterator it =
|
|
|
78 |
std::find(m_c2t.begin(), m_c2t.end(), typ);
|
|
|
79 |
if (it == m_c2t.end())
|
|
|
80 |
it = m_c2t.begin();
|
|
|
81 |
int cmbidx = it - m_c2t.begin();
|
|
|
82 |
|
|
|
83 |
expTypeCMB->setCurrentIndex(cmbidx);
|
|
|
84 |
|
|
|
85 |
// Stemming language combobox
|
77 |
// Stemming language combobox
|
86 |
stemLangCMB->clear();
|
78 |
stemLangCMB->clear();
|
87 |
vector<string> langs;
|
79 |
vector<string> langs;
|
88 |
if (!getStemLangs(langs)) {
|
80 |
if (!getStemLangs(langs)) {
|
89 |
QMessageBox::warning(0, "Recoll",
|
81 |
QMessageBox::warning(0, "Recoll",
|
|
... |
|
... |
103 |
connect(baseWordLE, SIGNAL(textChanged(const QString&)),
|
95 |
connect(baseWordLE, SIGNAL(textChanged(const QString&)),
|
104 |
this, SLOT(wordChanged(const QString&)));
|
96 |
this, SLOT(wordChanged(const QString&)));
|
105 |
connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand()));
|
97 |
connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand()));
|
106 |
connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand()));
|
98 |
connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand()));
|
107 |
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
|
99 |
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
|
108 |
connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(modeSet(int)));
|
100 |
connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(onModeChanged(int)));
|
109 |
|
101 |
|
110 |
resTW->setShowGrid(0);
|
102 |
resTW->setShowGrid(0);
|
111 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
103 |
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
112 |
resTW->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
104 |
resTW->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
113 |
#else
|
105 |
#else
|
|
... |
|
... |
120 |
|
112 |
|
121 |
resTW->setColumnWidth(0, 200);
|
113 |
resTW->setColumnWidth(0, 200);
|
122 |
resTW->setColumnWidth(1, 150);
|
114 |
resTW->setColumnWidth(1, 150);
|
123 |
resTW->installEventFilter(this);
|
115 |
resTW->installEventFilter(this);
|
124 |
|
116 |
|
125 |
if (o_index_stripchars) {
|
117 |
int idx = cmbIdx((comboboxchoice)prefs.termMatchType);
|
126 |
caseSensCB->setEnabled(false);
|
118 |
expTypeCMB->setCurrentIndex(idx);
|
127 |
caseSensCB->setEnabled(false);
|
119 |
onModeChanged(idx);
|
128 |
}
|
120 |
}
|
129 |
modeSet(cmbidx);
|
121 |
|
|
|
122 |
int SpellW::cmbIdx(comboboxchoice mode)
|
|
|
123 |
{
|
|
|
124 |
vector<comboboxchoice>::const_iterator it =
|
|
|
125 |
std::find(m_c2t.begin(), m_c2t.end(), mode);
|
|
|
126 |
if (it == m_c2t.end())
|
|
|
127 |
it = m_c2t.begin();
|
|
|
128 |
return it - m_c2t.begin();
|
130 |
}
|
129 |
}
|
131 |
|
130 |
|
132 |
static const int maxexpand = 10000;
|
131 |
static const int maxexpand = 10000;
|
133 |
|
132 |
|
134 |
/* Expand term according to current mode */
|
133 |
/* Expand term according to current mode */
|
|
... |
|
... |
304 |
QString::number(res.maxdoclen)));
|
303 |
QString::number(res.maxdoclen)));
|
305 |
|
304 |
|
306 |
if (!theconfig)
|
305 |
if (!theconfig)
|
307 |
return;
|
306 |
return;
|
308 |
|
307 |
|
|
|
308 |
baseWordLE->setText(QString::fromLocal8Bit(theconfig->getDbDir().c_str()));
|
|
|
309 |
|
309 |
ExecCmd cmd;
|
310 |
ExecCmd cmd;
|
310 |
vector<string> args;
|
311 |
vector<string> args;
|
311 |
int status;
|
312 |
int status;
|
312 |
args.push_back("-sk");
|
313 |
args.push_back("-sk");
|
313 |
args.push_back(theconfig->getDbDir());
|
314 |
args.push_back(theconfig->getDbDir());
|
314 |
string output;
|
315 |
string output;
|
315 |
status = cmd.doexec("du", args, 0, &output);
|
316 |
status = cmd.doexec("du", args, 0, &output);
|
316 |
int dbkbytes = 0;
|
317 |
long long dbkbytes = 0;
|
317 |
if (!status) {
|
318 |
if (!status) {
|
318 |
dbkbytes = atoi(output.c_str());
|
319 |
dbkbytes = atoll(output.c_str());
|
319 |
}
|
320 |
}
|
320 |
resTW->setRowCount(row+1);
|
321 |
resTW->setRowCount(row+1);
|
321 |
resTW->setItem(row, 0,
|
322 |
resTW->setItem(row, 0,
|
322 |
new QTableWidgetItem(tr("Database directory size")));
|
323 |
new QTableWidgetItem(tr("Database directory size")));
|
323 |
resTW->setItem(row++, 1, new QTableWidgetItem(
|
324 |
resTW->setItem(row++, 1, new QTableWidgetItem(
|
|
... |
|
... |
370 |
QTableWidgetItem *item = resTW->item(row, 0);
|
371 |
QTableWidgetItem *item = resTW->item(row, 0);
|
371 |
if (item)
|
372 |
if (item)
|
372 |
emit(wordSelect(item->text()));
|
373 |
emit(wordSelect(item->text()));
|
373 |
}
|
374 |
}
|
374 |
|
375 |
|
375 |
void SpellW::modeSet(int idx)
|
376 |
void SpellW::onModeChanged(int idx)
|
376 |
{
|
377 |
{
|
377 |
if (idx < 0 || idx > int(m_c2t.size()))
|
378 |
if (idx < 0 || idx > int(m_c2t.size()))
|
378 |
return;
|
379 |
return;
|
379 |
comboboxchoice mode = m_c2t[idx];
|
380 |
comboboxchoice mode = m_c2t[idx];
|
|
|
381 |
setModeCommon(mode);
|
|
|
382 |
}
|
|
|
383 |
|
|
|
384 |
void SpellW::setMode(comboboxchoice mode)
|
|
|
385 |
{
|
|
|
386 |
expTypeCMB->setCurrentIndex(cmbIdx(mode));
|
|
|
387 |
setModeCommon(mode);
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
void SpellW::setModeCommon(comboboxchoice mode)
|
|
|
391 |
{
|
|
|
392 |
if (m_prevmode == TYPECMB_STATS) {
|
|
|
393 |
baseWordLE->setText("");
|
|
|
394 |
}
|
|
|
395 |
m_prevmode = mode;
|
380 |
resTW->setRowCount(0);
|
396 |
resTW->setRowCount(0);
|
|
|
397 |
if (o_index_stripchars) {
|
|
|
398 |
caseSensCB->setEnabled(false);
|
|
|
399 |
diacSensCB->setEnabled(false);
|
|
|
400 |
} else {
|
|
|
401 |
caseSensCB->setEnabled(true);
|
|
|
402 |
diacSensCB->setEnabled(true);
|
|
|
403 |
}
|
381 |
|
404 |
|
382 |
if (mode == TYPECMB_STEM) {
|
405 |
if (mode == TYPECMB_STEM) {
|
383 |
stemLangCMB->setEnabled(true);
|
406 |
stemLangCMB->setEnabled(true);
|
384 |
diacSensCB->setChecked(false);
|
407 |
diacSensCB->setChecked(false);
|
385 |
diacSensCB->setEnabled(false);
|
408 |
diacSensCB->setEnabled(false);
|
386 |
caseSensCB->setChecked(false);
|
409 |
caseSensCB->setChecked(false);
|
387 |
caseSensCB->setEnabled(false);
|
410 |
caseSensCB->setEnabled(false);
|
388 |
} else {
|
411 |
} else {
|
389 |
stemLangCMB->setEnabled(false);
|
412 |
stemLangCMB->setEnabled(false);
|
390 |
diacSensCB->setEnabled(true);
|
|
|
391 |
caseSensCB->setEnabled(true);
|
|
|
392 |
}
|
413 |
}
|
393 |
if (mode == TYPECMB_STATS)
|
414 |
if (mode == TYPECMB_STATS)
|
394 |
baseWordLE->setEnabled(false);
|
415 |
baseWordLE->setEnabled(false);
|
395 |
else
|
416 |
else
|
396 |
baseWordLE->setEnabled(true);
|
417 |
baseWordLE->setEnabled(true);
|
|
... |
|
... |
398 |
|
419 |
|
399 |
if (mode == TYPECMB_STATS) {
|
420 |
if (mode == TYPECMB_STATS) {
|
400 |
QStringList labels(tr("Item"));
|
421 |
QStringList labels(tr("Item"));
|
401 |
labels.push_back(tr("Value"));
|
422 |
labels.push_back(tr("Value"));
|
402 |
resTW->setHorizontalHeaderLabels(labels);
|
423 |
resTW->setHorizontalHeaderLabels(labels);
|
|
|
424 |
diacSensCB->setEnabled(false);
|
|
|
425 |
caseSensCB->setEnabled(false);
|
403 |
doExpand();
|
426 |
doExpand();
|
404 |
} else {
|
427 |
} else {
|
405 |
QStringList labels(tr("Term"));
|
428 |
QStringList labels(tr("Term"));
|
406 |
labels.push_back(tr("Doc. / Tot."));
|
429 |
labels.push_back(tr("Doc. / Tot."));
|
407 |
resTW->setHorizontalHeaderLabels(labels);
|
430 |
resTW->setHorizontalHeaderLabels(labels);
|