refactoring: naming notify

This commit is contained in:
semenov
2024-08-28 10:44:35 +03:00
parent 9d1c8277d5
commit 3e43e897e7
14 changed files with 66 additions and 57 deletions

View File

@@ -50,25 +50,6 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
//qDebug() << Tools::GetTime() << "CLIENT: type: " << packetType;
}
if(packetType == PacketType::TYPE_MSG){ //поведение на тип пакета с сообщением
stream.startTransaction();
stream >> message;
if(!stream.commitTransaction()){
emit onSendDebugLog(Tools::GetTime() + "CLIENT: Message - FAIL commitTransaction");
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
emit onSendDebugLog(Tools::GetTime() + "ERROR: MESSAGE READ TIMEOUT");
return;
}
continue;
}
emit onSendDebugLog(Tools::GetTime() + " CLIENT: Message from server " + message); //результат обрабатывать тут?
packetType = PacketType::TYPE_NONE;
continue;
}
if(packetType == PacketType::TYPE_FOLDER){ //создание папок
stream.startTransaction();
stream >> filePath;
@@ -227,14 +208,16 @@ void RecognizeSystem::Recognize(QTcpSocket *socket)
if(packetType == PacketType::TYPE_NEEDUPDATE){ //нужно обновление
bool flag;
quint64 size;
bool flag = false;
quint64 size = 0;
quint64 fileCount = 0;
stream.startTransaction();
stream >> flag;
stream >> size;
stream >> fileCount;
emit onNeedUpdate(flag,size);
emit onNeedUpdate(flag,size,fileCount);
packetType = PacketType::TYPE_NONE;
}

View File

@@ -24,7 +24,7 @@ public:
signals:
void UpdateBytesAvailable(qint64 size,quint64 sended);
void LoadComplete();
void onNeedUpdate(bool flag,qint64 size);
void onNeedUpdate(bool flag,qint64 size,quint64 fileCount);
void onSendDebugLog(QString message);
void SockedDisabled();
void SaveLoginData(ServerAuthorization *serverAuth);

View File

@@ -36,3 +36,23 @@ QString Tools::CreateFullPath(QString path)
return fullPath;
}
QString Tools::convertFileSize(quint64 fileSize)
{
quint64 megaByte = fileSize / (1024 * 1024);
QString resultSize;
if (megaByte == 0)
{
auto kiloByte = fileSize / 1024;
resultSize = QString::number(kiloByte) + "кб. ";
}
else
{
resultSize = QString::number(megaByte) + "мб. ";
}
QString result = "Доступно обновление: " + resultSize;
return result;
}

View File

@@ -32,6 +32,7 @@ public:
static QString GetTime();
static QString CreateLocalPath(QString path);
static QString CreateFullPath(QString path);
static QString convertFileSize(quint64 fileSize);
};
#endif // GLOBAL_H

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2024-08-21T14:49:00. -->
<!-- Written by QtCreator 4.11.1, 2024-08-27T17:44:10. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_RecognizeSystem_t {
QByteArrayData data[16];
char stringdata0[197];
QByteArrayData data[17];
char stringdata0[207];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@@ -40,22 +40,23 @@ QT_MOC_LITERAL(4, 43, 6), // "sended"
QT_MOC_LITERAL(5, 50, 12), // "LoadComplete"
QT_MOC_LITERAL(6, 63, 12), // "onNeedUpdate"
QT_MOC_LITERAL(7, 76, 4), // "flag"
QT_MOC_LITERAL(8, 81, 14), // "onSendDebugLog"
QT_MOC_LITERAL(9, 96, 7), // "message"
QT_MOC_LITERAL(10, 104, 14), // "SockedDisabled"
QT_MOC_LITERAL(11, 119, 13), // "SaveLoginData"
QT_MOC_LITERAL(12, 133, 20), // "ServerAuthorization*"
QT_MOC_LITERAL(13, 154, 10), // "serverAuth"
QT_MOC_LITERAL(14, 165, 22), // "SocketWaitForReadyRead"
QT_MOC_LITERAL(15, 188, 8) // "waitTime"
QT_MOC_LITERAL(8, 81, 9), // "fileCount"
QT_MOC_LITERAL(9, 91, 14), // "onSendDebugLog"
QT_MOC_LITERAL(10, 106, 7), // "message"
QT_MOC_LITERAL(11, 114, 14), // "SockedDisabled"
QT_MOC_LITERAL(12, 129, 13), // "SaveLoginData"
QT_MOC_LITERAL(13, 143, 20), // "ServerAuthorization*"
QT_MOC_LITERAL(14, 164, 10), // "serverAuth"
QT_MOC_LITERAL(15, 175, 22), // "SocketWaitForReadyRead"
QT_MOC_LITERAL(16, 198, 8) // "waitTime"
},
"RecognizeSystem\0UpdateBytesAvailable\0"
"\0size\0sended\0LoadComplete\0onNeedUpdate\0"
"flag\0onSendDebugLog\0message\0SockedDisabled\0"
"SaveLoginData\0ServerAuthorization*\0"
"serverAuth\0SocketWaitForReadyRead\0"
"waitTime"
"flag\0fileCount\0onSendDebugLog\0message\0"
"SockedDisabled\0SaveLoginData\0"
"ServerAuthorization*\0serverAuth\0"
"SocketWaitForReadyRead\0waitTime"
};
#undef QT_MOC_LITERAL
@@ -75,20 +76,20 @@ static const uint qt_meta_data_RecognizeSystem[] = {
// signals: name, argc, parameters, tag, flags
1, 2, 49, 2, 0x06 /* Public */,
5, 0, 54, 2, 0x06 /* Public */,
6, 2, 55, 2, 0x06 /* Public */,
8, 1, 60, 2, 0x06 /* Public */,
10, 0, 63, 2, 0x06 /* Public */,
11, 1, 64, 2, 0x06 /* Public */,
14, 1, 67, 2, 0x06 /* Public */,
6, 3, 55, 2, 0x06 /* Public */,
9, 1, 62, 2, 0x06 /* Public */,
11, 0, 65, 2, 0x06 /* Public */,
12, 1, 66, 2, 0x06 /* Public */,
15, 1, 69, 2, 0x06 /* Public */,
// signals: parameters
QMetaType::Void, QMetaType::LongLong, QMetaType::ULongLong, 3, 4,
QMetaType::Void,
QMetaType::Void, QMetaType::Bool, QMetaType::LongLong, 7, 3,
QMetaType::Void, QMetaType::QString, 9,
QMetaType::Void, QMetaType::Bool, QMetaType::LongLong, QMetaType::ULongLong, 7, 3, 8,
QMetaType::Void, QMetaType::QString, 10,
QMetaType::Void,
QMetaType::Void, 0x80000000 | 12, 13,
QMetaType::Void, QMetaType::Int, 15,
QMetaType::Void, 0x80000000 | 13, 14,
QMetaType::Void, QMetaType::Int, 16,
0 // eod
};
@@ -101,7 +102,7 @@ void RecognizeSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int
switch (_id) {
case 0: _t->UpdateBytesAvailable((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< quint64(*)>(_a[2]))); break;
case 1: _t->LoadComplete(); break;
case 2: _t->onNeedUpdate((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break;
case 2: _t->onNeedUpdate((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2])),(*reinterpret_cast< quint64(*)>(_a[3]))); break;
case 3: _t->onSendDebugLog((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 4: _t->SockedDisabled(); break;
case 5: _t->SaveLoginData((*reinterpret_cast< ServerAuthorization*(*)>(_a[1]))); break;
@@ -125,7 +126,7 @@ void RecognizeSystem::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int
}
}
{
using _t = void (RecognizeSystem::*)(bool , qint64 );
using _t = void (RecognizeSystem::*)(bool , qint64 , quint64 );
if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&RecognizeSystem::onNeedUpdate)) {
*result = 2;
return;
@@ -216,9 +217,9 @@ void RecognizeSystem::LoadComplete()
}
// SIGNAL 2
void RecognizeSystem::onNeedUpdate(bool _t1, qint64 _t2)
void RecognizeSystem::onNeedUpdate(bool _t1, qint64 _t2, quint64 _t3)
{
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))) };
void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t1))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t2))), const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t3))) };
QMetaObject::activate(this, &staticMetaObject, 2, _a);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -102,15 +102,19 @@ void MainWindow::LoadComplete()
ui->startButton->setEnabled(true);
}
void MainWindow::SetNeedUpdate(bool flag,quint64 size)
void MainWindow::SetNeedUpdate(bool flag,quint64 size, quint64 fileCount)
{
maxBytesAvailable = 0;
if(flag){
quint64 megaByte = size / (1024 * 1024);
QString result = "Доступно обновление: " + QString::number(megaByte) + " мегабайт";
QString availableSizeText;
if (flag){
QString result = Tools::convertFileSize(size);
result += "Количество файлов: " + QString::number(fileCount);
ui->inlineTextDebug->setText(result);
maxBytesAvailable = size;
}else{
}
else
{
ui->inlineTextDebug->setText("Установлена последняя версия");
}

View File

@@ -72,7 +72,7 @@ private:
void Initialize();
void UpdateProgress(qint64 size,quint64 sended);
void LoadComplete();
void SetNeedUpdate(bool flag,quint64 size);
void SetNeedUpdate(bool flag,quint64 size,quint64 fileCount);
void LostConnection();
void CheckLoginResult(ServerAuthorization * serverAuth);
void CheckAppAvailable();