1-goldbach/{v3.1 → v4.0}/GoldbachModel.h RENAMED
@@ -1,40 +1,43 @@
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<QString> results;
 
17
  int fetchedRowCount = 0;
18
 
19
  public:
20
  explicit GoldbachModel(QObject *parent = nullptr);
21
  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
22
  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
 
 
23
 
24
  void calculate(long long number);
25
  void stop();
26
 
27
  protected:
28
  bool canFetchMore(const QModelIndex &parent) const override;
29
  void fetchMore(const QModelIndex &parent) override;
30
 
31
  signals:
32
  void calculationDone(long long sumCount);
33
  void progressUpdated(int percent) const;
34
 
35
  private slots:
36
  void workerDone(long long sumCount);
37
  void updateProgress(int percent);
38
  };
39
 
40
  #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< 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