From ce186cf0f79689cdf4b4c03a23af90434ba7eefc Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 26 Mar 2014 15:10:18 -0700 Subject: [PATCH] Added bunch of feedback --- libraries/shared/src/FstReader.cpp | 40 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/libraries/shared/src/FstReader.cpp b/libraries/shared/src/FstReader.cpp index 15e31cee07..e3b88f3870 100644 --- a/libraries/shared/src/FstReader.cpp +++ b/libraries/shared/src/FstReader.cpp @@ -62,19 +62,19 @@ bool FstReader::zip() { QString("ModelUploader::zip()"), QString("Could not open FST file."), QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Could not open FST file."); return false; } + qDebug() << "Reading FST file : " << QFileInfo(fst).filePath(); // Compress and copy the fst if (!compressFile(QFileInfo(fst).filePath(), _zipDir.path() + "/" + QFileInfo(fst).fileName())) { return false; } - _totalSize += QFileInfo(fst).size(); if (!addPart(_zipDir.path() + "/" + QFileInfo(fst).fileName(), QString("fst"))) { return false; } - qDebug() << "Reading FST file : " << QFileInfo(fst).filePath(); // Let's read through the FST file QTextStream stream(&fst); @@ -85,14 +85,6 @@ bool FstReader::zip() { continue; } - if (_totalSize > MAX_SIZE) { - QMessageBox::warning(NULL, - QString("ModelUploader::zip()"), - QString("Model too big, over %1 Bytes.").arg(MAX_SIZE), - QMessageBox::Ok); - return false; - } - // according to what is read, we modify the command if (line[0] == NAME_FIELD) { QHttpPart textPart; @@ -100,56 +92,56 @@ bool FstReader::zip() { " name=\"model_name\""); textPart.setBody(line[1].toUtf8()); _dataMultiPart->append(textPart); - } else if (line[1] == FILENAME_FIELD) { + } else if (line[0] == FILENAME_FIELD) { QFileInfo fbx(QFileInfo(fst).path() + "/" + line[1]); if (!fbx.exists() || !fbx.isFile()) { // Check existence QMessageBox::warning(NULL, QString("ModelUploader::zip()"), QString("FBX file %1 could not be found.").arg(fbx.fileName()), QMessageBox::Ok); + qDebug() << "[Warning] " << QString("FBX file %1 could not be found.").arg(fbx.fileName()); return false; } // Compress and copy if (!compressFile(fbx.filePath(), _zipDir.path() + "/" + line[1])) { return false; } - _totalSize += fbx.size(); if (!addPart(_zipDir.path() + "/" + line[1], "fbx")) { return false; } - } else if (line[1] == TEXDIR_FIELD) { // Check existence + } else if (line[0] == TEXDIR_FIELD) { // Check existence QFileInfo texdir(QFileInfo(fst).path() + "/" + line[1]); if (!texdir.exists() || !texdir.isDir()) { QMessageBox::warning(NULL, QString("ModelUploader::zip()"), QString("Texture directory could not be found."), QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Texture directory could not be found."); return false; } if (!addTextures(texdir)) { // Recursive compress and copy return false; } - } else if (line[1] == LOD_FIELD) { + } else if (line[0] == LOD_FIELD) { QFileInfo lod(QFileInfo(fst).path() + "/" + line[1]); if (!lod.exists() || !lod.isFile()) { // Check existence QMessageBox::warning(NULL, QString("ModelUploader::zip()"), QString("FBX file %1 could not be found.").arg(lod.fileName()), QMessageBox::Ok); + qDebug() << "[Warning] " << QString("FBX file %1 could not be found.").arg(lod.fileName()); return false; } // Compress and copy if (!compressFile(lod.filePath(), _zipDir.path() + "/" + line[1])) { return false; } - _totalSize += lod.size(); if (!addPart(_zipDir.path() + "/" + line[1], QString("lod%1").arg(++_lodCount))) { return false; } } } - QHttpPart textPart; textPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;" " name=\"model_category\""); @@ -190,7 +182,6 @@ bool FstReader::addTextures(const QFileInfo& texdir) { if (!compressFile(info.filePath(), _zipDir.path() + "/" + info.fileName())) { return false; } - _totalSize += info.size(); if (!addPart(_zipDir.path() + "/" + info.fileName(), QString("texture%1").arg(++_texturesCount))) { return false; @@ -218,6 +209,7 @@ bool FstReader::compressFile(const QString &inFileName, const QString &outFileNa QString("ModelUploader::compressFile()"), QString("Could not compress %1").arg(inFileName), QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Could not compress %1").arg(inFileName); return false; } } @@ -235,6 +227,7 @@ bool FstReader::addPart(const QString &path, const QString& name) { QString("ModelUploader::addPart()"), QString("Could not open %1").arg(path), QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Could not open %1").arg(path); return false; } @@ -247,6 +240,19 @@ bool FstReader::addPart(const QString &path, const QString& name) { _dataMultiPart->append(part); file->setParent(_dataMultiPart); + + qDebug() << "File " << QFileInfo(*file).fileName() << " added to model."; + _totalSize += file->size(); + if (_totalSize > MAX_SIZE) { + QMessageBox::warning(NULL, + QString("ModelUploader::zip()"), + QString("Model too big, over %1 Bytes.").arg(MAX_SIZE), + QMessageBox::Ok); + qDebug() << "[Warning] " << QString("Model too big, over %1 Bytes.").arg(MAX_SIZE); + return false; + } + qDebug() << "Current model size: " << _totalSize; + return true; }