Source Code (Use browser search to find items of interest.)
Class Index
empath'EmpathTask (./kdepim/empath/lib/EmpathTask.h:41)
class EmpathTask : public QObject
{
Q_OBJECT
public:
EmpathTask(const QString &);
~EmpathTask();
/**
* Set the maximum number of steps this task will take to complete.
*/
void setMax(int);
/**
* Set the current number of steps this task has taken.
*/
void setPos(int);
/**
* Signal that another item has been processed (increment the
* position).
*/
void doneOne();
/**
* Signal that the task has completed. You may go away now.
*/
void done();
int max() { return max_; }
int pos() { return pos_; }
bool isDone() { return done_; }
void timerEvent(QTimerEvent *);
QString name() { return name_; }
signals:
void maxChanged(int);
void posChanged(int);
void addOne();
void finished();
void newTask(EmpathTask *);
private:
QTime startTime_;
QString name_;
int max_;
int pos_;
bool done_;
unsigned int waitInterval_;
unsigned int waitCount_;
};
#endif
// vim:ts=4:sw=4:tw=78
empath'EmpathTask::EmpathTask() (./kdepim/empath/lib/EmpathTask.cpp:35)
EmpathTask::EmpathTask(const QString & name)
: QObject(),
name_(name),
max_(0),
pos_(0),
done_(false),
waitInterval_(1),
waitCount_(0)
{
startTime_ = QTime::currentTime();
QObject::connect(
this, SIGNAL(newTask(EmpathTask *)),
empath, SLOT(s_newTask(EmpathTask *)));
startTimer(50);
}
empath'EmpathTask::~EmpathTask() (./kdepim/empath/lib/EmpathTask.cpp:53)
EmpathTask::~EmpathTask()
{
emit(finished());
}
void
empath'EmpathTask::setMax() (./kdepim/empath/lib/EmpathTask.cpp:59)
EmpathTask::setMax(int i)
{
max_ = i;
emit(maxChanged(i));
}
void
empath'EmpathTask::setPos() (./kdepim/empath/lib/EmpathTask.cpp:66)
EmpathTask::setPos(int i)
{
pos_ = i;
emit(posChanged(i));
}
void
empath'EmpathTask::doneOne() (./kdepim/empath/lib/EmpathTask.cpp:73)
EmpathTask::doneOne()
{
emit(addOne());
#if 0
// Adaptive method for choosing a number of loops to make before
// processEvents(). Assumes loop iterations take approx. equal
// time. Concept credit: Coolo
if (waitCount_++ >= waitInterval_) {
kapp->processEvents();
QTime currentTime = QTime::currentTime();
int loopTime = startTime_.msecsTo(currentTime);
if (loopTime > 100) {
if (waitInterval_ < 5)
waitInterval_ = 0;
else
waitInterval_-=5;
waitCount_ = 0;
} else if (loopTime < 50) {
waitInterval_+=5;
waitCount_ = 0;
}
startTime_ = currentTime;
}
#endif
}
void
empath'EmpathTask::done() (./kdepim/empath/lib/EmpathTask.cpp:111)
EmpathTask::done()
{
killTimers();
done_ = true;
emit(finished());
kapp->processEvents();
}
void
empath'EmpathTask::timerEvent() (./kdepim/empath/lib/EmpathTask.cpp:120)
EmpathTask::timerEvent(QTimerEvent *)
{
killTimers();
emit(newTask(this));
kapp->processEvents();
}
// vim:ts=4:sw=4:tw=78