-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkersModel.h
More file actions
executable file
·45 lines (34 loc) · 1.03 KB
/
workersModel.h
File metadata and controls
executable file
·45 lines (34 loc) · 1.03 KB
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
42
43
44
45
#ifndef WORKERSMODEL_H
#define WORKERSMODEL_H
#include <vector>
#include <memory>
#include <QAbstractListModel>
#include "worker.h"
class WorkersModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit WorkersModel(QObject* parent = nullptr);
enum WorkerRoles
{
IdRole = Qt::UserRole + 1,
StatusRole
};
void addWorker(std::unique_ptr<Worker> worker);
void updateWorker(int workerId);
Worker* getFreeWorker();
std::vector<Worker*> getAllWorkers() const;
Worker* searchWorkerByTaskId(int taskId);
int countWorkersByStatus(const std::string& status) const;
int countWorkersAll() const;
signals:
void workersChanged();
protected:
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
std::vector<std::unique_ptr<Worker>> workers;
mutable std::mutex mutexWorkers;
};
#endif // WORKERSMODEL_H