Switch to unified view

a/src/qtgui/idxthread.cpp b/src/qtgui/idxthread.cpp
...
...
25
#include "debuglog.h"
25
#include "debuglog.h"
26
#include "idxthread.h"
26
#include "idxthread.h"
27
#include "smallut.h"
27
#include "smallut.h"
28
#include "rclinit.h"
28
#include "rclinit.h"
29
29
30
int stopindexing;
31
int startindexing;
32
IdxThreadStatus indexingstatus = IDXTS_OK;
33
string indexingReason;
34
static int stopidxthread;
35
30
static QMutex curfile_mutex;
36
static QMutex curfile_mutex;
31
37
32
class IdxThread : public QThread , public DbIxStatusUpdater {
38
class IdxThread : public QThread , public DbIxStatusUpdater {
33
    virtual void run();
39
    virtual void run();
34
 public:
40
 public:
...
...
36
    QMutexLocker locker(&curfile_mutex);
42
    QMutexLocker locker(&curfile_mutex);
37
    m_statusSnap = status;
43
    m_statusSnap = status;
38
    LOGDEB1(("IdxThread::update: indexing %s\n", m_statusSnap.fn.c_str()));
44
    LOGDEB1(("IdxThread::update: indexing %s\n", m_statusSnap.fn.c_str()));
39
    if (stopindexing) {
45
    if (stopindexing) {
40
        stopindexing = 0;
46
        stopindexing = 0;
47
      m_interrupted = true;
41
        return false;
48
        return false;
42
    }
49
    }
43
    return true;
50
    return true;
44
    }
51
    }
45
    // Maintain a copy/snapshot of idx status
52
    // Maintain a copy/snapshot of idx status
46
    DbIxStatus m_statusSnap;
53
    DbIxStatus m_statusSnap;
54
    bool m_interrupted;
47
    const RclConfig *cnf;
55
    const RclConfig *cnf;
48
};
56
};
49
50
int stopindexing;
51
int startindexing;
52
int indexingdone = 1;
53
IdxThreadStatus indexingstatus = IDXTS_NULL;
54
string indexingReason;
55
static int stopidxthread;
56
57
57
void IdxThread::run()
58
void IdxThread::run()
58
{
59
{
59
    recoll_threadinit();
60
    recoll_threadinit();
60
    for (;;) {
61
    for (;;) {
61
    if (stopidxthread) {
62
    if (stopidxthread) {
62
        return;
63
        return;
63
    }
64
    }
64
    if (startindexing) {
65
    if (startindexing) {
65
        startindexing = 0;
66
        startindexing = 0;
66
      indexingdone = 0;
67
      m_interrupted = false;
67
        indexingstatus = IDXTS_NULL;
68
        indexingstatus = IDXTS_NULL;
68
        // We have to make a copy of the config (setKeydir changes
69
        // We have to make a copy of the config (setKeydir changes
69
        // it during indexation)
70
        // it during indexation)
70
        RclConfig *myconf = new RclConfig(*cnf);
71
        RclConfig *myconf = new RclConfig(*cnf);
71
        int loglevel;
72
        int loglevel;
...
...
78
        indexingReason = "";
79
        indexingReason = "";
79
        } else {
80
        } else {
80
        indexingstatus = IDXTS_ERROR;
81
        indexingstatus = IDXTS_ERROR;
81
        indexingReason = "Indexing failed: " + indexer->getReason();
82
        indexingReason = "Indexing failed: " + indexer->getReason();
82
        }
83
        }
83
      indexingdone = 1;
84
        delete indexer;
84
        delete indexer;
85
    } 
85
    } 
86
    msleep(100);
86
    msleep(100);
87
    }
87
    }
88
}
88
}
...
...
103
}
103
}
104
104
105
DbIxStatus idxthread_idxStatus()
105
DbIxStatus idxthread_idxStatus()
106
{
106
{
107
    QMutexLocker locker(&curfile_mutex);
107
    QMutexLocker locker(&curfile_mutex);
108
    return(idxthread.m_statusSnap);
108
    return idxthread.m_statusSnap;
109
}
109
}
110
bool idxthread_idxInterrupted()
111
{
112
    return idxthread.m_interrupted;
113
}