GUI: add "start real time indexer" menu entry

This commit is contained in:
Jean-Francois Dockes 2022-01-20 15:51:11 +01:00
parent fdb18a7c4b
commit b5b48e4f50
5 changed files with 103 additions and 132 deletions

View File

@ -121,8 +121,7 @@ void RclMain::periodic100()
deleteZ(m_idxproc); deleteZ(m_idxproc);
if (status) { if (status) {
if (m_idxkilled) { if (m_idxkilled) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll", tr("Indexing interrupted"));
tr("Indexing interrupted"));
m_idxkilled = false; m_idxkilled = false;
} else { } else {
QString msg(tr("Indexing failed")); QString msg(tr("Indexing failed"));
@ -158,6 +157,8 @@ void RclMain::periodic100()
m_indexerState = IXST_RUNNINGMINE; m_indexerState = IXST_RUNNINGMINE;
fileToggleIndexingAction->setText(tr("Stop &Indexing")); fileToggleIndexingAction->setText(tr("Stop &Indexing"));
fileToggleIndexingAction->setEnabled(true); fileToggleIndexingAction->setEnabled(true);
fileStartMonitorAction->setEnabled(false);
fileBumpIndexingAction->setEnabled(false);
fileRebuildIndexAction->setEnabled(false); fileRebuildIndexAction->setEnabled(false);
actionSpecial_Indexing->setEnabled(false); actionSpecial_Indexing->setEnabled(false);
periodictimer->setInterval(200); periodictimer->setInterval(200);
@ -170,6 +171,8 @@ void RclMain::periodic100()
m_indexerState = IXST_NOTRUNNING; m_indexerState = IXST_NOTRUNNING;
fileToggleIndexingAction->setText(tr("Index locked")); fileToggleIndexingAction->setText(tr("Index locked"));
fileToggleIndexingAction->setEnabled(false); fileToggleIndexingAction->setEnabled(false);
fileStartMonitorAction->setEnabled(false);
fileBumpIndexingAction->setEnabled(false);
fileRebuildIndexAction->setEnabled(false); fileRebuildIndexAction->setEnabled(false);
actionSpecial_Indexing->setEnabled(false); actionSpecial_Indexing->setEnabled(false);
periodictimer->setInterval(1000); periodictimer->setInterval(1000);
@ -177,6 +180,8 @@ void RclMain::periodic100()
m_indexerState = IXST_NOTRUNNING; m_indexerState = IXST_NOTRUNNING;
fileToggleIndexingAction->setText(tr("Update &Index")); fileToggleIndexingAction->setText(tr("Update &Index"));
fileToggleIndexingAction->setEnabled(true); fileToggleIndexingAction->setEnabled(true);
fileStartMonitorAction->setEnabled(true);
fileBumpIndexingAction->setEnabled(false);
fileRebuildIndexAction->setEnabled(true); fileRebuildIndexAction->setEnabled(true);
actionSpecial_Indexing->setEnabled(true); actionSpecial_Indexing->setEnabled(true);
periodictimer->setInterval(1000); periodictimer->setInterval(1000);
@ -184,6 +189,7 @@ void RclMain::periodic100()
// Real time or externally started batch indexer running // Real time or externally started batch indexer running
m_indexerState = IXST_RUNNINGNOTMINE; m_indexerState = IXST_RUNNINGNOTMINE;
fileToggleIndexingAction->setText(tr("Stop &Indexing")); fileToggleIndexingAction->setText(tr("Stop &Indexing"));
fileToggleIndexingAction->setEnabled(true);
DbIxStatus status; DbIxStatus status;
readIdxStatus(theconfig, status); readIdxStatus(theconfig, status);
if (status.hasmonitor) { if (status.hasmonitor) {
@ -191,7 +197,7 @@ void RclMain::periodic100()
// incremental pass // incremental pass
fileBumpIndexingAction->setEnabled(true); fileBumpIndexingAction->setEnabled(true);
} }
fileToggleIndexingAction->setEnabled(true); fileStartMonitorAction->setEnabled(false);
fileRebuildIndexAction->setEnabled(false); fileRebuildIndexAction->setEnabled(false);
actionSpecial_Indexing->setEnabled(false); actionSpecial_Indexing->setEnabled(false);
periodictimer->setInterval(200); periodictimer->setInterval(200);
@ -254,9 +260,8 @@ void RclMain::toggleIndexing()
int rep = int rep =
QMessageBox::information( QMessageBox::information(
0, tr("Warning"), 0, tr("Warning"),
tr("The current indexing process was not started from this " tr("The current indexing process is a monitor or was not started from this "
"interface. Click Ok to kill it " "interface. Click Ok to kill it anyway, or Cancel to leave it alone"),
"anyway, or Cancel to leave it alone"),
QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton); QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton);
if (rep == QMessageBox::Ok) { if (rep == QMessageBox::Ok) {
#ifdef _WIN32 #ifdef _WIN32
@ -296,27 +301,34 @@ void RclMain::toggleIndexing()
} }
} }
#ifndef _WIN32 void RclMain::startMonitor()
{
DbIxStatus status;
readIdxStatus(theconfig, status);
if (nullptr == m_idxproc && m_indexerState == IXST_NOTRUNNING) {
if (!checkIdxPaths()) {
return;
}
vector<string> args{"-c", theconfig->getConfDir()};
if (m_idxreasontmp && m_idxreasontmp->ok()) {
args.push_back("-R");
args.push_back(m_idxreasontmp->filename());
}
args.push_back("-mw");
args.push_back("0");
m_idxproc = new ExecCmd;
m_idxproc->startExec("recollindex", args, false, false);
}
}
void RclMain::bumpIndexing() void RclMain::bumpIndexing()
{ {
DbIxStatus status; DbIxStatus status;
readIdxStatus(theconfig, status); readIdxStatus(theconfig, status);
if (status.hasmonitor) { if (status.hasmonitor) {
string cmd("touch "); path_utimes(path_cat(theconfig->getConfDir(), "recoll.conf"), nullptr);
string path = path_cat(theconfig->getConfDir(), "recoll.conf");
cmd += path;
int status;
if ((status = system(cmd.c_str()))) {
cerr << cmd << " failed with status " << status << endl;
}
} }
} }
#else
// Because moc does not understand ifdefs, have to have this as an empty func
void RclMain::bumpIndexing()
{
}
#endif
static void delay(int millisecondsWait) static void delay(int millisecondsWait)
{ {

View File

@ -50,8 +50,9 @@ void RclMain::buildMenus()
queryMenu->setTitle(QApplication::translate("RclMainBase", "&Query")); queryMenu->setTitle(QApplication::translate("RclMainBase", "&Query"));
fileMenu->insertAction(fileRebuildIndexAction, fileBumpIndexingAction);
fileMenu->addAction(fileToggleIndexingAction); fileMenu->addAction(fileToggleIndexingAction);
fileMenu->addAction(fileStartMonitorAction);
fileMenu->addAction(fileBumpIndexingAction);
fileMenu->addAction(fileRebuildIndexAction); fileMenu->addAction(fileRebuildIndexAction);
fileMenu->addAction(actionSpecial_Indexing); fileMenu->addAction(actionSpecial_Indexing);
fileMenu->addSeparator(); fileMenu->addSeparator();

View File

@ -100,6 +100,17 @@
<cstring>fileBumpIndexingAction</cstring> <cstring>fileBumpIndexingAction</cstring>
</property> </property>
</action> </action>
<action name="fileStartMonitorAction">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Start real time indexer</string>
</property>
<property name="name" stdset="0">
<cstring>fileStartMonitorAction</cstring>
</property>
</action>
<action name="fileRebuildIndexAction"> <action name="fileRebuildIndexAction">
<property name="text"> <property name="text">
<string>&amp;Rebuild index</string> <string>&amp;Rebuild index</string>

View File

@ -168,77 +168,45 @@ void RclMain::init()
SnippetsW::listShortcuts(); SnippetsW::listShortcuts();
AdvSearch::listShortcuts(); AdvSearch::listShortcuts();
connect(&SCBase::scBase(), SIGNAL(shortcutsChanged()), connect(&SCBase::scBase(), SIGNAL(shortcutsChanged()), this, SLOT(onNewShortcuts()));
this, SLOT(onNewShortcuts()));
connect(&m_watcher, SIGNAL(fileChanged(QString)), connect(&m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateIdxStatus()));
this, SLOT(updateIdxStatus()));
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)), connect(sSearch, SIGNAL(setDescription(QString)), this, SLOT(onSetDescription(QString)));
this, SLOT(onSetDescription(QString))); connect(sSearch, SIGNAL(clearSearch()), this, SLOT(resetSearch()));
connect(sSearch, SIGNAL(clearSearch()),
this, SLOT(resetSearch()));
connect(this, SIGNAL(uiPrefsChanged()), sSearch, SLOT(setPrefs())); connect(this, SIGNAL(uiPrefsChanged()), sSearch, SLOT(setPrefs()));
connect(preferencesMenu, SIGNAL(triggered(QAction*)), connect(preferencesMenu, SIGNAL(triggered(QAction*)), this, SLOT(setStemLang(QAction*)));
this, SLOT(setStemLang(QAction*))); connect(preferencesMenu, SIGNAL(aboutToShow()), this, SLOT(adjustPrefsMenu()));
connect(preferencesMenu, SIGNAL(aboutToShow()),
this, SLOT(adjustPrefsMenu())); connect(fileExitAction, SIGNAL(triggered()), this, SLOT(fileExit()));
connect(fileExitAction, SIGNAL(triggered() ), connect(fileToggleIndexingAction, SIGNAL(triggered()), this, SLOT(toggleIndexing()));
this, SLOT(fileExit() ) ); connect(fileStartMonitorAction, SIGNAL(triggered()), this, SLOT(startMonitor()));
connect(fileToggleIndexingAction, SIGNAL(triggered()), connect(fileBumpIndexingAction, SIGNAL(triggered()), this, SLOT(bumpIndexing()));
this, SLOT(toggleIndexing())); connect(fileRebuildIndexAction, SIGNAL(triggered()), this, SLOT(rebuildIndex()));
#ifndef _WIN32 connect(actionSpecial_Indexing, SIGNAL(triggered()), this, SLOT(showSpecIdx()));
fileMenu->insertAction(fileRebuildIndexAction, fileBumpIndexingAction); connect(fileEraseDocHistoryAction, SIGNAL(triggered()), this, SLOT(eraseDocHistory()));
connect(fileBumpIndexingAction, SIGNAL(triggered()), connect(fileEraseSearchHistoryAction, SIGNAL(triggered()), this, SLOT(eraseSearchHistory()));
this, SLOT(bumpIndexing()));
#endif
connect(fileRebuildIndexAction, SIGNAL(triggered()),
this, SLOT(rebuildIndex()));
connect(fileEraseDocHistoryAction, SIGNAL(triggered()),
this, SLOT(eraseDocHistory()));
connect(fileEraseSearchHistoryAction, SIGNAL(triggered()),
this, SLOT(eraseSearchHistory()));
connect(fileExportSSearchHistoryAction, SIGNAL(triggered()), connect(fileExportSSearchHistoryAction, SIGNAL(triggered()),
this, SLOT(exportSimpleSearchHistory())); this, SLOT(exportSimpleSearchHistory()));
connect(actionSave_last_query, SIGNAL(triggered()), connect(actionSave_last_query, SIGNAL(triggered()), this, SLOT(saveLastQuery()));
this, SLOT(saveLastQuery())); connect(actionLoad_saved_query, SIGNAL(triggered()), this, SLOT(loadSavedQuery()));
connect(actionLoad_saved_query, SIGNAL(triggered()), connect(actionShow_index_statistics, SIGNAL(triggered()), this, SLOT(showIndexStatistics()));
this, SLOT(loadSavedQuery())); connect(helpAbout_RecollAction, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
connect(actionShow_index_statistics, SIGNAL(triggered()), connect(showMissingHelpers_Action, SIGNAL(triggered()), this, SLOT(showMissingHelpers()));
this, SLOT(showIndexStatistics())); connect(showActiveTypes_Action, SIGNAL(triggered()), this, SLOT(showActiveTypes()));
connect(helpAbout_RecollAction, SIGNAL(triggered()), connect(userManualAction, SIGNAL(triggered()), this, SLOT(startManual()));
this, SLOT(showAboutDialog())); connect(toolsDoc_HistoryAction, SIGNAL(triggered()), this, SLOT(showDocHistory()));
connect(showMissingHelpers_Action, SIGNAL(triggered()), connect(toolsAdvanced_SearchAction, SIGNAL(triggered()), this, SLOT(showAdvSearchDialog()));
this, SLOT(showMissingHelpers())); connect(toolsSpellAction, SIGNAL(triggered()), this, SLOT(showSpellDialog()));
connect(showActiveTypes_Action, SIGNAL(triggered()), connect(actionWebcache_Editor, SIGNAL(triggered()), this, SLOT(showWebcacheDialog()));
this, SLOT(showActiveTypes())); connect(actionQuery_Fragments, SIGNAL(triggered()), this, SLOT(showFragButs()));
connect(userManualAction, SIGNAL(triggered()), connect(indexConfigAction, SIGNAL(triggered()), this, SLOT(showIndexConfig()));
this, SLOT(startManual())); connect(indexScheduleAction, SIGNAL(triggered()), this, SLOT(showIndexSched()));
connect(toolsDoc_HistoryAction, SIGNAL(triggered()), connect(queryPrefsAction, SIGNAL(triggered()), this, SLOT(showUIPrefs()));
this, SLOT(showDocHistory())); connect(extIdxAction, SIGNAL(triggered()), this, SLOT(showExtIdxDialog()));
connect(toolsAdvanced_SearchAction, SIGNAL(triggered()), connect(enbSynAction, SIGNAL(toggled(bool)), this, SLOT(setSynEnabled(bool)));
this, SLOT(showAdvSearchDialog()));
connect(toolsSpellAction, SIGNAL(triggered()),
this, SLOT(showSpellDialog()));
connect(actionWebcache_Editor, SIGNAL(triggered()),
this, SLOT(showWebcacheDialog()));
connect(actionQuery_Fragments, SIGNAL(triggered()),
this, SLOT(showFragButs()));
connect(actionSpecial_Indexing, SIGNAL(triggered()),
this, SLOT(showSpecIdx()));
connect(indexConfigAction, SIGNAL(triggered()),
this, SLOT(showIndexConfig()));
connect(indexScheduleAction, SIGNAL(triggered()),
this, SLOT(showIndexSched()));
connect(queryPrefsAction, SIGNAL(triggered()),
this, SLOT(showUIPrefs()));
connect(extIdxAction, SIGNAL(triggered()),
this, SLOT(showExtIdxDialog()));
connect(enbSynAction, SIGNAL(toggled(bool)),
this, SLOT(setSynEnabled(bool)));
connect(toggleFullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen())); connect(toggleFullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
zoomInAction->setShortcut(QKeySequence::ZoomIn); zoomInAction->setShortcut(QKeySequence::ZoomIn);
@ -246,20 +214,15 @@ void RclMain::init()
zoomOutAction->setShortcut(QKeySequence::ZoomOut); zoomOutAction->setShortcut(QKeySequence::ZoomOut);
connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut())); connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
connect(actionShowQueryDetails, SIGNAL(triggered()), connect(actionShowQueryDetails, SIGNAL(triggered()), reslist, SLOT(showQueryDetails()));
reslist, SLOT(showQueryDetails())); connect(periodictimer, SIGNAL(timeout()), this, SLOT(periodic100()));
connect(periodictimer, SIGNAL(timeout()),
this, SLOT(periodic100()));
restable->setRclMain(this, true); restable->setRclMain(this, true);
connect(actionSaveResultsAsCSV, SIGNAL(triggered()), connect(actionSaveResultsAsCSV, SIGNAL(triggered()), restable, SLOT(saveAsCSV()));
restable, SLOT(saveAsCSV()));
connect(this, SIGNAL(docSourceChanged(std::shared_ptr<DocSequence>)), connect(this, SIGNAL(docSourceChanged(std::shared_ptr<DocSequence>)),
restable, SLOT(setDocSource(std::shared_ptr<DocSequence>))); restable, SLOT(setDocSource(std::shared_ptr<DocSequence>)));
connect(this, SIGNAL(searchReset()), connect(this, SIGNAL(searchReset()), restable, SLOT(resetSource()));
restable, SLOT(resetSource())); connect(this, SIGNAL(resultsReady()), restable, SLOT(readDocSource()));
connect(this, SIGNAL(resultsReady()),
restable, SLOT(readDocSource()));
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)), connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
restable, SLOT(onSortDataChanged(DocSeqSortSpec))); restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)), connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
@ -271,55 +234,38 @@ void RclMain::init()
connect(restable, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)), connect(restable, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)),
this, SLOT(startPreview(int, Rcl::Doc, int))); this, SLOT(startPreview(int, Rcl::Doc, int)));
connect(restable, SIGNAL(docExpand(Rcl::Doc)), connect(restable, SIGNAL(docExpand(Rcl::Doc)), this, SLOT(docExpand(Rcl::Doc)));
this, SLOT(docExpand(Rcl::Doc))); connect(restable, SIGNAL(showSubDocs(Rcl::Doc)), this, SLOT(showSubDocs(Rcl::Doc)));
connect(restable, SIGNAL(showSubDocs(Rcl::Doc)),
this, SLOT(showSubDocs(Rcl::Doc)));
connect(restable, SIGNAL(openWithRequested(Rcl::Doc, string)), connect(restable, SIGNAL(openWithRequested(Rcl::Doc, string)),
this, SLOT(openWith(Rcl::Doc, string))); this, SLOT(openWith(Rcl::Doc, string)));
reslist->setRclMain(this, true); reslist->setRclMain(this, true);
connect(this, SIGNAL(docSourceChanged(std::shared_ptr<DocSequence>)), connect(this, SIGNAL(docSourceChanged(std::shared_ptr<DocSequence>)),
reslist, SLOT(setDocSource(std::shared_ptr<DocSequence>))); reslist, SLOT(setDocSource(std::shared_ptr<DocSequence>)));
connect(firstPageAction, SIGNAL(triggered()), connect(firstPageAction, SIGNAL(triggered()), reslist, SLOT(resultPageFirst()));
reslist, SLOT(resultPageFirst())); connect(prevPageAction, SIGNAL(triggered()), reslist, SLOT(resPageUpOrBack()));
connect(prevPageAction, SIGNAL(triggered()), connect(nextPageAction, SIGNAL(triggered()), reslist, SLOT(resPageDownOrNext()));
reslist, SLOT(resPageUpOrBack())); connect(this, SIGNAL(searchReset()), reslist, SLOT(resetList()));
connect(nextPageAction, SIGNAL(triggered()), connect(this, SIGNAL(resultsReady()), reslist, SLOT(readDocSource()));
reslist, SLOT(resPageDownOrNext()));
connect(this, SIGNAL(searchReset()),
reslist, SLOT(resetList()));
connect(this, SIGNAL(resultsReady()),
reslist, SLOT(readDocSource()));
connect(this, SIGNAL(uiPrefsChanged()), reslist, SLOT(onUiPrefsChanged())); connect(this, SIGNAL(uiPrefsChanged()), reslist, SLOT(onUiPrefsChanged()));
connect(reslist, SIGNAL(hasResults(int)), connect(reslist, SIGNAL(hasResults(int)), this, SLOT(resultCount(int)));
this, SLOT(resultCount(int))); connect(reslist, SIGNAL(wordSelect(QString)), sSearch, SLOT(addTerm(QString)));
connect(reslist, SIGNAL(wordSelect(QString)),
sSearch, SLOT(addTerm(QString)));
connect(reslist, SIGNAL(wordReplace(const QString&, const QString&)), connect(reslist, SIGNAL(wordReplace(const QString&, const QString&)),
sSearch, SLOT(onWordReplace(const QString&, const QString&))); sSearch, SLOT(onWordReplace(const QString&, const QString&)));
connect(reslist, SIGNAL(nextPageAvailable(bool)), connect(reslist, SIGNAL(nextPageAvailable(bool)), this, SLOT(enableNextPage(bool)));
this, SLOT(enableNextPage(bool))); connect(reslist, SIGNAL(prevPageAvailable(bool)), this, SLOT(enablePrevPage(bool)));
connect(reslist, SIGNAL(prevPageAvailable(bool)),
this, SLOT(enablePrevPage(bool)));
connect(reslist, SIGNAL(docExpand(Rcl::Doc)), connect(reslist, SIGNAL(docExpand(Rcl::Doc)), this, SLOT(docExpand(Rcl::Doc)));
this, SLOT(docExpand(Rcl::Doc))); connect(reslist, SIGNAL(showSnippets(Rcl::Doc)), this, SLOT(showSnippets(Rcl::Doc)));
connect(reslist, SIGNAL(showSnippets(Rcl::Doc)), connect(reslist, SIGNAL(showSubDocs(Rcl::Doc)), this, SLOT(showSubDocs(Rcl::Doc)));
this, SLOT(showSnippets(Rcl::Doc))); connect(reslist, SIGNAL(docSaveToFileClicked(Rcl::Doc)), this, SLOT(saveDocToFile(Rcl::Doc)));
connect(reslist, SIGNAL(showSubDocs(Rcl::Doc)), connect(reslist, SIGNAL(editRequested(Rcl::Doc)), this, SLOT(startNativeViewer(Rcl::Doc)));
this, SLOT(showSubDocs(Rcl::Doc)));
connect(reslist, SIGNAL(docSaveToFileClicked(Rcl::Doc)),
this, SLOT(saveDocToFile(Rcl::Doc)));
connect(reslist, SIGNAL(editRequested(Rcl::Doc)),
this, SLOT(startNativeViewer(Rcl::Doc)));
connect(reslist, SIGNAL(openWithRequested(Rcl::Doc, string)), connect(reslist, SIGNAL(openWithRequested(Rcl::Doc, string)),
this, SLOT(openWith(Rcl::Doc, string))); this, SLOT(openWith(Rcl::Doc, string)));
connect(reslist, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)), connect(reslist, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)),
this, SLOT(startPreview(int, Rcl::Doc, int))); this, SLOT(startPreview(int, Rcl::Doc, int)));
connect(reslist, SIGNAL(previewRequested(Rcl::Doc)), connect(reslist, SIGNAL(previewRequested(Rcl::Doc)), this, SLOT(startPreview(Rcl::Doc)));
this, SLOT(startPreview(Rcl::Doc)));
setFilterCtlStyle(prefs.filterCtlStyle); setFilterCtlStyle(prefs.filterCtlStyle);

View File

@ -102,6 +102,7 @@ public slots:
virtual void fileExit(); virtual void fileExit();
virtual void periodic100(); virtual void periodic100();
virtual void toggleIndexing(); virtual void toggleIndexing();
virtual void startMonitor();
virtual void bumpIndexing(); virtual void bumpIndexing();
virtual void rebuildIndex(); virtual void rebuildIndex();
virtual void specialIndex(); virtual void specialIndex();