Switch to unified view

a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.19 2007-01-25 15:46:38 dockes Exp $ (C) 2006 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.20 2007-02-06 10:19:40 dockes Exp $ (C) 2006 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
...
...
78
    return;
78
    return;
79
79
80
    string u8 = (const char *)queryText->currentText().utf8();
80
    string u8 = (const char *)queryText->currentText().utf8();
81
    LOGDEB(("SSearch::startSimpleSearch: [%s]\n", u8.c_str()));
81
    LOGDEB(("SSearch::startSimpleSearch: [%s]\n", u8.c_str()));
82
82
83
    trimstring(u8);
84
    if (u8.length() == 0)
85
  return;
86
83
    SSearchType tp = (SSearchType)searchTypCMB->currentItem();
87
    SSearchType tp = (SSearchType)searchTypCMB->currentItem();
84
    Rcl::SearchData *sdata = 0;
88
    Rcl::SearchData *sdata = 0;
85
89
86
    if (tp == SST_LANG) {
90
    if (tp == SST_LANG) {
87
    string reason;
91
    string reason;
...
...
96
    if (sdata == 0) {
100
    if (sdata == 0) {
97
        QMessageBox::warning(0, "Recoll", tr("Out of memory"));
101
        QMessageBox::warning(0, "Recoll", tr("Out of memory"));
98
        return;
102
        return;
99
    }
103
    }
100
104
105
  // If there is no white space inside the query, then the user
106
  // certainly means it as a phrase.
107
  bool isreallyaphrase = false;
108
  if (u8.find_first_of(" \t") == string::npos)
109
      isreallyaphrase = true;
110
101
    // Maybe add automatic phrase ? For ALL and ANY, and not if
111
    // Maybe add automatic phrase ? For ALL and ANY, and not if
102
    // there is already a phrase or wildcard terms.
112
    // there is already a phrase or wildcard terms.
113
  if (!isreallyaphrase && 
103
    if (prefs.ssearchAutoPhrase && (tp == SST_ANY || tp == SST_ALL) &&
114
        prefs.ssearchAutoPhrase && (tp == SST_ANY || tp == SST_ALL) &&
104
        u8.find_first_of("\"*[]?") == string::npos && 
115
        u8.find_first_of("\"*[]?") == string::npos && 
105
        TextSplit::countWords(u8) > 1) {
116
        TextSplit::countWords(u8) > 1) {
106
        sdata->addClause(new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, 
117
        sdata->addClause(new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, 
107
                               u8, 0));
118
                               u8, 0));
108
    }
119
    }
109
120
  Rcl::SearchDataClause *clp = 0;
110
    switch (tp) {
121
    switch (tp) {
111
    case SST_ANY:
122
    case SST_ANY:
112
    default: 
123
    default:
124
      clp = isreallyaphrase ? 
125
      new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, u8, 0) :
113
        sdata->addClause(new Rcl::SearchDataClauseSimple(Rcl::SCLT_OR,u8));
126
      new Rcl::SearchDataClauseSimple(Rcl::SCLT_OR, u8);
114
        break;
127
        break;
115
    case SST_ALL:
128
    case SST_ALL:
129
      clp = isreallyaphrase ? 
130
      new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, u8, 0) :
116
       sdata->addClause(new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND,u8));
131
      new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND, u8);
117
        break;
132
        break;
118
    case SST_FNM:
133
    case SST_FNM:
119
        sdata->addClause(new Rcl::SearchDataClauseFilename(u8));
134
        clp = new Rcl::SearchDataClauseFilename(u8);
120
        break;
135
        break;
121
    }
136
    }
137
  sdata->addClause(clp);
122
    }
138
    }
123
139
124
    // Search terms history
140
    // Search terms history
125
141
126
    // Need to remove any previous occurence of the search entry from
142
    // Need to remove any previous occurence of the search entry from