В основном работает

This commit is contained in:
krivoshein
2024-12-12 17:20:06 +03:00
parent d28453440f
commit 1c9e0510a9
51 changed files with 634 additions and 810 deletions

View File

@@ -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;
}
}
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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

View File

@@ -13,7 +13,7 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
treeWidget->setSelectionMode(QAbstractItemView::NoSelection);
preparationTreeWidget(/*ui->treeWidget*/);
preparationTreeWidget();
setNotLoggedInVisible(true);
}