-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewprocessdialog.cpp
87 lines (83 loc) · 2.01 KB
/
newprocessdialog.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
#include "newprocessdialog.h"
#include "ui_newprocessdialog.h"
newProcessDialog::newProcessDialog(QString* pid,int* time,int* priority,bool* add,int* fatherID,priority_queue<PCB> readyQ,queue<PCB> jobQ,QWidget *parent) :
QDialog(parent),
ui(new Ui::newProcessDialog)
{
ui->setupUi(this);
this->pid = pid;
this->time = time;
this->priority = priority;
this->add = add;
this->fatherID = fatherID;
while(!readyQ.empty())
{
allP->push(readyQ.top());
readyQ.pop();
}
while(!jobQ.empty())
{
allP->push(jobQ.front());
jobQ.pop();
}
int i = 0;
while(!allP->empty())
{
if(i < 6)
ui->com_father->addItem(QString::fromStdString(allP->front().PID));
allPID.push_back(allP->front().PID);
allP->pop();
i++;
}
}
newProcessDialog::~newProcessDialog()
{
delete ui;
}
void newProcessDialog::on_btn_confirm_clicked()
{
QString pidt = ui->edit_pid->text();
int l = pidt.length();
if(l == 0)
{
QMessageBox::warning(this,"重新输入PID","PID不可为空");
return;
}
else if(l >= 64)
{
QMessageBox::warning(this,"重新输入PID","PID长度超出限制");
ui->edit_pid->clear();
return;
}
if(pidt == "无")
{
QMessageBox::warning(this,"重新输入PID","PID不可为\"无\"");
ui->edit_pid->clear();
return;
}
else if(repeatPID(pidt.toStdString()))
{
QMessageBox::warning(this,"重新输入PID","PID不可重复");
ui->edit_pid->clear();
return;
}
*pid = pidt;
*priority = ui->spin_priority->value();
*time = ui->spin_time->value();
*add = true;
*fatherID = ui->com_father->currentIndex();
this->done(0);
}
bool newProcessDialog::repeatPID(string s)
{
for(int i = 0;i < allPID.size();i++)
{
if(s == allPID.at(i))
return true;
}
return false;
}
void newProcessDialog::on_btn_cancel_clicked()
{
this->done(1);
}