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(); saveCnf();
g_advshistory && g_advshistory->push(sdata); g_advshistory && g_advshistory->push(sdata);
emit startSearch(sdata); emit startSearch(sdata, false);
} }

View File

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

View File

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

View File

@ -127,7 +127,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>23</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="fileMenu"> <widget class="QMenu" name="fileMenu">
@ -177,8 +177,24 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="helpAbout_RecollAction"/> <addaction name="helpAbout_RecollAction"/>
</widget> </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="fileMenu"/>
<addaction name="toolsMenu"/> <addaction name="toolsMenu"/>
<addaction name="menuResults"/>
<addaction name="preferencesMenu"/> <addaction name="preferencesMenu"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="helpMenu"/> <addaction name="helpMenu"/>
@ -438,7 +454,7 @@
<normaloff>:/images/up.png</normaloff>:/images/up.png</iconset> <normaloff>:/images/up.png</normaloff>:/images/up.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>sortByDateAsc</string> <string>Sort by date, oldest first</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Sort by dates from oldest to newest</string> <string>Sort by dates from oldest to newest</string>
@ -456,7 +472,7 @@
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset> <normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>sortByDateDesc</string> <string>Sort by date, newest first</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Sort by dates from newest to oldest</string> <string>Sort by dates from newest to oldest</string>
@ -476,10 +492,33 @@
<normaloff>:/images/table.png</normaloff>:/images/table.png</iconset> <normaloff>:/images/table.png</normaloff>:/images/table.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Show results as table</string> <string>Show as table</string>
</property> </property>
<property name="toolTip"> <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> </property>
</action> </action>
</widget> </widget>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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