Arrange for the preview window title to be the search string for simple searches

This commit is contained in:
Jean-Francois Dockes 2019-03-07 10:06:41 +01:00
parent 3161d1db15
commit 0abf14b7a5
7 changed files with 23 additions and 4 deletions

View File

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

View File

@ -67,6 +67,7 @@ public slots:
signals: signals:
void startSearch(std::shared_ptr<Rcl::SearchData>, bool); void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
void setDescription(QString);
private: private:
virtual void init(); virtual void init();

View File

@ -51,6 +51,8 @@ void RclMain::showAdvSearchDialog()
connect(asearchform, connect(asearchform,
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)), SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool))); this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
connect(asearchform, SIGNAL(setDescription(QString)),
this, SLOT(onSetDescription(QString)));
asearchform->show(); asearchform->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...

View File

@ -297,6 +297,8 @@ void RclMain::init()
connect(sSearch, connect(sSearch,
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)), SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool))); this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
connect(sSearch, SIGNAL(setDescription(QString)),
this, SLOT(onSetDescription(QString)));
connect(sSearch, SIGNAL(clearSearch()), connect(sSearch, SIGNAL(clearSearch()),
this, SLOT(resetSearch())); this, SLOT(resetSearch()));
connect(preferencesMenu, SIGNAL(triggered(QAction*)), connect(preferencesMenu, SIGNAL(triggered(QAction*)),
@ -1085,11 +1087,17 @@ void RclMain::enablePrevPage(bool yesno)
} }
} }
void RclMain::onSetDescription(QString desc)
{
m_queryDescription = desc;
}
QString RclMain::getQueryDescription() QString RclMain::getQueryDescription()
{ {
if (!m_source) if (!m_source)
return ""; return "";
return QString::fromUtf8(m_source->getDescription().c_str()); return m_queryDescription.isEmpty() ?
u8s2qs(m_source->getDescription()) : m_queryDescription;
} }
// Set filter, action style // Set filter, action style

View File

@ -160,6 +160,7 @@ public slots:
virtual void applyStyleSheet(); virtual void applyStyleSheet();
virtual void setFilterCtlStyle(int stl); virtual void setFilterCtlStyle(int stl);
virtual void showTrayMessage(const QString& text); virtual void showTrayMessage(const QString& text);
virtual void onSetDescription(QString);
private slots: private slots:
virtual void updateIdxStatus(); virtual void updateIdxStatus();
@ -217,6 +218,10 @@ private:
bool m_firstIndexing{false}; bool m_firstIndexing{false};
// Last search was started from simple // Last search was started from simple
bool m_searchIsSimple{false}; bool m_searchIsSimple{false};
// This is set to the query string by ssearch, and to empty by
// advsearch, and used for the Preview window title. If empty, we
// use the Xapian Query string.
QString m_queryDescription;
// 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)
QString m_urltoview; QString m_urltoview;

View File

@ -426,6 +426,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
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 setDescription(u8s2qs(u8));
emit startSearch(rsdata, true); emit startSearch(rsdata, true);
return true; return true;
} }

View File

@ -100,6 +100,7 @@ private slots:
signals: signals:
void startSearch(std::shared_ptr<Rcl::SearchData>, bool); void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
void setDescription(QString);
void clearSearch(); void clearSearch();
void partialWord(int, const QString& text, const QString &partial); void partialWord(int, const QString& text, const QString &partial);