-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
120 lines (108 loc) · 2.81 KB
/
mainwindow.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QTime>
#include <QInputDialog>
#include <QMessageBox>
#include <QTimer>
#include <vector>
#include <QMouseEvent>
#include <QFontDatabase>
#include "sortAlgorithms.h"
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
const int HLAYOUTWIDTH = 780;
const int HLAYOUTHEIGHT = 410;
double multiWidth = 1.0;
double multiHigh = 1.0;
double columnWidth;
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
// 按钮
void on_btn_dataGenerate_clicked();
void on_btn_sortingStart_clicked();
void on_btn_sortingPause_clicked();
void on_btn_sortingContinue_clicked();
void on_btn_oneStep_clicked();
// 菜单栏
void menuAct_actRadixSort();
void menuAct_actQuickSort();
void menuAct_actMergeSort();
void menuAct_actHeapSort();
void menuAct_actShellSort();
void menuAct_actInsertSort();
void menuAct_actBubbleSort();
void menuAct_actSelectSort();
void menuAct_newWindow();
void menuAct_bestwin();
void menuAct_statistics();
// 其他
void setSpeed(int speed);
void sortingAlgorithm(int index);
void updateColumns(int a, int b, int *newHeights);
void updateOneColumn(int c, bool resetPrev, int *newHeights);
void highLightColumns(int a, int b);
void highLightBase(int base);
void showFinish();
void updateSortingTime();
void sbShow(int num, QString text);
private:
void initMenuBar();
void dataGenerator();
void addDataColumns();
void deleteColumns();
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override;
void initVar();
void initLabel();
void debug_outNumber();
// 对象
Ui::MainWindow *ui;
sortAlgorithms *sortCtrl;
QLabel *columns;
QTimer *timer;
QLabel *sortName;
QLabel *oprtContent;
QLabel *sortDscrb;
QLabel *keyValue;
// 菜单栏
QMenu *menu_algorithm;
QMenu *menu_windows;
QAction *actRadixSort;
QAction *actQuickSort;
QAction *actMergeSort;
QAction *actHeapSort;
QAction *actShellSort;
QAction *actInsertSort;
QAction *actBubbleSort;
QAction *actSelectSort;
QAction *actSortWindow;
QAction *actBestSort;
QAction *actStatistics;
// 变量
bool sorted = 0;
bool dataGenerating = 0;
bool dataImporting = 0;
bool datahaved = 0;
int algorithmSelected = 1;
int sortSpeed = 50;
int prevDataNum = 0;
int dataNum;
int *numbers;
float sortingTime = 0.00;
int prevUpdtA = -1, prevUpdtB = -1;
std::vector<int> prevUpdtC;
int prevCmpA = -1, prevCmpB = -1;
int prevBase = -1;
};
#endif // MAINWINDOW_H