1-goldbach/{v4.2 → v5.0}/GoldbachModel.h RENAMED
@@ -1,46 +1,47 @@
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
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
+ QVector<QString> fetchAllSums() const;
30
 
31
  void calculate(long long number);
32
  void stop();
33
 
34
  protected:
35
  bool canFetchMore(const QModelIndex &parent) const override;
36
  void fetchMore(const QModelIndex &parent) override;
37
 
38
  signals:
39
  void calculationDone(long long sumCount);
40
  void progressUpdated(int percent) const;
41
 
42
  private slots:
43
  void workerDone(long long sumCount);
44
  void updateProgress(int workerId, int percent);
45
  };
46
 
47
  #endif // GOLDBACHMODEL_H