mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
PSQL id 06.11.2024
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.1, 2024-11-02T13:43:21. -->
|
||||
<!-- Written by QtCreator 4.11.1, 2024-11-06T16:05:43. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
#include "commonview.h"
|
||||
|
||||
|
||||
CommonView::CommonView(TypeView type, QWidget *parent):
|
||||
CommonView::CommonView(TypeView type, bool adminMode, QWidget *parent):
|
||||
QWidget(parent),
|
||||
treeWidget(nullptr),
|
||||
typeView(type),
|
||||
archiveVisible(false),
|
||||
notLoggedInVisible(false),
|
||||
adminMode(false)
|
||||
adminMode(adminMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CommonView::setItemColorArchive(QTreeWidgetItem *item)
|
||||
{
|
||||
int columnCount = treeWidget->columnCount();
|
||||
|
||||
for (int i = 0; i < columnCount; i++)
|
||||
item->setBackground(i, QBrush(QColor(220, 220, 220)));
|
||||
setItemColor(item,QColor(220, 220, 220));
|
||||
}
|
||||
|
||||
void CommonView::setItemColorNoArchive(QTreeWidgetItem *item)
|
||||
{
|
||||
int columnCount = treeWidget->columnCount();
|
||||
|
||||
for (int i = 0; i < columnCount; i++)
|
||||
item->setBackground(i, QBrush(QColor(255, 255, 255)));
|
||||
setItemColor(item,QColor(255, 255, 255));
|
||||
}
|
||||
|
||||
void CommonView::setItemColor(QTreeWidgetItem *item, QColor color)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
//Родительский класс представления БД Инструкторов/Обучаемых (самого верхнего уровня)
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT CommonView : public QWidget
|
||||
class CommonView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
CommonView(TypeView type, QWidget *parent = nullptr);
|
||||
CommonView(TypeView type, bool adminMode, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void setArchiveVisible(bool archiveVisible)
|
||||
|
||||
@@ -36,9 +36,9 @@ bool DataBaseInstructors::AuthorizationInstructor(QString login, QString passwor
|
||||
Instructor instructor = listOfInstructors[i];
|
||||
instructor.setLoggedIn(true);
|
||||
|
||||
bool result = dbLMS->updateInstructor(instructor);
|
||||
int id = dbLMS->updateInstructor(instructor);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
LoadInstructorsPSQL();
|
||||
return true;
|
||||
@@ -63,9 +63,9 @@ bool DataBaseInstructors::deAuthorizationInstructor(QString login)
|
||||
Instructor instructor = listOfInstructors[i];
|
||||
instructor.setLoggedIn(false);
|
||||
|
||||
bool result = dbLMS->updateInstructor(instructor);
|
||||
int id = dbLMS->updateInstructor(instructor);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
LoadInstructorsPSQL();
|
||||
return true;
|
||||
@@ -77,12 +77,12 @@ bool DataBaseInstructors::deAuthorizationInstructor(QString login)
|
||||
return false;
|
||||
}
|
||||
|
||||
Instructor DataBaseInstructors::getInstructor(QString name)
|
||||
Instructor DataBaseInstructors::getInstructor(int id)
|
||||
{
|
||||
//Инструкторы
|
||||
for(int i = 0; i < listOfInstructors.count(); i++)
|
||||
{
|
||||
if(listOfInstructors[i].getName() == name)
|
||||
if(listOfInstructors[i].getID() == id)
|
||||
return listOfInstructors[i];
|
||||
}
|
||||
return Instructor();
|
||||
@@ -97,7 +97,7 @@ QString DataBaseInstructors::getNameInstructorByLogin(QString login)
|
||||
}
|
||||
return QString(QStringLiteral(""));
|
||||
}
|
||||
|
||||
/*
|
||||
QString DataBaseInstructors::getAuthorizedInstructorName()
|
||||
{
|
||||
//Инструкторы
|
||||
@@ -107,9 +107,9 @@ QString DataBaseInstructors::getAuthorizedInstructorName()
|
||||
return listOfInstructors[i].getName();
|
||||
}
|
||||
return QStringLiteral("");
|
||||
}
|
||||
}*/
|
||||
|
||||
QString DataBaseInstructors::newInstructor()
|
||||
int DataBaseInstructors::newInstructor()
|
||||
{
|
||||
Instructor instructor;
|
||||
instructor.setName(generateDefaultNameInstructor());
|
||||
@@ -119,83 +119,80 @@ QString DataBaseInstructors::newInstructor()
|
||||
instructor.setArchived(false);
|
||||
instructor.setLoggedIn(false);
|
||||
|
||||
bool result = dbLMS->insertInstructor(instructor);
|
||||
int id = dbLMS->insertInstructor(instructor);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
//listOfInstructors.append(instructor);
|
||||
LoadInstructorsPSQL();
|
||||
return instructor.getName();
|
||||
return id;
|
||||
}
|
||||
else
|
||||
return QStringLiteral("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DataBaseInstructors::deleteInstructor(QString name)
|
||||
int DataBaseInstructors::deleteInstructor(int id)
|
||||
{
|
||||
//Инструкторы
|
||||
for(int i = 0; i < listOfInstructors.count(); i++)
|
||||
{
|
||||
if(listOfInstructors[i].getName() == name)
|
||||
if(listOfInstructors[i].getID() == id)
|
||||
{
|
||||
int id = listOfInstructors[i].getID();
|
||||
int id_del = dbLMS->deleteInstructor(id);
|
||||
|
||||
bool result = dbLMS->deleteInstructor(id);
|
||||
|
||||
if(result)
|
||||
if(id_del)
|
||||
{
|
||||
LoadInstructorsPSQL();
|
||||
//listOfInstructors.removeAt(i);
|
||||
|
||||
return;
|
||||
return id_del;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseInstructors::editInstructor(QString name, Instructor instructor)
|
||||
int DataBaseInstructors::editInstructor(Instructor instructor)
|
||||
{
|
||||
//Инструкторы
|
||||
for(int i = 0; i < listOfInstructors.count(); i++)
|
||||
{
|
||||
if(listOfInstructors[i].getName() == name)
|
||||
if(listOfInstructors[i].getID() == instructor.getID())
|
||||
{
|
||||
if( (!checkExistNameInstructor(instructor.getName()) || instructor.getName() == name) &&
|
||||
if( (!checkExistNameInstructor(instructor.getName()) || instructor.getName() == listOfInstructors[i].getName()) &&
|
||||
(!checkExistLoginInstructor(instructor.getLogin()) || instructor.getLogin() == listOfInstructors[i].getLogin()) )
|
||||
{
|
||||
//instructor.setID(listOfInstructors[i].getID());
|
||||
int id = dbLMS->updateInstructor(instructor);
|
||||
|
||||
bool result = dbLMS->updateInstructor(instructor);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
//listOfInstructors.replace(i, instructor);
|
||||
LoadInstructorsPSQL();
|
||||
return true;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseInstructors::isAdmin(QString name)
|
||||
bool DataBaseInstructors::isAdmin(int id)
|
||||
{
|
||||
//Инструкторы
|
||||
for(int i = 0; i < listOfInstructors.count(); i++)
|
||||
{
|
||||
if(listOfInstructors[i].getName() == name)
|
||||
if(listOfInstructors[i].getID() == id)
|
||||
return listOfInstructors[i].getIsAdmin();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBaseInstructors::isArchived(QString name)
|
||||
bool DataBaseInstructors::isArchived(int id)
|
||||
{
|
||||
//Инструкторы
|
||||
for(int i = 0; i < listOfInstructors.count(); i++)
|
||||
{
|
||||
if(listOfInstructors[i].getName() == name)
|
||||
if(listOfInstructors[i].getID() == id)
|
||||
return listOfInstructors[i].getArchived();
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "databaselms.h"
|
||||
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT DataBaseInstructors : QObject
|
||||
class DataBaseInstructors : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -24,18 +24,18 @@ public:
|
||||
|
||||
QList<Instructor> getListInstructors(){ return listOfInstructors; } //Для загрузки
|
||||
|
||||
Instructor getInstructor(QString name);
|
||||
Instructor getInstructor(int id);
|
||||
|
||||
QString getNameInstructorByLogin(QString login);
|
||||
|
||||
QString getAuthorizedInstructorName();
|
||||
//QString getAuthorizedInstructorName();
|
||||
|
||||
QString newInstructor();
|
||||
void deleteInstructor(QString name);
|
||||
bool editInstructor(QString name, Instructor instructor);
|
||||
int newInstructor();
|
||||
int deleteInstructor(int id);
|
||||
int editInstructor(Instructor instructor);
|
||||
|
||||
bool isAdmin(QString name);
|
||||
bool isArchived(QString name);
|
||||
bool isAdmin(int id);
|
||||
bool isArchived(int id);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "ui_editorinstructors.h"
|
||||
|
||||
EditorInstructors::EditorInstructors(DataBaseInstructors* db, bool adminMode, QWidget *parent) :
|
||||
//QDialog(parent),
|
||||
InstructorsView(db, CommonView::TypeView::control, parent),
|
||||
InstructorsView(db, CommonView::TypeView::control, adminMode, parent),
|
||||
ui(new Ui::EditorInstructors)
|
||||
{
|
||||
ui->setupUi((QDialog*)this);
|
||||
@@ -22,9 +21,9 @@ EditorInstructors::~EditorInstructors()
|
||||
|
||||
void EditorInstructors::on_btnNewInstructor_clicked()
|
||||
{
|
||||
QString name = dbInstructors->newInstructor();
|
||||
int id = dbInstructors->newInstructor();
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(name);
|
||||
setCurrentInstructor(id);
|
||||
}
|
||||
|
||||
void EditorInstructors::on_btnDeleteInstructor_clicked()
|
||||
@@ -37,9 +36,9 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбран Инструктор
|
||||
|
||||
QString name = treeItemCurrent->text(0);
|
||||
int id = treeItemCurrent->text(0).toInt();
|
||||
|
||||
if(dbInstructors->isAdmin(name))
|
||||
if(dbInstructors->isAdmin(id))
|
||||
{//Это Админ!
|
||||
QMessageBox::critical(this, tr("Error!"), tr("You cannot delete the Administrator."));
|
||||
return;
|
||||
@@ -47,7 +46,7 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
|
||||
|
||||
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete it anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
dbInstructors->deleteInstructor(name);
|
||||
dbInstructors->deleteInstructor(id);
|
||||
loadInstructorsFromDB();
|
||||
}
|
||||
}
|
||||
@@ -64,29 +63,29 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбран Инструктор
|
||||
|
||||
QString name = treeItemCurrent->text(0);
|
||||
int id = treeItemCurrent->text(0).toInt();
|
||||
|
||||
Instructor instructor = dbInstructors->getInstructor(name);
|
||||
Instructor instructor = dbInstructors->getInstructor(id);
|
||||
|
||||
if(instructor.getArchived())
|
||||
{//Архивный
|
||||
instructor.setArchived(false);
|
||||
if(dbInstructors->editInstructor(name, instructor))
|
||||
if(int id_edit = dbInstructors->editInstructor(instructor))
|
||||
{
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(instructor.getName());
|
||||
setCurrentInstructor(id_edit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
instructor.setArchived(true);
|
||||
if(dbInstructors->editInstructor(name, instructor))
|
||||
if(int id_edit = dbInstructors->editInstructor(instructor))
|
||||
{
|
||||
if(!archiveVisible)
|
||||
ui->btnArchive->click();
|
||||
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(instructor.getName());
|
||||
setCurrentInstructor(id_edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,19 +103,19 @@ void EditorInstructors::on_btnEdit_clicked()
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбран Инструктор
|
||||
|
||||
QString name = treeItemCurrent->text(0);
|
||||
int id = treeItemCurrent->text(0).toInt();
|
||||
|
||||
DialogEditInstructor dlg(this);
|
||||
dlg.setInstructor(dbInstructors->getInstructor(name));
|
||||
dlg.setInstructor(dbInstructors->getInstructor(id));
|
||||
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
if(dbInstructors->editInstructor(name, dlg.getInstructor()))
|
||||
if(int id_edit = dbInstructors->editInstructor(dlg.getInstructor()))
|
||||
{
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(dlg.getInstructor().getName());
|
||||
setCurrentInstructor(id_edit);
|
||||
}
|
||||
else
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
@@ -149,9 +148,9 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбран инструктор
|
||||
|
||||
QString name = current->text(0);
|
||||
int id = current->text(0).toInt();
|
||||
|
||||
if(dbInstructors->isArchived(name))
|
||||
if(dbInstructors->isArchived(id))
|
||||
{//Архивный
|
||||
ui->btnToOrFromArchive->setText(tr("From archive"));
|
||||
ui->btnToOrFromArchive->setIcon(QIcon(QStringLiteral(":/icons/instructorFromArchive.png")));
|
||||
@@ -164,7 +163,7 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
|
||||
ui->btnNewInstructor->setEnabled(true);
|
||||
|
||||
if(dbInstructors->isAdmin(name))
|
||||
if(dbInstructors->isAdmin(id))
|
||||
{//Это Админ! Удалять/Архивировать нельзя!
|
||||
ui->btnDeleteInstructor->setEnabled(false);
|
||||
ui->btnToOrFromArchive->setEnabled(false);
|
||||
@@ -173,7 +172,7 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
{
|
||||
ui->btnToOrFromArchive->setEnabled(true);
|
||||
|
||||
if(dbInstructors->isArchived(name))
|
||||
if(dbInstructors->isArchived(id))
|
||||
ui->btnDeleteInstructor->setEnabled(true);
|
||||
else
|
||||
ui->btnDeleteInstructor->setEnabled(false);
|
||||
@@ -184,13 +183,13 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
}
|
||||
}
|
||||
|
||||
void EditorInstructors::setCurrentInstructor(QString name)
|
||||
void EditorInstructors::setCurrentInstructor(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(0) == name)
|
||||
if(item->text(0).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
break;
|
||||
|
||||
@@ -17,7 +17,7 @@ class EditorInstructors : public InstructorsView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorInstructors(DataBaseInstructors* db, bool adminMode = false, QWidget *parent = nullptr);
|
||||
explicit EditorInstructors(DataBaseInstructors* db, bool adminMode, QWidget *parent = nullptr);
|
||||
~EditorInstructors();
|
||||
|
||||
private Q_SLOTS:
|
||||
@@ -29,7 +29,7 @@ private Q_SLOTS:
|
||||
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
void setCurrentInstructor(QString name);
|
||||
void setCurrentInstructor(int id);
|
||||
|
||||
private:
|
||||
Ui::EditorInstructors *ui;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <QTranslator>
|
||||
#include "instructorsview.h"
|
||||
|
||||
InstructorsView::InstructorsView(DataBaseInstructors* db, TypeView type, QWidget *parent):
|
||||
CommonView(type, parent),
|
||||
InstructorsView::InstructorsView(DataBaseInstructors* db, TypeView type, bool adminMode, QWidget *parent):
|
||||
CommonView(type, adminMode, parent),
|
||||
dbInstructors(db)
|
||||
{
|
||||
|
||||
@@ -16,34 +16,35 @@ void InstructorsView::preparationTreeWidget(QTreeWidget* tree)
|
||||
if(treeWidget == nullptr)
|
||||
return;
|
||||
|
||||
treeWidget->setColumnCount(6);
|
||||
treeWidget->setColumnCount(7);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
|
||||
|
||||
treeWidget->setColumnWidth(0, 250);
|
||||
treeWidget->setColumnWidth(1, 100);
|
||||
treeWidget->setColumnWidth(0, 50);
|
||||
treeWidget->setColumnWidth(1, 250);
|
||||
treeWidget->setColumnWidth(2, 100);
|
||||
treeWidget->setColumnWidth(3, 100);
|
||||
treeWidget->setColumnWidth(4, 80);
|
||||
treeWidget->setColumnWidth(4, 100);
|
||||
treeWidget->setColumnWidth(5, 80);
|
||||
treeWidget->setColumnWidth(6, 80);
|
||||
|
||||
if(typeView == TypeView::onlyView)
|
||||
{//onlyView
|
||||
treeWidget->setColumnHidden(1, true);
|
||||
treeWidget->setColumnHidden(2, true);
|
||||
treeWidget->setColumnHidden(4, true);
|
||||
treeWidget->setColumnHidden(3, true);
|
||||
treeWidget->setColumnHidden(5, true);
|
||||
}
|
||||
else
|
||||
{//control
|
||||
treeWidget->setColumnHidden(4, true);
|
||||
treeWidget->setColumnHidden(5, true);
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsView::loadInstructorsFromDB()
|
||||
{
|
||||
//dbInstructors->LoadInstructorsPSQL();
|
||||
dbInstructors->LoadInstructorsPSQL();
|
||||
|
||||
if(treeWidget == nullptr)
|
||||
return;
|
||||
@@ -58,47 +59,48 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
{
|
||||
QTreeWidgetItem *ItemInstructor = new QTreeWidgetItem(treeWidget);
|
||||
|
||||
ItemInstructor->setText(0, instructor.getName());
|
||||
ItemInstructor->setText(1, instructor.getLogin());
|
||||
ItemInstructor->setText(2, instructor.getPassword());
|
||||
ItemInstructor->setText(0, QString::number(instructor.getID()));
|
||||
ItemInstructor->setText(1, instructor.getName());
|
||||
ItemInstructor->setText(2, instructor.getLogin());
|
||||
ItemInstructor->setText(3, instructor.getPassword());
|
||||
|
||||
if(instructor.getArchived())
|
||||
{//Архивный
|
||||
ItemInstructor->setText(4, tr("yes"));
|
||||
ItemInstructor->setIcon(0, QIcon(QStringLiteral(":/icons/instructorArchive.png")));
|
||||
ItemInstructor->setText(5, tr("yes"));
|
||||
ItemInstructor->setIcon(1, QIcon(QStringLiteral(":/icons/instructorArchive.png")));
|
||||
setItemColorArchive(ItemInstructor);
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
ItemInstructor->setText(4, tr("no"));
|
||||
ItemInstructor->setIcon(0, QIcon(QStringLiteral(":/icons/instructor.png")));
|
||||
ItemInstructor->setText(5, tr("no"));
|
||||
ItemInstructor->setIcon(1, QIcon(QStringLiteral(":/icons/instructor.png")));
|
||||
setItemColorNoArchive(ItemInstructor);
|
||||
}
|
||||
|
||||
if(instructor.getIsAdmin())
|
||||
{//Админ
|
||||
ItemInstructor->setText(3, tr("yes"));
|
||||
ItemInstructor->setIcon(0, QIcon(QStringLiteral(":/icons/admin.png")));
|
||||
ItemInstructor->setText(4, tr("yes"));
|
||||
ItemInstructor->setIcon(1, QIcon(QStringLiteral(":/icons/admin.png")));
|
||||
}
|
||||
else
|
||||
{//Не Админ
|
||||
ItemInstructor->setText(3, tr("no"));
|
||||
ItemInstructor->setText(4, tr("no"));
|
||||
}
|
||||
|
||||
if(instructor.getLoggedIn())
|
||||
{//Залогинен
|
||||
ItemInstructor->setText(5, tr("yes"));
|
||||
ItemInstructor->setIcon(5, QIcon(QStringLiteral(":/icons/circleGreen.png")));
|
||||
ItemInstructor->setText(6, tr("yes"));
|
||||
ItemInstructor->setIcon(6, QIcon(QStringLiteral(":/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{//Не Залогинен
|
||||
ItemInstructor->setText(5, tr("no"));
|
||||
ItemInstructor->setIcon(5, QIcon(QStringLiteral(":/icons/circleGray.png")));
|
||||
ItemInstructor->setText(6, tr("no"));
|
||||
ItemInstructor->setIcon(6, QIcon(QStringLiteral(":/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
//Скрываем архивных (при необходимости)
|
||||
if(instructor.getArchived())
|
||||
if(!archiveVisible)
|
||||
if(! archiveVisible)
|
||||
ItemInstructor->setHidden(true);
|
||||
|
||||
//Скрываем незалогиненых (при необходимости)
|
||||
@@ -108,7 +110,7 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
}
|
||||
|
||||
treeWidget->setSortingEnabled(true);
|
||||
treeWidget->sortItems(0, Qt::SortOrder::AscendingOrder);
|
||||
treeWidget->sortItems(1, Qt::SortOrder::AscendingOrder);
|
||||
treeWidget->expandAll();
|
||||
|
||||
if(typeView == TypeView::control)
|
||||
@@ -121,7 +123,7 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
|
||||
void InstructorsView::reSetHeadTreeWidget()
|
||||
{
|
||||
QStringList listHeaders = {tr("Instructor"), tr("Login"), tr("Password"), tr("Administrator"), tr("Archived"), tr("Logged")};
|
||||
QStringList listHeaders = {tr("ID"), tr("Instructor"), tr("Login"), tr("Password"), tr("Administrator"), tr("Archived"), tr("Logged")};
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
//Родительский класс представления БД Инструкторов (для просмотра и управления)
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT InstructorsView: public CommonView
|
||||
class InstructorsView: public CommonView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InstructorsView(DataBaseInstructors* db, TypeView type, QWidget *parent = nullptr);
|
||||
InstructorsView(DataBaseInstructors* db, TypeView type, bool adminMode, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void preparationTreeWidget(QTreeWidget* tree);
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "ui_viewerinstructors.h"
|
||||
|
||||
ViewerInstructors::ViewerInstructors(DataBaseInstructors* db, bool adminMode, QWidget *parent) :
|
||||
//QWidget(parent),
|
||||
InstructorsView(db, CommonView::TypeView::onlyView, parent),
|
||||
InstructorsView(db, CommonView::TypeView::onlyView, adminMode, parent),
|
||||
ui(new Ui::ViewerInstructors)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -63,16 +62,12 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
|
||||
}
|
||||
|
||||
EditorInstructors editorInstructors(dbInstructors, adminMode);
|
||||
//dlg.setWindowTitle(tr("List instructors"));
|
||||
//dlg.exec();
|
||||
//dlg.show();
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorInstructors);
|
||||
dialog->setWindowTitle(tr("List instructors"));
|
||||
dialog->setWindowTitle(tr("Editor of instructors"));
|
||||
dialog->setMinimumSize(1400, 800);
|
||||
dialog->exec();
|
||||
|
||||
dbInstructors->LoadInstructorsPSQL();
|
||||
loadInstructorsFromDB();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class ViewerInstructors;
|
||||
|
||||
//Виджет только для просмотра БД Инструкторов
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT ViewerInstructors : public InstructorsView
|
||||
class ViewerInstructors : public InstructorsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -29,7 +29,7 @@ public Q_SLOTS:
|
||||
void slot_LanguageChanged(QString language);
|
||||
|
||||
public:
|
||||
void setFilterInstructorLoggedIn( bool enabled );
|
||||
void setFilterInstructorLoggedIn(bool enabled);
|
||||
|
||||
private slots:
|
||||
void on_btnEditorInstructors_clicked();
|
||||
|
||||
@@ -16,7 +16,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
dataBaseTrainees = new DataBaseTrainees(dbLMS);
|
||||
dataBaseInstructors = new DataBaseInstructors(dbLMS);
|
||||
|
||||
//Авторизация Инструктора (Администратора)
|
||||
//Авторизация Инструктора локальная (Администратора)
|
||||
authorizationInstructorLocal(this);
|
||||
|
||||
m_viewerTrainees = new ViewerTrainees(dataBaseTrainees, adminMode);
|
||||
@@ -25,8 +25,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
ui->verticalLayout->addWidget(m_viewerTrainees);
|
||||
ui->verticalLayout->addWidget(m_viewerInstructors);
|
||||
|
||||
m_viewerTrainees->setMinimumSize(1000, 800);
|
||||
m_viewerInstructors->setMinimumSize(1000, 300);
|
||||
m_viewerTrainees->setMinimumSize(1400, 700);
|
||||
m_viewerInstructors->setMinimumSize(1400, 400);
|
||||
}
|
||||
|
||||
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
@@ -90,9 +90,9 @@ bool InstructorsAndTraineesWidget::authorizationCompleted()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InstructorsAndTraineesWidget::authorizationTrainee(QString login, QString password, QString learnClass = QStringLiteral(""), QString computer = QStringLiteral(""))
|
||||
bool InstructorsAndTraineesWidget::authorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name)
|
||||
{
|
||||
return dataBaseTrainees->AuthorizationTrainee(login, password, learnClass, computer);
|
||||
return dataBaseTrainees->AuthorizationTrainee(login, password, classroom_name, computer_name);
|
||||
}
|
||||
|
||||
bool InstructorsAndTraineesWidget::deAuthorizationTrainee(QString login)
|
||||
@@ -100,7 +100,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationTrainee(QString login)
|
||||
return dataBaseTrainees->deAuthorizationTrainee(login);
|
||||
}
|
||||
|
||||
bool InstructorsAndTraineesWidget::authorizationInstructorLocal(QString login, QString password)
|
||||
bool InstructorsAndTraineesWidget::authorizationInstructor(QString login, QString password)
|
||||
{
|
||||
return dataBaseInstructors->AuthorizationInstructor(login, password);
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ public:
|
||||
bool authorizationCompleted();
|
||||
|
||||
//Авторизация обучаемого на клиенте
|
||||
bool authorizationTrainee(QString login, QString password, QString learnClass, QString computer);
|
||||
bool authorizationTrainee(QString login, QString password, QString classroom_name = QStringLiteral(""), QString computer_name = QStringLiteral(""));
|
||||
bool deAuthorizationTrainee(QString login);
|
||||
|
||||
//Авторизация инструктора на клиенте
|
||||
bool authorizationInstructorLocal(QString login, QString password);
|
||||
bool authorizationInstructor(QString login, QString password);
|
||||
bool deAuthorizationInstructor(QString login);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "databasetrainees.h"
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
DataBaseTrainees::DataBaseTrainees(DataBaseLMS* dbLMS)
|
||||
{
|
||||
@@ -36,7 +37,7 @@ void DataBaseTrainees::LoadTraineesGroupsPSQL()
|
||||
QApplication::beep();
|
||||
}
|
||||
|
||||
bool DataBaseTrainees::AuthorizationTrainee(QString login, QString password, QString learnClass, QString computer)
|
||||
bool DataBaseTrainees::AuthorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name)
|
||||
{
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
@@ -48,12 +49,12 @@ bool DataBaseTrainees::AuthorizationTrainee(QString login, QString password, QSt
|
||||
{
|
||||
Trainee trainee = listOfTrainees[i];
|
||||
trainee.setLoggedIn(true);
|
||||
trainee.setLearnClass(learnClass);
|
||||
trainee.setComputer(computer);
|
||||
//trainee.setLearnClass(learnClass);
|
||||
//trainee.setComputer(computer);
|
||||
|
||||
bool result = dbLMS->updateTrainee(trainee);
|
||||
int id = dbLMS->updateTrainee(trainee);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
LoadTraineesGroupsPSQL();
|
||||
return true;
|
||||
@@ -77,12 +78,12 @@ bool DataBaseTrainees::deAuthorizationTrainee(QString login)
|
||||
{
|
||||
Trainee trainee = listOfTrainees[i];
|
||||
trainee.setLoggedIn(false);
|
||||
trainee.setLearnClass(QStringLiteral(""));
|
||||
trainee.setComputer(QStringLiteral(""));
|
||||
//trainee.setLearnClass(QStringLiteral(""));
|
||||
//trainee.setComputer(QStringLiteral(""));
|
||||
|
||||
bool result = dbLMS->updateTrainee(trainee);
|
||||
int id = dbLMS->updateTrainee(trainee);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
LoadTraineesGroupsPSQL();
|
||||
return true;
|
||||
@@ -94,6 +95,7 @@ bool DataBaseTrainees::deAuthorizationTrainee(QString login)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
void DataBaseTrainees::setTasks(QString login, QStringList tasks)
|
||||
{
|
||||
//Обучаемые
|
||||
@@ -102,39 +104,43 @@ void DataBaseTrainees::setTasks(QString login, QStringList tasks)
|
||||
if(listOfTrainees[i].getLogin() == login)
|
||||
listOfTrainees[i].setTasks(tasks);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
QStringList DataBaseTrainees::getTasks(QString login)
|
||||
{
|
||||
QStringList tasks;
|
||||
QStringList tasksStrList;
|
||||
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
{
|
||||
if(listOfTrainees[i].getLogin() == login)
|
||||
{
|
||||
tasks = listOfTrainees[i].getTasks();
|
||||
QList<Task> tasks = listOfTrainees[i].getTasks();
|
||||
for(Task task: tasks)
|
||||
{
|
||||
tasksStrList.append(task.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tasks;
|
||||
return tasksStrList;
|
||||
}
|
||||
|
||||
QString DataBaseTrainees::getNameTraineeOnComputer(QString computer)
|
||||
QString DataBaseTrainees::getNameTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getComputer() == computer)
|
||||
if(trainee.getComputer().getName() == computer_name)
|
||||
return trainee.getName();
|
||||
}
|
||||
return QString(QStringLiteral(""));
|
||||
}
|
||||
|
||||
Trainee DataBaseTrainees::getTraineeOnComputer(QString computer)
|
||||
Trainee DataBaseTrainees::getTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getComputer() == computer)
|
||||
if(trainee.getComputer().getName() == computer_name)
|
||||
return trainee;
|
||||
}
|
||||
return Trainee();
|
||||
@@ -149,7 +155,7 @@ QString DataBaseTrainees::getNameTraineeByLogin(QString login)
|
||||
}
|
||||
return QString(QStringLiteral(""));
|
||||
}
|
||||
|
||||
/*
|
||||
QColor DataBaseTrainees::getColorGroupByLogin(QString login)
|
||||
{
|
||||
QString nameTrainee = getNameTraineeByLogin(login);
|
||||
@@ -157,15 +163,15 @@ QColor DataBaseTrainees::getColorGroupByLogin(QString login)
|
||||
QString nameGroup = trainee.getGroup();
|
||||
Group group = getGroup(nameGroup);
|
||||
return getColorGroup(group.getColor());
|
||||
}
|
||||
}*/
|
||||
|
||||
QList<Trainee> DataBaseTrainees::getListTraineesInGroup(QString nameGroup)
|
||||
QList<Trainee> DataBaseTrainees::getListTraineesInGroup(int id)
|
||||
{
|
||||
QList<Trainee> listTrainees;
|
||||
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getGroup() == nameGroup)
|
||||
if(trainee.getGroup().getID() == id)
|
||||
listTrainees.append(trainee);
|
||||
}
|
||||
|
||||
@@ -176,199 +182,185 @@ QList<Group> DataBaseTrainees::getListGroups()
|
||||
{
|
||||
return listOfGroups;
|
||||
}
|
||||
|
||||
/*
|
||||
QColor DataBaseTrainees::getColorGroup(Group::ColorGroup numColor)
|
||||
{
|
||||
if(numColor > listOfColorGroup.count() - 1)
|
||||
return listOfColorGroup.at(Group::ColorGroup::colorAther);
|
||||
|
||||
return listOfColorGroup.at(numColor);
|
||||
}
|
||||
}*/
|
||||
|
||||
Trainee DataBaseTrainees::getTrainee(QString name)
|
||||
Trainee DataBaseTrainees::getTrainee(int id)
|
||||
{
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
{
|
||||
if(listOfTrainees[i].getName() == name)
|
||||
if(listOfTrainees[i].getID() == id)
|
||||
return listOfTrainees[i];
|
||||
}
|
||||
return Trainee();
|
||||
}
|
||||
|
||||
Group DataBaseTrainees::getGroup(QString nameGroup)
|
||||
Group DataBaseTrainees::getGroup(int id)
|
||||
{
|
||||
//Группы
|
||||
for(int i = 0; i < listOfGroups.count(); i++)
|
||||
{
|
||||
if(listOfGroups[i].getName() == nameGroup)
|
||||
if(listOfGroups[i].getID() == id)
|
||||
return listOfGroups[i];
|
||||
}
|
||||
return Group();
|
||||
}
|
||||
|
||||
QString DataBaseTrainees::newGroup()
|
||||
int DataBaseTrainees::newGroup()
|
||||
{
|
||||
Group group;
|
||||
group.setName(generateDefaultNameGroup());
|
||||
group.setColor(generateDefaultColorGroup());
|
||||
|
||||
bool result = dbLMS->insertGroup(group);
|
||||
int id = dbLMS->insertGroup(group);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
//listOfGroups.append(group);
|
||||
LoadTraineesGroupsPSQL();
|
||||
return group.getName();
|
||||
return id;
|
||||
}
|
||||
else
|
||||
return QStringLiteral("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseTrainees::deleteGroup(QString name)
|
||||
int DataBaseTrainees::deleteGroup(int id)
|
||||
{
|
||||
if(getListTraineesInGroup(name).count() > 0)
|
||||
{//Группа не пуста
|
||||
return false;
|
||||
}
|
||||
|
||||
//Группы
|
||||
for(int i = 0; i < listOfGroups.count(); i++)
|
||||
{
|
||||
if(listOfGroups[i].getName() == name)
|
||||
if(listOfGroups[i].getID() == id)
|
||||
{
|
||||
int id = listOfGroups[i].getID();
|
||||
int id_del = dbLMS->deleteGroup(id);
|
||||
|
||||
bool result = dbLMS->deleteGroup(id);
|
||||
|
||||
if(result)
|
||||
if(id_del)
|
||||
{
|
||||
LoadTraineesGroupsPSQL();
|
||||
//listOfGroups.removeAt(i);
|
||||
|
||||
break;
|
||||
return id_del;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseTrainees::editGroup(QString name, Group group)
|
||||
int DataBaseTrainees::editGroup(Group group)
|
||||
{
|
||||
//Группы
|
||||
for(int i = 0; i < listOfGroups.count(); i++)
|
||||
{
|
||||
if(listOfGroups[i].getName() == name)
|
||||
if(listOfGroups[i].getID() == group.getID())
|
||||
{
|
||||
if(!checkExistNameGroup(group.getName()) || group.getName() == name)
|
||||
if(!checkExistNameGroup(group.getName()) || group.getName() == listOfGroups[i].getName())
|
||||
{
|
||||
//group.setID(listOfGroups[i].getID());
|
||||
int id = dbLMS->updateGroup(group);
|
||||
|
||||
bool result = dbLMS->updateGroup(group);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
/*
|
||||
listOfGroups[i].setName(newName);
|
||||
|
||||
//Меняем имя группы у всех Обучаемых этой группы
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
{
|
||||
if(listOfTrainees[i].getGroup() == name)
|
||||
listOfTrainees[i].setGroup(newName);
|
||||
}
|
||||
*/
|
||||
LoadTraineesGroupsPSQL();
|
||||
|
||||
return true;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
tr("An existing group name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString DataBaseTrainees::newTrainee(QString nameGroup)
|
||||
int DataBaseTrainees::newTrainee(int id_group)
|
||||
{
|
||||
Trainee trainee;
|
||||
trainee.setGroup(nameGroup);
|
||||
Group group;
|
||||
group.setID(id_group);
|
||||
trainee.setGroup(group);
|
||||
trainee.setName(generateDefaultNameTrainee());
|
||||
trainee.setLogin(generateDefaultLoginTrainee());
|
||||
trainee.setPassword(QStringLiteral("<password>"));
|
||||
trainee.setLearnClass(QStringLiteral(""));
|
||||
trainee.setComputer(QStringLiteral(""));
|
||||
trainee.setArchived(false);
|
||||
trainee.setLoggedIn(false);
|
||||
//trainee.setWhatItDoes(QStringLiteral(""));
|
||||
|
||||
bool result = dbLMS->insertTrainee(trainee);
|
||||
int id = dbLMS->insertTrainee(trainee);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
//listOfTrainees.append(trainee);
|
||||
LoadTraineesGroupsPSQL();
|
||||
return trainee.getName();
|
||||
return id;
|
||||
}
|
||||
else
|
||||
return QStringLiteral("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DataBaseTrainees::deleteTrainee(QString name)
|
||||
int DataBaseTrainees::deleteTrainee(int id)
|
||||
{
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
{
|
||||
if(listOfTrainees[i].getName() == name)
|
||||
if(listOfTrainees[i].getID() == id)
|
||||
{
|
||||
int id = listOfTrainees[i].getID();
|
||||
int id_del = dbLMS->deleteTrainee(id);
|
||||
|
||||
bool result = dbLMS->deleteTrainee(id);
|
||||
|
||||
if(result)
|
||||
if(id_del)
|
||||
{
|
||||
LoadTraineesGroupsPSQL();
|
||||
//listOfTrainees.removeAt(i);
|
||||
return id_del;
|
||||
}
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseTrainees::editTrainee(QString name, Trainee trainee)
|
||||
int DataBaseTrainees::editTrainee(Trainee trainee)
|
||||
{
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
{
|
||||
if(listOfTrainees[i].getName() == name)
|
||||
if(listOfTrainees[i].getID() == trainee.getID())
|
||||
{
|
||||
if( (!checkExistNameTrainee(trainee.getName()) || trainee.getName() == name) &&
|
||||
if( (!checkExistNameTrainee(trainee.getName()) || trainee.getName() == listOfTrainees[i].getName()) &&
|
||||
(!checkExistLoginTrainee(trainee.getLogin()) || trainee.getLogin() == listOfTrainees[i].getLogin()) )
|
||||
{
|
||||
//trainee.setID(listOfTrainees[i].getID());
|
||||
int id = dbLMS->updateTrainee(trainee);
|
||||
|
||||
bool result = dbLMS->updateTrainee(trainee);
|
||||
|
||||
if(result)
|
||||
if(id)
|
||||
{
|
||||
//listOfTrainees.replace(i, trainee);
|
||||
LoadTraineesGroupsPSQL();
|
||||
return true;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
tr("An existing trainee's name or login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DataBaseTrainees::isArchived(QString name)
|
||||
bool DataBaseTrainees::isArchived(int id)
|
||||
{
|
||||
//Обучаемые
|
||||
for(int i = 0; i < listOfTrainees.count(); i++)
|
||||
{
|
||||
if(listOfTrainees[i].getName() == name)
|
||||
if(listOfTrainees[i].getID()== id)
|
||||
return listOfTrainees[i].getArchived();
|
||||
}
|
||||
return false;
|
||||
@@ -439,7 +431,7 @@ bool DataBaseTrainees::checkExistLoginTrainee(QString login)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Group::ColorGroup DataBaseTrainees::generateDefaultColorGroup()
|
||||
{
|
||||
for(int i = 0; i < Group::ColorGroup::countColor; i++)
|
||||
@@ -449,8 +441,8 @@ Group::ColorGroup DataBaseTrainees::generateDefaultColorGroup()
|
||||
return color;
|
||||
}
|
||||
return Group::ColorGroup::colorAther;
|
||||
}
|
||||
|
||||
}*/
|
||||
/*
|
||||
bool DataBaseTrainees::checkExistColorGroup(Group::ColorGroup color)
|
||||
{
|
||||
//Группы
|
||||
@@ -460,4 +452,4 @@ bool DataBaseTrainees::checkExistColorGroup(Group::ColorGroup color)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT DataBaseTrainees : QObject
|
||||
class DataBaseTrainees : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -21,35 +21,33 @@ public:
|
||||
|
||||
void LoadTraineesGroupsPSQL();
|
||||
|
||||
bool AuthorizationTrainee(QString login, QString password, QString learnClass, QString computer);
|
||||
bool AuthorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name);
|
||||
bool deAuthorizationTrainee(QString login);
|
||||
|
||||
void setTasks(QString login, QStringList tasks);
|
||||
//void setTasks(QString login, QStringList tasks);
|
||||
QStringList getTasks(QString login);
|
||||
|
||||
QString getNameTraineeOnComputer(QString computer);
|
||||
Trainee getTraineeOnComputer(QString computer);
|
||||
QString getNameTraineeOnComputer(QString computer_name);
|
||||
Trainee getTraineeOnComputer(QString computer_name);
|
||||
|
||||
QString getNameTraineeByLogin(QString login);
|
||||
QColor getColorGroupByLogin(QString login);
|
||||
//QColor getColorGroupByLogin(QString login);
|
||||
|
||||
QList<Trainee> getListTraineesInGroup(QString nameGroup);
|
||||
QList<Trainee> getListTraineesInGroup(int id);
|
||||
QList<Group> getListGroups();
|
||||
|
||||
QColor getColorGroup(Group::ColorGroup numColor);
|
||||
Trainee getTrainee(int id);
|
||||
Group getGroup(int id);
|
||||
|
||||
Trainee getTrainee(QString name);
|
||||
Group getGroup(QString nameGroup);
|
||||
int newGroup();
|
||||
int deleteGroup(int id);
|
||||
int editGroup(Group group);
|
||||
|
||||
QString newGroup();
|
||||
bool deleteGroup(QString name);
|
||||
bool editGroup(QString name, Group group);
|
||||
int newTrainee(int id_group);
|
||||
int deleteTrainee(int id);
|
||||
int editTrainee(Trainee trainee);
|
||||
|
||||
QString newTrainee(QString nameGroup);
|
||||
void deleteTrainee(QString name);
|
||||
bool editTrainee(QString name, Trainee trainee);
|
||||
|
||||
bool isArchived(QString name);
|
||||
bool isArchived(int id);
|
||||
|
||||
private:
|
||||
QString generateDefaultNameGroup();
|
||||
@@ -60,9 +58,6 @@ private:
|
||||
QString generateDefaultLoginTrainee();
|
||||
bool checkExistLoginTrainee(QString login);
|
||||
|
||||
Group::ColorGroup generateDefaultColorGroup();
|
||||
bool checkExistColorGroup(Group::ColorGroup color);
|
||||
|
||||
private:
|
||||
QList<Trainee> listOfTrainees;
|
||||
QList<Group> listOfGroups;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "dialogedittrainee.h"
|
||||
|
||||
EditorTrainees::EditorTrainees(DataBaseTrainees* db, bool adminMode, QWidget *parent) :
|
||||
//QDialog(parent),
|
||||
TraineesView(db, CommonView::TypeView::control, parent),
|
||||
TraineesView(db, CommonView::TypeView::control, adminMode, parent),
|
||||
ui(new Ui::EditorTrainees)
|
||||
{
|
||||
ui->setupUi((QDialog*)this);
|
||||
@@ -23,9 +22,9 @@ EditorTrainees::~EditorTrainees()
|
||||
|
||||
void EditorTrainees::on_btnNewGroup_clicked()
|
||||
{
|
||||
QString nameGroup = dbTrainees->newGroup();
|
||||
int id = dbTrainees->newGroup();
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(nameGroup);
|
||||
setCurrentGroup(id);
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnDeleteGroup_clicked()
|
||||
@@ -37,13 +36,24 @@ void EditorTrainees::on_btnDeleteGroup_clicked()
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
QString name = treeItemCurrent->text(0);
|
||||
if(dbTrainees->deleteGroup(name))
|
||||
{//Удалено
|
||||
loadTraineesFromDB();
|
||||
int id_group = treeItemCurrent->text(0).toInt();
|
||||
|
||||
if(dbTrainees->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
|
||||
QMessageBox::critical(this, tr("Editing error!"), tr("The group is not empty.\nIt is not possible to delete a non-empty group."));
|
||||
{//Пустая группа
|
||||
if(int id = dbTrainees->deleteGroup(id_group))
|
||||
{//Удалено
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка удаления
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,10 +67,16 @@ void EditorTrainees::on_btnNewTrainee_clicked()
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа. Можно добавить Обучаемого
|
||||
QString nameGroup = treeItemCurrent->text(0);
|
||||
dbTrainees->newTrainee(nameGroup);
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(nameGroup);
|
||||
int id_group = treeItemCurrent->text(0).toInt();
|
||||
if(int id = dbTrainees->newTrainee(id_group))
|
||||
{
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка добавления
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,14 +91,20 @@ void EditorTrainees::on_btnDeleteTrainee_clicked()
|
||||
if(treeItemParent != nullptr)
|
||||
{//Выбран обучаемый
|
||||
|
||||
QString name = treeItemCurrent->text(0);
|
||||
QString nameGroup = treeItemParent->text(0);
|
||||
int id_trainee = treeItemCurrent->text(0).toInt();
|
||||
int id_group = treeItemParent->text(0).toInt();
|
||||
|
||||
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
dbTrainees->deleteTrainee(name);
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(nameGroup);
|
||||
if(int id = dbTrainees->deleteTrainee(id_trainee))
|
||||
{//Удалено
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка удаления
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,29 +120,37 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
|
||||
if(treeItemParent != nullptr)
|
||||
{//Выбран обучаемый
|
||||
|
||||
QString name = treeItemCurrent->text(0);
|
||||
int id_trainee = treeItemCurrent->text(0).toInt();
|
||||
|
||||
Trainee trainee = dbTrainees->getTrainee(name);
|
||||
Trainee trainee = dbTrainees->getTrainee(id_trainee);
|
||||
|
||||
if(trainee.getArchived())
|
||||
{//Архивный
|
||||
trainee.setArchived(false);
|
||||
if(dbTrainees->editTrainee(name, trainee))
|
||||
{
|
||||
if(int id = dbTrainees->editTrainee(trainee))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentTrainee(trainee.getName());
|
||||
setCurrentTrainee(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка редактирования
|
||||
}
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
trainee.setArchived(true);
|
||||
if(dbTrainees->editTrainee(name, trainee))
|
||||
{
|
||||
if(int id = dbTrainees->editTrainee(trainee))
|
||||
{//Отредактировано
|
||||
if(!archiveVisible)
|
||||
ui->btnArchive->click();
|
||||
|
||||
loadTraineesFromDB();
|
||||
setCurrentTrainee(trainee.getName());
|
||||
setCurrentTrainee(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка редактирования
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,23 +168,25 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
|
||||
QString nameGroup = treeItemCurrent->text(0);
|
||||
int id_group = treeItemCurrent->text(0).toInt();
|
||||
|
||||
DialogEditGroup dlg(this);
|
||||
dlg.setGroup(dbTrainees->getGroup(nameGroup));
|
||||
dlg.setGroup(dbTrainees->getGroup(id_group));
|
||||
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
if(dbTrainees->editGroup(nameGroup, dlg.getGroup()))
|
||||
{
|
||||
if(int id = dbTrainees->editGroup(dlg.getGroup()))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(dlg.getGroup().getName());
|
||||
setCurrentGroup(id);
|
||||
}
|
||||
else
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing group name has been entered.\nThe changes will not be accepted."));
|
||||
{
|
||||
//Ошибка редактирования
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
@@ -166,23 +198,25 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
else
|
||||
{//Выбран обучаемый
|
||||
|
||||
QString name = treeItemCurrent->text(0);
|
||||
int id_trainee = treeItemCurrent->text(0).toInt();
|
||||
|
||||
DialogEditTrainee dlg(this);
|
||||
dlg.setTrainee(dbTrainees->getTrainee(name));
|
||||
dlg.setTrainee(dbTrainees->getTrainee(id_trainee));
|
||||
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
if(dbTrainees->editTrainee(name, dlg.getTrainee()))
|
||||
{
|
||||
if(int id = dbTrainees->editTrainee(dlg.getTrainee()))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentTrainee(dlg.getTrainee().getName());
|
||||
setCurrentTrainee(id);
|
||||
}
|
||||
else
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee's name or login has been entered.\nThe changes will not be accepted."));
|
||||
{
|
||||
//Ошибка редактирования
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
@@ -210,8 +244,27 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
QTreeWidgetItem *treeItemParent = current->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана группа
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
ui->btnDeleteGroup->setEnabled(true);
|
||||
int id_group = current->text(0).toInt();
|
||||
|
||||
if(adminMode)
|
||||
{
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
|
||||
if(dbTrainees->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);
|
||||
@@ -223,13 +276,13 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
}
|
||||
else
|
||||
{//Выбран обучаемый
|
||||
QString name = current->text(0);
|
||||
int id_trainee = current->text(0).toInt();
|
||||
|
||||
ui->btnNewGroup->setEnabled(false);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
|
||||
if(dbTrainees->isArchived(name))
|
||||
if(dbTrainees->isArchived(id_trainee))
|
||||
{//Архивный
|
||||
ui->btnDeleteTrainee->setEnabled(true);
|
||||
|
||||
@@ -251,13 +304,13 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::setCurrentGroup(QString nameGroup)
|
||||
void EditorTrainees::setCurrentGroup(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(0) == nameGroup)
|
||||
if(item->text(0).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
break;
|
||||
@@ -265,7 +318,7 @@ void EditorTrainees::setCurrentGroup(QString nameGroup)
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::setCurrentTrainee(QString name)
|
||||
void EditorTrainees::setCurrentTrainee(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
@@ -276,7 +329,7 @@ void EditorTrainees::setCurrentTrainee(QString name)
|
||||
{
|
||||
QTreeWidgetItem * itemChild = item->child(j);
|
||||
if(itemChild != nullptr)
|
||||
if(itemChild->text(0) == name)
|
||||
if(itemChild->text(0).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(itemChild);
|
||||
break;
|
||||
|
||||
@@ -18,7 +18,7 @@ class EditorTrainees : /*public QDialog,*/ public TraineesView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditorTrainees(DataBaseTrainees* db, bool adminMode = false, QWidget *parent = nullptr);
|
||||
explicit EditorTrainees(DataBaseTrainees* db, bool adminMode, QWidget *parent = nullptr);
|
||||
~EditorTrainees();
|
||||
|
||||
private Q_SLOTS:
|
||||
@@ -32,8 +32,8 @@ private Q_SLOTS:
|
||||
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
void setCurrentGroup(QString nameGroup);
|
||||
void setCurrentTrainee(QString name);
|
||||
void setCurrentGroup(int id);
|
||||
void setCurrentTrainee(int id);
|
||||
|
||||
private:
|
||||
Ui::EditorTrainees *ui;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <QHeaderView>
|
||||
#include "traineesview.h"
|
||||
|
||||
TraineesView::TraineesView(DataBaseTrainees* db, TypeView type, QWidget *parent):
|
||||
CommonView(type, parent),
|
||||
TraineesView::TraineesView(DataBaseTrainees* db, TypeView type, bool adminMode, QWidget *parent):
|
||||
CommonView(type, adminMode, parent),
|
||||
dbTrainees(db)
|
||||
{
|
||||
|
||||
@@ -15,38 +15,38 @@ void TraineesView::preparationTreeWidget(QTreeWidget *tree)
|
||||
if(treeWidget == nullptr)
|
||||
return;
|
||||
|
||||
treeWidget->setColumnCount(9);
|
||||
treeWidget->setColumnCount(10);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
|
||||
|
||||
treeWidget->setColumnWidth(0, 250);
|
||||
treeWidget->setColumnWidth(1, 100);
|
||||
treeWidget->setColumnWidth(0, 80);
|
||||
treeWidget->setColumnWidth(1, 250);
|
||||
treeWidget->setColumnWidth(2, 100);
|
||||
treeWidget->setColumnWidth(3, 130);
|
||||
treeWidget->setColumnWidth(3, 100);
|
||||
treeWidget->setColumnWidth(4, 130);
|
||||
treeWidget->setColumnWidth(5, 130);
|
||||
treeWidget->setColumnWidth(6, 80);
|
||||
treeWidget->setColumnWidth(6, 130);
|
||||
treeWidget->setColumnWidth(7, 80);
|
||||
treeWidget->setColumnWidth(8, 100);
|
||||
treeWidget->setColumnWidth(8, 80);
|
||||
treeWidget->setColumnWidth(9, 100);
|
||||
|
||||
if(typeView == TypeView::onlyView)
|
||||
{//onlyView
|
||||
treeWidget->setColumnHidden(1, true);
|
||||
treeWidget->setColumnHidden(2, true);
|
||||
treeWidget->setColumnHidden(6, true);
|
||||
treeWidget->setColumnHidden(8, true);
|
||||
treeWidget->setColumnHidden(3, true);
|
||||
treeWidget->setColumnHidden(7, true);
|
||||
}
|
||||
else
|
||||
{//control
|
||||
treeWidget->setColumnHidden(6, true);
|
||||
treeWidget->setColumnHidden(7, true);
|
||||
}
|
||||
}
|
||||
|
||||
void TraineesView::loadTraineesFromDB()
|
||||
{
|
||||
//dbTrainees->LoadTraineesGroupsPSQL();
|
||||
dbTrainees->LoadTraineesGroupsPSQL();
|
||||
|
||||
if(treeWidget == nullptr)
|
||||
return;
|
||||
@@ -58,56 +58,62 @@ void TraineesView::loadTraineesFromDB()
|
||||
{
|
||||
//Группа
|
||||
QTreeWidgetItem *ItemGroup = new QTreeWidgetItem(treeWidget);
|
||||
ItemGroup->setText(0, group.getName());
|
||||
ItemGroup->setIcon(0, QIcon(QStringLiteral(":/icons/group.png")));
|
||||
QColor color = dbTrainees->getColorGroup(/*group.getColor()*/Group::color0);
|
||||
setItemColor(ItemGroup, color);
|
||||
ItemGroup->setText(0, QString::number(group.getID()));
|
||||
ItemGroup->setText(1, group.getName());
|
||||
ItemGroup->setIcon(1, QIcon(QStringLiteral(":/icons/group.png")));
|
||||
setItemColor(ItemGroup, QColor(170, 190, 170));
|
||||
|
||||
//Обучаемые
|
||||
QList<Trainee> listTrainees;
|
||||
listTrainees = dbTrainees->getListTraineesInGroup(group.getName());
|
||||
listTrainees = dbTrainees->getListTraineesInGroup(group.getID());
|
||||
for(Trainee trainee : listTrainees)
|
||||
{
|
||||
QTreeWidgetItem *ItemTrainee = new QTreeWidgetItem();
|
||||
|
||||
ItemTrainee->setText(0, trainee.getName());
|
||||
ItemTrainee->setText(1, trainee.getLogin());
|
||||
ItemTrainee->setText(2, trainee.getPassword());
|
||||
ItemTrainee->setText(3, trainee.getLearnClass());
|
||||
ItemTrainee->setText(4, trainee.getComputer());
|
||||
ItemTrainee->setText(5, trainee.getIpAddress());
|
||||
ItemTrainee->setText(0, QString::number(trainee.getID()));
|
||||
ItemTrainee->setText(1, trainee.getName());
|
||||
ItemTrainee->setText(2, trainee.getLogin());
|
||||
ItemTrainee->setText(3, trainee.getPassword());
|
||||
ItemTrainee->setText(4, trainee.getComputer().getClassroom().getName());
|
||||
ItemTrainee->setText(5, trainee.getComputer().getName());
|
||||
ItemTrainee->setText(6, trainee.getComputer().getIpAddress());
|
||||
|
||||
if(trainee.getArchived())
|
||||
{//Архивный
|
||||
ItemTrainee->setText(6, tr("yes"));
|
||||
ItemTrainee->setIcon(0, QIcon(QStringLiteral(":/icons/traineeArchive.png")));
|
||||
ItemTrainee->setText(7, tr("yes"));
|
||||
ItemTrainee->setIcon(1, QIcon(QStringLiteral(":/icons/traineeArchive.png")));
|
||||
setItemColorArchive(ItemTrainee);
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
ItemTrainee->setText(6, tr("no"));
|
||||
ItemTrainee->setIcon(0, QIcon(QStringLiteral(":/icons/trainee.png")));
|
||||
ItemTrainee->setText(7, tr("no"));
|
||||
ItemTrainee->setIcon(1, QIcon(QStringLiteral(":/icons/trainee.png")));
|
||||
setItemColorNoArchive(ItemTrainee);
|
||||
}
|
||||
|
||||
if(trainee.getLoggedIn())
|
||||
{//Залогинен
|
||||
ItemTrainee->setText(7, tr("yes"));
|
||||
ItemTrainee->setIcon(7, QIcon(QStringLiteral(":/icons/circleGreen.png")));
|
||||
ItemTrainee->setText(8, tr("yes"));
|
||||
ItemTrainee->setIcon(8, QIcon(QStringLiteral(":/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{//Не Залогинен
|
||||
ItemTrainee->setText(7, tr("no"));
|
||||
ItemTrainee->setIcon(7, QIcon(QStringLiteral(":/icons/circleGray.png")));
|
||||
ItemTrainee->setText(8, tr("no"));
|
||||
ItemTrainee->setIcon(8, QIcon(QStringLiteral(":/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
ItemTrainee->setText(8, QString(trainee.getTasks().join(QStringLiteral(";"))));
|
||||
QString tasksStr;
|
||||
for(Task task: trainee.getTasks())
|
||||
{
|
||||
tasksStr += task.getName() + QStringLiteral("; ");
|
||||
}
|
||||
ItemTrainee->setText(9, tasksStr);
|
||||
|
||||
ItemGroup->addChild(ItemTrainee);
|
||||
|
||||
//Скрываем архивных (при необходимости)
|
||||
if(trainee.getArchived())
|
||||
if(!archiveVisible)
|
||||
if(! archiveVisible)
|
||||
ItemTrainee->setHidden(true);
|
||||
|
||||
//Скрываем незалогиненых (при необходимости)
|
||||
@@ -118,7 +124,7 @@ void TraineesView::loadTraineesFromDB()
|
||||
}
|
||||
|
||||
treeWidget->setSortingEnabled(true);
|
||||
treeWidget->sortItems(0, Qt::SortOrder::AscendingOrder);
|
||||
treeWidget->sortItems(1, Qt::SortOrder::AscendingOrder);
|
||||
treeWidget->expandAll();
|
||||
|
||||
if(typeView == TypeView::control)
|
||||
@@ -131,6 +137,6 @@ void TraineesView::loadTraineesFromDB()
|
||||
|
||||
void TraineesView::reSetHeadTreeWidget()
|
||||
{
|
||||
QStringList listHeaders = {tr("Trainee"), tr("Login"), tr("Password"), tr("Class"), tr("Computer"), tr("IP address"), tr("Archived"), tr("Logged"), tr("Tasks")};
|
||||
QStringList listHeaders = {tr("ID"), tr("Trainee"), tr("Login"), tr("Password"), tr("Class"), tr("Computer"), tr("IP address"), tr("Archived"), tr("Logged"), tr("Tasks")};
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
//Родительский класс представления БД Обучаемых (для просмотра и управления)
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT TraineesView: public CommonView
|
||||
class TraineesView: public CommonView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TraineesView(DataBaseTrainees* db, TypeView type, QWidget *parent = nullptr);
|
||||
TraineesView(DataBaseTrainees* db, TypeView type, bool adminMode, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void preparationTreeWidget(QTreeWidget* tree);
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#include "ui_viewertrainees.h"
|
||||
|
||||
ViewerTrainees::ViewerTrainees(DataBaseTrainees* db, bool adminMode, QWidget *parent) :
|
||||
//QWidget(parent),
|
||||
TraineesView(db, CommonView::TypeView::onlyView, parent),
|
||||
TraineesView(db, CommonView::TypeView::onlyView, adminMode, parent),
|
||||
ui(new Ui::ViewerTrainees)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -35,7 +34,7 @@ void ViewerTrainees::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column
|
||||
{
|
||||
if(item->childCount() == 0)
|
||||
{//Выбран обучаемый
|
||||
QString login = item->text(1);
|
||||
QString login = item->text(2);
|
||||
Q_EMIT signal_traineeSelected(login);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +47,7 @@ void ViewerTrainees::slot_tabMessengerChanged(QString login)
|
||||
|
||||
for (int j = 0; j < countChild; j++)
|
||||
{//Проход по обучаемым
|
||||
QString loginChild = ui->treeWidget->topLevelItem(i)->child(j)->text(1);
|
||||
QString loginChild = ui->treeWidget->topLevelItem(i)->child(j)->text(2);
|
||||
if(loginChild == login)
|
||||
{
|
||||
ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(i)->child(j));
|
||||
@@ -80,16 +79,12 @@ void ViewerTrainees::slot_LanguageChanged(QString language)
|
||||
void ViewerTrainees::on_btnEditorTrainees_clicked()
|
||||
{
|
||||
EditorTrainees editorTraineesGroups(dbTrainees, adminMode);
|
||||
//dlg.setWindowTitle(tr("List trainees"));
|
||||
//dlg.exec();
|
||||
//dlg.show();
|
||||
QDialog* dialog = new QDialog(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||
layout->addWidget(&editorTraineesGroups);
|
||||
dialog->setWindowTitle(tr("List trainees"));
|
||||
dialog->setWindowTitle(tr("Editor of trainees"));
|
||||
dialog->setMinimumSize(1400, 800);
|
||||
dialog->exec();
|
||||
|
||||
dbTrainees->LoadTraineesGroupsPSQL();
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ViewerTrainees;
|
||||
|
||||
//Виджет только для просмотра БД Обучаемых
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT ViewerTrainees : public TraineesView
|
||||
class ViewerTrainees : public TraineesView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user