before task parser

This commit is contained in:
krivoshein
2024-11-25 15:25:55 +03:00
parent 2ed1eac956
commit 7637922872
401 changed files with 39759 additions and 1630 deletions

View File

@@ -13,6 +13,7 @@
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
@@ -25,6 +26,11 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Login</string>
</property>
@@ -32,6 +38,11 @@
</item>
<item>
<widget class="QLineEdit" name="editLogin">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>admin</string>
</property>
@@ -43,6 +54,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Password</string>
</property>
@@ -50,6 +66,11 @@
</item>
<item>
<widget class="QLineEdit" name="editPassword">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>admin</string>
</property>
@@ -59,6 +80,11 @@
</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>

View File

@@ -13,6 +13,7 @@
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
@@ -25,6 +26,11 @@
<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>
@@ -43,6 +49,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Login</string>
</property>
@@ -57,6 +68,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Password</string>
</property>
@@ -74,6 +90,11 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Administrator</string>
</property>
@@ -96,6 +117,11 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Archived</string>
</property>
@@ -118,6 +144,11 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Logged</string>
</property>
@@ -137,6 +168,11 @@
</item>
<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>

View File

@@ -4,17 +4,23 @@
#include "ui_editorinstructors.h"
EditorInstructors::EditorInstructors(InterfaceDataBaseLMS* dbLMS, bool adminMode, QWidget *parent) :
InstructorsView(dbLMS, CommonView::TypeView::control, adminMode, parent),
InstructorsView(dbLMS, CommonView::TypeView::control, parent),
ui(new Ui::EditorInstructors)
{
ui->setupUi((QDialog*)this);
preparationTreeWidget(ui->treeWidget);
setNotLoggedInVisible(true);
connect(treeWidget, &QTreeWidget::currentItemChanged, this, &EditorInstructors::on_treeWidget_currentItemChanged);
ui->verticalLayout_1->addWidget(treeWidget);
this->adminMode = adminMode;
preparationTreeWidget(/*ui->treeWidget*/);
//setNotLoggedInVisible(true);
loadInstructorsFromDB();
if(adminMode)
ui->btnArchive->click();
ui->btnArchive->click();
}
EditorInstructors::~EditorInstructors()
@@ -72,7 +78,7 @@ void EditorInstructors::on_btnNewInstructor_clicked()
void EditorInstructors::on_btnDeleteInstructor_clicked()
{
QTreeWidgetItem *treeItemCurrent = ui->treeWidget->currentItem();
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
if(treeItemCurrent != nullptr)
{
@@ -88,6 +94,12 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
return;
}
if(dbLMS->isLoggedInInstructor(id))
{//Инструктор залогирован!
QMessageBox::critical(this, tr("Error!"), tr("You cannot delete a logged-in instructor."));
return;
}
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete it anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
{
if(dbLMS->delInstructor(id))
@@ -99,7 +111,7 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
void EditorInstructors::on_btnToOrFromArchive_clicked()
{
QTreeWidgetItem *treeItemCurrent = ui->treeWidget->currentItem();
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
if(treeItemCurrent != nullptr)
{
@@ -124,6 +136,12 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
}
else
{//Не Архивный
if(dbLMS->isLoggedInInstructor(id))
{//Инструктор залогирован!
QMessageBox::critical(this, tr("Error!"), tr("You cannot archive a logged-in instructor."));
return;
}
instructor.setArchived(true);
if(int id_edit = dbLMS->editInstructor(instructor))
{
@@ -140,7 +158,7 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
void EditorInstructors::on_btnEdit_clicked()
{
QTreeWidgetItem *treeItemCurrent = ui->treeWidget->currentItem();
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
if(treeItemCurrent == nullptr)
return;
@@ -151,6 +169,12 @@ void EditorInstructors::on_btnEdit_clicked()
int id = treeItemCurrent->text(ColumnsTreeInsructors::clmn_ID).toInt();
if(dbLMS->isLoggedInInstructor(id))
{//Инструктор залогирован!
QMessageBox::critical(this, tr("Error!"), tr("You cannot archive a logged-in instructor."));
return;
}
DialogEditInstructor dlg(this);
Instructor instructor = dbLMS->getInstructor(id);
@@ -225,10 +249,11 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
ui->btnNewInstructor->setEnabled(true);
if(dbLMS->isAdminInstructor(id))
{//Это Админ! Удалять/Архивировать нельзя!
if(dbLMS->isAdminInstructor(id) || dbLMS->isLoggedInInstructor(id))
{//Это Админ или залогированный! Удалять/Архивировать/Редактировать нельзя!
ui->btnDeleteInstructor->setEnabled(false);
ui->btnToOrFromArchive->setEnabled(false);
ui->btnEdit->setEnabled(false);
}
else
{
@@ -238,9 +263,11 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
ui->btnDeleteInstructor->setEnabled(true);
else
ui->btnDeleteInstructor->setEnabled(false);
ui->btnEdit->setEnabled(true);
}
ui->btnEdit->setEnabled(true);
//ui->btnEdit->setEnabled(true);
ui->btnArchive->setEnabled(true);
}
}

View File

@@ -10,6 +10,12 @@
<height>800</height>
</rect>
</property>
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
<string>List instructors</string>
</property>
@@ -18,7 +24,8 @@
<widget class="QWidget" name="widget" native="true">
<property name="font">
<font>
<pointsize>12</pointsize>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">
@@ -28,32 +35,7 @@
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<layout class="QVBoxLayout" name="verticalLayout_1">
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="columnCount">
<number>1</number>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
<layout class="QVBoxLayout" name="verticalLayout_1"/>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
@@ -72,6 +54,7 @@
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="styleSheet">

View File

@@ -2,33 +2,72 @@
#include <QTranslator>
#include "instructorsview.h"
InstructorsView::InstructorsView(InterfaceDataBaseLMS* dbLMS, TypeView type, bool adminMode, QWidget *parent):
CommonView(type, adminMode, parent),
dbLMS(dbLMS)
InstructorsView::InstructorsView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent):
CommonView(dbLMS, type, parent)
{
}
void InstructorsView::preparationTreeWidget(QTreeWidget* tree)
void InstructorsView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
{
treeWidget = tree;
if(typeView == TypeView::onlyView)
{
if(adminMode)
archiveVisible = true;
else
archiveVisible = false;
}
else
{
archiveVisible = true;
}
if(adminMode)
{
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_ID, false);
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_Archived, false);
}
else
{
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_ID, true);
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_Archived, true);
}
updateButtons();
if(treeInstructor)
loadInstructorsFromDB();
}
void InstructorsView::preparationTreeWidget(/*QTreeWidget* tree*/)
{
mtxTreeWidget.lock();
//treeWidget = tree;
/*
if(treeWidget == nullptr)
{
mtxTreeWidget.unlock();
return;
}
*/
treeWidget->setColumnCount(7);
reSetHeadTreeWidget();
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
//treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
treeWidget->setStyleSheet(QStringLiteral("font-size: 10pt;"
"font-family: Tahoma;"));
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_ID, 50);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Instructor, 250);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Login, 100);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Password, 100);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Administrator, 100);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Archived, 80);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Logged, 80);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Archived, 100);
treeWidget->setColumnWidth(ColumnsTreeInsructors::clmn_Logged, 100);
if(typeView == TypeView::onlyView)
{//onlyView
@@ -37,13 +76,22 @@ void InstructorsView::preparationTreeWidget(QTreeWidget* tree)
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_Password, true);
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_Archived, true);
treeWidget->setColumnHidden(ColumnsTreeInsructors::clmn_Administrator, true);
if(adminMode)
archiveVisible = true;
else
archiveVisible = false;
notLoggedInVisible = true;
}
else
{//control
archiveVisible = true;
notLoggedInVisible = true;
if(adminMode)
{
archiveVisible = true;
notLoggedInVisible = true;
}
else
{
@@ -54,16 +102,27 @@ void InstructorsView::preparationTreeWidget(QTreeWidget* tree)
treeWidget->setSortingEnabled(true);
treeWidget->sortItems(ColumnsTreeInsructors::clmn_Instructor, Qt::SortOrder::AscendingOrder);
mtxTreeWidget.unlock();
}
void InstructorsView::loadInstructorsFromDB()
{
/*
if(treeWidget == nullptr)
return;
return;*/
mtxTreeWidget.lock();
//Обновление дерева
treeWidget->clear();
if(!dbLMS->DBisConnected())
{
mtxTreeWidget.unlock();
return;
}
//Инструкторы
QList<Instructor> listInstructors;
listInstructors = dbLMS->getListInstructors();
@@ -77,7 +136,8 @@ void InstructorsView::loadInstructorsFromDB()
ItemInstructor->setText(ColumnsTreeInsructors::clmn_Password, instructor.getPassword());
//Сокрытие пароля
ItemInstructor->setText(ColumnsTreeInsructors::clmn_Password, QStringLiteral("******"));
if(!adminMode)
ItemInstructor->setText(ColumnsTreeInsructors::clmn_Password, QStringLiteral("******"));
if(instructor.getArchived())
{//Архивный
@@ -132,6 +192,8 @@ void InstructorsView::loadInstructorsFromDB()
if(item != nullptr)
treeWidget->setCurrentItem(item);
}
mtxTreeWidget.unlock();
}
void InstructorsView::reSetHeadTreeWidget()

View File

@@ -2,7 +2,6 @@
#define INSTRUCTORSVIEW_H
#include "instructorsAndTrainees_global.h"
#include "interfacedatabaselms.h"
#include "commonview.h"
//Родительский класс представления БД Инструкторов (для просмотра и управления)
@@ -12,7 +11,7 @@ class InstructorsView: public CommonView
Q_OBJECT
public:
InstructorsView(InterfaceDataBaseLMS* dbLMS, TypeView type, bool adminMode, QWidget *parent = nullptr);
InstructorsView(InterfaceDataBaseLMS* dbLMS, TypeView type, QWidget *parent = nullptr);
protected:
enum ColumnsTreeInsructors{
@@ -25,14 +24,16 @@ protected:
clmn_ID
};
public Q_SLOTS:
//Слот обработки сигнала необходимости обновления интерфейса
void slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee);
protected:
void preparationTreeWidget(QTreeWidget* tree);
virtual void updateButtons(){};
void preparationTreeWidget(/*QTreeWidget* tree*/);
void loadInstructorsFromDB();
void reSetHeadTreeWidget();
protected:
InterfaceDataBaseLMS* dbLMS;
};
#endif // INSTRUCTORSVIEW_H

View File

@@ -3,24 +3,16 @@
#include "viewerinstructors.h"
#include "ui_viewerinstructors.h"
ViewerInstructors::ViewerInstructors(InterfaceDataBaseLMS* db, bool adminMode, QWidget *parent) :
InstructorsView(db, CommonView::TypeView::onlyView, adminMode, parent),
ViewerInstructors::ViewerInstructors(InterfaceDataBaseLMS* db, QWidget *parent) :
InstructorsView(db, CommonView::TypeView::onlyView, parent),
ui(new Ui::ViewerInstructors)
{
ui->setupUi(this);
this->adminMode = adminMode;
ui->horizontalLayout_2->addWidget(treeWidget);
// Сделаем первоначальную инициализацию перевода для окна виджета
qtLanguageTranslator.load(QString(QStringLiteral("translations/InstructorsAndTrainees_")) + QString(QStringLiteral("ru_RU")), QStringLiteral("."));
qApp->installTranslator(&qtLanguageTranslator);
preparationTreeWidget(ui->treeWidget);
preparationTreeWidget(/*ui->treeWidget*/);
setNotLoggedInVisible(true);
loadInstructorsFromDB();
if(! this->adminMode)
ui->btnEditorInstructors->setEnabled(false);
}
ViewerInstructors::~ViewerInstructors()
@@ -28,38 +20,22 @@ ViewerInstructors::~ViewerInstructors()
delete ui;
}
void ViewerInstructors::setFilterInstructorLoggedIn(bool enabled)
{
setNotLoggedInVisible(!enabled);
loadInstructorsFromDB();
}
void ViewerInstructors::changeEvent(QEvent *event)
{
// В случае получения события изменения языка приложения
if (event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this); // переведём окно заново
{// переведём окно заново
ui->retranslateUi(this);
reSetHeadTreeWidget();
loadInstructorsFromDB();
//loadInstructorsFromDB();
slot_NeedUpdateUI(true, false);
}
}
void ViewerInstructors::slot_LanguageChanged(QString language)
{
qtLanguageTranslator.load(QString(QStringLiteral("translations/InstructorsAndTrainees_")) + language, QStringLiteral("."));
qApp->installTranslator(&qtLanguageTranslator);
}
void ViewerInstructors::on_btnEditorInstructors_clicked()
{
if(! adminMode)
{
QMessageBox::warning(this, tr("Attention!"),
tr("Only the Administrator has the right to edit instructors."));
return;
}
Q_EMIT signal_BlockAutorization(true);
EditorInstructors editorInstructors(dbLMS, adminMode);
QDialog* dialog = new QDialog(this);
@@ -70,4 +46,18 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
dialog->exec();
loadInstructorsFromDB();
Q_EMIT signal_BlockAutorization(false);
}
void ViewerInstructors::updateButtons()
{
if(adminMode && authComplited)
{
ui->btnEditorInstructors->setEnabled(true);
}
else
{
ui->btnEditorInstructors->setEnabled(false);
}
}

View File

@@ -1,9 +1,6 @@
#ifndef INSTRUCTORSWIDGET_H
#define INSTRUCTORSWIDGET_H
#include <QWidget>
#include "instructorsAndTrainees_global.h"
#include "interfacedatabaselms.h"
#include "instructorsview.h"
namespace Ui {
@@ -17,23 +14,22 @@ class ViewerInstructors : public InstructorsView
Q_OBJECT
public:
explicit ViewerInstructors(InterfaceDataBaseLMS* db, bool adminMode, QWidget *parent = nullptr);
explicit ViewerInstructors(InterfaceDataBaseLMS* db, QWidget *parent = nullptr);
~ViewerInstructors();
protected:
// Метод получения событий
// В нём будет производиться проверка события смены перевода приложения
void changeEvent(QEvent * event) override;
public Q_SLOTS:
void slot_LanguageChanged(QString language);
Q_SIGNALS:
//сигнал о блокировке авторизации
void signal_BlockAutorization(bool block);
public:
void setFilterInstructorLoggedIn(bool enabled);
private slots:
private Q_SLOTS:
void on_btnEditorInstructors_clicked();
private:
void updateButtons() override;
private:
Ui::ViewerInstructors *ui;
};

View File

@@ -13,6 +13,7 @@
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="windowTitle">
@@ -38,6 +39,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="btnEditorInstructors">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>130</width>
@@ -77,27 +81,6 @@
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
</layout>