PSQL 02.11.2024

This commit is contained in:
krivoshein
2024-11-02 13:43:57 +03:00
parent 9422c5e257
commit 0f1fa71c33
76 changed files with 576 additions and 493 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2024-11-01T11:44:20. -->
<!-- Written by QtCreator 4.11.1, 2024-11-02T13:43:21. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@@ -33,8 +33,18 @@ bool DataBaseInstructors::AuthorizationInstructor(QString login, QString passwor
if(listOfInstructors[i].getLogin() == login && listOfInstructors[i].getPassword() == password)
{
listOfInstructors[i].setLoggedIn(true);
return true;
Instructor instructor = listOfInstructors[i];
instructor.setLoggedIn(true);
bool result = dbLMS->updateInstructor(instructor);
if(result)
{
LoadInstructorsPSQL();
return true;
}
else
return false;
}
}
return false;
@@ -45,13 +55,23 @@ bool DataBaseInstructors::deAuthorizationInstructor(QString login)
//Инструкторы
for(int i = 0; i < listOfInstructors.count(); i++)
{
//if(listOfInstructors[i].getArchived())
//continue;
if(listOfInstructors[i].getArchived())
continue;
if(listOfInstructors[i].getLogin() == login)
{
listOfInstructors[i].setLoggedIn(false);
return true;
Instructor instructor = listOfInstructors[i];
instructor.setLoggedIn(false);
bool result = dbLMS->updateInstructor(instructor);
if(result)
{
LoadInstructorsPSQL();
return true;
}
else
return false;
}
}
return false;
@@ -131,46 +151,6 @@ void DataBaseInstructors::deleteInstructor(QString name)
}
}
void DataBaseInstructors::toArchiveInstructor(QString name)
{
//Инструкторы
for(int i = 0; i < listOfInstructors.count(); i++)
{
if(listOfInstructors[i].getName() == name)
if(! listOfInstructors[i].getArchived())
{
Instructor instructor = listOfInstructors[i];
instructor.setArchived(true);
bool result = dbLMS->updateInstructor(instructor);
if(result)
LoadInstructorsPSQL();
//listOfInstructors[i].setArchived(true);
}
}
}
void DataBaseInstructors::fromeArchiveInstructor(QString name)
{
//Инструкторы
for(int i = 0; i < listOfInstructors.count(); i++)
{
if(listOfInstructors[i].getName() == name)
if(listOfInstructors[i].getArchived())
{
Instructor instructor = listOfInstructors[i];
instructor.setArchived(false);
bool result = dbLMS->updateInstructor(instructor);
if(result)
LoadInstructorsPSQL();
//listOfInstructors[i].setArchived(false);
}
}
}
bool DataBaseInstructors::editInstructor(QString name, Instructor instructor)
{
//Инструкторы
@@ -181,7 +161,7 @@ bool DataBaseInstructors::editInstructor(QString name, Instructor instructor)
if( (!checkExistNameInstructor(instructor.getName()) || instructor.getName() == name) &&
(!checkExistLoginInstructor(instructor.getLogin()) || instructor.getLogin() == listOfInstructors[i].getLogin()) )
{
instructor.setID(listOfInstructors[i].getID());
//instructor.setID(listOfInstructors[i].getID());
bool result = dbLMS->updateInstructor(instructor);

View File

@@ -32,8 +32,6 @@ public:
QString newInstructor();
void deleteInstructor(QString name);
void toArchiveInstructor(QString name);
void fromeArchiveInstructor(QString name);
bool editInstructor(QString name, Instructor instructor);
bool isAdmin(QString name);

View File

@@ -3,7 +3,8 @@
DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogEditInstructor)
ui(new Ui::DialogEditInstructor),
instructorInput()
{
ui->setupUi(this);
}
@@ -15,9 +16,12 @@ DialogEditInstructor::~DialogEditInstructor()
void DialogEditInstructor::setInstructor(Instructor instructor)
{
instructorInput = instructor;
ui->editName ->setText(instructor.getName());
ui->editLogin->setText(instructor.getLogin());
ui->editPassword->setText(instructor.getPassword());
ui->checkIsAdmin->setChecked(instructor.getIsAdmin());
ui->checkArchived->setChecked(instructor.getArchived());
ui->checkLoggedIn->setChecked(instructor.getLoggedIn());
@@ -30,10 +34,12 @@ void DialogEditInstructor::setInstructor(Instructor instructor)
Instructor DialogEditInstructor::getInstructor()
{
Instructor instructor;
Instructor instructor = instructorInput;
instructor.setName(ui->editName->text());
instructor.setLogin(ui->editLogin->text());
instructor.setPassword(ui->editPassword->text());
instructor.setIsAdmin(ui->checkIsAdmin->isChecked());
instructor.setArchived(ui->checkArchived->isChecked());
instructor.setLoggedIn(ui->checkLoggedIn->isChecked());

View File

@@ -22,6 +22,8 @@ public:
private:
Ui::DialogEditInstructor *ui;
Instructor instructorInput;
};
#endif // DIALOGEDITINSTRUCTOR_H

View File

@@ -66,18 +66,28 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
QString name = treeItemCurrent->text(0);
if(dbInstructors->isArchived(name))
Instructor instructor = dbInstructors->getInstructor(name);
if(instructor.getArchived())
{//Архивный
dbInstructors->fromeArchiveInstructor(name);
loadInstructorsFromDB();
setCurrentInstructor(name);
instructor.setArchived(false);
if(dbInstructors->editInstructor(name, instructor))
{
loadInstructorsFromDB();
setCurrentInstructor(instructor.getName());
}
}
else
{//Не Архивный
dbInstructors->toArchiveInstructor(name);
loadInstructorsFromDB();
if(archiveVisible)
setCurrentInstructor(name);
instructor.setArchived(true);
if(dbInstructors->editInstructor(name, instructor))
{
if(!archiveVisible)
ui->btnArchive->click();
loadInstructorsFromDB();
setCurrentInstructor(instructor.getName());
}
}
}
}

View File

@@ -10,9 +10,9 @@ namespace Ui {
class EditorInstructors;
}
//Диалог для просмотра и управления БД Инструкторов
//Виджет для редактирования БД Инструкторов
class EditorInstructors : /*public QDialog,*/ public InstructorsView
class EditorInstructors : public InstructorsView
{
Q_OBJECT

View File

@@ -20,14 +20,14 @@ void InstructorsView::preparationTreeWidget(QTreeWidget* tree)
reSetHeadTreeWidget();
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 12pt;"));
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
treeWidget->setColumnWidth(0, 200);
treeWidget->setColumnWidth(1, 130);
treeWidget->setColumnWidth(2, 130);
treeWidget->setColumnWidth(3, 130);
treeWidget->setColumnWidth(4, 130);
treeWidget->setColumnWidth(5, 130);
treeWidget->setColumnWidth(0, 250);
treeWidget->setColumnWidth(1, 100);
treeWidget->setColumnWidth(2, 100);
treeWidget->setColumnWidth(3, 100);
treeWidget->setColumnWidth(4, 80);
treeWidget->setColumnWidth(5, 80);
if(typeView == TypeView::onlyView)
{//onlyView

View File

@@ -12,7 +12,7 @@ class ViewerInstructors;
//Виджет только для просмотра БД Инструкторов
class INSTRUCTORSANDTRAINEES_EXPORT ViewerInstructors : /*public QWidget,*/ public InstructorsView
class INSTRUCTORSANDTRAINEES_EXPORT ViewerInstructors : public InstructorsView
{
Q_OBJECT

View File

@@ -23,6 +23,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Instructors</string>
</property>

View File

@@ -6,7 +6,8 @@
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::InstructorsAndTraineesWidget),
adminMode(false)
adminMode(false),
loginInstructorLoggedIn(QStringLiteral(""))
{
ui->setupUi(this);
@@ -16,11 +17,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
dataBaseInstructors = new DataBaseInstructors(dbLMS);
//Авторизация Инструктора (Администратора)
while(! authorizationInstructor(this))
{
QMessageBox::warning(this, tr("Instructor authorization"), tr("Invalid login or password!"));
};
QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!"));
authorizationInstructorLocal(this);
m_viewerTrainees = new ViewerTrainees(dataBaseTrainees, adminMode);
m_viewerInstructors = new ViewerInstructors(dataBaseInstructors, adminMode);
@@ -28,12 +25,14 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
ui->verticalLayout->addWidget(m_viewerTrainees);
ui->verticalLayout->addWidget(m_viewerInstructors);
m_viewerTrainees->setMinimumSize(800, 800);
m_viewerInstructors->setMinimumSize(800, 300);
m_viewerTrainees->setMinimumSize(1000, 800);
m_viewerInstructors->setMinimumSize(1000, 300);
}
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
{
deAuthorizationInstructor(loginInstructorLoggedIn);
delete m_viewerInstructors;
delete m_viewerTrainees;
delete dataBaseInstructors;
@@ -42,35 +41,55 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
delete ui;
}
bool InstructorsAndTraineesWidget::authorizationInstructor(QWidget* parent)
bool InstructorsAndTraineesWidget::authorizationInstructorLocal(QWidget* parent)
{
DialogAuthorizationInstructor dlg(parent);
dlg.setWindowTitle(tr("Instructor authorithation"));
switch( dlg.exec() )
do
{
case QDialog::Accepted:
{
QString login = dlg.getLogin();
QString password = dlg.getPassword();
if(dataBaseInstructors->AuthorizationInstructor(login, password))
switch( dlg.exec() )
{
if(login == QStringLiteral("admin"))
adminMode = true;
return true;
case QDialog::Accepted:
{
QString login = dlg.getLogin();
QString password = dlg.getPassword();
if(dataBaseInstructors->AuthorizationInstructor(login, password))
{
loginInstructorLoggedIn = login;
if(login == QStringLiteral("admin"))
adminMode = true;
QMessageBox::information(parent, tr("Instructor authorization"), tr("Successfully!"));
return true;
}
else
QMessageBox::warning(parent, tr("Instructor authorization"), tr("Invalid login or password!"));
break;
}
case QDialog::Rejected:
return false;
default:
return false;
}
//break;
}
case QDialog::Rejected:
break;
default:
break;
}
while(true);
return false;
}
bool InstructorsAndTraineesWidget::authorizationCompleted()
{
if(loginInstructorLoggedIn == QStringLiteral(""))
return false;
else
return true;
}
bool InstructorsAndTraineesWidget::authorizationTrainee(QString login, QString password, QString learnClass = QStringLiteral(""), QString computer = QStringLiteral(""))
{
return dataBaseTrainees->AuthorizationTrainee(login, password, learnClass, computer);
@@ -81,7 +100,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationTrainee(QString login)
return dataBaseTrainees->deAuthorizationTrainee(login);
}
bool InstructorsAndTraineesWidget::authorizationInstructor(QString login, QString password)
bool InstructorsAndTraineesWidget::authorizationInstructorLocal(QString login, QString password)
{
return dataBaseInstructors->AuthorizationInstructor(login, password);
}

View File

@@ -22,14 +22,15 @@ public:
public:
//Авторизация инструктора локальная
bool authorizationInstructor(QWidget* parent = nullptr);
bool authorizationInstructorLocal(QWidget* parent = nullptr);
bool authorizationCompleted();
//Авторизация обучаемого на клиенте
bool authorizationTrainee(QString login, QString password, QString learnClass, QString computer);
bool deAuthorizationTrainee(QString login);
//Авторизация инструктора на клиенте
bool authorizationInstructor(QString login, QString password);
bool authorizationInstructorLocal(QString login, QString password);
bool deAuthorizationInstructor(QString login);
private:
@@ -44,6 +45,7 @@ private:
ViewerInstructors* m_viewerInstructors;
bool adminMode;
QString loginInstructorLoggedIn;
};
#endif // INSTRUCTORSANDTRAINEESWIDGET_H

View File

@@ -18,6 +18,11 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Database LMS</string>
</property>

View File

@@ -29,7 +29,7 @@ void TasksWidget::viewListTasksForTrainee(QString login)
{
QStringList listTasks;
listTasks = pDbTrainees->getWhatItDoes(login);
listTasks = pDbTrainees->getTasks(login);
ui->listWidgetTasks->clear();
ui->listWidgetTasks->addItems(listTasks);

View File

@@ -46,10 +46,20 @@ bool DataBaseTrainees::AuthorizationTrainee(QString login, QString password, QSt
if(listOfTrainees[i].getLogin() == login && listOfTrainees[i].getPassword() == password)
{
listOfTrainees[i].setLoggedIn(true);
listOfTrainees[i].setLearnClass(learnClass);
listOfTrainees[i].setComputer(computer);
return true;
Trainee trainee = listOfTrainees[i];
trainee.setLoggedIn(true);
trainee.setLearnClass(learnClass);
trainee.setComputer(computer);
bool result = dbLMS->updateTrainee(trainee);
if(result)
{
LoadTraineesGroupsPSQL();
return true;
}
else
return false;
}
}
return false;
@@ -60,42 +70,54 @@ bool DataBaseTrainees::deAuthorizationTrainee(QString login)
//Обучаемые
for(int i = 0; i < listOfTrainees.count(); i++)
{
//if(listOfTrainees[i].getArchived())
//continue;
if(listOfTrainees[i].getArchived())
continue;
if(listOfTrainees[i].getLogin() == login)
{
listOfTrainees[i].setLoggedIn(false);
listOfTrainees[i].setLearnClass(QStringLiteral(""));
listOfTrainees[i].setComputer(QStringLiteral(""));
return true;
Trainee trainee = listOfTrainees[i];
trainee.setLoggedIn(false);
trainee.setLearnClass(QStringLiteral(""));
trainee.setComputer(QStringLiteral(""));
bool result = dbLMS->updateTrainee(trainee);
if(result)
{
LoadTraineesGroupsPSQL();
return true;
}
else
return false;
}
}
return false;
}
void DataBaseTrainees::setWhatItDoes(QString login, QString whatItDoes)
void DataBaseTrainees::setTasks(QString login, QStringList tasks)
{
//Обучаемые
for(int i = 0; i < listOfTrainees.count(); i++)
{
if(listOfTrainees[i].getLogin() == login)
listOfTrainees[i].setWhatItDoes(whatItDoes);
listOfTrainees[i].setTasks(tasks);
}
}
QStringList DataBaseTrainees::getWhatItDoes(QString login)
QStringList DataBaseTrainees::getTasks(QString login)
{
QString whatItDoes = QStringLiteral("");
QStringList tasks;
//Обучаемые
for(int i = 0; i < listOfTrainees.count(); i++)
{
if(listOfTrainees[i].getLogin() == login)
whatItDoes = listOfTrainees[i].getWhatItDoes();
{
tasks = listOfTrainees[i].getTasks();
}
}
return whatItDoes.split(QStringLiteral(";"));
return tasks;
}
QString DataBaseTrainees::getNameTraineeOnComputer(QString computer)
@@ -230,17 +252,16 @@ bool DataBaseTrainees::deleteGroup(QString name)
return true;
}
bool DataBaseTrainees::editGroup(QString name, QString newName)
bool DataBaseTrainees::editGroup(QString name, Group group)
{
//Группы
for(int i = 0; i < listOfGroups.count(); i++)
{
if(listOfGroups[i].getName() == name)
{
if(!checkExistNameGroup(newName) || newName == name)
if(!checkExistNameGroup(group.getName()) || group.getName() == name)
{
Group group = listOfGroups[i];
group.setName(newName);
//group.setID(listOfGroups[i].getID());
bool result = dbLMS->updateGroup(group);
@@ -280,7 +301,7 @@ QString DataBaseTrainees::newTrainee(QString nameGroup)
trainee.setComputer(QStringLiteral(""));
trainee.setArchived(false);
trainee.setLoggedIn(false);
trainee.setWhatItDoes(QStringLiteral(""));
//trainee.setWhatItDoes(QStringLiteral(""));
bool result = dbLMS->insertTrainee(trainee);
@@ -314,46 +335,6 @@ void DataBaseTrainees::deleteTrainee(QString name)
}
}
void DataBaseTrainees::toArchiveTrainee(QString name)
{
//Обучаемые
for(int i = 0; i < listOfTrainees.count(); i++)
{
if(listOfTrainees[i].getName() == name)
if(! listOfTrainees[i].getArchived())
{
Trainee trainee = listOfTrainees[i];
trainee.setArchived(true);
bool result = dbLMS->updateTrainee(trainee);
if(result)
LoadTraineesGroupsPSQL();
//listOfTrainees[i].setArchived(true);
}
}
}
void DataBaseTrainees::fromeArchiveTrainee(QString name)
{
//Обучаемые
for(int i = 0; i < listOfTrainees.count(); i++)
{
if(listOfTrainees[i].getName() == name)
if(listOfTrainees[i].getArchived())
{
Trainee trainee = listOfTrainees[i];
trainee.setArchived(false);
bool result = dbLMS->updateTrainee(trainee);
if(result)
LoadTraineesGroupsPSQL();
//listOfTrainees[i].setArchived(false);
}
}
}
bool DataBaseTrainees::editTrainee(QString name, Trainee trainee)
{
//Обучаемые
@@ -364,7 +345,7 @@ bool DataBaseTrainees::editTrainee(QString name, Trainee trainee)
if( (!checkExistNameTrainee(trainee.getName()) || trainee.getName() == name) &&
(!checkExistLoginTrainee(trainee.getLogin()) || trainee.getLogin() == listOfTrainees[i].getLogin()) )
{
trainee.setID(listOfTrainees[i].getID());
//trainee.setID(listOfTrainees[i].getID());
bool result = dbLMS->updateTrainee(trainee);

View File

@@ -24,8 +24,8 @@ public:
bool AuthorizationTrainee(QString login, QString password, QString learnClass, QString computer);
bool deAuthorizationTrainee(QString login);
void setWhatItDoes(QString login, QString whatItDoes);
QStringList getWhatItDoes(QString login);
void setTasks(QString login, QStringList tasks);
QStringList getTasks(QString login);
QString getNameTraineeOnComputer(QString computer);
Trainee getTraineeOnComputer(QString computer);
@@ -43,12 +43,10 @@ public:
QString newGroup();
bool deleteGroup(QString name);
bool editGroup(QString name, QString newName);
bool editGroup(QString name, Group group);
QString newTrainee(QString nameGroup);
void deleteTrainee(QString name);
void toArchiveTrainee(QString name);
void fromeArchiveTrainee(QString name);
bool editTrainee(QString name, Trainee trainee);
bool isArchived(QString name);

View File

@@ -3,7 +3,8 @@
DialogEditGroup::DialogEditGroup(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogEditGroup)
ui(new Ui::DialogEditGroup),
groupInput()
{
ui->setupUi(this);
}
@@ -12,3 +13,19 @@ 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;
}

View File

@@ -4,6 +4,7 @@
#include <QDialog>
#include "ui_dialogeditgroup.h"
#include "computersLocations.h"
#include "group.h"
namespace Ui {
class DialogEditGroup;
@@ -17,18 +18,13 @@ public:
explicit DialogEditGroup(QWidget *parent = nullptr);
~DialogEditGroup();
void setName(QString name)
{
ui->editName->setText(name);
}
QString getName()
{
return ui->editName->text();
}
void setGroup(Group group);
Group getGroup();
private:
Ui::DialogEditGroup *ui;
Group groupInput;
};
#endif // DIALOGEDITGROUP_H

View File

@@ -4,7 +4,7 @@
DialogEditTrainee::DialogEditTrainee(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogEditTrainee),
nameGroup()
traineeInput()
{
ui->setupUi(this);
}
@@ -16,29 +16,26 @@ DialogEditTrainee::~DialogEditTrainee()
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());
nameGroup = trainee.getGroup();
}
Trainee DialogEditTrainee::getTrainee()
{
Trainee trainee;
Trainee trainee = traineeInput;
trainee.setName(ui->editName->text());
trainee.setLogin(ui->editLogin->text());
trainee.setPassword(ui->editPassword->text());
trainee.setLearnClass(QStringLiteral(""));
trainee.setComputer(QStringLiteral(""));
trainee.setArchived(ui->checkArchived->isChecked());
trainee.setLoggedIn(ui->checkLoggedIn->isChecked());
trainee.setWhatItDoes(QStringLiteral(""));
trainee.setGroup(nameGroup);
return trainee;
}

View File

@@ -22,7 +22,7 @@ public:
private:
Ui::DialogEditTrainee *ui;
QString nameGroup;
Trainee traineeInput;
};
#endif // DIALOGEDITTRAINEE_H

View File

@@ -100,21 +100,28 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
QString name = treeItemCurrent->text(0);
if(dbTrainees->isArchived(name))
Trainee trainee = dbTrainees->getTrainee(name);
if(trainee.getArchived())
{//Архивный
dbTrainees->fromeArchiveTrainee(name);
loadTraineesFromDB();
setCurrentTrainee(name);
trainee.setArchived(false);
if(dbTrainees->editTrainee(name, trainee))
{
loadTraineesFromDB();
setCurrentTrainee(trainee.getName());
}
}
else
{//Не Архивный
dbTrainees->toArchiveTrainee(name);
trainee.setArchived(true);
if(dbTrainees->editTrainee(name, trainee))
{
if(!archiveVisible)
ui->btnArchive->click();
if(!archiveVisible)
ui->btnArchive->click();
loadTraineesFromDB();
setCurrentTrainee(name);
loadTraineesFromDB();
setCurrentTrainee(trainee.getName());
}
}
}
}
@@ -134,15 +141,16 @@ void EditorTrainees::on_btnEdit_clicked()
QString nameGroup = treeItemCurrent->text(0);
DialogEditGroup dlg(this);
dlg.setName(nameGroup);
dlg.setGroup(dbTrainees->getGroup(nameGroup));
switch( dlg.exec() )
{
case QDialog::Accepted:
{
if(dbTrainees->editGroup(nameGroup, dlg.getName()))
if(dbTrainees->editGroup(nameGroup, dlg.getGroup()))
{
loadTraineesFromDB();
setCurrentGroup(dlg.getName());
setCurrentGroup(dlg.getGroup().getName());
}
else
QMessageBox::critical(this, tr("Editing error!"),

View File

@@ -11,7 +11,7 @@ namespace Ui {
class EditorTrainees;
}
//Диалог для просмотра и управления БД Обучаемых
//Виджет для редактирования БД Обучаемых
class EditorTrainees : /*public QDialog,*/ public TraineesView
{

View File

@@ -15,31 +15,32 @@ void TraineesView::preparationTreeWidget(QTreeWidget *tree)
if(treeWidget == nullptr)
return;
treeWidget->setColumnCount(8);
treeWidget->setColumnCount(9);
reSetHeadTreeWidget();
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 12pt;"));
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
treeWidget->setColumnWidth(0, 200);
treeWidget->setColumnWidth(1, 130);
treeWidget->setColumnWidth(2, 130);
treeWidget->setColumnWidth(0, 250);
treeWidget->setColumnWidth(1, 100);
treeWidget->setColumnWidth(2, 100);
treeWidget->setColumnWidth(3, 130);
treeWidget->setColumnWidth(4, 130);
treeWidget->setColumnWidth(5, 130);
treeWidget->setColumnWidth(6, 130);
treeWidget->setColumnWidth(7, 100);
treeWidget->setColumnWidth(6, 80);
treeWidget->setColumnWidth(7, 80);
treeWidget->setColumnWidth(8, 100);
if(typeView == TypeView::onlyView)
{//onlyView
treeWidget->setColumnHidden(1, true);
treeWidget->setColumnHidden(2, true);
treeWidget->setColumnHidden(5, true);
treeWidget->setColumnHidden(7, true);
treeWidget->setColumnHidden(6, true);
treeWidget->setColumnHidden(8, true);
}
else
{//control
treeWidget->setColumnHidden(5, true);
treeWidget->setColumnHidden(6, true);
}
}
@@ -74,32 +75,33 @@ void TraineesView::loadTraineesFromDB()
ItemTrainee->setText(2, trainee.getPassword());
ItemTrainee->setText(3, trainee.getLearnClass());
ItemTrainee->setText(4, trainee.getComputer());
ItemTrainee->setText(5, trainee.getIpAddress());
if(trainee.getArchived())
{//Архивный
ItemTrainee->setText(5, tr("yes"));
ItemTrainee->setText(6, tr("yes"));
ItemTrainee->setIcon(0, QIcon(QStringLiteral(":/icons/traineeArchive.png")));
setItemColorArchive(ItemTrainee);
}
else
{//Не Архивный
ItemTrainee->setText(5, tr("no"));
ItemTrainee->setText(6, tr("no"));
ItemTrainee->setIcon(0, QIcon(QStringLiteral(":/icons/trainee.png")));
setItemColorNoArchive(ItemTrainee);
}
if(trainee.getLoggedIn())
{//Залогинен
ItemTrainee->setText(6, tr("yes"));
ItemTrainee->setIcon(6, QIcon(QStringLiteral(":/icons/circleGreen.png")));
ItemTrainee->setText(7, tr("yes"));
ItemTrainee->setIcon(7, QIcon(QStringLiteral(":/icons/circleGreen.png")));
}
else
{//Не Залогинен
ItemTrainee->setText(6, tr("no"));
ItemTrainee->setIcon(6, QIcon(QStringLiteral(":/icons/circleGray.png")));
ItemTrainee->setText(7, tr("no"));
ItemTrainee->setIcon(7, QIcon(QStringLiteral(":/icons/circleGray.png")));
}
ItemTrainee->setText(7, trainee.getWhatItDoes());
ItemTrainee->setText(8, QString(trainee.getTasks().join(QStringLiteral(";"))));
ItemGroup->addChild(ItemTrainee);
@@ -129,6 +131,6 @@ void TraineesView::loadTraineesFromDB()
void TraineesView::reSetHeadTreeWidget()
{
QStringList listHeaders = {tr("Trainee"), tr("Login"), tr("Password"), tr("Class"), tr("Computer"), tr("Archived"), tr("Logged"), tr("Tasks")};
QStringList listHeaders = {tr("Trainee"), tr("Login"), tr("Password"), tr("Class"), tr("Computer"), tr("IP address"), tr("Archived"), tr("Logged"), tr("Tasks")};
treeWidget->setHeaderLabels(listHeaders);
}

View File

@@ -14,7 +14,7 @@ class ViewerTrainees;
//Виджет только для просмотра БД Обучаемых
class INSTRUCTORSANDTRAINEES_EXPORT ViewerTrainees : /*public QWidget,*/ public TraineesView
class INSTRUCTORSANDTRAINEES_EXPORT ViewerTrainees : public TraineesView
{
Q_OBJECT

View File

@@ -23,6 +23,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Trainees</string>
</property>