mcqThread.cpp 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
/**
 * \file mcqThread.cpp
 * \date December 09, 2011
 * \author Edlira Nano
 */

#include "mcqThread.h"

Langella Olivier's avatar
Langella Olivier committed
9
McqThread::McqThread(QObject *parent, const unsigned int maxProgress)
Langella Olivier's avatar
Langella Olivier committed
10
11
  : QThread(parent), _abort(false), _restart(false)
{
Langella Olivier's avatar
Langella Olivier committed
12
  setMaxProgress(maxProgress);
13
14
}

Langella Olivier's avatar
Langella Olivier committed
15
16
17
McqThread::~McqThread()
{
}
Langella Olivier's avatar
Langella Olivier committed
18
19
20
21
22
23
void
McqThread::canceled()
{
  qDebug() << "Stop Thread";
  _abort = true;
}
Langella Olivier's avatar
Langella Olivier committed
24
25
26
void
McqThread::setMaxProgress(const unsigned int value)
{
Langella Olivier's avatar
Langella Olivier committed
27
28
29
  _progressMutex.lock();
  _maxProgressValue = value;
  _progressMutex.unlock();
30
31
}

Langella Olivier's avatar
Langella Olivier committed
32
unsigned int
Langella Olivier's avatar
Langella Olivier committed
33
34
McqThread::getProgressValue()
{
Langella Olivier's avatar
Langella Olivier committed
35
36
37
38
  _progressMutex.lock();
  unsigned int ret = _progressValue;
  _progressMutex.unlock();
  return ret;
39
40
}

Langella Olivier's avatar
Langella Olivier committed
41
42
43
void
McqThread::incrementProgressValue()
{
Langella Olivier's avatar
Langella Olivier committed
44
45
46
  _progressMutex.lock();
  _progressValue++;
  _progressMutex.unlock();
47
48
}

Langella Olivier's avatar
Langella Olivier committed
49
50
51
void
McqThread::setProgressValue(const unsigned int val)
{
Langella Olivier's avatar
Langella Olivier committed
52
53
54
  _progressMutex.lock();
  _progressValue = val;
  _progressMutex.unlock();
55
56
}

Langella Olivier's avatar
Langella Olivier committed
57
unsigned int
Langella Olivier's avatar
Langella Olivier committed
58
59
McqThread::getMaxProgress()
{
Langella Olivier's avatar
Langella Olivier committed
60
61
62
63
  _progressMutex.lock();
  unsigned int ret = _maxProgressValue;
  _progressMutex.unlock();
  return ret;
64
65
}

Langella Olivier's avatar
Langella Olivier committed
66
bool
Langella Olivier's avatar
Langella Olivier committed
67
68
McqThread::getAbord()
{
Langella Olivier's avatar
Langella Olivier committed
69
70
71
72
  _progressMutex.lock();
  bool abort = _abort;
  _progressMutex.unlock();
  return abort;
73
74
}

Langella Olivier's avatar
Langella Olivier committed
75
bool
Langella Olivier's avatar
Langella Olivier committed
76
77
McqThread::getRestart()
{
Langella Olivier's avatar
Langella Olivier committed
78
79
80
81
  _progressMutex.lock();
  bool restart = _restart;
  _progressMutex.unlock();
  return restart;
82
}