Add logick for user workers

This commit is contained in:
E. Kozlovskaya 2021-01-05 16:44:30 +07:00
parent e7be0f23d6
commit 2bf8ff0f59
6 changed files with 42 additions and 17 deletions

View file

@ -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);
}

View file

@ -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();

View file

@ -9,6 +9,7 @@
#include "registrationdialog.h"
#include "administrationpanel.h"
#include "workerpanel.h"
QT_BEGIN_NAMESPACE
namespace Ui { class LoginWindow; }

View file

@ -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()));
}

View file

@ -3,20 +3,24 @@
#include <QMainWindow>
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

View file

@ -7,9 +7,21 @@
<x>0</x>
<y>0</y>
<width>651</width>
<height>415</height>
<height>272</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>651</width>
<height>272</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>651</width>
<height>272</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>