mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Переделано под один мега-проект LMS с общим CMakeLists.txt
This commit is contained in:
45
InstructorsAndTrainees/trainees/computersLocations.cpp
Normal file
45
InstructorsAndTrainees/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
InstructorsAndTrainees/trainees/computersLocations.h
Normal file
46
InstructorsAndTrainees/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
|
||||
48
InstructorsAndTrainees/trainees/dialogeditgroup.cpp
Normal file
48
InstructorsAndTrainees/trainees/dialogeditgroup.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "dialogeditgroup.h"
|
||||
#include "computersLocations.h"
|
||||
#include <QPushButton>
|
||||
|
||||
DialogEditGroup::DialogEditGroup(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogEditGroup),
|
||||
groupInput()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
}
|
||||
|
||||
DialogEditGroup::~DialogEditGroup()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogEditGroup::setGroup(Group group)
|
||||
{
|
||||
groupInput = group;
|
||||
|
||||
ui->editName->setText(group.getName());
|
||||
}
|
||||
|
||||
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->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
36
InstructorsAndTrainees/trainees/dialogeditgroup.h
Normal file
36
InstructorsAndTrainees/trainees/dialogeditgroup.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#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);
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
private:
|
||||
Ui::DialogEditGroup *ui;
|
||||
|
||||
Group groupInput;
|
||||
};
|
||||
|
||||
#endif // DIALOGEDITGROUP_H
|
||||
113
InstructorsAndTrainees/trainees/dialogeditgroup.ui
Normal file
113
InstructorsAndTrainees/trainees/dialogeditgroup.ui
Normal file
@@ -0,0 +1,113 @@
|
||||
<?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>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/icons/group.png</normaloff>:/icons/group.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogEditGroup</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogEditGroup</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
72
InstructorsAndTrainees/trainees/dialogedittrainee.cpp
Normal file
72
InstructorsAndTrainees/trainees/dialogedittrainee.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "dialogedittrainee.h"
|
||||
#include "ui_dialogedittrainee.h"
|
||||
#include <QPushButton>
|
||||
|
||||
DialogEditTrainee::DialogEditTrainee(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogEditTrainee),
|
||||
traineeInput()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
|
||||
ui->editName->setProperty("mandatoryField", true);
|
||||
ui->editLogin->setProperty("mandatoryField", true);
|
||||
ui->editPassword->setProperty("mandatoryField", true);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
Trainee DialogEditTrainee::getTrainee()
|
||||
{
|
||||
Trainee trainee = traineeInput;
|
||||
|
||||
trainee.setName(ui->editName->text());
|
||||
trainee.setLogin(ui->editLogin->text());
|
||||
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->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
38
InstructorsAndTrainees/trainees/dialogedittrainee.h
Normal file
38
InstructorsAndTrainees/trainees/dialogedittrainee.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef DIALOGEDITTRAINEE_H
|
||||
#define DIALOGEDITTRAINEE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "trainee.h"
|
||||
|
||||
namespace Ui {
|
||||
class DialogEditTrainee;
|
||||
}
|
||||
|
||||
class DialogEditTrainee : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogEditTrainee(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);
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
private:
|
||||
Ui::DialogEditTrainee *ui;
|
||||
|
||||
Trainee traineeInput;
|
||||
};
|
||||
|
||||
#endif // DIALOGEDITTRAINEE_H
|
||||
217
InstructorsAndTrainees/trainees/dialogedittrainee.ui
Normal file
217
InstructorsAndTrainees/trainees/dialogedittrainee.ui
Normal file
@@ -0,0 +1,217 @@
|
||||
<?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>300</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>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/trainee.png</normaloff>:/icons/trainee.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</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="../resources.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>Logged</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogEditTrainee</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogEditTrainee</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
537
InstructorsAndTrainees/trainees/editortrainees.cpp
Normal file
537
InstructorsAndTrainees/trainees/editortrainees.cpp
Normal file
@@ -0,0 +1,537 @@
|
||||
#include <QMessageBox>
|
||||
#include "editortrainees.h"
|
||||
#include "ui_editortrainees.h"
|
||||
#include "dialogeditgroup.h"
|
||||
#include "dialogedittrainee.h"
|
||||
|
||||
EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
ui(new Ui::EditorTrainees)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(treeWidget, &QTreeWidget::currentItemChanged, this, &EditorTrainees::on_treeWidget_currentItemChanged);
|
||||
|
||||
ui->verticalLayout_1->addWidget(treeWidget);
|
||||
|
||||
this->adminMode = adminMode;
|
||||
|
||||
preparationTreeWidget();
|
||||
//setNotLoggedInVisible(true);
|
||||
loadTraineesFromDB();
|
||||
|
||||
if(adminMode)
|
||||
ui->btnArchive->click();
|
||||
}
|
||||
|
||||
EditorTrainees::~EditorTrainees()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnNewGroup_clicked()
|
||||
{
|
||||
Group group;
|
||||
Group group_edit;
|
||||
|
||||
if(editGroup(group, &group_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_GROUP, 0, &group_edit);
|
||||
|
||||
return;
|
||||
/*
|
||||
if(int id_group = dbLMS->newGroup())
|
||||
{
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
|
||||
DialogEditGroup dlg(this);
|
||||
|
||||
Group group = dbLMS->getGroup(id_group);
|
||||
if(group.getID() == 0)
|
||||
return;
|
||||
|
||||
dlg.setGroup(group);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Group group_edit = dlg.getGroup();
|
||||
|
||||
if(int id_edit = dbLMS->editGroup(group_edit))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_edit);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg.setGroup(group_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
dbLMS->delGroup(id_group);
|
||||
loadTraineesFromDB();
|
||||
return;
|
||||
default:
|
||||
dbLMS->delGroup(id_group);
|
||||
loadTraineesFromDB();
|
||||
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(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Editing error!"), tr("The group is not empty.\nIt is not possible to delete a non-empty group."));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{//Пустая группа
|
||||
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
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(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
Trainee trainee;
|
||||
Trainee trainee_edit;
|
||||
|
||||
if(editTrainee(trainee, &trainee_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group, &trainee_edit);
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
if(int id_trainee = dbLMS->newTrainee(id_group))
|
||||
{
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
|
||||
DialogEditTrainee dlg(this);
|
||||
|
||||
Trainee trainee = dbLMS->getTrainee(id_trainee);
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
dlg.setTrainee(trainee);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Trainee trainee_edit = dlg.getTrainee();
|
||||
|
||||
if(int id_edit = dbLMS->editTrainee(trainee_edit))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
//setCurrentTrainee(id_edit);
|
||||
setCurrentGroup(id_group);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg.setTrainee(trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
dbLMS->delTrainee(id_trainee);
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
return;
|
||||
default:
|
||||
dbLMS->delTrainee(id_trainee);
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
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(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
int id_group = treeItemParent->text(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
QMessageBox::critical(this, tr("Error!"), tr("You cannot delete a logged-in trainee."));
|
||||
return;
|
||||
}
|
||||
|
||||
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
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(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
Trainee trainee = connectorToServer->getTrainee(id_trainee);
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
{//Архивный
|
||||
trainee.setArchived(false);
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee);
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
QMessageBox::critical(this, tr("Error!"), tr("You cannot archive a logged-in trainee."));
|
||||
return;
|
||||
}
|
||||
|
||||
trainee.setArchived(true);
|
||||
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(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
Group group = connectorToServer->getGroup(id_group);
|
||||
if(group.getID() == 0)
|
||||
return;
|
||||
|
||||
Group group_edit;
|
||||
|
||||
if(editGroup(group, &group_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_GROUP, id_group, &group_edit);
|
||||
}
|
||||
else
|
||||
{//Выбран обучаемый
|
||||
|
||||
int id_trainee = treeItemCurrent->text(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
QMessageBox::critical(this, tr("Error!"), 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))
|
||||
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)
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
|
||||
void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
//Определяем доступность и функционал кнопок для выбранного элемента
|
||||
|
||||
if(current == nullptr)
|
||||
return;
|
||||
|
||||
QTreeWidgetItem *treeItemParent = current->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
int id_group = current->text(ColumnsTreeTrainees::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(ColumnsTreeTrainees::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>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
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())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
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("<trainee>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Trainee> listTrainees = connectorToServer->getListTrainees();
|
||||
|
||||
for(Trainee exist_trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getName() == exist_trainee.getName() && trainee.getID() != exist_trainee.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee name has been entered."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == exist_trainee.getLogin() && trainee.getID() != exist_trainee.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTrainees::editGroup(Group group, Group *group_edit)
|
||||
{
|
||||
DialogEditGroup dlg(this);
|
||||
|
||||
dlg.setGroup(group);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*group_edit = dlg.getGroup();
|
||||
|
||||
if(! verifyGroup(*group_edit))
|
||||
{
|
||||
dlg.setGroup(*group_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
|
||||
{
|
||||
DialogEditTrainee dlg(this);
|
||||
|
||||
dlg.setTrainee(trainee);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*trainee_edit = dlg.getTrainee();
|
||||
|
||||
if(! verifyTrainee(*trainee_edit))
|
||||
{
|
||||
dlg.setTrainee(*trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
46
InstructorsAndTrainees/trainees/editortrainees.h
Normal file
46
InstructorsAndTrainees/trainees/editortrainees.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef DIALOGTRAINEESGROUPS_H
|
||||
#define DIALOGTRAINEESGROUPS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTreeWidget>
|
||||
#include "traineesview.h"
|
||||
//#include "computersLocations.h"
|
||||
|
||||
namespace Ui {
|
||||
class EditorTrainees;
|
||||
}
|
||||
|
||||
//Виджет для редактирования БД Обучаемых
|
||||
|
||||
class EditorTrainees : public TraineesView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent = nullptr);
|
||||
~EditorTrainees();
|
||||
|
||||
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_treeWidget_currentItemChanged(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;
|
||||
};
|
||||
|
||||
#endif // DIALOGTRAINEESGROUPS_H
|
||||
325
InstructorsAndTrainees/trainees/editortrainees.ui
Normal file
325
InstructorsAndTrainees/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>
|
||||
266
InstructorsAndTrainees/trainees/traineesview.cpp
Normal file
266
InstructorsAndTrainees/trainees/traineesview.cpp
Normal file
@@ -0,0 +1,266 @@
|
||||
#include <QHeaderView>
|
||||
#include "traineesview.h"
|
||||
|
||||
TraineesView::TraineesView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
CommonView(connectorToServer, type, parent)
|
||||
{
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
|
||||
void TraineesView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
{
|
||||
if(typeView == TypeView::onlyView)
|
||||
{
|
||||
if(adminMode)
|
||||
archiveVisible = false;
|
||||
else
|
||||
archiveVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
archiveVisible = true;
|
||||
}
|
||||
|
||||
if(adminMode)
|
||||
{
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_ID, false);
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_Archived, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_ID, true);
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_Archived, true);
|
||||
}
|
||||
|
||||
updateButtons();
|
||||
|
||||
if(treeTrainee)
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
|
||||
void TraineesView::preparationTreeWidget()
|
||||
{
|
||||
mtxTreeWidget.lock();
|
||||
|
||||
treeWidget->setColumnCount(10);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_ID, 80);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Trainee, 250);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Login, 100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Password, 100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Class, 130);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Computer, 130);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_IP_address, 130);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Archived, 100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Logged, 100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeTrainees::clmn_Tasks, 200);
|
||||
|
||||
|
||||
if(typeView == TypeView::onlyView)
|
||||
{//onlyView
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_ID, true);
|
||||
//treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_Login, true);
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_Password, true);
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_Archived, true);
|
||||
|
||||
if(adminMode)
|
||||
archiveVisible = false;
|
||||
else
|
||||
archiveVisible = false;
|
||||
|
||||
notLoggedInVisible = true;
|
||||
}
|
||||
else
|
||||
{//control
|
||||
archiveVisible = true;
|
||||
notLoggedInVisible = true;
|
||||
|
||||
if(adminMode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_ID, true);
|
||||
treeWidget->setColumnHidden(ColumnsTreeTrainees::clmn_Archived, true);
|
||||
}
|
||||
}
|
||||
|
||||
treeWidget->setSortingEnabled(true);
|
||||
treeWidget->sortItems(ColumnsTreeTrainees::clmn_Trainee, Qt::SortOrder::AscendingOrder);
|
||||
|
||||
mtxTreeWidget.unlock();
|
||||
}
|
||||
|
||||
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(ColumnsTreeTrainees::clmn_ID, QString::number(group.getID()));
|
||||
ItemGroup->setText(ColumnsTreeTrainees::clmn_Trainee, group.getName());
|
||||
ItemGroup->setIcon(ColumnsTreeTrainees::clmn_Trainee, QIcon(QStringLiteral(":/resources/icons/group.png")));
|
||||
setItemColor(ItemGroup, QColor(170, 190, 170));
|
||||
|
||||
//ItemGroup->set Property("greenButton", QVariant(true));
|
||||
//((QAbstractItemView*)ItemGroup)->setIconSize(QSize(32, 32));
|
||||
|
||||
//Обучаемые
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getGroup().getID() != group.getID())
|
||||
continue;
|
||||
|
||||
QTreeWidgetItem *ItemTrainee = new QTreeWidgetItem();
|
||||
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_ID, QString::number(trainee.getID()));
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Trainee, trainee.getName());
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Login, trainee.getLogin());
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Password, trainee.getPassword());
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Class, trainee.getComputer().getClassroom().getName());
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Computer, trainee.getComputer().getName());
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_IP_address, trainee.getComputer().getIpAddress());
|
||||
|
||||
//Сокрытие пароля
|
||||
if(!adminMode)
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Password, QStringLiteral("******"));
|
||||
|
||||
if(trainee.getArchived())
|
||||
{//Архивный
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Archived, tr("yes"));
|
||||
ItemTrainee->setIcon(ColumnsTreeTrainees::clmn_Trainee, QIcon(QStringLiteral(":/resources/icons/archive.png")));
|
||||
setItemColorArchive(ItemTrainee);
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Archived, tr("no"));
|
||||
ItemTrainee->setIcon(ColumnsTreeTrainees::clmn_Trainee, QIcon(QStringLiteral(":/resources/icons/trainee.png")));
|
||||
setItemColorNoArchive(ItemTrainee);
|
||||
cntChildsNotArchived++;
|
||||
}
|
||||
|
||||
if(trainee.getLoggedIn())
|
||||
{//Залогинен
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Logged, tr("yes"));
|
||||
ItemTrainee->setIcon(ColumnsTreeTrainees::clmn_Logged, QIcon(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{//Не Залогинен
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Logged, tr("no"));
|
||||
ItemTrainee->setIcon(ColumnsTreeTrainees::clmn_Logged, QIcon(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
QString tasksStr;
|
||||
for(Task task: trainee.getTasks())
|
||||
{
|
||||
tasksStr += task.getName() + QStringLiteral("; ");
|
||||
}
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Tasks, tasksStr);
|
||||
|
||||
ItemGroup->addChild(ItemTrainee);
|
||||
|
||||
//Скрываем архивных (при необходимости)
|
||||
if(trainee.getArchived())
|
||||
if(! archiveVisible)
|
||||
ItemTrainee->setHidden(true);
|
||||
|
||||
//Скрываем незалогиненых (при необходимости)
|
||||
if(! trainee.getLoggedIn())
|
||||
if(! notLoggedInVisible)
|
||||
ItemTrainee->setHidden(true);
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
mtxTreeWidget.unlock();
|
||||
}
|
||||
|
||||
void TraineesView::reSetHeadTreeWidget()
|
||||
{
|
||||
QStringList listHeaders = {tr("Trainee"), tr("Login"), tr("Password"), tr("Class"), tr("Computer"), tr("IP address"), tr("Archived"), tr("Logged"), tr("Tasks"), tr("ID")};
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
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(ColumnsTreeTrainees::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(ColumnsTreeTrainees::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);
|
||||
}
|
||||
45
InstructorsAndTrainees/trainees/traineesview.h
Normal file
45
InstructorsAndTrainees/trainees/traineesview.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#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);
|
||||
|
||||
protected:
|
||||
enum ColumnsTreeTrainees{
|
||||
clmn_Trainee = 0,
|
||||
clmn_Login,
|
||||
clmn_Password,
|
||||
clmn_Class,
|
||||
clmn_Computer,
|
||||
clmn_IP_address,
|
||||
clmn_Archived,
|
||||
clmn_Logged,
|
||||
clmn_Tasks,
|
||||
clmn_ID
|
||||
};
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки сигнала необходимости обновления интерфейса
|
||||
void slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
protected:
|
||||
virtual void updateButtons(){};
|
||||
void preparationTreeWidget();
|
||||
void loadTraineesFromDB();
|
||||
|
||||
void reSetHeadTreeWidget();
|
||||
|
||||
void setCurrentGroup(int id);
|
||||
void setCurrentTrainee(int id);
|
||||
};
|
||||
|
||||
#endif // TRAINEESVIEW_H
|
||||
109
InstructorsAndTrainees/trainees/viewertrainees.cpp
Normal file
109
InstructorsAndTrainees/trainees/viewertrainees.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
#include "editortrainees.h"
|
||||
#include "viewertrainees.h"
|
||||
#include "ui_viewertrainees.h"
|
||||
|
||||
ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::onlyView, parent),
|
||||
ui(new Ui::ViewerTrainees)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(treeWidget, &QTreeWidget::currentItemChanged, this, &ViewerTrainees::on_treeWidget_currentItemChanged);
|
||||
|
||||
ui->horizontalLayout_1->addWidget(treeWidget);
|
||||
|
||||
preparationTreeWidget();
|
||||
setNotLoggedInVisible(true);
|
||||
}
|
||||
|
||||
ViewerTrainees::~ViewerTrainees()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/*
|
||||
void ViewerTrainees::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if(item->childCount() == 0)
|
||||
{//Выбран обучаемый
|
||||
QString login = item->text(ColumnsTreeTrainees::clmn_Login);
|
||||
Q_EMIT signal_traineeSelected(login);
|
||||
}
|
||||
}*/
|
||||
|
||||
void ViewerTrainees::slot_tabMessengerChanged(QString login)
|
||||
{
|
||||
for (int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{//Проход по группам
|
||||
int countChild = treeWidget->topLevelItem(i)->childCount();
|
||||
|
||||
for (int j = 0; j < countChild; j++)
|
||||
{//Проход по обучаемым
|
||||
QString loginChild = treeWidget->topLevelItem(i)->child(j)->text(ColumnsTreeTrainees::clmn_Login);
|
||||
if(loginChild == login)
|
||||
{
|
||||
treeWidget->setCurrentItem(treeWidget->topLevelItem(i)->child(j));
|
||||
typeObject = TypeObject::objTrainee;
|
||||
lastCurrentID = connectorToServer->getIdTraineeByLogin(login);
|
||||
Q_EMIT signal_traineeSelected(login);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::changeEvent(QEvent *event)
|
||||
{
|
||||
// В случае получения события изменения языка приложения
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{// переведём окно заново
|
||||
ui->retranslateUi(this);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
//loadTraineesFromDB();
|
||||
slot_NeedUpdateUI(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
{
|
||||
Q_EMIT signal_BlockAutorization(true);
|
||||
|
||||
EditorTrainees editorTraineesGroups(connectorToServer, adminMode);
|
||||
connect(connectorToServer, &ConnectorToServer::signal_UpdateDB, &editorTraineesGroups, &EditorTrainees::slot_NeedUpdateUI);
|
||||
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorTraineesGroups);
|
||||
dialog->setWindowTitle(tr("Editor of trainees"));
|
||||
dialog->setMinimumSize(1600, 800);
|
||||
dialog->exec();
|
||||
|
||||
loadTraineesFromDB();
|
||||
|
||||
Q_EMIT signal_BlockAutorization(false);
|
||||
}
|
||||
|
||||
void ViewerTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
if(current == nullptr)
|
||||
return;
|
||||
|
||||
if(current->childCount() == 0)
|
||||
{//Выбран обучаемый
|
||||
QString login = current->text(ColumnsTreeTrainees::clmn_Login);
|
||||
Q_EMIT signal_traineeSelected(login);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerTrainees::updateButtons()
|
||||
{
|
||||
if(authComplited)
|
||||
{
|
||||
ui->btnEditorTrainees->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnEditorTrainees->setEnabled(false);
|
||||
}
|
||||
}
|
||||
47
InstructorsAndTrainees/trainees/viewertrainees.h
Normal file
47
InstructorsAndTrainees/trainees/viewertrainees.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef TRAINEESWIDGET_H
|
||||
#define TRAINEESWIDGET_H
|
||||
|
||||
#include "traineesview.h"
|
||||
|
||||
namespace Ui {
|
||||
class ViewerTrainees;
|
||||
}
|
||||
|
||||
//Виджет только для просмотра БД Обучаемых
|
||||
|
||||
class ViewerTrainees : public TraineesView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewerTrainees(ConnectorToServer* connectorToServer, QWidget *parent = nullptr);
|
||||
~ViewerTrainees();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
//сигнал о блокировке авторизации
|
||||
void signal_BlockAutorization(bool block);
|
||||
|
||||
private Q_SLOTS:
|
||||
//void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column);
|
||||
void on_btnEditorTrainees_clicked();
|
||||
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
public Q_SLOTS:
|
||||
//слот обработки сигнала об изменении вкладки диалога в мессенджере
|
||||
void slot_tabMessengerChanged(QString login);
|
||||
|
||||
Q_SIGNALS:
|
||||
//сигнал о выборе обучаемого
|
||||
void signal_traineeSelected(QString login);
|
||||
|
||||
private:
|
||||
void updateButtons() override;
|
||||
|
||||
private:
|
||||
Ui::ViewerTrainees *ui;
|
||||
};
|
||||
|
||||
#endif // TRAINEESWIDGET_H
|
||||
100
InstructorsAndTrainees/trainees/viewertrainees.ui
Normal file
100
InstructorsAndTrainees/trainees/viewertrainees.ui
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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="2" rowspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_0">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Trainees</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user