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 | #ifndef GOLDBACHMODEL_H
#define GOLDBACHMODEL_H
#include <QAbstractListModel>
#include <QVector>
class GoldbachWorker;
class GoldbachModel : public QAbstractListModel
{
Q_OBJECT
Q_DISABLE_COPY(GoldbachModel)
protected:
GoldbachWorker* worker = nullptr;
QVector<QString> results;
int fetchedRowCount = 0;
public:
explicit GoldbachModel(QObject *parent = nullptr);
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
void calculate(long long number);
protected:
bool canFetchMore(const QModelIndex &parent) const override;
void fetchMore(const QModelIndex &parent) override;
signals:
void calculationDone(long long sumCount);
private slots:
void workerSumFound(const QString& sum);
void workerDone(long long sumCount);
// void updateProgressBar(int percent);
};
#endif // GOLDBACHMODEL_H
|