mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
#include "hashcomparer.h"
|
|
|
|
HashComparer::HashComparer(QObject *)
|
|
{
|
|
|
|
}
|
|
|
|
void HashComparer::initialize(VersionContainer *versionContainer)
|
|
{
|
|
|
|
this->versionContainer = versionContainer;
|
|
}
|
|
|
|
void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<FileData> localStreamingHash)
|
|
{
|
|
// QList<FileData> *serverStreamingHash = new QList<FileData>;
|
|
// QList<FileData> *localStreamingHash = new QList<FileData>;
|
|
QList<FileData> *files = new QList<FileData>;
|
|
|
|
QMutableListIterator<FileData> iterator(localStreamingHash);
|
|
|
|
for (auto &item:localStreamingHash)
|
|
{
|
|
if(!serverStreamingHash->contains(item))
|
|
{
|
|
files->append(item);
|
|
}
|
|
}
|
|
|
|
filesForUpdate = files;
|
|
showDeltas();
|
|
}
|
|
|
|
void HashComparer::showDeltas()
|
|
{
|
|
|
|
if (filesForUpdate->length() <= 0)
|
|
{
|
|
emit sigCallCheck();
|
|
return;
|
|
}
|
|
for (auto &item:*filesForUpdate)
|
|
{
|
|
updateWidget->addToList(item);
|
|
}
|
|
|
|
emit sigHaveDelta();
|
|
}
|
|
|
|
void HashComparer::setWidget(UpdateNotifyWidget* updateWidget)
|
|
{
|
|
this->updateWidget = updateWidget;
|
|
}
|
|
|
|
quint16 HashComparer::getFileUpdateCount() const
|
|
{
|
|
return filesForUpdate->count();
|
|
}
|
|
|
|
QList<FileData> *HashComparer::getFilesForUpdate() const
|
|
{
|
|
QList<FileData> *completeList = filesForUpdate;
|
|
|
|
for (int i = 0; i < completeList->count();i++)
|
|
{
|
|
FileData data = completeList->at(i);
|
|
QString streamingAssetsName = "StreamingAssets";
|
|
quint16 baseIndex = data.path.indexOf("StreamingAssets");
|
|
data.path = data.path.remove(0,baseIndex + streamingAssetsName.length());
|
|
data.path.prepend("/SharedData/" + versionContainer->getLocalVersion());
|
|
|
|
completeList->replace(i,data);
|
|
}
|
|
|
|
return filesForUpdate;
|
|
}
|
|
|
|
HashComparer::~HashComparer()
|
|
{
|
|
|
|
}
|