From 2bf8ff0f593224ce73ba7cba76e22e783cb7ee72 Mon Sep 17 00:00:00 2001 From: "E. Kozlovskaya" Date: Tue, 5 Jan 2021 16:44:30 +0700 Subject: [PATCH] Add logick for user workers --- iFacility/administrationpanel.cpp | 2 +- iFacility/loginwindow.cpp | 4 ++-- iFacility/loginwindow.h | 1 + iFacility/workerpanel.cpp | 20 ++++++++++++++------ iFacility/workerpanel.h | 18 +++++++++++------- iFacility/workerpanel.ui | 14 +++++++++++++- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/iFacility/administrationpanel.cpp b/iFacility/administrationpanel.cpp index c8d6bbd..b2c15e6 100644 --- a/iFacility/administrationpanel.cpp +++ b/iFacility/administrationpanel.cpp @@ -28,7 +28,7 @@ AdministrationPanel::~AdministrationPanel() { void AdministrationPanel::setUser(User *user) { mUser = user; - ui->user->setText(user->getFullNameShortForm()); + ui->user->setText(tr("Hello, **%1**").arg(user->getFullNameShortForm())); ui->administrationGroup->setVisible(user->getUserType() == UserType::ADMINISTRATOR); } diff --git a/iFacility/loginwindow.cpp b/iFacility/loginwindow.cpp index 0f44e4c..32fd67e 100644 --- a/iFacility/loginwindow.cpp +++ b/iFacility/loginwindow.cpp @@ -44,8 +44,8 @@ void LoginWindow::doLogin() { QWidget *w; if (user->getUserType() == UserType::WORKER) { - QMessageBox::information(this, "Ok", "Ok"); - return; + w = new WorkerPanel(); + ((WorkerPanel*)w)->setUser(user); } else { w = new AdministrationPanel(); diff --git a/iFacility/loginwindow.h b/iFacility/loginwindow.h index 8bfda66..549a865 100644 --- a/iFacility/loginwindow.h +++ b/iFacility/loginwindow.h @@ -9,6 +9,7 @@ #include "registrationdialog.h" #include "administrationpanel.h" +#include "workerpanel.h" QT_BEGIN_NAMESPACE namespace Ui { class LoginWindow; } diff --git a/iFacility/workerpanel.cpp b/iFacility/workerpanel.cpp index 15c7123..e48e85b 100644 --- a/iFacility/workerpanel.cpp +++ b/iFacility/workerpanel.cpp @@ -1,14 +1,22 @@ #include "workerpanel.h" #include "ui_workerpanel.h" -WorkerPanel::WorkerPanel(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::WorkerPanel) -{ +WorkerPanel::WorkerPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::WorkerPanel) { ui->setupUi(this); + + upvm = new UserProfessionViewModel(this); + ui->userProfessions->setModel(upvm); + ui->userProfessions->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); } -WorkerPanel::~WorkerPanel() -{ +WorkerPanel::~WorkerPanel() { delete ui; + + delete upvm; +} + +void WorkerPanel::setUser(User *usr) { + mUser = usr; + upvm->setUser(mUser); + ui->user->setText(tr("Hello, **%1**").arg(mUser->getFullNameShortForm())); } diff --git a/iFacility/workerpanel.h b/iFacility/workerpanel.h index 0c7f138..d88aa7f 100644 --- a/iFacility/workerpanel.h +++ b/iFacility/workerpanel.h @@ -3,20 +3,24 @@ #include -namespace Ui { -class WorkerPanel; -} +#include "objects/user.h" +#include "viewmodels/userprofessionviewmodel.h" -class WorkerPanel : public QMainWindow -{ +namespace Ui { class WorkerPanel; } + +class WorkerPanel : public QMainWindow { +private: Q_OBJECT + Ui::WorkerPanel *ui; + UserProfessionViewModel *upvm; + User *mUser; + public: explicit WorkerPanel(QWidget *parent = nullptr); ~WorkerPanel(); -private: - Ui::WorkerPanel *ui; + void setUser(User *user); }; #endif // WORKERPANEL_H diff --git a/iFacility/workerpanel.ui b/iFacility/workerpanel.ui index 06ae59f..b852d5d 100644 --- a/iFacility/workerpanel.ui +++ b/iFacility/workerpanel.ui @@ -7,9 +7,21 @@ 0 0 651 - 415 + 272 + + + 651 + 272 + + + + + 651 + 272 + + MainWindow