#include "hashcomparer.h" HashComparer::HashComparer(QObject *) : updateWidget(nullptr), filesForUpdate(nullptr), versionContainer(nullptr) { } void HashComparer::initialize(VersionContainer *versionContainer,UpdateNotifyWidget* updateWidget) { this->versionContainer = versionContainer; this->updateWidget = updateWidget; filesForUpdate = new QList; } void HashComparer::CompareDeltas(QList *serverStreamingHash, QList localStreamingHash) { QList *files = new QList; QMutableListIterator iterator(localStreamingHash); for (auto &item:localStreamingHash) { if(!serverStreamingHash->contains(item)) { if (item.path.contains("docs.xml")) continue; //фильтр на docs 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(); } quint16 HashComparer::getFileUpdateCount() const { return filesForUpdate->count(); } QList *HashComparer::getFilesForUpdate() const { QList *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; }