Add logick for user workers
This commit is contained in:
parent
e7be0f23d6
commit
2bf8ff0f59
6 changed files with 42 additions and 17 deletions
|
|
@ -28,7 +28,7 @@ AdministrationPanel::~AdministrationPanel() {
|
||||||
|
|
||||||
void AdministrationPanel::setUser(User *user) {
|
void AdministrationPanel::setUser(User *user) {
|
||||||
mUser = user;
|
mUser = user;
|
||||||
ui->user->setText(user->getFullNameShortForm());
|
ui->user->setText(tr("Hello, **%1**").arg(user->getFullNameShortForm()));
|
||||||
ui->administrationGroup->setVisible(user->getUserType() == UserType::ADMINISTRATOR);
|
ui->administrationGroup->setVisible(user->getUserType() == UserType::ADMINISTRATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ void LoginWindow::doLogin() {
|
||||||
|
|
||||||
QWidget *w;
|
QWidget *w;
|
||||||
if (user->getUserType() == UserType::WORKER) {
|
if (user->getUserType() == UserType::WORKER) {
|
||||||
QMessageBox::information(this, "Ok", "Ok");
|
w = new WorkerPanel();
|
||||||
return;
|
((WorkerPanel*)w)->setUser(user);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
w = new AdministrationPanel();
|
w = new AdministrationPanel();
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "registrationdialog.h"
|
#include "registrationdialog.h"
|
||||||
#include "administrationpanel.h"
|
#include "administrationpanel.h"
|
||||||
|
#include "workerpanel.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class LoginWindow; }
|
namespace Ui { class LoginWindow; }
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,22 @@
|
||||||
#include "workerpanel.h"
|
#include "workerpanel.h"
|
||||||
#include "ui_workerpanel.h"
|
#include "ui_workerpanel.h"
|
||||||
|
|
||||||
WorkerPanel::WorkerPanel(QWidget *parent) :
|
WorkerPanel::WorkerPanel(QWidget *parent) : QMainWindow(parent), ui(new Ui::WorkerPanel) {
|
||||||
QMainWindow(parent),
|
|
||||||
ui(new Ui::WorkerPanel)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
upvm = new UserProfessionViewModel(this);
|
||||||
|
ui->userProfessions->setModel(upvm);
|
||||||
|
ui->userProfessions->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkerPanel::~WorkerPanel()
|
WorkerPanel::~WorkerPanel() {
|
||||||
{
|
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
|
delete upvm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkerPanel::setUser(User *usr) {
|
||||||
|
mUser = usr;
|
||||||
|
upvm->setUser(mUser);
|
||||||
|
ui->user->setText(tr("Hello, **%1**").arg(mUser->getFullNameShortForm()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,24 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
namespace Ui {
|
#include "objects/user.h"
|
||||||
class WorkerPanel;
|
#include "viewmodels/userprofessionviewmodel.h"
|
||||||
}
|
|
||||||
|
|
||||||
class WorkerPanel : public QMainWindow
|
namespace Ui { class WorkerPanel; }
|
||||||
{
|
|
||||||
|
class WorkerPanel : public QMainWindow {
|
||||||
|
private:
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Ui::WorkerPanel *ui;
|
||||||
|
UserProfessionViewModel *upvm;
|
||||||
|
User *mUser;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WorkerPanel(QWidget *parent = nullptr);
|
explicit WorkerPanel(QWidget *parent = nullptr);
|
||||||
~WorkerPanel();
|
~WorkerPanel();
|
||||||
|
|
||||||
private:
|
void setUser(User *user);
|
||||||
Ui::WorkerPanel *ui;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKERPANEL_H
|
#endif // WORKERPANEL_H
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,21 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>651</width>
|
<width>651</width>
|
||||||
<height>415</height>
|
<height>272</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</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">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue