mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
В основном работает
This commit is contained in:
@@ -5,45 +5,21 @@
|
||||
|
||||
CommonView::CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
QWidget(parent),
|
||||
dbLMS(nullptr), //TODO
|
||||
connectorToServer(connectorToServer),
|
||||
treeWidget(nullptr),
|
||||
typeView(type),
|
||||
archiveVisible(false),
|
||||
notLoggedInVisible(false),
|
||||
adminMode(false),
|
||||
authComplited(false)
|
||||
authComplited(false),
|
||||
lastCurrentID(0),
|
||||
typeObject(TypeObject::objInstructor)
|
||||
{
|
||||
treeWidget = new QTreeWidget();
|
||||
|
||||
//QString name = treeWidget->objectName();
|
||||
//treeWidget->setObjectName("onlyView");
|
||||
//treeWidget->setAccessibleName("onlyView");
|
||||
|
||||
//treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
|
||||
//treeWidget->setStyleSheet(QStringLiteral("font-size: 10pt;"
|
||||
// "font-family: Tahoma;"));
|
||||
|
||||
treeWidget->setIconSize(QSize(20, 20));
|
||||
treeWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
||||
|
||||
/*
|
||||
treeWidget->setStyleSheet("QTreeWidget {font-size: 10pt; font-family: Tahoma;}"
|
||||
"QTreeWidget::item:selected {"
|
||||
"background-color: #ddffdd; "
|
||||
"border-style: solid solid solid solid; "
|
||||
"color: #000000;}"
|
||||
"QTreeWidgetItem::item:selected {"
|
||||
"background-color: #ddaadd; "
|
||||
"border-style: solid solid solid solid; "
|
||||
"color: #000000;}");
|
||||
|
||||
treeWidget->setStyleSheet("QTreeWidget {font-size: 10pt; font-family: Tahoma;}"
|
||||
"QTreeWidget::item:selected {"
|
||||
"background-color: #ddffdd; "
|
||||
"border-style: solid solid solid solid; "
|
||||
"color: #000000;}");*/
|
||||
|
||||
updateMyStyleSheet();
|
||||
}
|
||||
|
||||
@@ -59,8 +35,6 @@ void CommonView::setItemColorNoArchive(QTreeWidgetItem *item)
|
||||
|
||||
void CommonView::setItemColor(QTreeWidgetItem *item, QColor color)
|
||||
{
|
||||
//int columnCount = treeWidget->columnCount();
|
||||
|
||||
for (int i = 0; i < item->columnCount(); i++)
|
||||
item->setBackground(i, color);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <QTranslator>
|
||||
#include <QMutex>
|
||||
#include "instructorsAndTrainees_global.h"
|
||||
#include "interfacedatabaselms.h"
|
||||
#include "connectortoserver.h"
|
||||
|
||||
//Родительский класс представления БД Инструкторов/Обучаемых (самого верхнего уровня)
|
||||
@@ -21,6 +20,13 @@ public:
|
||||
control
|
||||
};
|
||||
|
||||
enum TypeObject
|
||||
{
|
||||
objInstructor,
|
||||
objTrainee,
|
||||
objGroup
|
||||
};
|
||||
|
||||
public:
|
||||
CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent = nullptr);
|
||||
|
||||
@@ -56,7 +62,6 @@ private:
|
||||
QString loadStyleSheet();
|
||||
|
||||
protected:
|
||||
InterfaceDataBaseLMS* dbLMS;
|
||||
ConnectorToServer* connectorToServer;
|
||||
QTreeWidget* treeWidget;
|
||||
QMutex mtxTreeWidget;
|
||||
@@ -65,6 +70,8 @@ protected:
|
||||
bool notLoggedInVisible;
|
||||
bool adminMode;
|
||||
bool authComplited;
|
||||
int lastCurrentID;
|
||||
TypeObject typeObject;
|
||||
};
|
||||
|
||||
#endif // COMMONVIEW_H
|
||||
|
||||
@@ -31,7 +31,7 @@ void TCPClient::setConnect(ServerSettings *serverSettings)
|
||||
emit sigSendDebugLog("Try connect...");
|
||||
isConnected = true;
|
||||
|
||||
if (socket->waitForConnected(2000))
|
||||
if (socket->waitForConnected(5))
|
||||
{
|
||||
connect(socket,&QTcpSocket::readyRead,this,&TCPClient::slotReadyRead,Qt::DirectConnection);
|
||||
connect(socket,&QTcpSocket::disconnected,this,&TCPClient::setDisconnect);
|
||||
@@ -42,6 +42,8 @@ void TCPClient::setConnect(ServerSettings *serverSettings)
|
||||
|
||||
emit sigSetSocket(socket);
|
||||
slotConnectNotify();
|
||||
|
||||
emit signal_ConnectedToServer(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -56,6 +58,8 @@ void TCPClient::setDisconnect()
|
||||
isConnected = false;
|
||||
emit sigServerDisconnect();
|
||||
emit sigSendDebugLog("Server disabled");
|
||||
|
||||
emit signal_ConnectedToServer(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ signals:
|
||||
void sigConnectionState(bool flag);
|
||||
void sigSetSocket(QTcpSocket *socket);
|
||||
|
||||
void signal_ConnectedToServer(bool state);
|
||||
|
||||
public slots:
|
||||
void slotSendCommand(QString message);
|
||||
void slotConnectNotify();
|
||||
|
||||
@@ -62,6 +62,11 @@ bool ConnectorToServer::sendQueryToDB(TypeQueryToDB typeQuery, int id, void* dat
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConnectorToServer::SetConnectToServer()
|
||||
{
|
||||
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
|
||||
}
|
||||
|
||||
QList<Instructor> ConnectorToServer::getListInstructors()
|
||||
{
|
||||
return listInstructors;
|
||||
@@ -193,6 +198,7 @@ Group ConnectorToServer::getGroup(int id)
|
||||
return Group();
|
||||
}
|
||||
|
||||
/*
|
||||
void ConnectorToServer::slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
QList<Trainee>* listTrainees,
|
||||
QList<Group>* listGroups)
|
||||
@@ -201,7 +207,7 @@ void ConnectorToServer::slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
this->listTrainees = *listTrainees;
|
||||
this->listGroups = *listGroups;
|
||||
emit signal_UpdateDB(true, true);
|
||||
}
|
||||
}*/
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors)
|
||||
{
|
||||
@@ -263,7 +269,7 @@ void ConnectorToServer::bindConnection()
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAuth,this,&ConnectorToServer::sigLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB,this,&ConnectorToServer::slot_AnswerQueryToDB);
|
||||
//connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB,this,&ConnectorToServer::slot_AnswerQueryToDB);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListInstructors,this,&ConnectorToServer::slot_AnswerQueryToDB_ListInstructors);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListGroups,this,&ConnectorToServer::slot_AnswerQueryToDB_ListGroups);
|
||||
@@ -271,6 +277,8 @@ void ConnectorToServer::bindConnection()
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListComputers,this,&ConnectorToServer::slot_AnswerQueryToDB_ListComputers);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListClassrooms,this,&ConnectorToServer::slot_AnswerQueryToDB_ListClassrooms);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB_ListTasks,this,&ConnectorToServer::slot_AnswerQueryToDB_ListTasks);
|
||||
|
||||
connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer);
|
||||
}
|
||||
|
||||
void ConnectorToServer::createObjects()
|
||||
|
||||
@@ -22,9 +22,10 @@ public:
|
||||
bool authorizationInstructorLocal(QString login, QString password);
|
||||
bool deAuthorizationInstructorLocal(QString login);
|
||||
|
||||
//bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0, Instructor* instructor = nullptr);
|
||||
bool sendQueryToDB(TypeQueryToDB typeQuery, int id = 0, void* data = nullptr);
|
||||
|
||||
void SetConnectToServer();
|
||||
|
||||
public:
|
||||
//Запросы к БД (локальной)
|
||||
QList<Instructor> getListInstructors();
|
||||
@@ -46,9 +47,9 @@ public:
|
||||
Group getGroup(int id);
|
||||
|
||||
public slots:
|
||||
void slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
/*void slot_AnswerQueryToDB(QList<Instructor>* listInstructors,
|
||||
QList<Trainee>* listTrainees,
|
||||
QList<Group>* listGroups);
|
||||
QList<Group>* listGroups);*/
|
||||
|
||||
void slot_AnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors);
|
||||
void slot_AnswerQueryToDB_ListGroups(QList<Group> listGroups);
|
||||
@@ -73,6 +74,8 @@ signals:
|
||||
|
||||
void signal_UpdateDB(bool treeInstructor, bool treeTrainee);
|
||||
|
||||
void signal_ConnectedToServer(bool state);
|
||||
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
@@ -15,7 +15,7 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool
|
||||
|
||||
this->adminMode = adminMode;
|
||||
|
||||
preparationTreeWidget(/*ui->treeWidget*/);
|
||||
preparationTreeWidget();
|
||||
//setNotLoggedInVisible(true);
|
||||
loadInstructorsFromDB();
|
||||
|
||||
@@ -107,8 +107,6 @@ 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)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id);
|
||||
//if(dbLMS->delInstructor(id))
|
||||
//loadInstructorsFromDB();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,15 +128,10 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
|
||||
if(instructor.getID() == 0)
|
||||
return;
|
||||
|
||||
if(connectorToServer->isArchivedInstructor(id)/* instructor.getArchived()*/)
|
||||
if(connectorToServer->isArchivedInstructor(id))
|
||||
{//Архивный
|
||||
instructor.setArchived(false);
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR, id, &instructor);
|
||||
/*if(int id_edit = dbLMS->editInstructor(instructor))
|
||||
{
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(id_edit);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
@@ -150,6 +143,8 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
|
||||
|
||||
instructor.setArchived(true);
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR, id, &instructor);
|
||||
if(!archiveVisible)
|
||||
ui->btnArchive->click();
|
||||
/*if(int id_edit = dbLMS->editInstructor(instructor))
|
||||
{
|
||||
if(!archiveVisible)
|
||||
@@ -197,25 +192,8 @@ void EditorInstructors::on_btnEdit_clicked()
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Instructor instructor_edit = dlg.getInstructor();
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_INSTRUCTOR, id, &instructor_edit);
|
||||
|
||||
return;
|
||||
/*
|
||||
if(int id_edit = connectorToServer->editInstructor(instructor_edit))
|
||||
{//Отредактировано
|
||||
loadInstructorsFromDB();
|
||||
setCurrentInstructor(id_edit);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg.setInstructor(instructor_edit);
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return;
|
||||
@@ -232,6 +210,10 @@ void EditorInstructors::on_btnArchive_clicked()
|
||||
{
|
||||
bool state = ui->btnArchive->isChecked();
|
||||
setArchiveVisible(state);
|
||||
if(!state)
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
}
|
||||
loadInstructorsFromDB();
|
||||
}
|
||||
|
||||
@@ -248,6 +230,8 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
|
||||
int id = current->text(ColumnsTreeInsructors::clmn_ID).toInt();
|
||||
|
||||
lastCurrentID = id;
|
||||
|
||||
if(connectorToServer->isArchivedInstructor(id))
|
||||
{//Архивный
|
||||
ui->btnToOrFromArchive->setText(tr("From archive"));
|
||||
@@ -284,16 +268,4 @@ void EditorInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *curren
|
||||
}
|
||||
}
|
||||
|
||||
void EditorInstructors::setCurrentInstructor(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeInsructors::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ private Q_SLOTS:
|
||||
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
void setCurrentInstructor(int id);
|
||||
//void setCurrentInstructor(int id);
|
||||
|
||||
private:
|
||||
Ui::EditorInstructors *ui;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
InstructorsView::InstructorsView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
CommonView(connectorToServer, type, parent)
|
||||
{
|
||||
|
||||
typeObject = TypeObject::objInstructor;
|
||||
}
|
||||
|
||||
void InstructorsView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
@@ -39,7 +39,7 @@ void InstructorsView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
loadInstructorsFromDB();
|
||||
}
|
||||
|
||||
void InstructorsView::preparationTreeWidget(/*QTreeWidget* tree*/)
|
||||
void InstructorsView::preparationTreeWidget()
|
||||
{
|
||||
mtxTreeWidget.lock();
|
||||
|
||||
@@ -101,9 +101,6 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
|
||||
//Инструкторы
|
||||
QList<Instructor> listInstructors;
|
||||
//TODO
|
||||
//listInstructors = dbLMS->getListInstructors();
|
||||
//sendSystem->getListInstructors();
|
||||
|
||||
listInstructors = connectorToServer->getListInstructors();
|
||||
|
||||
@@ -123,7 +120,7 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
if(instructor.getArchived())
|
||||
{//Архивный
|
||||
ItemInstructor->setText(ColumnsTreeInsructors::clmn_Archived, tr("yes"));
|
||||
ItemInstructor->setIcon(ColumnsTreeInsructors::clmn_Instructor, QIcon(QStringLiteral(":/icons/instructorArchive.png")));
|
||||
ItemInstructor->setIcon(ColumnsTreeInsructors::clmn_Instructor, QIcon(QStringLiteral(":/icons/archive.png")));
|
||||
setItemColorArchive(ItemInstructor);
|
||||
}
|
||||
else
|
||||
@@ -167,12 +164,15 @@ void InstructorsView::loadInstructorsFromDB()
|
||||
|
||||
treeWidget->expandAll();
|
||||
|
||||
/*
|
||||
//if(typeView == TypeView::control)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
}
|
||||
}*/
|
||||
|
||||
setCurrentInstructor(lastCurrentID);
|
||||
|
||||
mtxTreeWidget.unlock();
|
||||
}
|
||||
@@ -183,3 +183,21 @@ void InstructorsView::reSetHeadTreeWidget()
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
void InstructorsView::setCurrentInstructor(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeInsructors::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,12 @@ public Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual void updateButtons(){};
|
||||
void preparationTreeWidget(/*QTreeWidget* tree*/);
|
||||
void preparationTreeWidget();
|
||||
void loadInstructorsFromDB();
|
||||
|
||||
void reSetHeadTreeWidget();
|
||||
|
||||
void setCurrentInstructor(int id);
|
||||
};
|
||||
|
||||
#endif // INSTRUCTORSVIEW_H
|
||||
|
||||
@@ -13,7 +13,7 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
|
||||
|
||||
treeWidget->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
|
||||
preparationTreeWidget(/*ui->treeWidget*/);
|
||||
preparationTreeWidget();
|
||||
setNotLoggedInVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::InstructorsAndTraineesWidget),
|
||||
connectorToServer(nullptr),
|
||||
dbLMS(nullptr),
|
||||
viewerTrainees(nullptr),
|
||||
viewerInstructors(nullptr),
|
||||
messangerWidget(nullptr),
|
||||
@@ -31,9 +30,6 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
connect(connectorToServer,&ConnectorToServer::sigLoginResult,this,&InstructorsAndTraineesWidget::checkLoginResult);
|
||||
connect(connectorToServer,&ConnectorToServer::sigDeLoginResult,this,&InstructorsAndTraineesWidget::checkDeLoginResult);
|
||||
|
||||
dbLMS = new InterfaceDataBaseLMS(this);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_LanguageChanged, dbLMS, &InterfaceDataBaseLMS::slot_LanguageChanged);
|
||||
|
||||
viewerTrainees = new ViewerTrainees(connectorToServer, this);
|
||||
viewerInstructors = new ViewerInstructors(connectorToServer, this);
|
||||
connect(this, &InstructorsAndTraineesWidget::signal_NeedUpdateUI, viewerTrainees, &ViewerTrainees::slot_NeedUpdateUI);
|
||||
@@ -46,6 +42,9 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
connect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI);
|
||||
connect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerTrainees,&ViewerTrainees::slot_NeedUpdateUI);
|
||||
|
||||
connect(connectorToServer,&ConnectorToServer::signal_ConnectedToServer,this,&InstructorsAndTraineesWidget::slot_ConnectedToServer);
|
||||
|
||||
|
||||
messangerWidget = new MessangerWidget(this);
|
||||
|
||||
docTasksWidget = new DocTasksWidget(this);
|
||||
@@ -57,6 +56,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
|
||||
viewerTrainees->setMinimumSize(1600, 600);
|
||||
viewerInstructors->setMinimumSize(1600, 300);
|
||||
|
||||
ui->btnAuthorizationInstructor->setEnabled(false);
|
||||
}
|
||||
|
||||
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
@@ -68,7 +69,6 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
delete messangerWidget;
|
||||
delete viewerInstructors;
|
||||
delete viewerTrainees;
|
||||
delete dbLMS;
|
||||
delete connectorToServer;
|
||||
delete ui;
|
||||
}
|
||||
@@ -85,10 +85,12 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
|
||||
else
|
||||
ui->btnAuthorizationInstructor->setText(tr("Authorization Instructor"));
|
||||
|
||||
/*
|
||||
if(ui->btnConnectionToDB->isChecked())
|
||||
ui->btnConnectionToDB->setText(tr("Disconnection DB"));
|
||||
else
|
||||
ui->btnConnectionToDB->setText(tr("Connection DB"));
|
||||
*/
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
}
|
||||
@@ -162,6 +164,28 @@ void InstructorsAndTraineesWidget::checkDeLoginResult(ServerDeAuthorization *ser
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
||||
{
|
||||
if(state)
|
||||
{//Сервер подключен
|
||||
|
||||
//ui->btnConnectionToDB->setText(tr("Disconnection DB"));
|
||||
ui->btnConnectionToServer->setEnabled(false);
|
||||
ui->btnAuthorizationInstructor->setEnabled(true);
|
||||
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{//Сервер отключен
|
||||
|
||||
//ui->btnConnectionToDB->setText(tr("Connection DB"));
|
||||
ui->btnConnectionToServer->setEnabled(true);
|
||||
ui->btnAuthorizationInstructor->setEnabled(false);
|
||||
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/icons/circleGray.png")));
|
||||
}
|
||||
}
|
||||
|
||||
bool InstructorsAndTraineesWidget::authorizationInstructorDialog(QWidget* parent)
|
||||
{
|
||||
DialogAuthorizationInstructor dlg(parent);
|
||||
@@ -205,12 +229,15 @@ bool InstructorsAndTraineesWidget::authorizationIsCompleted()
|
||||
return true;
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
void InstructorsAndTraineesWidget::on_btnConnectionToServer_clicked()
|
||||
{
|
||||
bool stateIsChecked = ui->btnConnectionToDB->isChecked();
|
||||
connectorToServer->SetConnectToServer();
|
||||
|
||||
if(stateIsChecked)
|
||||
if(true)
|
||||
{//Подключение к БД
|
||||
/*
|
||||
connectorToServer->SetConnectToServer();
|
||||
|
||||
|
||||
if(! dbLMS->DBisConnected())
|
||||
{
|
||||
@@ -227,10 +254,11 @@ void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
|
||||
Q_EMIT signal_InitMessanger(dbLMS->getListTrainees());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{//Отключение от БД
|
||||
/*
|
||||
bool stateIsCheckedAuthorization = ui->btnAuthorizationInstructor->isChecked();
|
||||
if(stateIsCheckedAuthorization)
|
||||
ui->btnAuthorizationInstructor->click();
|
||||
@@ -247,7 +275,7 @@ void InstructorsAndTraineesWidget::on_btnConnectionToDB_clicked()
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/icons/circleGray.png")));
|
||||
|
||||
Q_EMIT signal_NeedUpdateUI(true, true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,8 +327,3 @@ void InstructorsAndTraineesWidget::on_btnUpdateStyleSheet_clicked()
|
||||
viewerTrainees->updateMyStyleSheet();
|
||||
viewerInstructors->updateMyStyleSheet();
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnQueryGetAllLists_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_GET_ALL_LISTS);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "viewerinstructors.h"
|
||||
#include "messangerwidget.h"
|
||||
#include "doctaskswidget.h"
|
||||
#include "interfacedatabaselms.h"
|
||||
#include "connectortoserver.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QList<Instructor>)
|
||||
@@ -41,6 +40,8 @@ public Q_SLOTS:
|
||||
//Слот обработки результата деавторизации
|
||||
void checkDeLoginResult(ServerDeAuthorization * serverDeAuth);
|
||||
|
||||
void slot_ConnectedToServer(bool state);
|
||||
|
||||
Q_SIGNALS:
|
||||
//сигнал об изменении языка интерфейса
|
||||
void signal_LanguageChanged(QString language);
|
||||
@@ -55,13 +56,13 @@ Q_SIGNALS:
|
||||
//сигнал об инициализации мессенджера
|
||||
void signal_InitMessanger(QList<Trainee> listTrainees);
|
||||
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_btnConnectionToDB_clicked();
|
||||
void on_btnConnectionToServer_clicked();
|
||||
void on_btnAuthorizationInstructor_clicked();
|
||||
void on_btnUpdateStyleSheet_clicked();
|
||||
|
||||
void on_btnQueryGetAllLists_clicked();
|
||||
|
||||
private:
|
||||
//Авторизация инструктора локальная
|
||||
bool authorizationInstructorDialog(QWidget* parent = nullptr);
|
||||
@@ -74,8 +75,6 @@ private:
|
||||
|
||||
ConnectorToServer* connectorToServer;
|
||||
|
||||
InterfaceDataBaseLMS* dbLMS;
|
||||
|
||||
ViewerTrainees* viewerTrainees;
|
||||
ViewerInstructors* viewerInstructors;
|
||||
MessangerWidget* messangerWidget;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnConnectionToDB">
|
||||
<widget class="QToolButton" name="btnConnectionToServer">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
@@ -55,7 +55,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection to DB</string>
|
||||
<string>Connection to Server</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
@@ -68,7 +68,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
@@ -212,19 +212,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnQueryGetAllLists">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>GET_ALL_LISTS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -16,7 +16,7 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM
|
||||
|
||||
this->adminMode = adminMode;
|
||||
|
||||
preparationTreeWidget(/*ui->treeWidget*/);
|
||||
preparationTreeWidget();
|
||||
//setNotLoggedInVisible(true);
|
||||
loadTraineesFromDB();
|
||||
|
||||
@@ -102,15 +102,6 @@ void EditorTrainees::on_btnDeleteGroup_clicked()
|
||||
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group);
|
||||
/*
|
||||
if(int id = dbLMS->delGroup(id_group))
|
||||
{//Удалено
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка удаления
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,16 +198,6 @@ void EditorTrainees::on_btnDeleteTrainee_clicked()
|
||||
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee);
|
||||
/*
|
||||
if(int id = dbLMS->delTrainee(id_trainee))
|
||||
{//Удалено
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка удаления
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,20 +219,10 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee) /*trainee.getArchived()*/)
|
||||
if(connectorToServer->isArchivedTrainee(id_trainee))
|
||||
{//Архивный
|
||||
trainee.setArchived(false);
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee);
|
||||
/*
|
||||
if(int id = dbLMS->editTrainee(trainee))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentTrainee(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка редактирования
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{//Не Архивный
|
||||
@@ -263,19 +234,8 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
|
||||
|
||||
trainee.setArchived(true);
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee);
|
||||
/*
|
||||
if(int id = dbLMS->editTrainee(trainee))
|
||||
{//Отредактировано
|
||||
if(!archiveVisible)
|
||||
ui->btnArchive->click();
|
||||
|
||||
loadTraineesFromDB();
|
||||
setCurrentTrainee(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ошибка редактирования
|
||||
}*/
|
||||
if(!archiveVisible)
|
||||
ui->btnArchive->click();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,6 +355,11 @@ void EditorTrainees::on_btnArchive_clicked()
|
||||
{
|
||||
bool state = ui->btnArchive->isChecked();
|
||||
setArchiveVisible(state);
|
||||
if(!state)
|
||||
{
|
||||
lastCurrentID = 0;
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
|
||||
@@ -410,6 +375,9 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
{//Выбрана группа
|
||||
int id_group = current->text(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
lastCurrentID = id_group;
|
||||
typeObject = TypeObject::objGroup;
|
||||
|
||||
if(adminMode)
|
||||
{
|
||||
ui->btnNewGroup->setEnabled(true);
|
||||
@@ -442,6 +410,9 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
{//Выбран обучаемый
|
||||
int id_trainee = current->text(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
lastCurrentID = id_trainee;
|
||||
typeObject = TypeObject::objTrainee;
|
||||
|
||||
ui->btnNewGroup->setEnabled(false);
|
||||
ui->btnDeleteGroup->setEnabled(false);
|
||||
ui->btnNewTrainee->setEnabled(false);
|
||||
@@ -486,37 +457,4 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::setCurrentGroup(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeTrainees::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTrainees::setCurrentTrainee(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
{
|
||||
for (int j = 0; j < item->childCount(); j++)
|
||||
{
|
||||
QTreeWidgetItem * itemChild = item->child(j);
|
||||
if(itemChild != nullptr)
|
||||
if(itemChild->text(ColumnsTreeTrainees::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(itemChild);
|
||||
break;
|
||||
}
|
||||
}//for (int j = 0; j < item->childCount(); j++)
|
||||
}
|
||||
}//for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ private Q_SLOTS:
|
||||
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
void setCurrentGroup(int id);
|
||||
void setCurrentTrainee(int id);
|
||||
//void setCurrentGroup(int id);
|
||||
//void setCurrentTrainee(int id);
|
||||
|
||||
private:
|
||||
Ui::EditorTrainees *ui;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
TraineesView::TraineesView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
|
||||
CommonView(connectorToServer, type, parent)
|
||||
{
|
||||
|
||||
typeObject = TypeObject::objGroup;
|
||||
}
|
||||
|
||||
void TraineesView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
@@ -38,7 +38,7 @@ void TraineesView::slot_NeedUpdateUI(bool treeInstructor, bool treeTrainee)
|
||||
loadTraineesFromDB();
|
||||
}
|
||||
|
||||
void TraineesView::preparationTreeWidget(/*QTreeWidget *tree*/)
|
||||
void TraineesView::preparationTreeWidget()
|
||||
{
|
||||
mtxTreeWidget.lock();
|
||||
|
||||
@@ -104,10 +104,6 @@ void TraineesView::loadTraineesFromDB()
|
||||
QList <Group> listGroups;
|
||||
QList <Trainee> listTrainees;
|
||||
|
||||
//TODO
|
||||
//listGroups = dbLMS->getListGroups();
|
||||
//listTrainees = dbLMS->getListTrainees();
|
||||
|
||||
listGroups = connectorToServer->getListGroups();
|
||||
listTrainees = connectorToServer->getListTrainees();
|
||||
|
||||
@@ -145,7 +141,7 @@ void TraineesView::loadTraineesFromDB()
|
||||
if(trainee.getArchived())
|
||||
{//Архивный
|
||||
ItemTrainee->setText(ColumnsTreeTrainees::clmn_Archived, tr("yes"));
|
||||
ItemTrainee->setIcon(ColumnsTreeTrainees::clmn_Trainee, QIcon(QStringLiteral(":/icons/traineeArchive.png")));
|
||||
ItemTrainee->setIcon(ColumnsTreeTrainees::clmn_Trainee, QIcon(QStringLiteral(":/icons/archive.png")));
|
||||
setItemColorArchive(ItemTrainee);
|
||||
}
|
||||
else
|
||||
@@ -187,12 +183,13 @@ void TraineesView::loadTraineesFromDB()
|
||||
ItemTrainee->setHidden(true);
|
||||
}
|
||||
|
||||
//if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
//delete ItemGroup;
|
||||
if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
delete ItemGroup;
|
||||
}
|
||||
|
||||
treeWidget->expandAll();
|
||||
|
||||
/*
|
||||
//if(typeView == TypeView::control)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
@@ -202,7 +199,12 @@ void TraineesView::loadTraineesFromDB()
|
||||
if(itemChild != nullptr)
|
||||
treeWidget->setCurrentItem(itemChild);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if(typeObject == TypeObject::objGroup)
|
||||
setCurrentGroup(lastCurrentID);
|
||||
else
|
||||
setCurrentTrainee(lastCurrentID);
|
||||
|
||||
mtxTreeWidget.unlock();
|
||||
}
|
||||
@@ -212,3 +214,50 @@ void TraineesView::reSetHeadTreeWidget()
|
||||
QStringList listHeaders = {tr("Trainee"), tr("Login"), tr("Password"), tr("Class"), tr("Computer"), tr("IP address"), tr("Archived"), tr("Logged"), tr("Tasks"), tr("ID")};
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
void TraineesView::setCurrentGroup(int id)
|
||||
{
|
||||
typeObject = TypeObject::objGroup;
|
||||
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeTrainees::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
}
|
||||
|
||||
void TraineesView::setCurrentTrainee(int id)
|
||||
{
|
||||
typeObject = TypeObject::objTrainee;
|
||||
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
{
|
||||
for (int j = 0; j < item->childCount(); j++)
|
||||
{
|
||||
QTreeWidgetItem * itemChild = item->child(j);
|
||||
if(itemChild != nullptr)
|
||||
if(itemChild->text(ColumnsTreeTrainees::clmn_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(itemChild);
|
||||
return;
|
||||
}
|
||||
}//for (int j = 0; j < item->childCount(); j++)
|
||||
}
|
||||
}//for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,13 @@ public Q_SLOTS:
|
||||
|
||||
protected:
|
||||
virtual void updateButtons(){};
|
||||
void preparationTreeWidget(/*QTreeWidget* tree*/);
|
||||
void preparationTreeWidget();
|
||||
void loadTraineesFromDB();
|
||||
|
||||
void reSetHeadTreeWidget();
|
||||
|
||||
void setCurrentGroup(int id);
|
||||
void setCurrentTrainee(int id);
|
||||
};
|
||||
|
||||
#endif // TRAINEESVIEW_H
|
||||
|
||||
@@ -12,7 +12,7 @@ ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, QWidget *pa
|
||||
|
||||
ui->horizontalLayout_1->addWidget(treeWidget);
|
||||
|
||||
preparationTreeWidget(/*ui->treeWidget*/);
|
||||
preparationTreeWidget();
|
||||
setNotLoggedInVisible(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user