mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
допилил ownerWidget в DataBaseLMS
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
const QString DataBaseLMS::TypeUserDBInstructor = "instructor";
|
const QString DataBaseLMS::TypeUserDBInstructor = "instructor";
|
||||||
const QString DataBaseLMS::TypeUserDBTrainee = "trainee";
|
const QString DataBaseLMS::TypeUserDBTrainee = "trainee";
|
||||||
|
|
||||||
DataBaseLMS::DataBaseLMS(QWidget *ownerWidget):
|
DataBaseLMS::DataBaseLMS(QWidget *ownerWidget, QObject *parent):
|
||||||
|
QObject(parent),
|
||||||
db(nullptr),
|
db(nullptr),
|
||||||
transactionBegined(false),
|
|
||||||
ownerWidget(ownerWidget)
|
ownerWidget(ownerWidget)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -22,6 +22,12 @@ DataBaseLMS::~DataBaseLMS()
|
|||||||
deleteConnection();
|
deleteConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataBaseLMS::slot_LanguageChanged(QString language)
|
||||||
|
{
|
||||||
|
qtLanguageTranslator.load(QString(QStringLiteral("translations/DataBaseLMS_")) + language, QStringLiteral("."));
|
||||||
|
QCoreApplication::installTranslator(&qtLanguageTranslator);
|
||||||
|
}
|
||||||
|
|
||||||
bool DataBaseLMS::createConnection()
|
bool DataBaseLMS::createConnection()
|
||||||
{
|
{
|
||||||
dbSettings = getDataBaseSettings();
|
dbSettings = getDataBaseSettings();
|
||||||
@@ -52,9 +58,6 @@ bool DataBaseLMS::createConnection()
|
|||||||
|
|
||||||
void DataBaseLMS::deleteConnection()
|
void DataBaseLMS::deleteConnection()
|
||||||
{
|
{
|
||||||
if(transactionBegined)
|
|
||||||
QSqlDatabase::database().rollback();
|
|
||||||
|
|
||||||
if(db != nullptr)
|
if(db != nullptr)
|
||||||
{
|
{
|
||||||
if(db->isOpen())
|
if(db->isOpen())
|
||||||
@@ -87,7 +90,7 @@ DataBaseSettings DataBaseLMS::getDataBaseSettings()
|
|||||||
QFile file("config/settings.xml");
|
QFile file("config/settings.xml");
|
||||||
if(!file.open(QIODevice::ReadOnly))
|
if(!file.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(ownerWidget, "Attention!", "The file could not be opened: config/settings.xml");
|
QMessageBox::critical(ownerWidget, tr("Attention!"), tr("The file could not be opened:") + "config/settings.xml");
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
QXmlStreamReader xmlReader(&file);
|
QXmlStreamReader xmlReader(&file);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
#include "instructor.h"
|
#include "instructor.h"
|
||||||
#include "trainee.h"
|
#include "trainee.h"
|
||||||
@@ -23,12 +24,17 @@ public:
|
|||||||
int dbPort = 5432;
|
int dbPort = 5432;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataBaseLMS
|
class DataBaseLMS : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataBaseLMS(QWidget *ownerWidget);
|
DataBaseLMS(QWidget *ownerWidget, QObject *parent = nullptr);
|
||||||
~DataBaseLMS();
|
~DataBaseLMS();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void slot_LanguageChanged(QString language);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString TypeUserDBInstructor;
|
static const QString TypeUserDBInstructor;
|
||||||
static const QString TypeUserDBTrainee;
|
static const QString TypeUserDBTrainee;
|
||||||
@@ -110,9 +116,9 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
QSqlDatabase* db;
|
QSqlDatabase* db;
|
||||||
DataBaseSettings dbSettings;
|
DataBaseSettings dbSettings;
|
||||||
|
QTranslator qtLanguageTranslator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool transactionBegined;
|
|
||||||
QWidget* ownerWidget;
|
QWidget* ownerWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,25 +6,19 @@
|
|||||||
#include "interfacedatabaselms.h"
|
#include "interfacedatabaselms.h"
|
||||||
|
|
||||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent):
|
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent):
|
||||||
QObject(parent),
|
//QObject(parent),
|
||||||
DataBaseLMS(ownerWidget),
|
DataBaseLMS(ownerWidget, parent),
|
||||||
ownerWidget(ownerWidget)
|
ownerWidget(ownerWidget)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterfaceDataBaseLMS::slot_LanguageChanged(QString language)
|
|
||||||
{
|
|
||||||
qtLanguageTranslator.load(QString(QStringLiteral("translations/DataBaseLMS_")) + language, QStringLiteral("."));
|
|
||||||
QCoreApplication::installTranslator(&qtLanguageTranslator);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InterfaceDataBaseLMS::connectionToDB()
|
bool InterfaceDataBaseLMS::connectionToDB()
|
||||||
{
|
{
|
||||||
//QMutexLocker mtxLocker(&mtxAccess);
|
//QMutexLocker mtxLocker(&mtxAccess);
|
||||||
if(!createConnection())
|
if(!createConnection())
|
||||||
{
|
{
|
||||||
QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error: ") + db->lastError().text());
|
QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error") /*+ db->lastError().text()*/);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,16 +8,13 @@
|
|||||||
#include "DataBaseLMS_global.h"
|
#include "DataBaseLMS_global.h"
|
||||||
#include "databaselms.h"
|
#include "databaselms.h"
|
||||||
|
|
||||||
class DATABASELMS_EXPORT InterfaceDataBaseLMS : public QObject, DataBaseLMS
|
class DATABASELMS_EXPORT InterfaceDataBaseLMS : public /*QObject,*/ DataBaseLMS
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
//Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent = nullptr);
|
InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent = nullptr);
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void slot_LanguageChanged(QString language);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Соединение
|
//Соединение
|
||||||
bool connectionToDB();
|
bool connectionToDB();
|
||||||
@@ -102,8 +99,7 @@ public:
|
|||||||
int changeStatusTaskFIM(int id_task, QString status);
|
int changeStatusTaskFIM(int id_task, QString status);
|
||||||
int changeStatusTaskAMM(int id_task, QString status);
|
int changeStatusTaskAMM(int id_task, QString status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTranslator qtLanguageTranslator;
|
|
||||||
QWidget* ownerWidget;
|
QWidget* ownerWidget;
|
||||||
//QMutex mtxAccess;
|
//QMutex mtxAccess;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
#include "providerdblms.h"
|
#include "providerdblms.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
ProviderDBLMS::ProviderDBLMS(QWidget *parentWidget, QObject *parent) :
|
ProviderDBLMS::ProviderDBLMS(QWidget *parentWidget, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
dbLMS(nullptr)
|
dbLMS(nullptr),
|
||||||
|
parentWidget(parentWidget)
|
||||||
{
|
{
|
||||||
dbLMS = new InterfaceDataBaseLMS(/*parentWidget*/nullptr);
|
dbLMS = new InterfaceDataBaseLMS(parentWidget);
|
||||||
//ConnectionToDB();
|
//ConnectionToDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
InterfaceDataBaseLMS* dbLMS;
|
InterfaceDataBaseLMS* dbLMS;
|
||||||
QMutex mtxAccess;
|
QMutex mtxAccess;
|
||||||
|
QWidget *parentWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROVIDERDBLMS_H
|
#endif // PROVIDERDBLMS_H
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public slots:
|
|||||||
void slot_LanguageChanged(QString language);
|
void slot_LanguageChanged(QString language);
|
||||||
void slotUpdateListClients();
|
void slotUpdateListClients();
|
||||||
void slot_BlockAutorization(bool block);
|
void slot_BlockAutorization(bool block);
|
||||||
void addToLog(QString message);
|
void addToLog(QString message);
|
||||||
public:
|
public:
|
||||||
void removeClient(int socketId);
|
void removeClient(int socketId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user