1-goldbach/{v4.0 → v4.1}/GoldbachModel.h RENAMED
@@ -1,43 +1,46 @@
1
  #ifndef GOLDBACHMODEL_H
2
  #define GOLDBACHMODEL_H
3
 
4
  #include <QAbstractListModel>
5
  #include <QVector>
6
 
7
  class GoldbachWorker;
8
 
9
  class GoldbachModel : public QAbstractListModel
10
  {
11
  Q_OBJECT
12
  Q_DISABLE_COPY(GoldbachModel)
13
 
14
  protected:
15
  //GoldbachWorker* worker = nullptr;
16
  QVector<GoldbachWorker*> workers;
 
 
 
17
  QVector< QVector<QString> > results;
18
  int fetchedRowCount = 0;
19
 
20
  public:
21
  explicit GoldbachModel(QObject *parent = nullptr);
22
  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
23
  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
24
  const QString& findValue(int index) const;
25
  int countResults() const;
26
 
27
  void calculate(long long number);
28
  void stop();
29
 
30
  protected:
31
  bool canFetchMore(const QModelIndex &parent) const override;
32
  void fetchMore(const QModelIndex &parent) override;
33
 
34
  signals:
35
  void calculationDone(long long sumCount);
36
  void progressUpdated(int percent) const;
37
 
38
  private slots:
39
  void workerDone(long long sumCount);
40
- void updateProgress(int percent);
41
  };
42
 
43
  #endif // GOLDBACHMODEL_H
1
  #ifndef GOLDBACHMODEL_H
2
  #define GOLDBACHMODEL_H
3
 
4
  #include <QAbstractListModel>
5
  #include <QVector>
6
 
7
  class GoldbachWorker;
8
 
9
  class GoldbachModel : public QAbstractListModel
10
  {
11
  Q_OBJECT
12
  Q_DISABLE_COPY(GoldbachModel)
13
 
14
  protected:
15
  //GoldbachWorker* worker = nullptr;
16
  QVector<GoldbachWorker*> workers;
17
+ QVector<int> progressPercents;
18
+ int overallProgressPercent = 0;
19
+ int finishedWorkerCount = 0;
20
  QVector< QVector<QString> > results;
21
  int fetchedRowCount = 0;
22
 
23
  public:
24
  explicit GoldbachModel(QObject *parent = nullptr);
25
  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
26
  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
27
  const QString& findValue(int index) const;
28
  int countResults() const;
29
 
30
  void calculate(long long number);
31
  void stop();
32
 
33
  protected:
34
  bool canFetchMore(const QModelIndex &parent) const override;
35
  void fetchMore(const QModelIndex &parent) override;
36
 
37
  signals:
38
  void calculationDone(long long sumCount);
39
  void progressUpdated(int percent) const;
40
 
41
  private slots:
42
  void workerDone(long long sumCount);
43
+ void updateProgress(int workerId, int percent);
44
  };
45
 
46
  #endif // GOLDBACHMODEL_H