Switch to unified view

a/src/qtgui/idxthread.cpp b/src/qtgui/idxthread.cpp
...
...
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
 */
18
 */
19
19
20
20
21
#include <qthread.h>
21
#include <qthread.h>
22
#include <qmutex.h>
22
23
23
#include "indexer.h"
24
#include "indexer.h"
24
#include "debuglog.h"
25
#include "debuglog.h"
25
#include "idxthread.h"
26
#include "idxthread.h"
26
27
27
class IdxThread : public QThread {
28
static QMutex curfile_mutex;
29
30
class IdxThread : public QThread , public DbIxStatusUpdater {
28
    virtual void run();
31
    virtual void run();
29
 public:
32
 public:
33
    virtual void update(const string &fn) {
34
  QMutexLocker locker(&curfile_mutex);
35
  m_curfile = fn;
36
  LOGDEB(("IdxThread::update: indexing %s\n", m_curfile.c_str()));
37
    }
30
    ConfIndexer *indexer;
38
    ConfIndexer *indexer;
39
    string m_curfile;
40
    int loglevel;
31
};
41
};
32
42
33
int startindexing;
43
int startindexing;
34
int indexingdone = 1;
44
int indexingdone = 1;
35
bool indexingstatus = false;
45
bool indexingstatus = false;
36
46
37
static int stopidxthread;
47
static int stopidxthread;
38
48
39
void IdxThread::run()
49
void IdxThread::run()
40
{
50
{
41
    DebugLog::getdbl()->setloglevel(DEBDEB1);
51
    DebugLog::getdbl()->setloglevel(loglevel);
42
    for (;;) {
52
    for (;;) {
43
    if (stopidxthread) {
53
    if (stopidxthread) {
44
        delete indexer;
54
        delete indexer;
45
        return;
55
        return;
46
    }
56
    }
...
...
60
void start_idxthread(const RclConfig& cnf)
70
void start_idxthread(const RclConfig& cnf)
61
{
71
{
62
    // We have to make a copy of the config (setKeydir changes it during 
72
    // We have to make a copy of the config (setKeydir changes it during 
63
    // indexation)
73
    // indexation)
64
    RclConfig *myconf = new RclConfig(cnf);
74
    RclConfig *myconf = new RclConfig(cnf);
65
    ConfIndexer *ix = new ConfIndexer(myconf);
75
    ConfIndexer *ix = new ConfIndexer(myconf, &idxthread);
66
    idxthread.indexer = ix;
76
    idxthread.indexer = ix;
77
    idxthread.loglevel = DebugLog::getdbl()->getlevel();
67
    idxthread.start();
78
    idxthread.start();
68
}
79
}
69
80
70
void stop_idxthread()
81
void stop_idxthread()
71
{
82
{
72
    stopidxthread = 1;
83
    stopidxthread = 1;
73
    idxthread.wait();
84
    idxthread.wait();
74
}
85
}
86
87
std::string idxthread_currentfile()
88
{
89
    QMutexLocker locker(&curfile_mutex);
90
    return(idxthread.m_curfile);
91
}