Switch to unified view

a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.4 2006-09-13 08:13:36 dockes Exp $ (C) 2005 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.5 2006-11-13 08:58:47 dockes Exp $ (C) 2005 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
159
    noFiltypsLB->setSelected(i, true);
159
    noFiltypsLB->setSelected(i, true);
160
    }
160
    }
161
    addFiltypPB_clicked();
161
    addFiltypPB_clicked();
162
}
162
}
163
163
164
165
// Activate file type selection
164
// Activate file type selection
166
void AdvSearch::restrictFtCB_toggled(bool on)
165
void AdvSearch::restrictFtCB_toggled(bool on)
167
{
166
{
168
    yesFiltypsLB->setEnabled(on);
167
    yesFiltypsLB->setEnabled(on);
169
    delFiltypPB->setEnabled(on);
168
    delFiltypPB->setEnabled(on);
...
...
171
    delAFiltypPB->setEnabled(on);
170
    delAFiltypPB->setEnabled(on);
172
    addAFiltypPB->setEnabled(on);
171
    addAFiltypPB->setEnabled(on);
173
    noFiltypsLB->setEnabled(on);
172
    noFiltypsLB->setEnabled(on);
174
}
173
}
175
174
175
using namespace Rcl;
176
void AdvSearch::searchPB_clicked()
176
void AdvSearch::searchPB_clicked()
177
{
177
{
178
    Rcl::AdvSearchData mydata;
178
    RefCntr<SearchData> sdata(new SearchData(SCLT_AND));
179
    bool hasnotnot = false;
180
    bool hasnot = false;
181
    if (!andWordsLE->text().isEmpty()) {
182
  sdata->addClause(new SearchDataClauseSimple(SCLT_AND,
183
                  (const char *)andWordsLE->text().utf8()));
184
  hasnotnot = true;
185
    }
186
    if (!orWordsLE->text().isEmpty()) {
187
  sdata->addClause(new SearchDataClauseSimple(SCLT_OR,
188
                  (const char *)orWordsLE->text().utf8()));
189
  hasnotnot = true;
190
    }
191
    if (!orWords1LE->text().isEmpty()) {
192
  sdata->addClause(new SearchDataClauseSimple(SCLT_OR,
193
                  (const char *)orWords1LE->text().utf8()));
194
  hasnotnot = true;
195
    }
196
    if (!noWordsLE->text().isEmpty()) {
197
  sdata->addClause(new SearchDataClauseSimple(SCLT_EXCL,
198
                  (const char *)noWordsLE->text().utf8()));
199
  hasnot = true;
200
    }
201
    if (!fileNameLE->text().isEmpty()) {
202
  sdata->addClause(new SearchDataClauseFilename(
203
                   (const char *)fileNameLE->text().utf8()));
204
  hasnotnot = true;
205
    }
206
    if (!phraseLE->text().isEmpty()) {
207
  sdata->addClause(new SearchDataClauseDist(SCLT_PHRASE,
208
                (const char *)phraseLE->text().utf8(), 0));
209
  hasnotnot = true;
210
    }
179
211
180
    mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
212
    if (!hasnotnot) {
181
    mydata.phrase  = string((const char*)(phraseLE->text().utf8()));
213
  if (!hasnot)
182
    mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
183
    mydata.orwords1 = string((const char*)(orWords1LE->text().utf8()));
184
    mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
185
    mydata.filename = string((const char*)(fileNameLE->text().utf8()));
186
187
    if (mydata.allwords.empty() && mydata.phrase.empty() && 
188
  mydata.orwords.empty() && mydata.orwords1.empty() && 
189
  mydata.filename.empty()) {
190
  if (mydata.nowords.empty())
191
        return;
214
        return;
192
    QMessageBox::warning(0, "Recoll",
215
    QMessageBox::warning(0, "Recoll",
193
                 tr("Cannot execute pure negative query. "
216
                 tr("Cannot execute pure negative query. "
194
                "Please enter common terms in the 'any words' field")); 
217
                "Please enter common terms in the 'any words' field")); 
195
    return;
218
    return;
196
    }
219
    }
197
198
    if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
220
    if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
199
    for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
221
    for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
200
        QCString ctext = yesFiltypsLB->item(i)->text().utf8();
222
        QCString ctext = yesFiltypsLB->item(i)->text().utf8();
201
        mydata.filetypes.push_back(string((const char *)ctext));
223
        sdata->m_filetypes.push_back(string((const char *)ctext));
202
    }
224
    }
203
    }
225
    }
204
226
205
    if (!subtreeCMB->currentText().isEmpty()) {
227
    if (!subtreeCMB->currentText().isEmpty()) {
206
    mydata.topdir = 
228
    sdata->m_topdir = 
207
        string((const char*)(subtreeCMB->currentText().utf8()));
229
        string((const char*)(subtreeCMB->currentText().utf8()));
208
    // The listbox is set for no insertion, do it. Have to check
230
    // The listbox is set for no insertion, do it. Have to check
209
    // for dups as the internal feature seems to only work for
231
    // for dups as the internal feature seems to only work for
210
    // user-inserted strings
232
    // user-inserted strings
211
    if (!subtreeCMB->listBox()->findItem(subtreeCMB->currentText(),
233
    if (!subtreeCMB->listBox()->findItem(subtreeCMB->currentText(),
...
...
215
    subtreeCMB->listBox()->sort();
237
    subtreeCMB->listBox()->sort();
216
    prefs.asearchSubdirHist.clear();
238
    prefs.asearchSubdirHist.clear();
217
    for (int index = 0; index < subtreeCMB->count(); index++)
239
    for (int index = 0; index < subtreeCMB->count(); index++)
218
        prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
240
        prefs.asearchSubdirHist.push_back(subtreeCMB->text(index));
219
    }
241
    }
220
    emit startSearch(mydata);
242
    emit startSearch(sdata);
221
}
243
}
222
244
223
245
224
void AdvSearch::browsePB_clicked()
246
void AdvSearch::browsePB_clicked()
225
{
247
{