GUI: add menu to export simple search history to text file
This commit is contained in:
parent
1681ab1172
commit
a42d52cd20
@ -79,7 +79,9 @@
|
||||
<addaction name="actionSave_last_query"/>
|
||||
<addaction name="actionLoad_saved_query"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="fileExportSSearchHistoryAction"/>
|
||||
<addaction name="fileEraseSearchHistoryAction"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="fileEraseDocHistoryAction"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="fileExitAction"/>
|
||||
@ -205,6 +207,14 @@
|
||||
<cstring>fileEraseSearchHistoryAction</cstring>
|
||||
</property>
|
||||
</action>
|
||||
<action name="fileExportSSearchHistoryAction">
|
||||
<property name="text">
|
||||
<string>E&xport simple search history</string>
|
||||
</property>
|
||||
<property name="name" stdset="0">
|
||||
<cstring>fileExportSSearchHistoryAction</cstring>
|
||||
</property>
|
||||
</action>
|
||||
<action name="showMissingHelpers_Action">
|
||||
<property name="text">
|
||||
<string>Missing &helpers</string>
|
||||
|
||||
@ -315,6 +315,8 @@ void RclMain::init()
|
||||
this, SLOT(eraseDocHistory()));
|
||||
connect(fileEraseSearchHistoryAction, SIGNAL(triggered()),
|
||||
this, SLOT(eraseSearchHistory()));
|
||||
connect(fileExportSSearchHistoryAction, SIGNAL(triggered()),
|
||||
this, SLOT(exportSimpleSearchHistory()));
|
||||
connect(actionSave_last_query, SIGNAL(triggered()),
|
||||
this, SLOT(saveLastQuery()));
|
||||
connect(actionLoad_saved_query, SIGNAL(triggered()),
|
||||
@ -739,7 +741,7 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
||||
|
||||
class QueryThread : public QThread {
|
||||
std::shared_ptr<DocSequence> m_source;
|
||||
public:
|
||||
public:
|
||||
QueryThread(std::shared_ptr<DocSequence> source)
|
||||
: m_source(source)
|
||||
{
|
||||
@ -1005,7 +1007,8 @@ void RclMain::showDocHistory()
|
||||
}
|
||||
// Construct a bogus SearchData structure
|
||||
std::shared_ptr<Rcl::SearchData>searchdata =
|
||||
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND, cstr_null));
|
||||
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND,
|
||||
cstr_null));
|
||||
searchdata->setDescription((const char *)tr("History data").toUtf8());
|
||||
|
||||
|
||||
@ -1014,7 +1017,8 @@ void RclMain::showDocHistory()
|
||||
new DocSequenceHistory(rcldb, g_dynconf,
|
||||
string(tr("Document history").toUtf8()));
|
||||
src->setDescription((const char *)tr("History data").toUtf8());
|
||||
DocSource *source = new DocSource(theconfig, std::shared_ptr<DocSequence>(src));
|
||||
DocSource *source = new DocSource(theconfig,
|
||||
std::shared_ptr<DocSequence>(src));
|
||||
m_source = std::shared_ptr<DocSequence>(source);
|
||||
m_source->setSortSpec(m_sortspec);
|
||||
m_source->setFiltSpec(m_filtspec);
|
||||
@ -1037,11 +1041,43 @@ void RclMain::eraseDocHistory()
|
||||
|
||||
void RclMain::eraseSearchHistory()
|
||||
{
|
||||
int rep = QMessageBox::warning(
|
||||
0, tr("Confirm"),
|
||||
tr("Erasing simple and advanced search history lists, "
|
||||
"please click Ok to confirm"),
|
||||
QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton);
|
||||
if (rep == QMessageBox::Ok) {
|
||||
prefs.ssearchHistory.clear();
|
||||
if (sSearch)
|
||||
sSearch->clearAll();
|
||||
if (g_advshistory)
|
||||
g_advshistory->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void RclMain::exportSimpleSearchHistory()
|
||||
{
|
||||
QFileDialog dialog(0, "Saving simple search history");
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
QFlags<QDir::Filter> flags = QDir::NoDotAndDotDot|QDir::Files;
|
||||
dialog.setFilter(flags);
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
string path = qs2utf8s(dialog.selectedFiles().value(0));
|
||||
LOGDEB("Chosen path: " << path << "\n");
|
||||
FILE *fp = fopen(path.c_str(), "wb");
|
||||
if (fp == 0) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Could not open/create file"));
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < prefs.ssearchHistory.count(); i++) {
|
||||
fprintf(fp, "%s\n", qs2utf8s(prefs.ssearchHistory[i]).c_str());
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
// Called when the uiprefs dialog is ok'd
|
||||
|
||||
@ -139,6 +139,7 @@ public slots:
|
||||
virtual void resetSearch();
|
||||
virtual void eraseDocHistory();
|
||||
virtual void eraseSearchHistory();
|
||||
virtual void exportSimpleSearchHistory();
|
||||
virtual void saveLastQuery();
|
||||
virtual void loadSavedQuery();
|
||||
virtual void setStemLang(QAction *id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user