compacted res list + completions in ssearch + additional or field
This commit is contained in:
+53
-39
@@ -63,45 +63,6 @@
|
||||
<property name="margin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<widget class="QLabel" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>orWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these words</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="2" column="1">
|
||||
<property name="name">
|
||||
<cstring>orWordsLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="4" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File name matching</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="4" column="1">
|
||||
<property name="name">
|
||||
<cstring>fileNameLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="3" column="0">
|
||||
<property name="name">
|
||||
<cstring>noWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>None of these words</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="3" column="1">
|
||||
<property name="name">
|
||||
<cstring>noWordsLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>andWordsTL</cstring>
|
||||
@@ -128,6 +89,58 @@
|
||||
<cstring>phraseLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>orWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these words</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="2" column="1">
|
||||
<property name="name">
|
||||
<cstring>orWordsLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="3" column="0">
|
||||
<property name="name">
|
||||
<cstring>orWords1TL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Any of these words</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="3" column="1">
|
||||
<property name="name">
|
||||
<cstring>orWords1LE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="4" column="0">
|
||||
<property name="name">
|
||||
<cstring>noWordsTL</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>None of these words</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="4" column="1">
|
||||
<property name="name">
|
||||
<cstring>noWordsLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="5" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File name matching</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" row="5" column="1">
|
||||
<property name="name">
|
||||
<cstring>fileNameLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</hbox>
|
||||
@@ -483,6 +496,7 @@
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in declaration">recoll.h</include>
|
||||
<include location="local" impldecl="in declaration">searchdata.h</include>
|
||||
<include location="local" impldecl="in implementation">advsearch.ui.h</include>
|
||||
</includes>
|
||||
<signals>
|
||||
|
||||
@@ -40,6 +40,7 @@ using std::string;
|
||||
#include "recoll.h"
|
||||
#include "rclconfig.h"
|
||||
#include "debuglog.h"
|
||||
#include "searchdata.h"
|
||||
|
||||
extern RclConfig *rclconfig;
|
||||
|
||||
@@ -132,11 +133,13 @@ void advsearch::searchPB_clicked()
|
||||
mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
|
||||
mydata.phrase = string((const char*)(phraseLE->text().utf8()));
|
||||
mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
|
||||
mydata.orwords1 = string((const char*)(orWords1LE->text().utf8()));
|
||||
mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
|
||||
mydata.filename = string((const char*)(fileNameLE->text().utf8()));
|
||||
|
||||
if (mydata.allwords.empty() && mydata.phrase.empty() &&
|
||||
mydata.orwords.empty() && mydata.filename.empty()) {
|
||||
mydata.orwords.empty() && mydata.orwords1.empty() &&
|
||||
mydata.filename.empty()) {
|
||||
if (mydata.nowords.empty())
|
||||
return;
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
|
||||
+1
-4
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.41 2006-04-15 17:15:01 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.42 2006-04-19 08:26:08 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -40,9 +40,6 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.41 2006-04-15 17:15:01 dockes Exp $
|
||||
#include <qcombobox.h>
|
||||
|
||||
#include "rcldb.h"
|
||||
#ifndef NO_NAMESPACES
|
||||
using Rcl::AdvSearchData;
|
||||
#endif /* NO_NAMESPACES */
|
||||
#include "rclconfig.h"
|
||||
#include "pathut.h"
|
||||
#include "recoll.h"
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "sort.h"
|
||||
#include "uiprefs.h"
|
||||
#include "rcldb.h"
|
||||
#include "searchdata.h"
|
||||
|
||||
#include "recollmain.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.11 2006-04-18 08:53:28 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.12 2006-04-19 08:26:08 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
@@ -283,8 +283,7 @@ void RclResList::showResultPage()
|
||||
time_t mtime = doc.dmtime.empty() ?
|
||||
atol(doc.fmtime.c_str()) : atol(doc.dmtime.c_str());
|
||||
struct tm *tm = localtime(&mtime);
|
||||
strftime(datebuf, 99,
|
||||
"<i>Modified:</i> %Y-%m-%d %H:%M:%S", tm);
|
||||
strftime(datebuf, 99, " %Y-%m-%d %H:%M:%S", tm);
|
||||
}
|
||||
|
||||
// Size information. We print both doc and file if they differ a lot
|
||||
@@ -301,6 +300,7 @@ void RclResList::showResultPage()
|
||||
} else if (fsize >= 0) {
|
||||
sizebuf = displayableBytes(fsize);
|
||||
}
|
||||
|
||||
// Abstract
|
||||
string abst = escapeHtml(doc.abstract);
|
||||
LOGDEB1(("Abstract: {%s}\n", abst.c_str()));
|
||||
@@ -311,12 +311,9 @@ void RclResList::showResultPage()
|
||||
result += string("<p><b>") + sh + "</p>\n<p>";
|
||||
else
|
||||
result += "<p>";
|
||||
result += string(perbuf) + sizebuf + "<b>" + doc.title + "</b><br>";
|
||||
result += doc.mimetype + " ";
|
||||
result += string(datebuf) + " ";
|
||||
|
||||
|
||||
// Set up the preview and edit links
|
||||
// Percent relevant + size + preview/edit links + title
|
||||
result += string(perbuf) + sizebuf;
|
||||
char vlbuf[100];
|
||||
if (canIntern(doc.mimetype, rclconfig)) {
|
||||
sprintf(vlbuf, "\"P%d\"", m_winfirst+i);
|
||||
@@ -327,12 +324,17 @@ void RclResList::showResultPage()
|
||||
sprintf(vlbuf, "E%d", m_winfirst+i);
|
||||
result += string("<a href=") + vlbuf + ">" + "Edit" + "</a>";
|
||||
}
|
||||
result += string("<br>");
|
||||
result += " <b>" + doc.title + "</b><br>";
|
||||
|
||||
// Mime type, date modified, url
|
||||
result += doc.mimetype + " ";
|
||||
result += string(datebuf) + " ";
|
||||
if (!img_name.empty()) {
|
||||
result += "<img source=\"" + img_name + "\" align=\"left\">";
|
||||
}
|
||||
result += "<i>" + url + +"</i><br>";
|
||||
|
||||
// Text: abstract and keywords
|
||||
if (!abst.empty())
|
||||
result += abst + "<br>";
|
||||
if (!doc.keywords.empty())
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in declaration">recoll.h</include>
|
||||
<include location="local" impldecl="in declaration">searchdata.h</include>
|
||||
<include location="local" impldecl="in implementation">ssearchb.ui.h</include>
|
||||
</includes>
|
||||
<signals>
|
||||
@@ -144,6 +145,8 @@
|
||||
</slots>
|
||||
<functions>
|
||||
<function>init()</function>
|
||||
<function>completion()</function>
|
||||
<function returnType="bool">event( QEvent * evt )</function>
|
||||
</functions>
|
||||
<layoutdefaults spacing="6" margin="0"/>
|
||||
</UI>
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
** These will automatically be called by the form's constructor and
|
||||
** destructor.
|
||||
*****************************************************************************/
|
||||
#include <qapplication.h>
|
||||
#include <qinputdialog.h>
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "guiutils.h"
|
||||
#include "searchdata.h"
|
||||
|
||||
void SSearchBase::init()
|
||||
{
|
||||
@@ -72,3 +75,72 @@ void SSearchBase::startSimpleSearch()
|
||||
|
||||
emit startSearch(sdata);
|
||||
}
|
||||
|
||||
// Complete last word in input by querying db for all possible terms.
|
||||
void SSearchBase::completion()
|
||||
{
|
||||
if (!rcldb)
|
||||
return;
|
||||
|
||||
// Extract last word in text
|
||||
string txt = (const char *)queryText->text().utf8();
|
||||
string::size_type cs = txt.find_last_of(" ");
|
||||
if (cs == string::npos)
|
||||
cs = 0;
|
||||
else
|
||||
cs++;
|
||||
if (txt.size() == 0 || cs == txt.size()) {
|
||||
QApplication::beep();
|
||||
return;
|
||||
}
|
||||
string s = txt.substr(cs);
|
||||
LOGDEB(("Completing: [%s]\n", s.c_str()));
|
||||
|
||||
// Query database
|
||||
const int max = 100;
|
||||
list<string> strs = rcldb->completions(s, prefs.queryStemLang.ascii(),max);
|
||||
if (strs.size() == 0 || strs.size() == (unsigned int)max) {
|
||||
QApplication::beep();
|
||||
return;
|
||||
}
|
||||
|
||||
// If list from db is single word, insert it, else ask user to select
|
||||
QString res;
|
||||
bool ok = false;
|
||||
if (strs.size() == 1) {
|
||||
res = QString::fromUtf8(strs.begin()->c_str());
|
||||
ok = true;
|
||||
} else {
|
||||
QStringList lst;
|
||||
for (list<string>::iterator it=strs.begin(); it != strs.end(); it++)
|
||||
lst.push_back(QString::fromUtf8(it->c_str()));
|
||||
res = QInputDialog::getItem(tr("Completions"),
|
||||
tr("Select an item:"), lst, 0,
|
||||
FALSE, &ok, this);
|
||||
}
|
||||
|
||||
// Insert result
|
||||
if (ok) {
|
||||
txt.erase(cs);
|
||||
txt.append(res.utf8());
|
||||
queryText->setText(QString::fromUtf8(txt.c_str()));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle CTRL-TAB to mean completion
|
||||
bool SSearchBase::event( QEvent *evt )
|
||||
{
|
||||
if ( evt->type() == QEvent::KeyPress ) {
|
||||
QKeyEvent *ke = (QKeyEvent *)evt;
|
||||
if ( ke->key() == Key_Tab && (ke->state() & Qt::ControlButton)) {
|
||||
// special tab handling here
|
||||
completion();
|
||||
ke->accept();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return QWidget::event( evt );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user