-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsgwidget.h
41 lines (32 loc) · 903 Bytes
/
sgwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef SGOBJECT_H
#define SGOBJECT_H
#include <QWidget>
#include <QQueue>
#include <QTimer>
#include <QDebug>
/***
* Most widgets used in SG should inherit this class.
*
* Every class that inherits SGWidget must define the private slot
* do_work(). This function automatically is called several times a second
* and is meant to be a place where the class deals with the messages
* in its _work_queue put there by the server class.
*/
class SGWidget : public QWidget
{
Q_OBJECT
public:
explicit SGWidget(QString name, QWidget *parent = nullptr, int work_interval_msec = 500);
~SGWidget();
void enqueue(QByteArray work_message);
protected:
QQueue<QByteArray> _work_queue;
QList<QByteArray> split(QByteArray& message, int max_split = 0);
signals:
public slots:
private slots:
virtual void do_work() = 0;
private:
QTimer _work_timer;
};
#endif // SGOBJECT_H