-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
68 lines (60 loc) · 1.18 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "allocation.h"
#include <QString>
#include "entity.h"
#include "memory.h"
#include <QList>
Entity h(false);
Memory memo;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_add_clicked()
{
QString a = ui->address->text();
QString s =ui->size->text();
h.set_base_address(a.toInt());
h.set_size(s.toInt());
memo.push_element(h);
}
void MainWindow::on_initalize_clicked()
{
ui->out->setText(Memory::print(memo));
}
void MainWindow::on_process_add_clicked()
{
Entity pro(true);
QString a = ui->process_name->text();
QString s =ui->process_size->text();
pro.set_name(a);
pro.set_size(s.toInt());
if(ui->first->isChecked())
{
Allocation::FirstFit(memo,pro);
}
else if(ui->best->isChecked())
{
Allocation::BestFit(memo,pro);
}
else if(ui->worst->isChecked())
{
Allocation::WorstFit(memo,pro);
}
}
void MainWindow::on_reset_clicked()
{
memo.reset();
ui->out->clear();
}
void MainWindow::on_exit_clicked()
{
close();
}