-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
99 lines (83 loc) · 2.15 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
updateComponents();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::resizeEvent(QResizeEvent *e)
{
Q_UNUSED(e);
ui->fibHeapView->resize(MainWindow::width()/*-20*/, MainWindow::height()-105);
}
void MainWindow::on_pushButton_Insert_clicked()
{
// QEvent e
ui->fibHeapView->insertNode(ui->spinBox->value());
}
void MainWindow::on_pushButton_ExtractMin_clicked()
{
ui->fibHeapView->extractMin();
updateComponents();
}
void MainWindow::on_pushButton_Delete_clicked()
{
ui->fibHeapView->deleteNode();
updateComponents();
}
void MainWindow::on_pushButton_DecreaseKey_clicked()
{
ui->fibHeapView->decreaseKey(ui->spinBox->value());
updateComponents();
}
void MainWindow::on_pushButton_SwitchHeap_clicked()
{
ui->fibHeapView->switchHeap();
updateComponents();
}
void MainWindow::on_pushButton_Union_clicked()
{
ui->fibHeapView->unionOperation();
updateComponents();
}
void MainWindow::on_pushButton_NextStep_clicked()
{
ui->fibHeapView->nextStep();
updateComponents();
}
void MainWindow::updateComponents()
{
bool enabled = !ui->fibHeapView->blockComponents();
ui->pushButton_Clear->setEnabled(enabled);
ui->pushButton_DecreaseKey->setEnabled(enabled);
ui->pushButton_Delete->setEnabled(enabled);
ui->pushButton_ExtractMin->setEnabled(enabled);
ui->pushButton_Insert->setEnabled(enabled);
ui->pushButton_NextStep->setEnabled(!enabled);
ui->pushButton_SwitchHeap->setEnabled(enabled);
ui->pushButton_Union->setEnabled(enabled);
ui->pushButton_ClearAll->setEnabled(enabled);
ui->menuFile->setEnabled(enabled);
}
void MainWindow::on_actionSave_Selected_Heap_triggered()
{
ui->fibHeapView->ExportHeap();
}
void MainWindow::on_actionLoad_To_selected_Heap_triggered()
{
ui->fibHeapView->ImportHeap();
}
void MainWindow::on_pushButton_Clear_clicked()
{
ui->fibHeapView->clearSelected();
}
void MainWindow::on_pushButton_ClearAll_clicked()
{
ui->fibHeapView->reset(); // reset = clearAll
}