make ssearch a combobox

This commit is contained in:
dockes
2006-04-27 09:23:10 +00:00
parent 42ce501ce1
commit e3332fcfa5
6 changed files with 203 additions and 40 deletions
+10 -1
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.9 2006-04-18 08:53:28 dockes Exp $ (C) 2005 Jean-Francois Dockes";
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.10 2006-04-27 09:23:10 dockes Exp $ (C) 2005 Jean-Francois Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -141,6 +141,15 @@ void rwSettings(bool writing)
SETTING_RW(prefs.queryReplaceAbstract,
"/Recoll/prefs/query/replaceAbstract", Bool, false);
// Ssearch combobox history list
if (writing) {
settings.writeEntry("/Recoll/prefs/query/ssearchHistory",
prefs.ssearchHistory);
} else {
prefs.ssearchHistory =
settings.readListEntry("/Recoll/prefs/query/ssearchHistory");
}
// The extra databases settings. These are stored as a list of
// xapian directory names, encoded in base64 to avoid any
// binary/charset conversion issues. There are 2 lists for all
+4 -1
View File
@@ -17,7 +17,7 @@
#ifndef _GUIUTILS_H_INCLUDED_
#define _GUIUTILS_H_INCLUDED_
/*
* @(#$Id: guiutils.h,v 1.5 2006-04-18 08:53:28 dockes Exp $ (C) 2005 Jean-Francois Dockes
* @(#$Id: guiutils.h,v 1.6 2006-04-27 09:23:10 dockes Exp $ (C) 2005 Jean-Francois Dockes
* jean-francois.dockes@wanadoo.fr
*
* This program is free software; you can redistribute it and/or modify
@@ -39,6 +39,7 @@
#include <string>
#include <list>
#include <qstring.h>
#include <qstringlist.h>
#ifndef NO_NAMESPACES
using std::string;
@@ -67,6 +68,8 @@ class PrefsPack {
// to the qt settings file to avoid any bin string/ charset conv issues
list<string> allExtraDbs;
list<string> activeExtraDbs;
// Textual history of simple searches (this is just the combobox list)
QStringList ssearchHistory;
PrefsPack() :
showicons(true),
+9 -5
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.26 2006-04-27 06:12:10 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.27 2006-04-27 09:23:10 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -457,9 +457,9 @@ void RclMain::ssearchAddTerm(QString term)
return;
term = QString::fromUtf8(t.c_str());
QString text = sSearch->queryText->text();
QString text = sSearch->queryText->currentText();
text += QString::fromLatin1(" ") + term;
sSearch->queryText->setText(text);
sSearch->queryText->setEditText(text);
}
void RclMain::startNativeViewer(int docnum)
@@ -543,12 +543,16 @@ void RclMain::docExpand(int docnum)
list<string> terms;
terms = rcldb->expand(doc);
// Do we keep the original query. I think we'd better not.
QString text;// = sSearch->queryText->text();
// rcldb->expand is set to keep the original query terms instead.
QString text;// = sSearch->queryText->currentText();
for (list<string>::iterator it = terms.begin(); it != terms.end(); it++) {
text += QString::fromLatin1(" \"") +
QString::fromUtf8((*it).c_str()) + QString::fromLatin1("\"");
}
sSearch->queryText->setText(text);
// We need to insert item here, its not auto-done like when the user types
// CR
sSearch->queryText->setEditText(text);
sSearch->queryText->insertItem(text, 0);
sSearch->setAnyTermMode();
sSearch->startSimpleSearch();
}
+15 -24
View File
@@ -72,7 +72,7 @@
<string>Choose type of search: any term, all terms, filename with possible wildcards.</string>
</property>
</widget>
<widget class="QLineEdit">
<widget class="QComboBox">
<property name="name">
<cstring>queryText</cstring>
</property>
@@ -90,11 +90,20 @@
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>LineEditPanel</enum>
<property name="editable">
<bool>true</bool>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
<property name="sizeLimit">
<number>20</number>
</property>
<property name="maxCount">
<number>30</number>
</property>
<property name="insertionPolicy">
<enum>AtTop</enum>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<property name="toolTip" stdset="0">
<string>Enter search terms here</string>
@@ -111,24 +120,6 @@
<receiver>SSearchBase</receiver>
<slot>startSimpleSearch()</slot>
</connection>
<connection>
<sender>queryText</sender>
<signal>returnPressed()</signal>
<receiver>SSearchBase</receiver>
<slot>startSimpleSearch()</slot>
</connection>
<connection>
<sender>queryText</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>SSearchBase</receiver>
<slot>searchTextChanged(const QString&amp;)</slot>
</connection>
<connection>
<sender>clearqPB</sender>
<signal>clicked()</signal>
<receiver>queryText</receiver>
<slot>clear()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">recoll.h</include>
@@ -145,9 +136,9 @@
</slots>
<functions>
<function>init()</function>
<function>setAnyTermMode()</function>
<function>completion()</function>
<function returnType="bool">event( QEvent * evt )</function>
<function>setAnyTermMode()</function>
</functions>
<layoutdefaults spacing="6" margin="0"/>
</UI>
+16 -4
View File
@@ -37,6 +37,14 @@ void SSearchBase::init()
searchTypCMB->insertItem(tr("Any term"));
searchTypCMB->insertItem(tr("All terms"));
searchTypCMB->insertItem(tr("File name"));
queryText->insertStringList(prefs.ssearchHistory);
queryText->setEditText("");
connect(queryText->lineEdit(), SIGNAL(returnPressed()),
this, SLOT(startSimpleSearch()));
connect(queryText->lineEdit(), SIGNAL(textChanged(const QString&)),
this, SLOT(searchTextChanged(const QString&)));
connect(clearqPB, SIGNAL(clicked()),
queryText->lineEdit(), SLOT(clear()));
}
void SSearchBase::searchTextChanged( const QString & text )
@@ -48,7 +56,7 @@ void SSearchBase::searchTextChanged( const QString & text )
} else {
searchPB->setEnabled(true);
clearqPB->setEnabled(true);
string u8 = (const char *)queryText->text().utf8();
string u8 = (const char *)queryText->currentText().utf8();
if (prefs.autoSearchOnWS && !u8.empty() && u8[u8.length()-1] == ' ')
startSimpleSearch();
}
@@ -59,7 +67,7 @@ void SSearchBase::startSimpleSearch()
LOGDEB(("SSearchBase::startSimpleSearch\n"));
Rcl::AdvSearchData sdata;
QCString u8 = queryText->text().utf8();
QCString u8 = queryText->currentText().utf8();
switch (searchTypCMB->currentItem()) {
case 0:
default:
@@ -72,9 +80,13 @@ void SSearchBase::startSimpleSearch()
sdata.filename = u8;
break;
}
prefs.ssearchHistory.clear();
for (int index = 0; index < queryText->count(); index++)
prefs.ssearchHistory.push_back(queryText->text(index));
emit startSearch(sdata);
}
void SSearchBase::setAnyTermMode()
{
searchTypCMB->setCurrentItem(0);
@@ -91,7 +103,7 @@ void SSearchBase::completion()
return;
}
// Extract last word in text
string txt = (const char *)queryText->text().utf8();
string txt = (const char *)queryText->currentText().utf8();
string::size_type cs = txt.find_last_of(" ");
if (cs == string::npos)
cs = 0;
@@ -131,7 +143,7 @@ void SSearchBase::completion()
if (ok) {
txt.erase(cs);
txt.append(res.utf8());
queryText->setText(QString::fromUtf8(txt.c_str()));
queryText->setEditText(QString::fromUtf8(txt.c_str()));
} else {
return;
}