-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
94 lines (79 loc) · 2.81 KB
/
Copy pathmainwindow.cpp
File metadata and controls
94 lines (79 loc) · 2.81 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "euser.h"
#include "eclient.h"
//#include "esupplier.h"
#include <QMessageBox>
#include <QCloseEvent>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
e_operator = 0;
supplier = 0;
client = 0;
admin = 0;
}
MainWindow::~MainWindow()
{
qDebug("MainWindow destructor");
delete e_operator;
delete supplier;
delete client;
delete admin;
delete ui;
}
void MainWindow::startP(long user_id)
{
EUser user(user_id);
qDebug()<<">> User"<<user.getName()<<"has been connected.";
if (user.getType() == EUser::CLIENT) {
client = new EClient(user);
this->setCentralWidget(client->window());
this->setWindowTitle(QString("Client : \"%1 %2\"").arg(client->getName()).arg(client->getlastname()));
this->resize(680, 270);
qDebug()<<">> CLIENT has been connected.";
} else if (user.getType() == EUser::AUTHOR) {
qDebug()<<">> AUTHOR has been connected.";
} else if (user.getType() == EUser::SUPPLIER) {
supplier = new ESupplier(user);
this->setCentralWidget(supplier->window());
this->setWindowTitle(QString("Supplier : \"%1 %2\"").arg(supplier->getName()).arg(supplier->getlastname()));
this->resize(700, 280);
qDebug()<<">> SUPPLIER has been connected.";
} else if (user.getType() == EUser::CEO) {
qDebug()<<">> CEO has been connected.";
} else if (user.getType() == EUser::OPERATOR) {
e_operator = new EOperator(user);
this->setCentralWidget(e_operator->window());
this->setWindowTitle(QString("Operator : \"%1 %2\"").arg(e_operator->getName()).arg(e_operator->getlastname()));
this->resize(780, 270);
qDebug()<<">> OPERATOR has been connected.";
} else if (EUser::ADMIN) {
admin = new EAdmin(user);
this->setCentralWidget(admin->window());
this->setWindowTitle(QString("Admin : \"%1 %2\"").arg(admin->getName()).arg(admin->getlastname()));
this->resize(550, 400);
qDebug()<<">> ADMIN has been connected.";
}
show();
}
//обработчик выхода
void MainWindow::closeEvent(QCloseEvent* event)
{
//выдаём сообщение
int result =QMessageBox::question(0, trUtf8("Питання"),
trUtf8("Ви точно хочете вийти з робочого місця?"),
QMessageBox::Ok, QMessageBox::Cancel);
//анализируем ответ
if (result == QMessageBox::Ok){
//выходим
emit exitWorkplace();
event->accept();
}
else{
//остаёмся
event->ignore();
}
}