mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
refact1
This commit is contained in:
45
LibInstructorsAndTrainees/trainees/computersLocations.cpp
Normal file
45
LibInstructorsAndTrainees/trainees/computersLocations.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "computersLocations.h"
|
||||
|
||||
ComputersLocations::ComputersLocations():
|
||||
locations(),
|
||||
computers(),
|
||||
listComputerInLocation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ComputersLocations::addComputer(QString computer, QString location)
|
||||
{
|
||||
if(!computers.contains(computer))
|
||||
{
|
||||
computers.append(computer);
|
||||
if(!locations.contains(location))
|
||||
locations.append(location);
|
||||
|
||||
computerInLocation comp = {computer, location};
|
||||
listComputerInLocation.append(comp);
|
||||
}
|
||||
}
|
||||
|
||||
QString ComputersLocations::getLocationOfComputer(QString computer)
|
||||
{
|
||||
for(computerInLocation compInLoc : listComputerInLocation)
|
||||
{
|
||||
if(computer == compInLoc.computer)
|
||||
return compInLoc.location;
|
||||
}
|
||||
return QString(QStringLiteral(""));
|
||||
}
|
||||
|
||||
QStringList ComputersLocations::getAllComputersOfLocation(QString location)
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
for(computerInLocation compInLoc : listComputerInLocation)
|
||||
{
|
||||
if(location == compInLoc.location)
|
||||
list.append(compInLoc.computer);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
46
LibInstructorsAndTrainees/trainees/computersLocations.h
Normal file
46
LibInstructorsAndTrainees/trainees/computersLocations.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef COMPUTERSLOCATIONS_H
|
||||
#define COMPUTERSLOCATIONS_H
|
||||
|
||||
#include <QStringList>
|
||||
#include "instructorsAndTrainees_global.h"
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT ComputersLocations
|
||||
{
|
||||
public:
|
||||
ComputersLocations();
|
||||
|
||||
struct computerInLocation
|
||||
{
|
||||
QString computer;
|
||||
QString location;
|
||||
};
|
||||
|
||||
void clear()
|
||||
{
|
||||
listComputerInLocation.clear();
|
||||
locations.clear();
|
||||
computers.clear();
|
||||
}
|
||||
|
||||
void addComputer(QString computer, QString location);
|
||||
|
||||
QStringList getAllLocations()
|
||||
{
|
||||
return locations;
|
||||
}
|
||||
|
||||
QStringList getAllComputers()
|
||||
{
|
||||
return computers;
|
||||
}
|
||||
|
||||
QString getLocationOfComputer(QString computer);
|
||||
QStringList getAllComputersOfLocation(QString location);
|
||||
|
||||
private:
|
||||
QStringList locations;
|
||||
QStringList computers;
|
||||
QList <computerInLocation> listComputerInLocation;
|
||||
};
|
||||
|
||||
#endif // COMPUTERSLOCATIONS_H
|
||||
32
LibInstructorsAndTrainees/trainees/dialogcardtrainee.cpp
Normal file
32
LibInstructorsAndTrainees/trainees/dialogcardtrainee.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "dialogcardtrainee.h"
|
||||
|
||||
DialogCardTrainee::DialogCardTrainee(ConnectorToServer* connectorToServer, MessangerController* messangerController,
|
||||
int id_trainee, AMMtasksWidget* ammTasksWidget_common, FIMtasksWidget* fimTasksWidget_common,
|
||||
QWidget *parent) :
|
||||
QDialog(parent,
|
||||
Qt::WindowSystemMenuHint
|
||||
| Qt::WindowMaximizeButtonHint
|
||||
| Qt::WindowMinimizeButtonHint
|
||||
| Qt::WindowCloseButtonHint),
|
||||
cardTrainee(nullptr)
|
||||
{
|
||||
cardTrainee = new PersonalCardTrainee(connectorToServer, messangerController,
|
||||
id_trainee, ammTasksWidget_common, fimTasksWidget_common, this);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(cardTrainee);
|
||||
this->setWindowTitle(tr("Personal card trainee"));
|
||||
this->setMinimumSize(1600, 800);
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
this->setModal(true);
|
||||
}
|
||||
|
||||
DialogCardTrainee::~DialogCardTrainee()
|
||||
{
|
||||
delete cardTrainee;
|
||||
}
|
||||
|
||||
void DialogCardTrainee::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
cardTrainee->close();
|
||||
}
|
||||
23
LibInstructorsAndTrainees/trainees/dialogcardtrainee.h
Normal file
23
LibInstructorsAndTrainees/trainees/dialogcardtrainee.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef DIALOGCARDTRAINEE_H
|
||||
#define DIALOGCARDTRAINEE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include "personalcardtrainee.h"
|
||||
|
||||
class DialogCardTrainee : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialogCardTrainee(ConnectorToServer* connectorToServer, MessangerController* messangerController,
|
||||
int id_trainee, AMMtasksWidget* ammTasksWidget_common, FIMtasksWidget* fimTasksWidget_common,
|
||||
QWidget *parent = nullptr);
|
||||
~DialogCardTrainee();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
PersonalCardTrainee* cardTrainee;
|
||||
};
|
||||
|
||||
#endif // DIALOGCARDTRAINEE_H
|
||||
59
LibInstructorsAndTrainees/trainees/dialogeditgroup.cpp
Normal file
59
LibInstructorsAndTrainees/trainees/dialogeditgroup.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include <QPushButton>
|
||||
#include <QRegExpValidator>
|
||||
#include "dialogeditgroup.h"
|
||||
#include "computersLocations.h"
|
||||
#include "ui_dialogeditgroup.h"
|
||||
|
||||
DialogEditGroup::DialogEditGroup(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogEditGroup),
|
||||
groupInput()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
}
|
||||
|
||||
DialogEditGroup::~DialogEditGroup()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogEditGroup::setGroup(Group group)
|
||||
{
|
||||
groupInput = group;
|
||||
|
||||
ui->editName->setText(group.getName());
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
|
||||
Group DialogEditGroup::getGroup()
|
||||
{
|
||||
Group group = groupInput;
|
||||
|
||||
group.setName(ui->editName->text());
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
void DialogEditGroup::on_editName_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditGroup::verify()
|
||||
{
|
||||
if(ui->editName->text().trimmed() == QStringLiteral(""))
|
||||
ui->btnOK->setEnabled(false);
|
||||
else
|
||||
ui->btnOK->setEnabled(true);
|
||||
}
|
||||
|
||||
void DialogEditGroup::on_btnOK_clicked()
|
||||
{
|
||||
this->accept();
|
||||
}
|
||||
38
LibInstructorsAndTrainees/trainees/dialogeditgroup.h
Normal file
38
LibInstructorsAndTrainees/trainees/dialogeditgroup.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef DIALOGEDITGROUP_H
|
||||
#define DIALOGEDITGROUP_H
|
||||
|
||||
#include <QDialog>
|
||||
//#include "ui_dialogeditgroup.h"
|
||||
#include "computersLocations.h"
|
||||
#include "group.h"
|
||||
|
||||
namespace Ui {
|
||||
class DialogEditGroup;
|
||||
}
|
||||
|
||||
class DialogEditGroup : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogEditGroup(QWidget *parent = nullptr);
|
||||
~DialogEditGroup();
|
||||
|
||||
void setGroup(Group group);
|
||||
Group getGroup();
|
||||
|
||||
private slots:
|
||||
void on_editName_textChanged(const QString &arg1);
|
||||
|
||||
void on_btnOK_clicked();
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
private:
|
||||
Ui::DialogEditGroup *ui;
|
||||
|
||||
Group groupInput;
|
||||
};
|
||||
|
||||
#endif // DIALOGEDITGROUP_H
|
||||
86
LibInstructorsAndTrainees/trainees/dialogeditgroup.ui
Normal file
86
LibInstructorsAndTrainees/trainees/dialogeditgroup.ui
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogEditGroup</class>
|
||||
<widget class="QDialog" name="DialogEditGroup">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>96</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Name">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Btn">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOK">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
145
LibInstructorsAndTrainees/trainees/dialogedittrainee.cpp
Normal file
145
LibInstructorsAndTrainees/trainees/dialogedittrainee.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
#include "dialogedittrainee.h"
|
||||
#include "ui_dialogedittrainee.h"
|
||||
#include "hashtools.h"
|
||||
#include <QPushButton>
|
||||
#include <QRegExpValidator>
|
||||
#include <QToolTip>
|
||||
|
||||
DialogEditTrainee::DialogEditTrainee(bool adminMode, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogEditTrainee),
|
||||
traineeInput(),
|
||||
flNeedHashPassword(false),
|
||||
adminMode(adminMode)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
|
||||
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||
ui->btnChangePassword->setObjectName("btnChangePassword");
|
||||
|
||||
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||
|
||||
ui->editPassword->setEnabled(false);
|
||||
//#ifndef PROJECT_TYPE_DEBUG
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
//#endif
|
||||
|
||||
ui->btnViewPassword->setEnabled(false);
|
||||
ui->btnChangePassword->setEnabled(false);
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
|
||||
DialogEditTrainee::~DialogEditTrainee()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogEditTrainee::setTrainee(Trainee trainee)
|
||||
{
|
||||
traineeInput = trainee;
|
||||
|
||||
ui->editName->setText(trainee.getName());
|
||||
ui->editLogin->setText(trainee.getLogin());
|
||||
ui->editPassword->setText(trainee.getPassword());
|
||||
|
||||
ui->checkArchived->setChecked(trainee.getArchived());
|
||||
ui->checkLoggedIn->setChecked(trainee.getLoggedIn());
|
||||
|
||||
if(trainee.getNeedSetPassword())
|
||||
{
|
||||
ui->editPassword->setEnabled(true);
|
||||
ui->btnViewPassword->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if(adminMode)
|
||||
ui->btnChangePassword->setEnabled(true);
|
||||
}
|
||||
|
||||
ui->btnOK->setEnabled(false);
|
||||
}
|
||||
|
||||
Trainee DialogEditTrainee::getTrainee()
|
||||
{
|
||||
Trainee trainee = traineeInput;
|
||||
|
||||
trainee.setName(ui->editName->text());
|
||||
trainee.setLogin(ui->editLogin->text());
|
||||
|
||||
if(flNeedHashPassword)
|
||||
{
|
||||
QString psw = ui->editPassword->text();
|
||||
psw = HashTools::hashingMD5string(psw);
|
||||
trainee.setPassword(psw);
|
||||
}
|
||||
else
|
||||
trainee.setPassword(ui->editPassword->text());
|
||||
|
||||
trainee.setArchived(ui->checkArchived->isChecked());
|
||||
trainee.setLoggedIn(ui->checkLoggedIn->isChecked());
|
||||
|
||||
return trainee;
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_editName_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_editLogin_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_editPassword_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditTrainee::verify()
|
||||
{
|
||||
if(ui->editName->text().trimmed() == QStringLiteral("") ||
|
||||
ui->editLogin->text().trimmed() == QStringLiteral("") ||
|
||||
ui->editPassword->text().trimmed() == QStringLiteral(""))
|
||||
ui->btnOK->setEnabled(false);
|
||||
else
|
||||
ui->btnOK->setEnabled(true);
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_btnOK_clicked()
|
||||
{
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_btnViewPassword_pressed()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Normal);
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_btnViewPassword_released()
|
||||
{
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_btnChangePassword_clicked()
|
||||
{
|
||||
ui->editPassword->setEnabled(true);
|
||||
ui->btnViewPassword->setEnabled(true);
|
||||
|
||||
ui->editPassword->setText("");
|
||||
flNeedHashPassword = true;
|
||||
|
||||
ui->editPassword->setFocus();
|
||||
}
|
||||
|
||||
void DialogEditTrainee::on_editLogin_inputRejected()
|
||||
{
|
||||
QToolTip::showText(QCursor::pos(),tr("Only Latin letters and numbers"));
|
||||
}
|
||||
52
LibInstructorsAndTrainees/trainees/dialogedittrainee.h
Normal file
52
LibInstructorsAndTrainees/trainees/dialogedittrainee.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef DIALOGEDITTRAINEE_H
|
||||
#define DIALOGEDITTRAINEE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "trainee.h"
|
||||
|
||||
namespace Ui {
|
||||
class DialogEditTrainee;
|
||||
}
|
||||
|
||||
class DialogEditTrainee : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogEditTrainee(bool adminMode, QWidget *parent = nullptr);
|
||||
~DialogEditTrainee();
|
||||
|
||||
void setTrainee(Trainee trainee);
|
||||
Trainee getTrainee();
|
||||
|
||||
private slots:
|
||||
void on_editName_textChanged(const QString &arg1);
|
||||
|
||||
void on_editLogin_textChanged(const QString &arg1);
|
||||
|
||||
void on_editPassword_textChanged(const QString &arg1);
|
||||
|
||||
void on_btnOK_clicked();
|
||||
|
||||
void on_btnViewPassword_pressed();
|
||||
|
||||
void on_btnViewPassword_released();
|
||||
|
||||
void on_btnChangePassword_clicked();
|
||||
|
||||
void on_editLogin_inputRejected();
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
private:
|
||||
Ui::DialogEditTrainee *ui;
|
||||
|
||||
Trainee traineeInput;
|
||||
|
||||
bool flNeedHashPassword;
|
||||
|
||||
bool adminMode;
|
||||
};
|
||||
|
||||
#endif // DIALOGEDITTRAINEE_H
|
||||
228
LibInstructorsAndTrainees/trainees/dialogedittrainee.ui
Normal file
228
LibInstructorsAndTrainees/trainees/dialogedittrainee.ui
Normal file
@@ -0,0 +1,228 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogEditTrainee</class>
|
||||
<widget class="QDialog" name="DialogEditTrainee">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>252</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Trainee</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editName">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editLogin">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnViewPassword">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/eye.png</normaloff>:/resources/icons/eye.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnChangePassword">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkArchived">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Archived</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/archive.png</normaloff>
|
||||
<disabledoff>:/resources/icons/archive.png</disabledoff>:/resources/icons/archive.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkLoggedIn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Online</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/circleGreen.png</normaloff>
|
||||
<disabledoff>:/resources/icons/circleGreen.png</disabledoff>:/resources/icons/circleGreen.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOK">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../InstructorsAndTrainees.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <QHBoxLayout>
|
||||
#include "dialogredactortrainees.h"
|
||||
|
||||
DialogRedactorTrainees::DialogRedactorTrainees(ConnectorToServer* connectorToServer,
|
||||
bool adminMode, QWidget *parent) :
|
||||
QDialog(parent,
|
||||
Qt::WindowSystemMenuHint
|
||||
| Qt::WindowMaximizeButtonHint
|
||||
| Qt::WindowMinimizeButtonHint
|
||||
| Qt::WindowCloseButtonHint),
|
||||
editorTraineesGroups(nullptr)
|
||||
{
|
||||
editorTraineesGroups = new EditorTrainees(connectorToServer, adminMode, this);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateDB, editorTraineesGroups, &EditorTrainees::slot_NeedUpdateUI);
|
||||
editorTraineesGroups->activate();
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(editorTraineesGroups);
|
||||
this->setWindowTitle(tr("Editor of trainees"));
|
||||
this->setMinimumSize(1400, 700);
|
||||
//this->setWindowState(Qt::WindowMaximized);
|
||||
this->setModal(true);
|
||||
}
|
||||
|
||||
DialogRedactorTrainees::~DialogRedactorTrainees()
|
||||
{
|
||||
delete editorTraineesGroups;
|
||||
}
|
||||
|
||||
void DialogRedactorTrainees::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
editorTraineesGroups->close();
|
||||
}
|
||||
22
LibInstructorsAndTrainees/trainees/dialogredactortrainees.h
Normal file
22
LibInstructorsAndTrainees/trainees/dialogredactortrainees.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef DIALOGREDACTORTRAINEES_H
|
||||
#define DIALOGREDACTORTRAINEES_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include "connectortoserver.h"
|
||||
#include "editortrainees.h"
|
||||
|
||||
class DialogRedactorTrainees : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialogRedactorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent = nullptr);
|
||||
~DialogRedactorTrainees();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
EditorTrainees* editorTraineesGroups;
|
||||
};
|
||||
|
||||
#endif // DIALOGREDACTORTRAINEES_H
|
||||
561
LibInstructorsAndTrainees/trainees/editortrainees.cpp
Normal file
561
LibInstructorsAndTrainees/trainees/editortrainees.cpp
Normal file
@@ -0,0 +1,561 @@
|
||||
#include <QMessageBox>
|
||||
#include "editortrainees.h"
|
||||
#include "ui_editortrainees.h"
|
||||
#include "dialogeditgroup.h"
|
||||
#include "dialogedittrainee.h"
|
||||
#include "specialmessagebox.h"
|
||||
|
||||
EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
ui(new Ui::EditorTrainees),
|
||||
dlgEditTrainee(nullptr),
|
||||
dlgEditGroup(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(treeWidget, &QTreeWidget::currentItemChanged, this, &EditorTrainees::on_treeWidgetCurrentItemChanged);
|
||||
|
||||
ui->verticalLayout_1->addWidget(treeWidget);
|
||||
|
||||
this->adminMode = adminMode;
|
||||
|
||||
preparationTreeWidget();
|
||||
//setNotLoggedInVisible(true);
|
||||
loadTraineesFromDB();
|
||||
|
||||
if(adminMode)
|
||||
ui->btnArchive->click();
|
||||
|
||||
waitAnimationWidget->setParent(this);
|
||||
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(false);
|
||||
ui->btnEdit->setEnabled(false);
|
||||
|
||||
authComplited = true;
|
||||
}
|
||||
|
||||
EditorTrainees::~EditorTrainees()
|
||||
{
|
||||
if(dlgEditTrainee)
|
||||
{
|
||||
dlgEditTrainee->close();
|
||||
delete dlgEditTrainee;
|
||||
dlgEditTrainee = nullptr;
|
||||
}
|
||||
|
||||
if(dlgEditGroup)
|
||||
{
|
||||
dlgEditGroup->close();
|
||||
delete dlgEditGroup;
|
||||
dlgEditGroup = nullptr;
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EditorTrainees::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(dlgEditTrainee)
|
||||
dlgEditTrainee->close();
|
||||
|
||||
if(dlgEditGroup)
|
||||
dlgEditGroup->close();
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnNewGroup_clicked()
|
||||
{
|
||||
Group group;
|
||||
Group group_edit;
|
||||
|
||||
if(editGroup(group, &group_edit))
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_GROUP, 0, &group_edit);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnDeleteGroup_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
int id_group = treeItemCurrent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
|
||||
{
|
||||
SpecMsgBox::CriticalClose(this, tr("The group is not empty.\nIt is not possible to delete a non-empty group."));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{//Пустая группа
|
||||
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnNewTrainee_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа. Можно добавить Обучаемого
|
||||
int id_group = treeItemCurrent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
Trainee trainee;
|
||||
Trainee trainee_edit;
|
||||
|
||||
trainee.setNeedSetPassword(true);
|
||||
|
||||
if(editTrainee(trainee, &trainee_edit))
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group, &trainee_edit);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnDeleteTrainee_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent != nullptr)
|
||||
{//Выбран обучаемый
|
||||
|
||||
int id_trainee = treeItemCurrent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
int id_group = treeItemParent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in trainee."));
|
||||
return;
|
||||
}
|
||||
|
||||
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent != nullptr)
|
||||
{//Выбран обучаемый
|
||||
|
||||
int id_trainee = treeItemCurrent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
Trainee trainee = connectorToServer->getTrainee(id_trainee);
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
{//Архивный
|
||||
trainee.setArchived(false);
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee);
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in trainee."));
|
||||
return;
|
||||
}
|
||||
|
||||
trainee.setArchived(true);
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee);
|
||||
if(!archiveVisible)
|
||||
ui->btnArchive->click();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnEdit_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent == nullptr)
|
||||
return;
|
||||
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
|
||||
int id_group = treeItemCurrent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
Group group = connectorToServer->getGroup(id_group);
|
||||
if(group.getID() == 0)
|
||||
return;
|
||||
|
||||
Group group_edit;
|
||||
|
||||
if(editGroup(group, &group_edit))
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_GROUP, id_group, &group_edit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Выбран обучаемый
|
||||
|
||||
int id_trainee = treeItemCurrent->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in trainee."));
|
||||
return;
|
||||
}
|
||||
|
||||
Trainee trainee = connectorToServer->getTrainee(id_trainee);
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
Trainee trainee_edit;
|
||||
|
||||
if(editTrainee(trainee, &trainee_edit))
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee_edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnArchive_clicked()
|
||||
{
|
||||
bool state = ui->btnArchive->isChecked();
|
||||
setArchiveVisible(state);
|
||||
if(!state)
|
||||
{
|
||||
if(typeObject == TypeObject::objTrainee)
|
||||
{
|
||||
Trainee trainee = connectorToServer->getTrainee(lastCurrentID);
|
||||
if(trainee.getID())
|
||||
{
|
||||
if(trainee.getArchived())
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
}
|
||||
else if(typeObject == TypeObject::objGroup)
|
||||
{
|
||||
Group group = connectorToServer->getGroup(lastCurrentID);
|
||||
if(group.getID())
|
||||
{}
|
||||
else
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
}
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
|
||||
void EditorTrainees::on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
//Определяем доступность и функционал кнопок для выбранного элемента
|
||||
|
||||
if(current == nullptr)
|
||||
{
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(false);
|
||||
ui->btnEdit->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *treeItemParent = current->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
int id_group = current->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
lastCurrentID = id_group;
|
||||
typeObject = TypeObject::objGroup;
|
||||
|
||||
if(adminMode)
|
||||
{
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
|
||||
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
|
||||
{//Группа не пуста
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{//Группа пуста
|
||||
ui->btnDeleteGroup->setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnNewGroup->setEnabled(false);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->btnNewTrainee->setEnabled(true);
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(false);
|
||||
ui->btnEdit->setEnabled(true);
|
||||
ui->btnArchive->setEnabled(true);
|
||||
|
||||
ui->btnToOrFromArchiveTrainee->setText(tr("To archive"));
|
||||
ui->btnToOrFromArchiveTrainee->setIcon(QIcon(QStringLiteral(":/resources/icons/traineeArchive.png")));
|
||||
}
|
||||
else
|
||||
{//Выбран обучаемый
|
||||
int id_trainee = current->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
lastCurrentID = id_trainee;
|
||||
typeObject = TypeObject::objTrainee;
|
||||
|
||||
ui->btnNewGroup->setEnabled(false);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
{//Архивный
|
||||
//ui->btnDeleteTrainee->setEnabled(true);
|
||||
|
||||
ui->btnToOrFromArchiveTrainee->setText(tr("From archive"));
|
||||
ui->btnToOrFromArchiveTrainee->setIcon(QIcon(QStringLiteral(":/resources/icons/traineeFromArchive.png")));
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
//ui->btnDeleteTrainee->setEnabled(false);
|
||||
|
||||
ui->btnToOrFromArchiveTrainee->setText(tr("To archive"));
|
||||
ui->btnToOrFromArchiveTrainee->setIcon(QIcon(QStringLiteral(":/resources/icons/traineeArchive.png")));
|
||||
}
|
||||
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Это залогированный! Удалять/Архивировать/Редактировать нельзя!
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(false);
|
||||
ui->btnEdit->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnToOrFromArchiveTrainee->setEnabled(true);
|
||||
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
ui->btnDeleteTrainee->setEnabled(true);
|
||||
else
|
||||
ui->btnDeleteTrainee->setEnabled(false);
|
||||
|
||||
ui->btnEdit->setEnabled(true);
|
||||
}
|
||||
|
||||
//ui->btnToOrFromArchiveTrainee->setEnabled(true);
|
||||
|
||||
//ui->btnEdit->setEnabled(true);
|
||||
ui->btnArchive->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorTrainees::verifyGroup(Group group)
|
||||
{
|
||||
//Проверка корректности имени
|
||||
|
||||
if(group.getName() == QStringLiteral("<group>"))
|
||||
{//Имя не корректно!
|
||||
SpecMsgBox::CriticalClose(this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Group> listGroups = connectorToServer->getListGroups();
|
||||
|
||||
for(Group exist_group : listGroups)
|
||||
{
|
||||
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
|
||||
{//Имя уже существует
|
||||
SpecMsgBox::CriticalClose(this, tr("An existing group name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTrainees::verifyTrainee(Trainee trainee)
|
||||
{
|
||||
//Проверка корректности логина, имени, пароля
|
||||
|
||||
if(trainee.getName() == QStringLiteral("<name>"))
|
||||
{//Имя не корректно!
|
||||
SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int user_I = connectorToServer->getIdInstructorByLogin(trainee.getLogin());
|
||||
int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin());
|
||||
if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID())))
|
||||
{//Логин уже существует!
|
||||
SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTrainees::editGroup(Group group, Group *group_edit)
|
||||
{
|
||||
dlgEditGroup = new DialogEditGroup(this);
|
||||
dlgEditGroup->setWindowFlags(dlgEditGroup->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
dlgEditGroup->setGroup(group);
|
||||
|
||||
bool flStop = false;
|
||||
bool res = false;
|
||||
|
||||
while (!flStop)
|
||||
{
|
||||
switch( dlgEditGroup->exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*group_edit = dlgEditGroup->getGroup();
|
||||
|
||||
if(! verifyGroup(*group_edit))
|
||||
{
|
||||
dlgEditGroup->setGroup(*group_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
flStop = true;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
default:
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dlgEditGroup)
|
||||
{
|
||||
delete dlgEditGroup;
|
||||
dlgEditGroup = nullptr;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
|
||||
{
|
||||
dlgEditTrainee = new DialogEditTrainee(adminMode, this);
|
||||
dlgEditTrainee->setWindowFlags(dlgEditTrainee->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
dlgEditTrainee->setTrainee(trainee);
|
||||
|
||||
bool flStop = false;
|
||||
bool res = false;
|
||||
|
||||
while (!flStop)
|
||||
{
|
||||
switch( dlgEditTrainee->exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*trainee_edit = dlgEditTrainee->getTrainee();
|
||||
|
||||
if(! verifyTrainee(*trainee_edit))
|
||||
{
|
||||
dlgEditTrainee->setTrainee(*trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(trainee_edit->getNeedSetPassword())
|
||||
{
|
||||
//Хэшируем пароль
|
||||
trainee_edit->hashingPassword();
|
||||
trainee_edit->setNeedSetPassword(false);
|
||||
}
|
||||
|
||||
flStop = true;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
default:
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dlgEditTrainee)
|
||||
{
|
||||
delete dlgEditTrainee;
|
||||
dlgEditTrainee = nullptr;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
54
LibInstructorsAndTrainees/trainees/editortrainees.h
Normal file
54
LibInstructorsAndTrainees/trainees/editortrainees.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef DIALOGTRAINEESGROUPS_H
|
||||
#define DIALOGTRAINEESGROUPS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTreeWidget>
|
||||
#include "traineesview.h"
|
||||
//#include "computersLocations.h"
|
||||
#include "dialogedittrainee.h"
|
||||
#include "dialogeditgroup.h"
|
||||
#include "specialmessagebox.h"
|
||||
|
||||
namespace Ui {
|
||||
class EditorTrainees;
|
||||
}
|
||||
|
||||
//Виджет для редактирования БД Обучаемых
|
||||
|
||||
class EditorTrainees : public TraineesView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent = nullptr);
|
||||
~EditorTrainees();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_btnNewGroup_clicked();
|
||||
void on_btnDeleteGroup_clicked();
|
||||
void on_btnNewTrainee_clicked();
|
||||
void on_btnDeleteTrainee_clicked();
|
||||
void on_btnToOrFromArchiveTrainee_clicked();
|
||||
void on_btnEdit_clicked();
|
||||
void on_btnArchive_clicked();
|
||||
void on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
//void setCurrentGroup(int id);
|
||||
//void setCurrentTrainee(int id);
|
||||
bool verifyGroup(Group group);
|
||||
bool verifyTrainee(Trainee trainee);
|
||||
|
||||
bool editGroup(Group group, Group* group_edit);
|
||||
bool editTrainee(Trainee trainee, Trainee* trainee_edit);
|
||||
|
||||
private:
|
||||
Ui::EditorTrainees *ui;
|
||||
|
||||
DialogEditTrainee* dlgEditTrainee;
|
||||
DialogEditGroup* dlgEditGroup;
|
||||
};
|
||||
|
||||
#endif // DIALOGTRAINEESGROUPS_H
|
||||
325
LibInstructorsAndTrainees/trainees/editortrainees.ui
Normal file
325
LibInstructorsAndTrainees/trainees/editortrainees.ui
Normal file
@@ -0,0 +1,325 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditorTrainees</class>
|
||||
<widget class="QWidget" name="EditorTrainees">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1300</width>
|
||||
<height>800</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>List trainees</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnNewGroup">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New group</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/newGroup.png</normaloff>:/resources/icons/newGroup.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDeleteGroup">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete group</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/deleteGroup.png</normaloff>:/resources/icons/deleteGroup.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnNewTrainee">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New trainee</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/addTrainee.png</normaloff>:/resources/icons/addTrainee.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDeleteTrainee">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete trainee</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/deleteTrainee.png</normaloff>:/resources/icons/deleteTrainee.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnToOrFromArchiveTrainee">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To archive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/traineeArchive.png</normaloff>:/resources/icons/traineeArchive.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/edit.png</normaloff>:/resources/icons/edit.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnArchive">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>55</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show archive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/archive.png</normaloff>:/resources/icons/archive.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
128
LibInstructorsAndTrainees/trainees/personalcardtrainee.cpp
Normal file
128
LibInstructorsAndTrainees/trainees/personalcardtrainee.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include "personalcardtrainee.h"
|
||||
#include "ui_personalcardtrainee.h"
|
||||
|
||||
PersonalCardTrainee::PersonalCardTrainee(ConnectorToServer* connectorToServer, MessangerController* messangerController, int id_trainee, AMMtasksWidget* ammTasksWidgetIn, FIMtasksWidget* fimTasksWidgetIn, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
connectorToServer(connectorToServer),
|
||||
messangerController(messangerController),
|
||||
id_trainee(id_trainee),
|
||||
ammTasksWidget_personal(nullptr),
|
||||
fimTasksWidget_personal(nullptr),
|
||||
ammTasksWidget_common(ammTasksWidgetIn),
|
||||
fimTasksWidget_common(fimTasksWidgetIn),
|
||||
messangerWidget(nullptr),
|
||||
ui(new Ui::PersonalCardTrainee)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
loadInfo();
|
||||
|
||||
ui->lblName->setObjectName("PersonalCard_lblName");
|
||||
|
||||
ui->lblLoginIn->setVisible(false);
|
||||
|
||||
ammTasksWidget_personal = new AMMtasksWidget(connectorToServer, TypeListTreeAMMFIM::listForTrainee, this);
|
||||
fimTasksWidget_personal = new FIMtasksWidget(connectorToServer, TypeListTreeAMMFIM::listForTrainee, this);
|
||||
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateTasksAMMforTrainee, ammTasksWidget_personal, &AMMtasksWidget::slot_UpdateTasksAMMforTrainee);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateTasksFIMforTrainee, fimTasksWidget_personal, &FIMtasksWidget::slot_UpdateTasksFIMforTrainee);
|
||||
|
||||
connect(ammTasksWidget_personal, &AMMtasksWidget::signal_countTasksAMMforTraineeChanged, this, &PersonalCardTrainee::slot_countTasksAMMforTraineeChanged);
|
||||
connect(fimTasksWidget_personal, &FIMtasksWidget::signal_countTasksFIMforTraineeChanged, this, &PersonalCardTrainee::slot_countTasksFIMforTraineeChanged);
|
||||
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateDB, this, &PersonalCardTrainee::slot_NeedUpdateUI);
|
||||
|
||||
fimTasksWidget_personal->slot_traineeSelected(id_trainee);
|
||||
ammTasksWidget_personal->slot_traineeSelected(id_trainee);
|
||||
|
||||
ui->verticalLayout_AMMpersonal->addWidget(ammTasksWidget_personal);
|
||||
ui->verticalLayout_FIMpersonal->addWidget(fimTasksWidget_personal);
|
||||
|
||||
ui->verticalLayout_AMMcommon->addWidget(ammTasksWidget_common);
|
||||
ui->verticalLayout_FIMcommon->addWidget(fimTasksWidget_common);
|
||||
|
||||
ui->groupBox_Messenger->setMaximumWidth(500);
|
||||
ui->groupBox_Messenger->setMinimumWidth(500);
|
||||
|
||||
ui->groupBox_Messenger->setMinimumHeight(400);
|
||||
|
||||
ammTasksWidget_personal->setMinimumWidth(700);
|
||||
fimTasksWidget_personal->setMinimumWidth(700);
|
||||
|
||||
/* Messanger*/
|
||||
Trainee trainee = connectorToServer->getTrainee(id_trainee);
|
||||
messangerWidget = messangerController->newWidget(this, &trainee, ui->verticalLayout_Messenger);
|
||||
}
|
||||
|
||||
PersonalCardTrainee::~PersonalCardTrainee()
|
||||
{
|
||||
if(ammTasksWidget_personal)
|
||||
{
|
||||
delete ammTasksWidget_personal;
|
||||
ammTasksWidget_personal = nullptr;
|
||||
}
|
||||
|
||||
if(fimTasksWidget_personal)
|
||||
{
|
||||
delete fimTasksWidget_personal;
|
||||
fimTasksWidget_personal = nullptr;
|
||||
}
|
||||
|
||||
messangerController->deleteWidget(messangerWidget);
|
||||
|
||||
//ui->verticalLayout_AMMcommon->removeWidget(ammTasksWidget_common);
|
||||
//ui->verticalLayout_FIMcommon->removeWidget(fimTasksWidget_common);
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PersonalCardTrainee::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
fimTasksWidget_personal->closeChildDlg();
|
||||
fimTasksWidget_common->closeChildDlg();
|
||||
|
||||
ammTasksWidget_personal->closeChildDlg();
|
||||
ammTasksWidget_common->closeChildDlg();
|
||||
}
|
||||
|
||||
void PersonalCardTrainee::loadInfo()
|
||||
{
|
||||
Trainee trainee = connectorToServer->getTrainee(id_trainee);
|
||||
|
||||
ui->lblName->setText(trainee.getName());
|
||||
|
||||
if(trainee.getLoggedIn())
|
||||
ui->lblLoginIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
else
|
||||
ui->lblLoginIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
|
||||
TimingOfTrainee timing = trainee.getTiming();
|
||||
|
||||
ui->lblTimeOperation->setText(timing.getOperatingTimeS());
|
||||
ui->lblLoginTime->setText(timing.getEntryTimeS());
|
||||
ui->lblTimeExit->setText(timing.getExitTimeS());
|
||||
}
|
||||
|
||||
void PersonalCardTrainee::slot_countTasksAMMforTraineeChanged(int trainee_id, int count)
|
||||
{
|
||||
if(id_trainee == trainee_id)
|
||||
{
|
||||
ui->lblCntAMM->setText(QString::number(count));
|
||||
}
|
||||
}
|
||||
|
||||
void PersonalCardTrainee::slot_countTasksFIMforTraineeChanged(int trainee_id, int count)
|
||||
{
|
||||
if(id_trainee == trainee_id)
|
||||
{
|
||||
ui->lblCntFIM->setText(QString::number(count));
|
||||
}
|
||||
}
|
||||
|
||||
void PersonalCardTrainee::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
{
|
||||
if(treeTrainee)
|
||||
{
|
||||
loadInfo();
|
||||
}
|
||||
}
|
||||
51
LibInstructorsAndTrainees/trainees/personalcardtrainee.h
Normal file
51
LibInstructorsAndTrainees/trainees/personalcardtrainee.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef PERSONALCARDTRAINEE_H
|
||||
#define PERSONALCARDTRAINEE_H
|
||||
|
||||
#include"connectortoserver.h"
|
||||
#include "ammtaskswidget.h"
|
||||
#include "fimtaskswidget.h"
|
||||
#include "messangerwidget.h"
|
||||
#include "messangercontroller.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class PersonalCardTrainee;
|
||||
}
|
||||
|
||||
class PersonalCardTrainee : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PersonalCardTrainee(ConnectorToServer* connectorToServer, MessangerController* messangerController, int id_trainee, AMMtasksWidget* ammTasksWidget_common, FIMtasksWidget* fimTasksWidget_common, QWidget *parent = nullptr);
|
||||
~PersonalCardTrainee();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
void loadInfo();
|
||||
|
||||
public slots:
|
||||
void slot_countTasksAMMforTraineeChanged(int trainee_id, int count);
|
||||
void slot_countTasksFIMforTraineeChanged(int trainee_id, int count);
|
||||
|
||||
void slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
private:
|
||||
ConnectorToServer* connectorToServer;
|
||||
MessangerController* messangerController;
|
||||
int id_trainee;
|
||||
|
||||
AMMtasksWidget* ammTasksWidget_personal;
|
||||
FIMtasksWidget* fimTasksWidget_personal;
|
||||
|
||||
AMMtasksWidget* ammTasksWidget_common;
|
||||
FIMtasksWidget* fimTasksWidget_common;
|
||||
|
||||
MessangerWidget* messangerWidget;
|
||||
|
||||
private:
|
||||
Ui::PersonalCardTrainee *ui;
|
||||
};
|
||||
|
||||
#endif // PERSONALCARDTRAINEE_H
|
||||
303
LibInstructorsAndTrainees/trainees/personalcardtrainee.ui
Normal file
303
LibInstructorsAndTrainees/trainees/personalcardtrainee.ui
Normal file
@@ -0,0 +1,303 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PersonalCardTrainee</class>
|
||||
<widget class="QWidget" name="PersonalCardTrainee">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1125</width>
|
||||
<height>764</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_TraineeChat">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Trainee">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Trainee</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_AssAMM">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Assigned AMM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCntAMM">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Name">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblLoginIn">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Simulator">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>Time spent on the simulator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblTimeOperation">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Exit">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Last exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblTimeExit">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Line" name="line_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_AssFIM">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Assigned FIM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCntFIM">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Login">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Last login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblLoginTime">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Messenger">
|
||||
<property name="title">
|
||||
<string>Chat</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Messenger"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Tasks">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Tasks</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_AMM">
|
||||
<attribute name="title">
|
||||
<string>AMM</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_AMM">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_AMM">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_AMMcommon">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="text">
|
||||
<string>List</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_AMMpersonal">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Attached</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_FIM">
|
||||
<attribute name="title">
|
||||
<string>FIM</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_FIM">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_FIM">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_FIMcommon">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>List</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_FIMpersonal">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Attached</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../InstructorsAndTrainees.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
202
LibInstructorsAndTrainees/trainees/traineesview.cpp
Normal file
202
LibInstructorsAndTrainees/trainees/traineesview.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
#include <QHeaderView>
|
||||
#include <QResizeEvent>
|
||||
#include "traineesview.h"
|
||||
|
||||
TraineesView::TraineesView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
CommonView(connectorToServer, type, parent)
|
||||
{
|
||||
typeObject = TypeObject::objTrainee;
|
||||
TypeUserDB = User::TypeUserDBTrainee;
|
||||
}
|
||||
|
||||
void TraineesView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
{
|
||||
updateButtons();
|
||||
|
||||
if(authComplited)
|
||||
{
|
||||
if(treeTrainee)
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
}
|
||||
|
||||
void TraineesView::loadTraineesFromDB()
|
||||
{
|
||||
mtxTreeWidget.lock();
|
||||
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
QList <Group> listGroups;
|
||||
QList <Trainee> listTrainees;
|
||||
|
||||
listGroups = connectorToServer->getListGroups();
|
||||
listTrainees = connectorToServer->getListTrainees();
|
||||
|
||||
|
||||
for(Group group : listGroups)
|
||||
{
|
||||
//Группа
|
||||
int cntChildsNotArchived = 0;
|
||||
QTreeWidgetItem *ItemGroup = new QTreeWidgetItem(treeWidget);
|
||||
ItemGroup->setText(ColumnsTreeUsers::clmn_ID, QString::number(group.getID()));
|
||||
ItemGroup->setText(ColumnsTreeUsers::clmn_Name, group.getName());
|
||||
ItemGroup->setIcon(ColumnsTreeUsers::clmn_Name, QIcon(QStringLiteral(":/resources/icons/group.png")));
|
||||
setItemColor(ItemGroup, QColor(220, 220, 220));
|
||||
|
||||
|
||||
//Обучаемые
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getGroup().getID() != group.getID())
|
||||
continue;
|
||||
|
||||
QTreeWidgetItem *ItemTrainee = new QTreeWidgetItem();
|
||||
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_ID, QString::number(trainee.getID()));
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Name, trainee.getName());
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Login, trainee.getLogin());
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Password, trainee.getPassword());
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Class, trainee.getComputer().getClassroom().getName());
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Computer, trainee.getComputer().getName());
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_IP_address, trainee.getComputer().getIpAddress());
|
||||
|
||||
//Сокрытие пароля
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Password, QStringLiteral("******"));
|
||||
|
||||
if(trainee.getArchived())
|
||||
{//Архивный
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Archived, tr("yes"));
|
||||
ItemTrainee->setIcon(ColumnsTreeUsers::clmn_Name, QIcon(QStringLiteral(":/resources/icons/archive.png")));
|
||||
setItemColorArchive(ItemTrainee);
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
ItemTrainee->setText(ColumnsTreeUsers::clmn_Archived, tr("no"));
|
||||
ItemTrainee->setIcon(ColumnsTreeUsers::clmn_Name, QIcon(QStringLiteral(":/resources/icons/trainee.png")));
|
||||
setItemColorNoArchive(ItemTrainee);
|
||||
cntChildsNotArchived++;
|
||||
}
|
||||
|
||||
if(trainee.getLoggedIn())
|
||||
{//Залогинен
|
||||
//ItemTrainee->setText(ColumnsTreeUsers::clmn_Logged, tr("yes"));
|
||||
ItemTrainee->setIcon(ColumnsTreeUsers::clmn_Logged, QIcon(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{//Не Залогинен
|
||||
//ItemTrainee->setText(ColumnsTreeUsers::clmn_Logged, tr("no"));
|
||||
ItemTrainee->setIcon(ColumnsTreeUsers::clmn_Logged, QIcon(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
ItemGroup->addChild(ItemTrainee);
|
||||
|
||||
//Скрываем архивных (при необходимости)
|
||||
if(trainee.getArchived())
|
||||
if(! archiveVisible)
|
||||
ItemTrainee->setHidden(true);
|
||||
|
||||
//Скрываем незалогиненых (при необходимости)
|
||||
if(! trainee.getLoggedIn())
|
||||
if(! notLoggedInVisible)
|
||||
ItemTrainee->setHidden(true);
|
||||
|
||||
mtxmapNewMsg.lock();
|
||||
if(mapNewMsg.contains(trainee.getID()))
|
||||
{//Есть непрочитанные сообщения от него
|
||||
if(mapNewMsg.value(trainee.getID()))
|
||||
{
|
||||
if(lastCurrentID == trainee.getID())
|
||||
mapNewMsg.take(lastCurrentID);
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < ColumnsTreeUsers::clmn_count; i++)
|
||||
{
|
||||
ItemTrainee->setBackground(i, QBrush(QColor(250, 210, 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mtxmapNewMsg.unlock();
|
||||
}
|
||||
|
||||
//if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
//delete ItemGroup;
|
||||
}
|
||||
|
||||
treeWidget->expandAll();
|
||||
|
||||
/*
|
||||
//if(typeView == TypeView::control)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
{
|
||||
QTreeWidgetItem * itemChild = item->child(0);
|
||||
if(itemChild != nullptr)
|
||||
treeWidget->setCurrentItem(itemChild);
|
||||
}
|
||||
}*/
|
||||
|
||||
if(typeObject == TypeObject::objGroup)
|
||||
setCurrentGroup(lastCurrentID);
|
||||
else
|
||||
setCurrentTrainee(lastCurrentID);
|
||||
|
||||
treeWidget->sortItems(ColumnsTreeUsers::clmn_Name, Qt::SortOrder::AscendingOrder);
|
||||
|
||||
mtxTreeWidget.unlock();
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void TraineesView::setCurrentGroup(int id)
|
||||
{
|
||||
typeObject = TypeObject::objGroup;
|
||||
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeUsers::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
*/
|
||||
}
|
||||
|
||||
void TraineesView::setCurrentTrainee(int id)
|
||||
{
|
||||
typeObject = TypeObject::objTrainee;
|
||||
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
{
|
||||
for (int j = 0; j < item->childCount(); j++)
|
||||
{
|
||||
QTreeWidgetItem * itemChild = item->child(j);
|
||||
if(itemChild != nullptr)
|
||||
if(itemChild->text(ColumnsTreeUsers::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(itemChild);
|
||||
return;
|
||||
}
|
||||
}//for (int j = 0; j < item->childCount(); j++)
|
||||
}
|
||||
}//for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
|
||||
/*
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
*/
|
||||
}
|
||||
27
LibInstructorsAndTrainees/trainees/traineesview.h
Normal file
27
LibInstructorsAndTrainees/trainees/traineesview.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef TRAINEESVIEW_H
|
||||
#define TRAINEESVIEW_H
|
||||
|
||||
#include "instructorsAndTrainees_global.h"
|
||||
#include "commonview.h"
|
||||
|
||||
//Родительский класс представления БД Обучаемых (для просмотра и управления)
|
||||
|
||||
class TraineesView: public CommonView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TraineesView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent = nullptr);
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки сигнала необходимости обновления интерфейса
|
||||
void slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
protected:
|
||||
virtual void updateButtons(){};
|
||||
void loadTraineesFromDB();
|
||||
void setCurrentGroup(int id);
|
||||
void setCurrentTrainee(int id);
|
||||
};
|
||||
|
||||
#endif // TRAINEESVIEW_H
|
||||
236
LibInstructorsAndTrainees/trainees/viewertrainees.cpp
Normal file
236
LibInstructorsAndTrainees/trainees/viewertrainees.cpp
Normal file
@@ -0,0 +1,236 @@
|
||||
#include "editortrainees.h"
|
||||
#include "viewertrainees.h"
|
||||
#include "personalcardtrainee.h"
|
||||
#include "dialogcardtrainee.h"
|
||||
#include "ui_viewertrainees.h"
|
||||
|
||||
ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, MessangerController* messangerController, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::onlyView, parent),
|
||||
ammTasksWidgetCommon(nullptr),
|
||||
fimTasksWidgetCommon(nullptr),
|
||||
messangerController(messangerController),
|
||||
dlgRedactor(nullptr),
|
||||
dlgCardTrainee(nullptr),
|
||||
ui(new Ui::ViewerTrainees)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(treeWidget, &QTreeWidget::itemDoubleClicked, this, &ViewerTrainees::on_itemDoubleClicked);
|
||||
connect(treeWidget, &QTreeWidget::itemClicked, this, &ViewerTrainees::on_treeWidgetItemClicked);
|
||||
|
||||
ui->horizontalLayout_1->addWidget(treeWidget);
|
||||
|
||||
ammTasksWidgetCommon = new AMMtasksWidget(connectorToServer, TypeListTreeAMMFIM::listCommon, /*this*/nullptr);
|
||||
fimTasksWidgetCommon = new FIMtasksWidget(connectorToServer, TypeListTreeAMMFIM::listCommon, /*this*/nullptr);
|
||||
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateTasksFIM, fimTasksWidgetCommon, &FIMtasksWidget::slot_NeedUpdateUI);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateTasksAMM, ammTasksWidgetCommon, &AMMtasksWidget::slot_NeedUpdateUI);
|
||||
connect(this, &ViewerTrainees::signal_traineeSelected, fimTasksWidgetCommon, &FIMtasksWidget::slot_traineeSelected);
|
||||
connect(this, &ViewerTrainees::signal_traineeSelected, ammTasksWidgetCommon, &AMMtasksWidget::slot_traineeSelected);
|
||||
|
||||
preparationTreeWidget();
|
||||
setNotLoggedInVisible(true);
|
||||
|
||||
ui->btnEditorTrainees->setVisible(false);
|
||||
}
|
||||
|
||||
ViewerTrainees::~ViewerTrainees()
|
||||
{
|
||||
if(ammTasksWidgetCommon)
|
||||
{
|
||||
delete ammTasksWidgetCommon;
|
||||
ammTasksWidgetCommon = nullptr;
|
||||
}
|
||||
|
||||
if(fimTasksWidgetCommon)
|
||||
{
|
||||
delete fimTasksWidgetCommon;
|
||||
fimTasksWidgetCommon = nullptr;
|
||||
}
|
||||
|
||||
if(dlgRedactor)
|
||||
{
|
||||
dlgRedactor->close();
|
||||
delete dlgRedactor;
|
||||
dlgRedactor = nullptr;
|
||||
}
|
||||
|
||||
if(dlgCardTrainee)
|
||||
dlgCardTrainee->close();
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ViewerTrainees::setAuthComplited(bool authComplited)
|
||||
{
|
||||
this->authComplited = authComplited;
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void ViewerTrainees::deactivate()
|
||||
{
|
||||
if(dlgRedactor)
|
||||
{
|
||||
dlgRedactor->close();
|
||||
delete dlgRedactor;
|
||||
dlgRedactor = nullptr;
|
||||
}
|
||||
|
||||
if(dlgCardTrainee)
|
||||
dlgCardTrainee->close();
|
||||
|
||||
CommonView::deactivate();
|
||||
|
||||
ammTasksWidgetCommon->deactivate();
|
||||
fimTasksWidgetCommon->deactivate();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void ViewerTrainees::changeEvent(QEvent *event)
|
||||
{
|
||||
// В случае получения события изменения языка приложения
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{// переведём окно заново
|
||||
ui->retranslateUi(this);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
slot_NeedUpdateUI(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::slot_receiveMessage(ClientMessage clientMessage)
|
||||
{
|
||||
int id_trainee = clientMessage.fromId.toInt();
|
||||
|
||||
mtxmapNewMsg.lock();
|
||||
mapNewMsg.insert(id_trainee, true);
|
||||
mtxmapNewMsg.unlock();
|
||||
|
||||
slot_NeedUpdateUI(false, true);
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryBlockAuth(true);
|
||||
|
||||
dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this);
|
||||
dlgRedactor->exec();
|
||||
|
||||
if(dlgRedactor)
|
||||
{
|
||||
delete dlgRedactor;
|
||||
dlgRedactor = nullptr;
|
||||
}
|
||||
|
||||
if(authComplited)
|
||||
loadTraineesFromDB();
|
||||
|
||||
connectorToServer->sendQueryBlockAuth(false);
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_btnPersonalCard_clicked()
|
||||
{
|
||||
if(lastCurrentID && typeObject == TypeObject::objTrainee)
|
||||
{
|
||||
dlgCardTrainee = new DialogCardTrainee(connectorToServer, messangerController, lastCurrentID, ammTasksWidgetCommon, fimTasksWidgetCommon, this);
|
||||
dlgCardTrainee->exec();
|
||||
|
||||
ammTasksWidgetCommon->setParent(this);
|
||||
fimTasksWidgetCommon->setParent(this);
|
||||
|
||||
if(dlgCardTrainee)
|
||||
{
|
||||
delete dlgCardTrainee;
|
||||
dlgCardTrainee = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if(item == nullptr)
|
||||
return;
|
||||
|
||||
if(item->childCount() == 0)
|
||||
{//Выбран обучаемый
|
||||
QString login = item->text(ColumnsTreeUsers::clmn_Login);
|
||||
if(login != "")
|
||||
{
|
||||
int id_trainee = connectorToServer->getIdTraineeByLogin(login);
|
||||
|
||||
dlgCardTrainee = new DialogCardTrainee(connectorToServer, messangerController, id_trainee, ammTasksWidgetCommon, fimTasksWidgetCommon, this);
|
||||
dlgCardTrainee->exec();
|
||||
|
||||
ammTasksWidgetCommon->setParent(this);
|
||||
fimTasksWidgetCommon->setParent(this);
|
||||
|
||||
if(dlgCardTrainee)
|
||||
{
|
||||
delete dlgCardTrainee;
|
||||
dlgCardTrainee = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if(item == nullptr)
|
||||
return;
|
||||
|
||||
if(item->childCount() == 0)
|
||||
{//Выбран обучаемый
|
||||
typeObject = TypeObject::objTrainee;
|
||||
|
||||
QString login = item->text(ColumnsTreeUsers::clmn_Login);
|
||||
//if(login != "")
|
||||
{
|
||||
int newCurrentID = connectorToServer->getIdTraineeByLogin(login);
|
||||
|
||||
//if(newCurrentID == lastCurrentID)
|
||||
//return;
|
||||
|
||||
lastCurrentID = newCurrentID;
|
||||
|
||||
mtxmapNewMsg.lock();
|
||||
if(mapNewMsg.contains(newCurrentID))
|
||||
{//Есть непрочитанные сообщения от него
|
||||
if(mapNewMsg.value(newCurrentID))
|
||||
{
|
||||
for (int i = 0; i < ColumnsTreeUsers::clmn_count; i++)
|
||||
{
|
||||
item->setBackground(i, QBrush(Qt::GlobalColor::white));
|
||||
}
|
||||
mapNewMsg.take(newCurrentID);
|
||||
}
|
||||
}
|
||||
mtxmapNewMsg.unlock();
|
||||
|
||||
Q_EMIT signal_traineeSelected(newCurrentID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Выбрана группа
|
||||
typeObject = TypeObject::objGroup;
|
||||
|
||||
int id_group = item->text(ColumnsTreeUsers::clmn_ID).toInt();
|
||||
|
||||
lastCurrentID = id_group;
|
||||
typeObject = TypeObject::objGroup;
|
||||
|
||||
QString login = "";
|
||||
Q_EMIT signal_traineeSelected(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::updateButtons()
|
||||
{
|
||||
if(authComplited)
|
||||
{
|
||||
ui->btnEditorTrainees->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnEditorTrainees->setEnabled(false);
|
||||
}
|
||||
}
|
||||
66
LibInstructorsAndTrainees/trainees/viewertrainees.h
Normal file
66
LibInstructorsAndTrainees/trainees/viewertrainees.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef TRAINEESWIDGET_H
|
||||
#define TRAINEESWIDGET_H
|
||||
|
||||
#include "traineesview.h"
|
||||
#include "ammtaskswidget.h"
|
||||
#include "fimtaskswidget.h"
|
||||
#include "messangercontroller.h"
|
||||
#include "dialogcardtrainee.h"
|
||||
#include "dialogredactortrainees.h"
|
||||
|
||||
namespace Ui {
|
||||
class ViewerTrainees;
|
||||
}
|
||||
|
||||
//Виджет только для просмотра БД Обучаемых
|
||||
|
||||
class ViewerTrainees : public TraineesView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewerTrainees(ConnectorToServer* connectorToServer, MessangerController* messangerController, QWidget *parent = nullptr);
|
||||
~ViewerTrainees();
|
||||
|
||||
public:
|
||||
void setAuthComplited(bool authComplited);
|
||||
|
||||
void deactivate();
|
||||
|
||||
AMMtasksWidget* getAmmTasksWidgetCommon(){return ammTasksWidgetCommon;};
|
||||
FIMtasksWidget* getFimTasksWidgetCommon(){return fimTasksWidgetCommon;};
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
public slots:
|
||||
void slot_receiveMessage(ClientMessage clientMessage);
|
||||
|
||||
public Q_SLOTS:
|
||||
void on_btnEditorTrainees_clicked();
|
||||
void on_btnPersonalCard_clicked();
|
||||
private Q_SLOTS:
|
||||
void on_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void on_treeWidgetItemClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
Q_SIGNALS:
|
||||
//сигнал о выборе обучаемого
|
||||
void signal_traineeSelected(int id_trainee);
|
||||
|
||||
private:
|
||||
void updateButtons() override;
|
||||
|
||||
private:
|
||||
AMMtasksWidget* ammTasksWidgetCommon;
|
||||
FIMtasksWidget* fimTasksWidgetCommon;
|
||||
|
||||
MessangerController* messangerController;
|
||||
|
||||
DialogRedactorTrainees* dlgRedactor;
|
||||
DialogCardTrainee* dlgCardTrainee;
|
||||
|
||||
private:
|
||||
Ui::ViewerTrainees *ui;
|
||||
};
|
||||
|
||||
#endif // TRAINEESWIDGET_H
|
||||
73
LibInstructorsAndTrainees/trainees/viewertrainees.ui
Normal file
73
LibInstructorsAndTrainees/trainees/viewertrainees.ui
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ViewerTrainees</class>
|
||||
<widget class="QWidget" name="ViewerTrainees">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Trainees</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_0">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnEditorTrainees">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Editor of Trainees</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/DB-trainees.png</normaloff>:/resources/icons/DB-trainees.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user