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) {
|
||||
mUser = user;
|
||||
ui->user->setText(user->getFullNameShortForm());
|
||||
ui->user->setText(tr("Hello, **%1**").arg(user->getFullNameShortForm()));
|
||||
ui->administrationGroup->setVisible(user->getUserType() == UserType::ADMINISTRATOR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "registrationdialog.h"
|
||||
#include "administrationpanel.h"
|
||||
#include "workerpanel.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class LoginWindow; }
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue