From baf5f535f9aafdc63872c1899d05262dbbacd18a Mon Sep 17 00:00:00 2001 From: semenov Date: Wed, 22 Jan 2025 10:14:43 +0300 Subject: [PATCH] bugfix:version info complete --- .../instructorsandtraineeswidget.cpp | 2 +- .../widgets/newversionwidget.ui | 41 ++++++++++++++++--- ServerLMS/Data/StreamingVersionData.h | 10 ++++- ServerLMS/Systems/assetsmanager.cpp | 29 ++++++------- ServerLMS/Systems/tools.cpp | 5 +++ ServerLMS/Systems/tools.h | 1 + ServerLMS/Systems/updatecontroller.cpp | 2 +- 7 files changed, 65 insertions(+), 25 deletions(-) diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index d00a1ec..1634632 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -170,7 +170,7 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA ui->btnAuthorizationInstructor->setText(tr("Deauthorization Instructor")); updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName); - connectorToServer->setLoginName(loginInstructorLoggedInLocal); + connectorToServer->setLoginName(nameInstructorLoggedInLocal); QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!")); } else diff --git a/InstructorsAndTrainees/widgets/newversionwidget.ui b/InstructorsAndTrainees/widgets/newversionwidget.ui index 9ba102e..03871e5 100644 --- a/InstructorsAndTrainees/widgets/newversionwidget.ui +++ b/InstructorsAndTrainees/widgets/newversionwidget.ui @@ -6,7 +6,7 @@ 0 0 - 325 + 344 200 @@ -61,7 +61,7 @@ - + 0 0 @@ -73,6 +73,12 @@ + + + 150 + 30 + + TextLabel @@ -92,13 +98,25 @@ 5 - 20 + 5 5 + + + 99 + 40 + + + + + 0 + 0 + + Новое название: @@ -108,8 +126,8 @@ - 0 - 0 + 150 + 30 @@ -126,6 +144,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + diff --git a/ServerLMS/Data/StreamingVersionData.h b/ServerLMS/Data/StreamingVersionData.h index 752aecc..2e3e892 100644 --- a/ServerLMS/Data/StreamingVersionData.h +++ b/ServerLMS/Data/StreamingVersionData.h @@ -14,12 +14,20 @@ public: this->createData = data; this->size = size; this->isChangeable = true; - this->author = ""; } StreamingVersionData(){}; ~StreamingVersionData(); + void fill(StreamingVersionData* data) + { + this->absolutePath = data->getAbsolutPath(); + this->viewName = data->getViewName(); + this->createData = data->getCreateData(); + this->size = data->getSize(); + this->isChangeable = data->getIsChangeable(); + this->author = data->getAuthor(); + } QString getAbsolutPath() const { return absolutePath; diff --git a/ServerLMS/Systems/assetsmanager.cpp b/ServerLMS/Systems/assetsmanager.cpp index 4f75ebb..385dcb3 100644 --- a/ServerLMS/Systems/assetsmanager.cpp +++ b/ServerLMS/Systems/assetsmanager.cpp @@ -170,22 +170,13 @@ void AssetsManager::addVersion(StreamingVersionData *data) void AssetsManager::createCopyVersion(QString versionName,QString newVersionName,QString author) { qDebug() << "assetManager thread ID " << QThread::currentThreadId(); - QListIterator iterator(*datas); StreamingVersionData* data = new StreamingVersionData; - while (iterator.hasNext()) - { - StreamingVersionData *version = iterator.next(); - - if (version->getViewName() == versionName) - { - data->setAbsolutePath(version->getAbsolutPath()); - } - } - + data->setAbsolutePath(Tools::createSharedPath("/" + newVersionName)); data->setAuthor(author); data->setIsChangeable(true); data->setViewName(newVersionName); + data->setCreateData(QDateTime::currentDateTime()); datas->append(data); qDebug() << "Version for copy " << versionName; @@ -282,7 +273,7 @@ void AssetsManager::copyAllRecurse(QString source,QString destination) void AssetsManager::writeVersionsToFile(QList version,bool isFirst) { QList listTag; - + datas->clear(); QFile file(versionListFile); foreach(StreamingVersionData* ver,version) @@ -337,10 +328,10 @@ void AssetsManager::writeVersionsToFile(QList version,boo void AssetsManager::createFirstVersionListXML(QList version) //TODO: переименовать и перебросить в AssetManager { QFile file(versionListFile); - + QList *temp = new QList(); if(!file.exists()) { - writeVersionsToFile(version,true); + writeVersionsToFile(version,true); } else { @@ -353,16 +344,20 @@ void AssetsManager::createFirstVersionListXML(QList versi { if(ver->getViewName() == data->getViewName()) { - data->setAbsolutePath(ver->getAbsolutPath()); + StreamingVersionData *tempData = new StreamingVersionData; + + tempData->fill(data); + tempData->setAbsolutePath(ver->getAbsolutPath()); + temp->append(tempData); + break; } } } - writeVersionsToFile(*datas,false); + writeVersionsToFile(*temp,false); } - } void AssetsManager::saveVersionToFile(StreamingVersionData *streamingVersion) //TODO: переименовать и перебросить в AssetManager diff --git a/ServerLMS/Systems/tools.cpp b/ServerLMS/Systems/tools.cpp index 68de94f..70e2093 100644 --- a/ServerLMS/Systems/tools.cpp +++ b/ServerLMS/Systems/tools.cpp @@ -66,6 +66,11 @@ QString Tools::createStreamingToRealPath(QString path,StreamingVersionData* stre } +QString Tools::createVersionHashFilepath(QString fileName) +{ + return staticDataFolderName + "/" + fileName + "Hash.xml"; +} + QString Tools::createUpdateFilePath(QString path) { //qDebug() << "Full path: " << path; diff --git a/ServerLMS/Systems/tools.h b/ServerLMS/Systems/tools.h index cf5fd3e..cd8840f 100644 --- a/ServerLMS/Systems/tools.h +++ b/ServerLMS/Systems/tools.h @@ -56,6 +56,7 @@ public: static QString createSharedPath(QString path); static QString createRealPath(QString path,StreamingVersionData* currentVersionData); static QString createStreamingToRealPath(QString path, StreamingVersionData *streamingVersionData); + static QString createVersionHashFilepath(QString fileName); }; diff --git a/ServerLMS/Systems/updatecontroller.cpp b/ServerLMS/Systems/updatecontroller.cpp index 2c55a2e..9a45f73 100644 --- a/ServerLMS/Systems/updatecontroller.cpp +++ b/ServerLMS/Systems/updatecontroller.cpp @@ -428,7 +428,7 @@ void UpdateController::calculateSharedHash() if (fileInfo.fileName() == "." || fileInfo.fileName() == "..") continue; - QString fileName = staticDataFolderName + "/" + fileInfo.fileName() + "Hash.xml"; + QString fileName = Tools::createVersionHashFilepath(fileInfo.fileName()); fileList = calculateHash(fileInfo.absoluteFilePath()); saveHash(fileName,fileList);