|
... |
|
... |
17 |
* Free Software Foundation, Inc.,
|
17 |
* Free Software Foundation, Inc.,
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
19 |
*/
|
19 |
*/
|
20 |
#include "autoconfig.h"
|
20 |
#include "autoconfig.h"
|
21 |
|
21 |
|
|
|
22 |
#include "recoll.h"
|
|
|
23 |
|
22 |
#include "searchclause_w.h"
|
24 |
#include "searchclause_w.h"
|
23 |
|
25 |
|
24 |
#include <qvariant.h>
|
26 |
#include <qvariant.h>
|
25 |
#include <qcombobox.h>
|
27 |
#include <qcombobox.h>
|
26 |
#include <qspinbox.h>
|
28 |
#include <qspinbox.h>
|
|
... |
|
... |
35 |
*/
|
37 |
*/
|
36 |
SearchClauseW::SearchClauseW(QWidget* parent)
|
38 |
SearchClauseW::SearchClauseW(QWidget* parent)
|
37 |
: QWidget(parent)
|
39 |
: QWidget(parent)
|
38 |
{
|
40 |
{
|
39 |
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
41 |
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
|
|
42 |
|
40 |
sTpCMB = new QComboBox(this);
|
43 |
sTpCMB = new QComboBox(this);
|
41 |
sTpCMB->setEditable(false);
|
44 |
sTpCMB->setEditable(false);
|
42 |
hLayout->addWidget(sTpCMB);
|
45 |
hLayout->addWidget(sTpCMB);
|
|
|
46 |
|
|
|
47 |
fldCMB = new QComboBox(this);
|
|
|
48 |
fldCMB->setEditable(false);
|
|
|
49 |
hLayout->addWidget(fldCMB);
|
43 |
|
50 |
|
44 |
proxSlackSB = new QSpinBox(this);
|
51 |
proxSlackSB = new QSpinBox(this);
|
45 |
hLayout->addWidget(proxSlackSB);
|
52 |
hLayout->addWidget(proxSlackSB);
|
46 |
|
53 |
|
47 |
wordsLE = new QLineEdit(this);
|
54 |
wordsLE = new QLineEdit(this);
|
|
... |
|
... |
75 |
sTpCMB->addItem(tr("This phrase"));//3
|
82 |
sTpCMB->addItem(tr("This phrase"));//3
|
76 |
sTpCMB->addItem(tr("Terms in proximity"));//4
|
83 |
sTpCMB->addItem(tr("Terms in proximity"));//4
|
77 |
sTpCMB->addItem(tr("File name matching"));//5
|
84 |
sTpCMB->addItem(tr("File name matching"));//5
|
78 |
// sTpCMB->insertItem(tr("Complex clause"));//6
|
85 |
// sTpCMB->insertItem(tr("Complex clause"));//6
|
79 |
|
86 |
|
|
|
87 |
fldCMB->addItem(tr("In field"));
|
|
|
88 |
if (rclconfig) {
|
|
|
89 |
set<string> fields = rclconfig->getIndexedFields();
|
|
|
90 |
for (set<string>::const_iterator it = fields.begin();
|
|
|
91 |
it != fields.end(); it++) {
|
|
|
92 |
// Some fields don't make sense here
|
|
|
93 |
if (it->compare("filename")) {
|
|
|
94 |
fldCMB->addItem(QString::fromUtf8(it->c_str()));
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
}
|
80 |
// Ensure that the spinbox will be enabled/disabled depending on
|
98 |
// Ensure that the spinbox will be enabled/disabled depending on
|
81 |
// combobox state
|
99 |
// combobox state
|
82 |
tpChange(0);
|
100 |
tpChange(0);
|
83 |
|
101 |
|
84 |
sTpCMB->setToolTip(tr("Select the type of query that will be performed with the words"));
|
102 |
sTpCMB->setToolTip(tr("Select the type of query that will be performed with the words"));
|
|
... |
|
... |
91 |
SearchDataClause *
|
109 |
SearchDataClause *
|
92 |
SearchClauseW::getClause()
|
110 |
SearchClauseW::getClause()
|
93 |
{
|
111 |
{
|
94 |
if (wordsLE->text().isEmpty())
|
112 |
if (wordsLE->text().isEmpty())
|
95 |
return 0;
|
113 |
return 0;
|
|
|
114 |
string field;
|
|
|
115 |
if (fldCMB->currentIndex() != 0) {
|
|
|
116 |
field = (const char *)fldCMB->currentText().toUtf8();
|
|
|
117 |
}
|
|
|
118 |
string text = (const char *)wordsLE->text().toUtf8();
|
96 |
switch (sTpCMB->currentIndex()) {
|
119 |
switch (sTpCMB->currentIndex()) {
|
97 |
case 0:
|
120 |
case 0:
|
98 |
return new SearchDataClauseSimple(SCLT_OR,
|
121 |
return new SearchDataClauseSimple(SCLT_OR, text, field);
|
99 |
(const char *)wordsLE->text().toUtf8());
|
|
|
100 |
case 1:
|
122 |
case 1:
|
101 |
return new SearchDataClauseSimple(SCLT_AND,
|
123 |
return new SearchDataClauseSimple(SCLT_AND, text, field);
|
102 |
(const char *)wordsLE->text().toUtf8());
|
|
|
103 |
case 2:
|
124 |
case 2:
|
104 |
return new SearchDataClauseSimple(SCLT_EXCL,
|
125 |
return new SearchDataClauseSimple(SCLT_EXCL, text, field);
|
105 |
(const char *)wordsLE->text().toUtf8());
|
|
|
106 |
case 3:
|
126 |
case 3:
|
107 |
return new SearchDataClauseDist(SCLT_PHRASE,
|
127 |
return new SearchDataClauseDist(SCLT_PHRASE, text,
|
108 |
(const char *)wordsLE->text().toUtf8(),
|
|
|
109 |
proxSlackSB->value());
|
128 |
proxSlackSB->value(), field);
|
110 |
case 4:
|
129 |
case 4:
|
111 |
return new SearchDataClauseDist(SCLT_NEAR,
|
130 |
return new SearchDataClauseDist(SCLT_NEAR, text,
|
112 |
(const char *)wordsLE->text().toUtf8(),
|
|
|
113 |
proxSlackSB->value());
|
131 |
proxSlackSB->value(), field);
|
114 |
case 5:
|
132 |
case 5:
|
115 |
return new SearchDataClauseFilename((const char *)wordsLE->text().toUtf8());
|
133 |
return new SearchDataClauseFilename(text);
|
116 |
case 6:
|
134 |
case 6:
|
117 |
default:
|
135 |
default:
|
118 |
return 0;
|
136 |
return 0;
|
119 |
}
|
137 |
}
|
120 |
}
|
138 |
}
|
121 |
|
139 |
|
122 |
// Handle combobox change: may need to enable/disable the distance spinbox
|
140 |
// Handle combobox change: may need to enable/disable the distance
|
|
|
141 |
// spinbox and field spec
|
123 |
void SearchClauseW::tpChange(int index)
|
142 |
void SearchClauseW::tpChange(int index)
|
124 |
{
|
143 |
{
|
125 |
if (index < 0 || index > 5)
|
144 |
if (index < 0 || index > 5)
|
126 |
return;
|
145 |
return;
|
127 |
if (sTpCMB->currentIndex() != index)
|
146 |
if (sTpCMB->currentIndex() != index)
|
|
... |
|
... |
135 |
proxSlackSB->setValue(10);
|
154 |
proxSlackSB->setValue(10);
|
136 |
break;
|
155 |
break;
|
137 |
default:
|
156 |
default:
|
138 |
proxSlackSB->close();
|
157 |
proxSlackSB->close();
|
139 |
}
|
158 |
}
|
|
|
159 |
if (index == 5) {
|
|
|
160 |
fldCMB->close();
|
|
|
161 |
} else {
|
|
|
162 |
fldCMB->show();
|
|
|
163 |
}
|
140 |
}
|
164 |
}
|