Also restore search mode when loading saved simple search data
This commit is contained in:
parent
90dab89303
commit
502a347df6
@ -115,14 +115,14 @@ void RclMain::loadSavedQuery()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to parse as SearchData
|
// Try to parse as advanced search SearchData
|
||||||
std::shared_ptr<SearchData> sd = xmlToSearchData(xml);
|
std::shared_ptr<SearchData> sd = xmlToSearchData(xml, false);
|
||||||
if (sd) {
|
if (sd) {
|
||||||
showAdvSearchDialog();
|
showAdvSearchDialog();
|
||||||
asearchform->fromSearch(sd);
|
asearchform->fromSearch(sd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LOGDEB("loadSavedQuery: Not advanced search. Parsing as simple search\n");
|
||||||
// Try to parse as Simple Search
|
// Try to parse as Simple Search
|
||||||
SSearchDef sdef;
|
SSearchDef sdef;
|
||||||
if (xmlToSSearch(xml, sdef)) {
|
if (xmlToSSearch(xml, sdef)) {
|
||||||
|
|||||||
@ -364,7 +364,10 @@ bool SSearch::fromXML(const SSearchDef& fxml)
|
|||||||
tr("Autophrase is unset but it was set for stored query"));
|
tr("Autophrase is unset but it was set for stored query"));
|
||||||
}
|
}
|
||||||
setSearchString(QString::fromUtf8(fxml.text.c_str()));
|
setSearchString(QString::fromUtf8(fxml.text.c_str()));
|
||||||
searchTypCMB->setCurrentIndex(prefs.ssearchTyp);
|
// We used to use prefs.ssearchTyp here. Not too sure why?
|
||||||
|
// Minimize user surprise factor ? Anyway it seems cleaner to
|
||||||
|
// restore the saved search type
|
||||||
|
searchTypCMB->setCurrentIndex(fxml.mode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ bool SDHXMLHandler::startElement(const QString & /* namespaceURI */,
|
|||||||
// either if type is absent, or if it's searchdata
|
// either if type is absent, or if it's searchdata
|
||||||
int idx = attrs.index("type");
|
int idx = attrs.index("type");
|
||||||
if (idx >= 0 && attrs.value(idx).compare("searchdata")) {
|
if (idx >= 0 && attrs.value(idx).compare("searchdata")) {
|
||||||
LOGDEB("XMLTOSD: bad type\n");
|
LOGDEB("XMLTOSD: bad type: " << qs2utf8s(attrs.value(idx)) << endl);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
resetTemps();
|
resetTemps();
|
||||||
@ -206,7 +206,8 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<Rcl::SearchData> xmlToSearchData(const string& xml)
|
std::shared_ptr<Rcl::SearchData> xmlToSearchData(const string& xml,
|
||||||
|
bool verbose)
|
||||||
{
|
{
|
||||||
SDHXMLHandler handler;
|
SDHXMLHandler handler;
|
||||||
QXmlSimpleReader reader;
|
QXmlSimpleReader reader;
|
||||||
@ -217,7 +218,9 @@ std::shared_ptr<Rcl::SearchData> xmlToSearchData(const string& xml)
|
|||||||
xmlInputSource.setData(QString::fromUtf8(xml.c_str()));
|
xmlInputSource.setData(QString::fromUtf8(xml.c_str()));
|
||||||
|
|
||||||
if (!reader.parse(xmlInputSource) || !handler.isvalid) {
|
if (!reader.parse(xmlInputSource) || !handler.isvalid) {
|
||||||
LOGERR("xmlToSearchData: parse failed for [" << xml << "]\n");
|
if (verbose) {
|
||||||
|
LOGERR("xmlToSearchData: parse failed for [" << xml << "]\n");
|
||||||
|
}
|
||||||
return std::shared_ptr<SearchData>();
|
return std::shared_ptr<SearchData>();
|
||||||
}
|
}
|
||||||
return handler.sd;
|
return handler.sd;
|
||||||
@ -271,8 +274,13 @@ bool SSHXMLHandler::startElement(const QString & /* namespaceURI */,
|
|||||||
if (qName == "SD") {
|
if (qName == "SD") {
|
||||||
// Simple search saved data has a type='ssearch' attribute.
|
// Simple search saved data has a type='ssearch' attribute.
|
||||||
int idx = attrs.index("type");
|
int idx = attrs.index("type");
|
||||||
if (idx < 0 && attrs.value(idx).compare("ssearch")) {
|
if (idx < 0 || attrs.value(idx).compare("ssearch")) {
|
||||||
LOGDEB("XMLTOSSS: bad type\n");
|
if (idx < 0) {
|
||||||
|
LOGDEB("XMLTOSSS: bad type\n");
|
||||||
|
} else {
|
||||||
|
LOGDEB("XMLTOSSS: bad type: " << qs2utf8s(attrs.value(idx))
|
||||||
|
<< endl);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
resetTemps();
|
resetTemps();
|
||||||
|
|||||||
@ -63,9 +63,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include "searchdata.h"
|
#include "searchdata.h"
|
||||||
|
|
||||||
// Parsing XML from advanced search history or saved advanced search to to
|
// Parsing XML from advanced search history or saved advanced search into
|
||||||
// SearchData structure:
|
// a SearchData structure:
|
||||||
std::shared_ptr<Rcl::SearchData> xmlToSearchData(const string& xml);
|
std::shared_ptr<Rcl::SearchData> xmlToSearchData(const string& xml,
|
||||||
|
bool complain = true);
|
||||||
|
|
||||||
// Parsing XML from saved simple search to ssearch parameters
|
// Parsing XML from saved simple search to ssearch parameters
|
||||||
struct SSearchDef {
|
struct SSearchDef {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user