show current filename as feedback during indexation

This commit is contained in:
dockes 2006-03-22 16:24:41 +00:00
parent 462000eca2
commit e4d066994a
6 changed files with 83 additions and 30 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.25 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.26 2006-03-22 16:24:41 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -200,6 +200,8 @@ FsTreeWalker::Status
DbIndexer::processone(const std::string &fn, const struct stat *stp,
FsTreeWalker::CbFlag flg)
{
if (m_updfunc)
m_updfunc->update(fn);
// If we're changing directories, possibly adjust parameters (set
// the current directory in configuration object)
if (flg == FsTreeWalker::FtwDirEnter ||
@ -309,7 +311,7 @@ bool ConfIndexer::index(bool resetbefore)
// cout << *dit << " ";
//}
//cout << endl;
dbindexer = new DbIndexer(config, dbit->first);
dbindexer = new DbIndexer(config, dbit->first, m_updfunc);
if (!dbindexer->indexDb(resetbefore, &dbit->second)) {
deleteZ(dbindexer);
return false;

View File

@ -16,7 +16,7 @@
*/
#ifndef _INDEXER_H_INCLUDED_
#define _INDEXER_H_INCLUDED_
/* @(#$Id: indexer.h,v 1.10 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: indexer.h,v 1.11 2006-03-22 16:24:41 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include <list>
@ -28,6 +28,13 @@
/* Forward decl for lower level indexing object */
class DbIndexer;
/* Callback to say what we're doing */
class DbIxStatusUpdater {
public:
virtual ~DbIxStatusUpdater(){}
virtual void update(const std::string &) = 0;
};
/**
The top level indexing object. Processes the configuration, then invokes
file system walking to populate/update the database(s).
@ -40,15 +47,16 @@ class DbIndexer;
class ConfIndexer {
public:
enum runStatus {IndexerOk, IndexerError};
ConfIndexer(RclConfig *cnf) : config(cnf), dbindexer(0)
{
}
ConfIndexer(RclConfig *cnf, DbIxStatusUpdater *updfunc = 0)
: config(cnf), dbindexer(0), m_updfunc(updfunc)
{}
virtual ~ConfIndexer();
/** Worker function: doe the actual indexing */
bool index(bool resetbefore = false);
private:
RclConfig *config;
DbIndexer *dbindexer; // Object to process directories for a given db
RclConfig *config;
DbIndexer *dbindexer; // Object to process directories for a given db
DbIxStatusUpdater *m_updfunc;
};
/** Index things into one database
@ -64,8 +72,11 @@ Single file(s) indexing: no database purging or stem db updating.
class DbIndexer : public FsTreeWalkerCB {
public:
/** Constructor does nothing but store parameters */
DbIndexer(RclConfig *cnf, const std::string &dbd)
: config(cnf), dbdir(dbd) {
DbIndexer(RclConfig *cnf, // Configuration data
const std::string &dbd, // Place where the db lives
DbIxStatusUpdater *updfunc = 0 // status updater callback
)
: config(cnf), dbdir(dbd), m_updfunc(updfunc) {
}
virtual ~DbIndexer();
@ -99,6 +110,7 @@ class DbIndexer : public FsTreeWalkerCB {
std::string dbdir;
Rcl::Db db;
std::string tmpdir;
DbIxStatusUpdater *m_updfunc;
bool init(bool rst = false);
};

View File

@ -19,15 +19,25 @@
#include <qthread.h>
#include <qmutex.h>
#include "indexer.h"
#include "debuglog.h"
#include "idxthread.h"
class IdxThread : public QThread {
static QMutex curfile_mutex;
class IdxThread : public QThread , public DbIxStatusUpdater {
virtual void run();
public:
virtual void update(const string &fn) {
QMutexLocker locker(&curfile_mutex);
m_curfile = fn;
LOGDEB(("IdxThread::update: indexing %s\n", m_curfile.c_str()));
}
ConfIndexer *indexer;
string m_curfile;
int loglevel;
};
int startindexing;
@ -38,7 +48,7 @@ static int stopidxthread;
void IdxThread::run()
{
DebugLog::getdbl()->setloglevel(DEBDEB1);
DebugLog::getdbl()->setloglevel(loglevel);
for (;;) {
if (stopidxthread) {
delete indexer;
@ -62,8 +72,9 @@ void start_idxthread(const RclConfig& cnf)
// We have to make a copy of the config (setKeydir changes it during
// indexation)
RclConfig *myconf = new RclConfig(cnf);
ConfIndexer *ix = new ConfIndexer(myconf);
ConfIndexer *ix = new ConfIndexer(myconf, &idxthread);
idxthread.indexer = ix;
idxthread.loglevel = DebugLog::getdbl()->getlevel();
idxthread.start();
}
@ -72,3 +83,9 @@ void stop_idxthread()
stopidxthread = 1;
idxthread.wait();
}
std::string idxthread_currentfile()
{
QMutexLocker locker(&curfile_mutex);
return(idxthread.m_curfile);
}

View File

@ -16,7 +16,8 @@
*/
#ifndef _IDXTHREAD_H_INCLUDED_
#define _IDXTHREAD_H_INCLUDED_
/* @(#$Id: idxthread.h,v 1.3 2006-01-30 11:15:28 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: idxthread.h,v 1.4 2006-03-22 16:24:41 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
class RclConfig;
@ -24,6 +25,7 @@ class RclConfig;
// sessions.
extern void start_idxthread(const RclConfig& cnf);
extern void stop_idxthread();
extern std::string idxthread_currentfile();
extern int startindexing;
extern int indexingdone;

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.13 2006-03-21 13:46:37 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.14 2006-03-22 16:24:41 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -208,7 +208,7 @@ void RclMain::fileExit()
// thread and a possible need to exit
void RclMain::periodic100()
{
static int toggle;
static int toggle = 0;
// Check if indexing thread done
if (indexingstatus) {
statusBar()->message("");
@ -217,14 +217,15 @@ void RclMain::periodic100()
LOGINFO(("Indexing done: closing query database\n"));
rcldb->close();
} else if (indexingdone == 0) {
if (toggle < 9) {
statusBar()->message(tr("Indexing in progress"));
} else {
if (toggle == 0) {
QString msg = tr("Indexing in progress: ");
msg += idxthread_currentfile().c_str();
statusBar()->message(msg);
} else if (toggle == 9) {
statusBar()->message("");
}
if (toggle >= 10)
if (++toggle >= 10)
toggle = 0;
toggle++;
}
if (recollNeedsExit)
fileExit();

View File

@ -136,6 +136,22 @@
<pixmap>image0</pixmap>
<signal>startSearch(Rcl::AdvSearchData)</signal>
</customwidget>
<customwidget>
<class>RclResList</class>
<header location="local">rclreslist.h</header>
<sizehint>
<width>300</width>
<height>200</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
<verdata>5</verdata>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<pixmap>image0</pixmap>
</customwidget>
</customwidgets>
<actions>
<action>
@ -148,6 +164,9 @@
<property name="menuText">
<string>E&amp;xit</string>
</property>
<property name="accel">
<string>Ctrl+Q</string>
</property>
</action>
<action>
<property name="name">
@ -283,9 +302,6 @@
<image name="image0">
<data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
</image>
<image name="image1">
<data format="XBM.GZ" length="79">789c534e494dcbcc4b554829cdcdad8c2fcf4c29c95030e0524611cd48cd4ccf28010a1797249664262b2467241641a592324b8aa363156c15aab914146aadb90067111b1f</data>
</image>
</images>
<connections>
<connection>
@ -330,6 +346,12 @@
<receiver>RclMainBase</receiver>
<slot>showSortDialog()</slot>
</connection>
<connection>
<sender>preferencesQuery_PrefsAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showUIPrefs()</slot>
</connection>
<connection>
<sender>prevPageAction</sender>
<signal>activated()</signal>
@ -342,12 +364,6 @@
<receiver>resList</receiver>
<slot>showResultPage()</slot>
</connection>
<connection>
<sender>preferencesQuery_PrefsAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showUIPrefs()</slot>
</connection>
<connection>
<sender>resList</sender>
<signal>nextPageAvailable(bool)</signal>
@ -403,4 +419,7 @@
</slots>
<pixmapinproject/>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>rclreslist.h</includehint>
</includehints>
</UI>