ssearch:indent, log messages etc.
This commit is contained in:
parent
a193412fa1
commit
4d6ad4c3ea
@ -71,7 +71,8 @@ void SSearch::init()
|
|||||||
connect(clearqPB, SIGNAL(clicked()),
|
connect(clearqPB, SIGNAL(clicked()),
|
||||||
queryText->lineEdit(), SLOT(clear()));
|
queryText->lineEdit(), SLOT(clear()));
|
||||||
connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
|
connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
|
||||||
connect(searchTypCMB, SIGNAL(activated(int)), this, SLOT(searchTypeChanged(int)));
|
connect(searchTypCMB, SIGNAL(activated(int)), this,
|
||||||
|
SLOT(searchTypeChanged(int)));
|
||||||
|
|
||||||
queryText->installEventFilter(this);
|
queryText->installEventFilter(this);
|
||||||
queryText->view()->installEventFilter(this);
|
queryText->view()->installEventFilter(this);
|
||||||
@ -106,14 +107,15 @@ void SSearch::takeFocus()
|
|||||||
void SSearch::timerDone()
|
void SSearch::timerDone()
|
||||||
{
|
{
|
||||||
QString qs = queryText->currentText();
|
QString qs = queryText->currentText();
|
||||||
LOGDEB1("SSearch::timerDone: qs [" << (qs2utf8s(qs)) << "]\n" );
|
LOGDEB1("SSearch::timerDone: qs [" << qs2utf8s(qs) << "]\n");
|
||||||
searchTextChanged(qs);
|
searchTextChanged(qs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSearch::searchTextChanged(const QString& text)
|
void SSearch::searchTextChanged(const QString& text)
|
||||||
{
|
{
|
||||||
QString qs = queryText->currentText();
|
QString qs = queryText->currentText();
|
||||||
LOGDEB1("SSearch::searchTextChanged. ks " << (m_keystroke) << " qs [" << (qs2utf8s(text)) << "]\n" );
|
LOGDEB1("SSearch::searchTextChanged. ks " << m_keystroke << " qs [" <<
|
||||||
|
qs2utf8s(text) << "]\n");
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
searchPB->setEnabled(false);
|
searchPB->setEnabled(false);
|
||||||
clearqPB->setEnabled(false);
|
clearqPB->setEnabled(false);
|
||||||
@ -130,7 +132,8 @@ void SSearch::searchTextChanged(const QString& text)
|
|||||||
m_disableAutosearch = true;
|
m_disableAutosearch = true;
|
||||||
string s;
|
string s;
|
||||||
int cs = partialWord(s);
|
int cs = partialWord(s);
|
||||||
LOGDEB1("SSearch::searchTextChanged: autosearch. cs " << (cs) << " s [" << (s) << "]\n" );
|
LOGDEB1("SSearch::searchTextChanged: autosearch. cs " << cs <<
|
||||||
|
" s [" << s << "]\n");
|
||||||
if (cs < 0) {
|
if (cs < 0) {
|
||||||
startSimpleSearch();
|
startSimpleSearch();
|
||||||
} else if (!m_stroketimeout->isActive() && s.size() >= 2) {
|
} else if (!m_stroketimeout->isActive() && s.size() >= 2) {
|
||||||
@ -145,19 +148,20 @@ void SSearch::searchTextChanged(const QString& text)
|
|||||||
|
|
||||||
void SSearch::searchTypeChanged(int typ)
|
void SSearch::searchTypeChanged(int typ)
|
||||||
{
|
{
|
||||||
LOGDEB("Search type now " << (typ) << "\n" );
|
LOGDEB("Search type now " << typ << "\n");
|
||||||
// Adjust context help
|
// Adjust context help
|
||||||
if (typ == SST_LANG)
|
if (typ == SST_LANG) {
|
||||||
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
||||||
"RCL.SEARCH.LANG");
|
"RCL.SEARCH.LANG");
|
||||||
else
|
} else {
|
||||||
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
HelpClient::installMap((const char *)this->objectName().toUtf8(),
|
||||||
"RCL.SEARCH.GUI.SIMPLE");
|
"RCL.SEARCH.GUI.SIMPLE");
|
||||||
|
}
|
||||||
// Also fix tooltips
|
// Also fix tooltips
|
||||||
switch (typ) {
|
switch (typ) {
|
||||||
case SST_LANG:
|
case SST_LANG:
|
||||||
queryText->setToolTip(tr(
|
queryText->setToolTip(
|
||||||
|
tr(
|
||||||
"Enter query language expression. Cheat sheet:<br>\n"
|
"Enter query language expression. Cheat sheet:<br>\n"
|
||||||
"<i>term1 term2</i> : 'term1' and 'term2' in any field.<br>\n"
|
"<i>term1 term2</i> : 'term1' and 'term2' in any field.<br>\n"
|
||||||
"<i>field:term1</i> : 'term1' in field 'field'.<br>\n"
|
"<i>field:term1</i> : 'term1' in field 'field'.<br>\n"
|
||||||
@ -178,7 +182,8 @@ void SSearch::searchTypeChanged(int typ)
|
|||||||
case SST_ANY:
|
case SST_ANY:
|
||||||
case SST_ALL:
|
case SST_ALL:
|
||||||
default:
|
default:
|
||||||
queryText->setToolTip(tr(
|
queryText->setToolTip(
|
||||||
|
tr(
|
||||||
"Enter search terms here. Type ESC SPC for completions of current term."
|
"Enter search terms here. Type ESC SPC for completions of current term."
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -187,7 +192,7 @@ void SSearch::searchTypeChanged(int typ)
|
|||||||
void SSearch::startSimpleSearch()
|
void SSearch::startSimpleSearch()
|
||||||
{
|
{
|
||||||
QString qs = queryText->currentText();
|
QString qs = queryText->currentText();
|
||||||
LOGDEB("SSearch::startSimpleSearch(): qs [" << (qs2utf8s(qs)) << "]\n" );
|
LOGDEB("SSearch::startSimpleSearch(): qs [" << qs2utf8s(qs) << "]\n");
|
||||||
if (qs.length() == 0)
|
if (qs.length() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -241,7 +246,7 @@ string SSearch::asXML()
|
|||||||
|
|
||||||
bool SSearch::startSimpleSearch(const string& u8, int maxexp)
|
bool SSearch::startSimpleSearch(const string& u8, int maxexp)
|
||||||
{
|
{
|
||||||
LOGDEB("SSearch::startSimpleSearch(" << (u8) << ")\n" );
|
LOGDEB("SSearch::startSimpleSearch(" << u8 << ")\n");
|
||||||
string stemlang = prefs.stemlang();
|
string stemlang = prefs.stemlang();
|
||||||
|
|
||||||
ostringstream xml;
|
ostringstream xml;
|
||||||
@ -307,7 +312,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
|
|||||||
|
|
||||||
xml << "</SD>\n";
|
xml << "</SD>\n";
|
||||||
m_xml = xml.str();
|
m_xml = xml.str();
|
||||||
LOGDEB("SSearch::startSimpleSearch:xml:[" << (m_xml) << "]\n" );
|
LOGDEB("SSearch::startSimpleSearch:xml:[" << m_xml << "]\n");
|
||||||
|
|
||||||
std::shared_ptr<Rcl::SearchData> rsdata(sdata);
|
std::shared_ptr<Rcl::SearchData> rsdata(sdata);
|
||||||
emit startSearch(rsdata, true);
|
emit startSearch(rsdata, true);
|
||||||
@ -393,7 +398,7 @@ bool SSearch::hasSearchString()
|
|||||||
static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r";
|
static const char* punct = " \t()<>\"'[]{}!^*.,:;\n\r";
|
||||||
void SSearch::addTerm(QString term)
|
void SSearch::addTerm(QString term)
|
||||||
{
|
{
|
||||||
LOGDEB("SSearch::AddTerm: [" << ((const char *)term.toUtf8()) << "]\n" );
|
LOGDEB("SSearch::AddTerm: [" << qs2utf8s(term) << "]\n");
|
||||||
string t = (const char *)term.toUtf8();
|
string t = (const char *)term.toUtf8();
|
||||||
string::size_type pos = t.find_last_not_of(punct);
|
string::size_type pos = t.find_last_not_of(punct);
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
@ -415,7 +420,8 @@ void SSearch::addTerm(QString term)
|
|||||||
|
|
||||||
void SSearch::onWordReplace(const QString& o, const QString& n)
|
void SSearch::onWordReplace(const QString& o, const QString& n)
|
||||||
{
|
{
|
||||||
LOGDEB("SSearch::onWordReplace: o [" << (qs2utf8s(o)) << "] n [" << (qs2utf8s(n)) << "]\n" );
|
LOGDEB("SSearch::onWordReplace: o [" << qs2utf8s(o) << "] n [" <<
|
||||||
|
qs2utf8s(n) << "]\n");
|
||||||
QString txt = queryText->currentText();
|
QString txt = queryText->currentText();
|
||||||
QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b"));
|
QRegExp exp = QRegExp(QString("\\b") + o + QString("\\b"));
|
||||||
exp.setCaseSensitivity(Qt::CaseInsensitive);
|
exp.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
@ -466,9 +472,8 @@ int SSearch::completionList(string s, QStringList& lst, int max)
|
|||||||
tmres.entries.size() == 0) {
|
tmres.entries.size() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (vector<Rcl::TermMatchEntry>::iterator it = tmres.entries.begin();
|
for (const auto& entry: tmres.entries) {
|
||||||
it != tmres.entries.end(); it++) {
|
lst.push_back(u8s2qs(entry.term));
|
||||||
lst.push_back(QString::fromUtf8(it->term.c_str()));
|
|
||||||
}
|
}
|
||||||
return lst.size();
|
return lst.size();
|
||||||
}
|
}
|
||||||
@ -707,7 +712,9 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
|
|||||||
event->type() == QEvent::UpdateRequest ||
|
event->type() == QEvent::UpdateRequest ||
|
||||||
event->type() == QEvent::Paint)
|
event->type() == QEvent::Paint)
|
||||||
return false;
|
return false;
|
||||||
LOGDEB2("SSearch::eventFilter: target " << (target) << " (" << (queryText->lineEdit()) << ") type " << (eventTypeToStr(event->type())) << "\n" );
|
LOGDEB2("SSearch::eventFilter: target " << target << " (" <<
|
||||||
|
queryText->lineEdit() << ") type " <<
|
||||||
|
eventTypeToStr(event->type()) << "\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (target == (QObject*)(queryText->view())) {
|
if (target == (QObject*)(queryText->view())) {
|
||||||
@ -723,7 +730,8 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
|
|||||||
|
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *ke = (QKeyEvent *)event;
|
QKeyEvent *ke = (QKeyEvent *)event;
|
||||||
LOGDEB1("SSearch::eventFilter: keyPress (m_escape " << (m_escape) << ") key " << (ke->key()) << "\n" );
|
LOGDEB1("SSearch::eventFilter: keyPress (m_escape " << m_escape <<
|
||||||
|
") key " << ke->key() << "\n");
|
||||||
if (ke->key() == Qt::Key_Escape) {
|
if (ke->key() == Qt::Key_Escape) {
|
||||||
LOGDEB("Escape\n");
|
LOGDEB("Escape\n");
|
||||||
m_escape = true;
|
m_escape = true;
|
||||||
@ -747,11 +755,11 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
|
|||||||
if (prefs.ssearchAsYouType) {
|
if (prefs.ssearchAsYouType) {
|
||||||
m_disableAutosearch = false;
|
m_disableAutosearch = false;
|
||||||
QString qs = queryText->currentText();
|
QString qs = queryText->currentText();
|
||||||
LOGDEB0("SSearch::eventFilter: start timer, qs [" << (qs2utf8s(qs)) << "]\n" );
|
LOGDEB0("SSearch::eventFilter: start timer, qs [" <<
|
||||||
|
qs2utf8s(qs) << "]\n");
|
||||||
m_stroketimeout->start(strokeTimeoutMS);
|
m_stroketimeout->start(strokeTimeoutMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user