Switch to unified view

a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp
...
...
34
#include "refcntr.h"
34
#include "refcntr.h"
35
#include "textsplit.h"
35
#include "textsplit.h"
36
#include "wasatorcl.h"
36
#include "wasatorcl.h"
37
#include "rclhelp.h"
37
#include "rclhelp.h"
38
38
39
// Typing interval after which we consider starting autosearch: no sense to do
40
// this is user is typing fast and continuously
41
static const int strokeTimeoutMS = 250;
42
39
void SSearch::init()
43
void SSearch::init()
40
{
44
{
41
    // See enum above and keep in order !
45
    // See enum above and keep in order !
42
    searchTypCMB->addItem(tr("Any term"));
46
    searchTypCMB->addItem(tr("Any term"));
43
    searchTypCMB->addItem(tr("All terms"));
47
    searchTypCMB->addItem(tr("All terms"));
...
...
101
        m_tstartqs = qs;
105
        m_tstartqs = qs;
102
    }
106
    }
103
    if (prefs.ssearchAsYouType && !m_disableAutosearch && 
107
    if (prefs.ssearchAsYouType && !m_disableAutosearch && 
104
        !m_keystroke && m_tstartqs == qs) {
108
        !m_keystroke && m_tstartqs == qs) {
105
        m_disableAutosearch = true;
109
        m_disableAutosearch = true;
106
      LOGDEB0(("SSearch::searchTextChanged: autosearch\n"));
107
        string s;
110
        string s;
108
        int cs = partialWord(s);
111
        int cs = partialWord(s);
112
      LOGDEB0(("SSearch::searchTextChanged: autosearch. cs %d s [%s]\n", 
113
           cs, s.c_str()));
109
        if (cs < 0) {
114
        if (cs < 0) {
110
        startSimpleSearch();
115
        startSimpleSearch();
111
        } else if (!m_stroketimeout->isActive()) {
116
        } else if (!m_stroketimeout->isActive() && s.size() >= 2) {
112
        s = qs2utf8s(queryText->currentText());
117
        s = qs2utf8s(queryText->currentText());
113
        s += "*";
118
        s += "*";
114
        startSimpleSearch(s, 20);
119
        startSimpleSearch(s, 20);
115
        }
120
        }
116
    }
121
    }
...
...
326
void SSearch::setAnyTermMode()
331
void SSearch::setAnyTermMode()
327
{
332
{
328
    searchTypCMB->setCurrentIndex(SST_ANY);
333
    searchTypCMB->setCurrentIndex(SST_ANY);
329
}
334
}
330
335
336
// If text does not end with space, return last (partial) word and >0
337
// else return -1
331
int SSearch::partialWord(string& s)
338
int SSearch::partialWord(string& s)
332
{
339
{
333
    // Extract last word in text
340
    // Extract last word in text
334
    QString txt = queryText->currentText();
341
    QString txt = queryText->currentText();
335
    int cs = txt.lastIndexOf(" ");
342
    int cs = txt.lastIndexOf(" ");
...
...
646
        if (prefs.ssearchAsYouType) {
653
        if (prefs.ssearchAsYouType) {
647
        m_disableAutosearch = false;
654
        m_disableAutosearch = false;
648
        QString qs = queryText->currentText();
655
        QString qs = queryText->currentText();
649
        LOGDEB0(("SSearch::eventFilter: start timer, qs [%s]\n", 
656
        LOGDEB0(("SSearch::eventFilter: start timer, qs [%s]\n", 
650
             qs2utf8s(qs).c_str()));
657
             qs2utf8s(qs).c_str()));
651
        m_stroketimeout->start(200);
658
        m_stroketimeout->start(strokeTimeoutMS);
652
        }
659
        }
653
    }
660
    }
654
    }
661
    }
655
    return false;
662
    return false;
656
}
663
}