improve indexing status reporting

This commit is contained in:
dockes
2006-04-12 10:41:39 +00:00
parent c9cf0c9460
commit 9086c6e531
8 changed files with 123 additions and 44 deletions
+7 -6
View File
@@ -30,10 +30,10 @@ static QMutex curfile_mutex;
class IdxThread : public QThread , public DbIxStatusUpdater {
virtual void run();
public:
virtual bool update(const string &fn) {
virtual bool update() {
QMutexLocker locker(&curfile_mutex);
m_curfile = fn;
LOGDEB1(("IdxThread::update: indexing %s\n", m_curfile.c_str()));
m_statusSnap = status;
LOGDEB1(("IdxThread::update: indexing %s\n", m_statusSnap.fn.c_str()));
if (stopindexing) {
stopindexing = 0;
return false;
@@ -41,7 +41,8 @@ class IdxThread : public QThread , public DbIxStatusUpdater {
return true;
}
ConfIndexer *indexer;
string m_curfile;
// Maintain a copy/snapshot of idx status
DbIxStatus m_statusSnap;
int loglevel;
};
@@ -97,8 +98,8 @@ void stop_idxthread()
idxthread.wait();
}
std::string idxthread_currentfile()
DbIxStatus idxthread_idxStatus()
{
QMutexLocker locker(&curfile_mutex);
return(idxthread.m_curfile);
return(idxthread.m_statusSnap);
}
+3 -2
View File
@@ -16,8 +16,9 @@
*/
#ifndef _IDXTHREAD_H_INCLUDED_
#define _IDXTHREAD_H_INCLUDED_
/* @(#$Id: idxthread.h,v 1.5 2006-04-04 13:49:55 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: idxthread.h,v 1.6 2006-04-12 10:41:39 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include "indexer.h"
class RclConfig;
@@ -25,7 +26,7 @@ class RclConfig;
// sessions.
extern void start_idxthread(const RclConfig& cnf);
extern void stop_idxthread();
extern std::string idxthread_currentfile();
extern DbIxStatus idxthread_idxStatus();
extern int stopindexing;
extern int startindexing;
+23 -4
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.20 2006-04-12 07:26:17 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.21 2006-04-12 10:41:39 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -219,17 +219,35 @@ void RclMain::periodic100()
QString::fromAscii(indexingReason.c_str()));
}
indexingstatus = IDXTS_NULL;
fileStart_IndexingAction->setEnabled(TRUE);
// Make sure we reopen the db to get the results.
LOGINFO(("Indexing done: closing query database\n"));
rcldb->close();
} else if (indexingdone == 0) {
if (toggle == 0) {
QString msg = tr("Indexing in progress: ");
string cf = idxthread_currentfile();
DbIxStatus status = idxthread_idxStatus();
QString phs;
switch (status.phase) {
case DbIxStatus::DBIXS_FILES: phs=tr("Files");break;
case DbIxStatus::DBIXS_PURGE: phs=tr("Purge");break;
case DbIxStatus::DBIXS_STEMDB: phs=tr("Stemdb");break;
case DbIxStatus::DBIXS_CLOSING:phs=tr("Closing");break;
default: phs=tr("Unknown");break;
}
msg += phs + " ";
if (status.phase == DbIxStatus::DBIXS_FILES) {
char cnts[100];
if (status.dbtotdocs>0)
sprintf(cnts,"(%d/%d) ",status.docsdone, status.dbtotdocs);
else
sprintf(cnts, "(%d) ", status.docsdone);
msg += QString::fromAscii(cnts) + " ";
}
string mf;int ecnt = 0;
string fcharset = rclconfig->getDefCharset(true);
if (!transcode(cf, mf, fcharset, "UTF-8", &ecnt) || ecnt) {
mf = url_encode(cf, 0);
if (!transcode(status.fn, mf, fcharset, "UTF-8", &ecnt) || ecnt) {
mf = url_encode(status.fn, 0);
}
msg += QString::fromUtf8(mf.c_str());
statusBar()->message(msg);
@@ -247,6 +265,7 @@ void RclMain::fileStart_IndexingAction_activated()
{
if (indexingdone)
startindexing = 1;
fileStart_IndexingAction->setEnabled(FALSE);
}
// Note that all our 'urls' are like : file://...
+2 -2
View File
@@ -173,10 +173,10 @@
<cstring>fileStart_IndexingAction</cstring>
</property>
<property name="text">
<string>Start Indexing</string>
<string>Update index</string>
</property>
<property name="menuText">
<string>Start &amp;Indexing</string>
<string>Update &amp;index</string>
</property>
</action>
<action>