QTfrontend/ui/page/pagedata.cpp
changeset 6616 f77bb02b669f
parent 6384 8b7e8ff1b16a
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    84         connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
    84         connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
    85 
    85 
    86         QProgressBar *progressBar = new QProgressBar(this);
    86         QProgressBar *progressBar = new QProgressBar(this);
    87         progressBarsLayout->addWidget(progressBar);
    87         progressBarsLayout->addWidget(progressBar);
    88         progressBars.insert(reply, progressBar);
    88         progressBars.insert(reply, progressBar);
    89     } else
    89     }
       
    90     else
    90     {
    91     {
    91         qWarning() << "Page Request" << url.toString();
    92         qWarning() << "Page Request" << url.toString();
    92 
    93 
    93         QNetworkRequest newRequest(finalUrl);
    94         QNetworkRequest newRequest(finalUrl);
    94 
    95 
   164 
   165 
   165     QuaZip zip;
   166     QuaZip zip;
   166     zip.setIoDevice(&buffer);
   167     zip.setIoDevice(&buffer);
   167     if(!zip.open(QuaZip::mdUnzip))
   168     if(!zip.open(QuaZip::mdUnzip))
   168     {
   169     {
   169       qWarning("testRead(): zip.open(): %d", zip.getZipError());
   170         qWarning("testRead(): zip.open(): %d", zip.getZipError());
   170       return false;
   171         return false;
   171     }
   172     }
   172 
   173 
   173     QuaZipFile file(&zip);
   174     QuaZipFile file(&zip);
   174 
   175 
   175     QDir extractDir(*cfgdir);
   176     QDir extractDir(*cfgdir);
   188         QString filePath = extractDir.filePath(fileName);
   189         QString filePath = extractDir.filePath(fileName);
   189         if (fileName.endsWith("/"))
   190         if (fileName.endsWith("/"))
   190         {
   191         {
   191             QFileInfo fi(filePath);
   192             QFileInfo fi(filePath);
   192             QDir().mkpath(fi.filePath());
   193             QDir().mkpath(fi.filePath());
   193         } else
   194         }
       
   195         else
   194         {
   196         {
   195             qDebug() << "Extracting" << filePath;
   197             qDebug() << "Extracting" << filePath;
   196             QFile out(filePath);
   198             QFile out(filePath);
   197             if(!out.open(QFile::WriteOnly))
   199             if(!out.open(QFile::WriteOnly))
   198             {
   200             {
   202 
   204 
   203             out.write(file.readAll());
   205             out.write(file.readAll());
   204 
   206 
   205             out.close();
   207             out.close();
   206 
   208 
   207             if(file.getZipError() != UNZ_OK) {
   209             if(file.getZipError() != UNZ_OK)
       
   210             {
   208                 qWarning("file.getFileName(): %d", file.getZipError());
   211                 qWarning("file.getFileName(): %d", file.getZipError());
   209                 return false;
   212                 return false;
   210             }
   213             }
   211 
   214 
   212             if(!file.atEnd()) {
   215             if(!file.atEnd())
       
   216             {
   213                 qWarning("read all but not EOF");
   217                 qWarning("read all but not EOF");
   214                 return false;
   218                 return false;
   215             }
   219             }
   216         }
   220         }
   217 
   221 
   218         file.close();
   222         file.close();
   219 
   223 
   220         if(file.getZipError()!=UNZ_OK) {
   224         if(file.getZipError()!=UNZ_OK)
       
   225         {
   221             qWarning("file.close(): %d", file.getZipError());
   226             qWarning("file.close(): %d", file.getZipError());
   222             return false;
   227             return false;
   223         }
   228         }
   224     }
   229     }
   225 
   230