add menu entry to erase index and restart
This commit is contained in:
parent
9d7b654395
commit
ce0e808fc2
@ -135,6 +135,7 @@
|
|||||||
<string>&File</string>
|
<string>&File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="fileToggleIndexingAction"/>
|
<addaction name="fileToggleIndexingAction"/>
|
||||||
|
<addaction name="fileRebuildIndexAction"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="fileEraseSearchHistoryAction"/>
|
<addaction name="fileEraseSearchHistoryAction"/>
|
||||||
<addaction name="fileEraseDocHistoryAction"/>
|
<addaction name="fileEraseDocHistoryAction"/>
|
||||||
@ -201,6 +202,14 @@
|
|||||||
<cstring>fileToggleIndexingAction</cstring>
|
<cstring>fileToggleIndexingAction</cstring>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="fileRebuildIndexAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Rebuild index</string>
|
||||||
|
</property>
|
||||||
|
<property name="name" stdset="0">
|
||||||
|
<cstring>fileRebuildIndexAction</cstring>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="fileEraseDocHistoryAction">
|
<action name="fileEraseDocHistoryAction">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Erase document history</string>
|
<string>&Erase document history</string>
|
||||||
|
|||||||
@ -228,6 +228,8 @@ void RclMain::init()
|
|||||||
this, SLOT(fileExit() ) );
|
this, SLOT(fileExit() ) );
|
||||||
connect(fileToggleIndexingAction, SIGNAL(activated()),
|
connect(fileToggleIndexingAction, SIGNAL(activated()),
|
||||||
this, SLOT(toggleIndexing()));
|
this, SLOT(toggleIndexing()));
|
||||||
|
connect(fileRebuildIndexAction, SIGNAL(activated()),
|
||||||
|
this, SLOT(rebuildIndex()));
|
||||||
connect(fileEraseDocHistoryAction, SIGNAL(activated()),
|
connect(fileEraseDocHistoryAction, SIGNAL(activated()),
|
||||||
this, SLOT(eraseDocHistory()));
|
this, SLOT(eraseDocHistory()));
|
||||||
connect(fileEraseSearchHistoryAction, SIGNAL(activated()),
|
connect(fileEraseSearchHistoryAction, SIGNAL(activated()),
|
||||||
@ -333,6 +335,8 @@ void RclMain::init()
|
|||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileRebuildIndexAction->setEnabled(FALSE);
|
||||||
|
fileToggleIndexingAction->setEnabled(FALSE);
|
||||||
// Start timer on a slow period (used for checking ^C). Will be
|
// Start timer on a slow period (used for checking ^C). Will be
|
||||||
// speeded up during indexing
|
// speeded up during indexing
|
||||||
periodictimer->start(1000);
|
periodictimer->start(1000);
|
||||||
@ -556,17 +560,26 @@ void RclMain::periodic100()
|
|||||||
// Update the "start/stop indexing" menu entry, can't be done from
|
// Update the "start/stop indexing" menu entry, can't be done from
|
||||||
// the "start/stop indexing" slot itself
|
// the "start/stop indexing" slot itself
|
||||||
if (m_idxproc) {
|
if (m_idxproc) {
|
||||||
|
m_indexerState = IXST_RUNNINGMINE;
|
||||||
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
||||||
fileToggleIndexingAction->setEnabled(TRUE);
|
fileToggleIndexingAction->setEnabled(TRUE);
|
||||||
|
fileRebuildIndexAction->setEnabled(FALSE);
|
||||||
|
periodictimer->setInterval(200);
|
||||||
} else {
|
} else {
|
||||||
fileToggleIndexingAction->setText(tr("Update &Index"));
|
|
||||||
// No indexer of our own runnin, but the real time one may be up, check
|
|
||||||
// for some other indexer.
|
|
||||||
Pidfile pidfile(theconfig->getPidfile());
|
Pidfile pidfile(theconfig->getPidfile());
|
||||||
if (pidfile.open() == 0) {
|
if (pidfile.open() == 0) {
|
||||||
|
m_indexerState = IXST_NOTRUNNING;
|
||||||
|
fileToggleIndexingAction->setText(tr("Update &Index"));
|
||||||
fileToggleIndexingAction->setEnabled(TRUE);
|
fileToggleIndexingAction->setEnabled(TRUE);
|
||||||
|
fileRebuildIndexAction->setEnabled(TRUE);
|
||||||
|
periodictimer->setInterval(1000);
|
||||||
} else {
|
} else {
|
||||||
fileToggleIndexingAction->setEnabled(FALSE);
|
// Real time or externally started batch indexer running
|
||||||
|
m_indexerState = IXST_RUNNINGNOTMINE;
|
||||||
|
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
||||||
|
fileToggleIndexingAction->setEnabled(TRUE);
|
||||||
|
fileRebuildIndexAction->setEnabled(FALSE);
|
||||||
|
periodictimer->setInterval(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,24 +603,78 @@ void RclMain::periodic100()
|
|||||||
fileExit();
|
fileExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This gets called when the indexing action is activated. It starts
|
// This gets called when the "update iindex" action is activated. It executes
|
||||||
// the requested action, and disables the menu entry. This will be
|
// the requested action, and disables the menu entry. This will be
|
||||||
// re-enabled by the indexing status check
|
// re-enabled by the indexing status check
|
||||||
void RclMain::toggleIndexing()
|
void RclMain::toggleIndexing()
|
||||||
{
|
{
|
||||||
if (m_idxproc) {
|
switch (m_indexerState) {
|
||||||
// Indexing was in progress, request stop. Let the periodic
|
case IXST_RUNNINGMINE:
|
||||||
// routine check for the results.
|
if (m_idxproc) {
|
||||||
kill(m_idxproc->getChildPid(), SIGTERM);
|
// Indexing was in progress, request stop. Let the periodic
|
||||||
} else {
|
// routine check for the results.
|
||||||
|
int pid = m_idxproc->getChildPid();
|
||||||
|
if (pid > 0)
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IXST_RUNNINGNOTMINE:
|
||||||
|
{
|
||||||
|
int rep =
|
||||||
|
QMessageBox::information(0, tr("Warning"),
|
||||||
|
tr("The current indexing process "
|
||||||
|
"was not started from this "
|
||||||
|
"interface. Click Ok to kill it "
|
||||||
|
"anyway, or Cancel to leave it alone"),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Cancel,
|
||||||
|
QMessageBox::NoButton);
|
||||||
|
if (rep == QMessageBox::Ok) {
|
||||||
|
Pidfile pidfile(theconfig->getPidfile());
|
||||||
|
pid_t pid = pidfile.open();
|
||||||
|
if (pid > 0)
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IXST_NOTRUNNING:
|
||||||
|
{
|
||||||
list<string> args;
|
list<string> args;
|
||||||
args.push_back("-c");
|
args.push_back("-c");
|
||||||
args.push_back(theconfig->getConfDir());
|
args.push_back(theconfig->getConfDir());
|
||||||
m_idxproc = new ExecCmd;
|
m_idxproc = new ExecCmd;
|
||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec("recollindex", args, false, false);
|
||||||
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
|
||||||
}
|
}
|
||||||
fileToggleIndexingAction->setEnabled(FALSE);
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RclMain::rebuildIndex()
|
||||||
|
{
|
||||||
|
switch (m_indexerState) {
|
||||||
|
case IXST_RUNNINGMINE:
|
||||||
|
case IXST_RUNNINGNOTMINE:
|
||||||
|
return; //?? Should not have been called
|
||||||
|
case IXST_NOTRUNNING:
|
||||||
|
{
|
||||||
|
int rep =
|
||||||
|
QMessageBox::warning(0, tr("Erasing index"),
|
||||||
|
tr("Reset the index and start "
|
||||||
|
"from scratch ?"),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Cancel,
|
||||||
|
QMessageBox::NoButton);
|
||||||
|
if (rep == QMessageBox::Ok) {
|
||||||
|
list<string> args;
|
||||||
|
args.push_back("-c");
|
||||||
|
args.push_back(theconfig->getConfDir());
|
||||||
|
args.push_back("-z");
|
||||||
|
m_idxproc = new ExecCmd;
|
||||||
|
m_idxproc->startExec("recollindex", args, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a db query and set the reslist docsource
|
// Start a db query and set the reslist docsource
|
||||||
|
|||||||
@ -52,6 +52,7 @@ class RclMain : public QMainWindow, public Ui::RclMainBase
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum IndexerState {IXST_NOTRUNNING, IXST_RUNNINGMINE, IXST_RUNNINGNOTMINE};
|
||||||
RclMain(QWidget * parent = 0)
|
RclMain(QWidget * parent = 0)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
curPreview(0),
|
curPreview(0),
|
||||||
@ -69,7 +70,7 @@ public:
|
|||||||
m_idAllStem(0),
|
m_idAllStem(0),
|
||||||
m_idxproc(0),
|
m_idxproc(0),
|
||||||
m_sortspecnochange(false),
|
m_sortspecnochange(false),
|
||||||
m_periodicToggle(0)
|
m_indexerState(IXST_RUNNINGNOTMINE)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
init();
|
init();
|
||||||
@ -84,6 +85,7 @@ public slots:
|
|||||||
virtual void idxStatus();
|
virtual void idxStatus();
|
||||||
virtual void periodic100();
|
virtual void periodic100();
|
||||||
virtual void toggleIndexing();
|
virtual void toggleIndexing();
|
||||||
|
virtual void rebuildIndex();
|
||||||
virtual void startSearch(RefCntr<Rcl::SearchData> sdata);
|
virtual void startSearch(RefCntr<Rcl::SearchData> sdata);
|
||||||
virtual void previewClosed(Preview *w);
|
virtual void previewClosed(Preview *w);
|
||||||
virtual void showAdvSearchDialog();
|
virtual void showAdvSearchDialog();
|
||||||
@ -156,7 +158,6 @@ private:
|
|||||||
QAction *m_idNoStem;
|
QAction *m_idNoStem;
|
||||||
QAction *m_idAllStem;
|
QAction *m_idAllStem;
|
||||||
QFileSystemWatcher m_watcher;
|
QFileSystemWatcher m_watcher;
|
||||||
|
|
||||||
vector<ExecCmd*> m_viewers;
|
vector<ExecCmd*> m_viewers;
|
||||||
ExecCmd *m_idxproc; // Indexing process
|
ExecCmd *m_idxproc; // Indexing process
|
||||||
map<QString, QAction*> m_stemLangToId;
|
map<QString, QAction*> m_stemLangToId;
|
||||||
@ -165,7 +166,7 @@ private:
|
|||||||
bool m_sortspecnochange;
|
bool m_sortspecnochange;
|
||||||
DocSeqSortSpec m_sortspec;
|
DocSeqSortSpec m_sortspec;
|
||||||
RefCntr<DocSequence> m_source;
|
RefCntr<DocSequence> m_source;
|
||||||
int m_periodicToggle;
|
IndexerState m_indexerState;
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
|
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user