#ifndef WORKOBJECT_H
#define WORKOBJECT_H

#include <QObject>
#include <QEventLoop>
#include <QTimer>

#define EVENTWAIT(timer) do{                                \
        QEventLoop loop;                                    \
        QTimer::singleShot(timer, &loop, SLOT(quit()));     \
        loop.exec();                                        \
    } while(0)

class WorkObject : public QObject
{
    Q_OBJECT
public:
    explicit WorkObject(QObject *parent = 0);

    ~WorkObject();

    void moveToThread(QThread *thread, bool with_thread_start);

signals:
    void workclose();

    void quit();

public slots:
    virtual void workstart();

protected:
    bool _stopflag;

    bool _stoped;

};

#endif // WORKOBJECT_H
