/
xycalculatethread.h
82 lines (66 loc) · 2.35 KB
/
xycalculatethread.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef XYCALCULATETHREAD_H
#define XYCALCULATETHREAD_H
#include <QThread>
#include <QTreeWidget>
#include "xytreemodel.h"
class XYCalculateThread : public QThread
{
Q_OBJECT
public:
enum TYPE {FINDRESULTS, FINDSAME, FINDWITHKEY, FINDRESULTSWITHUSER};
explicit XYCalculateThread(QObject *parent = 0);
~XYCalculateThread();
TYPE getStartType();
void start(bool include3,
bool include4,
bool include5,
bool include6,
bool includeBracket,
int resultValue,
int maxValue);
void start(const QList<int > &values, bool includeBracket, int resultValue);
void start(XYTreeModel *tree, int colums);
void start(bool include, const QStringList &keys, const QStringList &all);
// 查找满足要求的组合
void isOKGroup(const QList<int> &values);
// 计算一组数的结果,不包括括号,顺序计算
void calculateTwoNumbers(int a, int b, QString &text, const QList<int> &values, int index);
// 计算一组数的结果,包括括号,首先按照括号的顺序计算
QMap<int, QString> calculateGroups(const QList<int> &values, bool outer = false, bool filter = true);
// 查找一组数是否相加得value的值
bool isNumbersAddToFixedValue(int a, int b, int value, const QList<int> &values, int index);
// 获取一组数的排列组合方式
void getNumbersByOrder(const QList<int> &source, QList<int> &target);
// 函数获取一个组数不同排列顺序
QList<QList<int> > getNumberByOrder(int maxNums);
signals:
void addString(const QString &oneResult, const QString &userData);
void addSameString(const QString &sameText);
void updateTree();
void updateList(QStringList datas, bool all);
protected:
void run();
private:
void findResultes();
void findResultesWithUserValues();
void findTreeSameColumns();
void findKeys();
bool findColumnSameItem(int column, const QString &data, QString &sameData);
private:
TYPE type;
bool include3;
bool include4;
bool include5;
bool include6;
bool includeBracket;
int maxValue;
int resultValue;
QList<int> userValues;
XYTreeModel *tree;
int columns;
int okGroupNumbers;
QStringList allSameTexts;
bool include;
QStringList keys;
};
#endif // XYCALCULATETHREAD_H