spell suggestions after adv search should not be links to start simple search

This commit is contained in:
Jean-Francois Dockes 2013-04-29 12:52:46 +02:00
parent 92331bfcbc
commit 10eaf5e6cb
10 changed files with 80 additions and 22 deletions

View File

@ -449,7 +449,7 @@ void AdvSearch::runSearch()
}
saveCnf();
g_advshistory && g_advshistory->push(sdata);
emit startSearch(sdata);
emit startSearch(sdata, false);
}

View File

@ -67,7 +67,7 @@ public slots:
virtual void slotHistoryPrev();
signals:
void startSearch(RefCntr<Rcl::SearchData>);
void startSearch(RefCntr<Rcl::SearchData>, bool);
private:
virtual void init();

View File

@ -40,8 +40,8 @@ RclConfig *theconfig;
// introducing blank space.
const char *PrefsPack::dfltResListFormat =
"<table><tr><td><a href='%U'><img src='%I' width='64'></a></td>"
"<td>%S %L &nbsp;&nbsp;<b>%T</b><br>"
"%M&nbsp;%D&nbsp;&nbsp;&nbsp;<i>%U</i>&nbsp;%i<br>"
"<td>%L &nbsp;<i>%S</i> &nbsp;&nbsp;<b>%T</b><br>"
"<span style='white-space:nowrap'>%M&nbsp;%D</span>&nbsp;&nbsp;&nbsp; <i>%U</i>&nbsp;%i<br>"
"%A %K</td></tr></table>"
;

View File

@ -127,7 +127,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>23</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="fileMenu">
@ -177,8 +177,24 @@
<addaction name="separator"/>
<addaction name="helpAbout_RecollAction"/>
</widget>
<widget class="QMenu" name="menuResults">
<property name="title">
<string>&amp;Results</string>
</property>
<addaction name="nextPageAction"/>
<addaction name="prevPageAction"/>
<addaction name="firstPageAction"/>
<addaction name="separator"/>
<addaction name="actionSortByDateAsc"/>
<addaction name="actionSortByDateDesc"/>
<addaction name="separator"/>
<addaction name="actionShowResultsAsTable"/>
<addaction name="separator"/>
<addaction name="actionSaveResultsAsCSV"/>
</widget>
<addaction name="fileMenu"/>
<addaction name="toolsMenu"/>
<addaction name="menuResults"/>
<addaction name="preferencesMenu"/>
<addaction name="separator"/>
<addaction name="helpMenu"/>
@ -438,7 +454,7 @@
<normaloff>:/images/up.png</normaloff>:/images/up.png</iconset>
</property>
<property name="text">
<string>sortByDateAsc</string>
<string>Sort by date, oldest first</string>
</property>
<property name="toolTip">
<string>Sort by dates from oldest to newest</string>
@ -456,7 +472,7 @@
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</property>
<property name="text">
<string>sortByDateDesc</string>
<string>Sort by date, newest first</string>
</property>
<property name="toolTip">
<string>Sort by dates from newest to oldest</string>
@ -476,10 +492,33 @@
<normaloff>:/images/table.png</normaloff>:/images/table.png</iconset>
</property>
<property name="text">
<string>Show results as table</string>
<string>Show as table</string>
</property>
<property name="toolTip">
<string>Show results as table</string>
<string>Show results in a spreadsheet-like table</string>
</property>
</action>
<action name="actionSaveResultsAsCSV">
<property name="text">
<string>Save as CSV (spreadsheet) file</string>
</property>
<property name="toolTip">
<string>Saves the result into a file which you can load in a spreadsheet</string>
</property>
</action>
<action name="actionNext_Page">
<property name="text">
<string>Next Page</string>
</property>
</action>
<action name="actionPrevious_Page">
<property name="text">
<string>Previous Page</string>
</property>
</action>
<action name="actionFirst_Page">
<property name="text">
<string>First Page</string>
</property>
</action>
</widget>

View File

@ -228,8 +228,8 @@ void RclMain::init()
connect(&m_watcher, SIGNAL(fileChanged(QString)),
this, SLOT(idxStatus()));
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(RefCntr<Rcl::SearchData>, bool)));
connect(sSearch, SIGNAL(clearSearch()),
this, SLOT(resetSearch()));
@ -281,6 +281,8 @@ void RclMain::init()
this, SLOT(periodic100()));
restable->setRclMain(this, true);
connect(actionSaveResultsAsCSV, SIGNAL(activated()),
restable, SLOT(saveAsCSV()));
connect(this, SIGNAL(docSourceChanged(RefCntr<DocSequence>)),
restable, SLOT(setDocSource(RefCntr<DocSequence>)));
connect(this, SIGNAL(searchReset()),
@ -775,7 +777,7 @@ void RclMain::rebuildIndex()
}
// Start a db query and set the reslist docsource
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
{
LOGDEB(("RclMain::startSearch. Indexing %s Active %d\n",
m_idxproc?"on":"off", m_queryActive));
@ -786,6 +788,8 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
m_queryActive = true;
m_source = RefCntr<DocSequence>();
m_searchIsSimple = issimple;
// The db may have been closed at the end of indexing
string reason;
// If indexing is being performed, we reopen the db at each query.
@ -897,8 +901,9 @@ void RclMain::showAdvSearchDialog()
connect(new QShortcut(quitKeySeq, asearchform), SIGNAL (activated()),
this, SLOT (fileExit()));
connect(asearchform, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
connect(asearchform,
SIGNAL(startSearch(RefCntr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(RefCntr<Rcl::SearchData>, bool)));
asearchform->show();
} else {
// Close and reopen, in hope that makes us visible...
@ -1464,15 +1469,15 @@ void RclMain::on_actionShowResultsAsTable_toggled(bool on)
{
LOGDEB(("RclMain::on_actionShowResultsAsTable_toggled(%d)\n", int(on)));
prefs.showResultsAsTable = on;
displayingTable = on;
restable->setVisible(on);
reslist->setVisible(!on);
actionSaveResultsAsCSV->setEnabled(on);
if (!on) {
displayingTable = false;
int docnum = restable->getDetailDocNumOrTopRow();
if (docnum >= 0)
reslist->resultPageFor(docnum);
} else {
displayingTable = true;
int docnum = reslist->pageFirstDocNum();
if (docnum >= 0) {
restable->makeRowVisible(docnum);

View File

@ -72,7 +72,8 @@ public:
m_sortspecnochange(false),
m_indexerState(IXST_RUNNINGNOTMINE),
m_queryActive(false),
m_firstIndexing(false)
m_firstIndexing(false),
m_searchIsSimple(false)
{
setupUi(this);
init();
@ -87,6 +88,11 @@ public:
/** Same usage: actually display the current urltoview */
virtual void viewUrl();
bool lastSearchSimple()
{
return m_searchIsSimple;
}
public slots:
virtual bool close();
virtual void fileExit();
@ -94,7 +100,7 @@ public slots:
virtual void periodic100();
virtual void toggleIndexing();
virtual void rebuildIndex();
virtual void startSearch(RefCntr<Rcl::SearchData> sdata);
virtual void startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple);
virtual void previewClosed(Preview *w);
virtual void showAdvSearchDialog();
virtual void showSpellDialog();
@ -180,6 +186,7 @@ private:
IndexerState m_indexerState;
bool m_queryActive;
bool m_firstIndexing;
bool m_searchIsSimple; // Last search was started from simple
// If set on init, will be displayed either through ext app, or
// preview (if no ext app set)

View File

@ -191,6 +191,9 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
return;
}
bool issimple = m_reslist && m_reslist->m_rclmain &&
m_reslist->m_rclmain->lastSearchSimple();
for (vector<string>::const_iterator uit = uterms.begin();
uit != uterms.end(); uit++) {
list<string> asuggs;
@ -217,8 +220,10 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
// Set up the links as a <href="Sold|new">.
for (vector<string>::iterator it = sugg[*uit].begin();
it != sugg[*uit].end(); it++) {
*it = string("<a href=\"S") + *uit + "|" + *it + "\">" +
*it + "</a>";
if (issimple) {
*it = string("<a href=\"S") + *uit + "|" + *it + "\">" +
*it + "</a>";
}
}
}
}

View File

@ -675,6 +675,8 @@ void ResTable::saveAsCSV()
tr("Save table to CSV file"),
QString::fromLocal8Bit(path_home().c_str())
);
if (s.isEmpty())
return;
const char *tofile = s.toLocal8Bit();
FILE *fp = fopen(tofile, "w");
if (fp == 0) {

View File

@ -266,7 +266,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
sdata->setMaxExpand(maxexp);
}
RefCntr<Rcl::SearchData> rsdata(sdata);
emit startSearch(rsdata);
emit startSearch(rsdata, true);
return true;
}

View File

@ -59,7 +59,7 @@ public slots:
virtual void wrapupCompletion();
virtual void timerDone();
signals:
void startSearch(RefCntr<Rcl::SearchData>);
void startSearch(RefCntr<Rcl::SearchData>, bool);
void clearSearch();
private:
bool m_escape;