void JamendoService::DownloadDirectoryFinished() { QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); Q_ASSERT(reply); app_->task_manager()->SetTaskFinished(load_database_task_id_); load_database_task_id_ = 0; // TODO: Not leak reply. QtIOCompressor* gzip = new QtIOCompressor(reply); gzip->setStreamFormat(QtIOCompressor::GzipFormat); if (!gzip->open(QIODevice::ReadOnly)) { qLog(Warning) << "Jamendo library not in gzip format"; delete gzip; return; } load_database_task_id_ = app_->task_manager()->StartTask(tr("Parsing Jamendo catalogue")); QFuture<void> future = QtConcurrent::run(this, &JamendoService::ParseDirectory, gzip); QFutureWatcher<void>* watcher = new QFutureWatcher<void>(); watcher->setFuture(future); connect(watcher, SIGNAL(finished()), SLOT(ParseDirectoryFinished())); }
GaussianFchk::GaussianFchk(const QString &filename, BasisSet* basis) { // Open the file for reading and process it QFile* file = new QFile(filename); QtIOCompressor* compressedFile = 0; if (filename.endsWith(".gz")) { compressedFile = new QtIOCompressor(file); compressedFile->setStreamFormat(QtIOCompressor::GzipFormat); compressedFile->open(QIODevice::ReadOnly); m_in = compressedFile; } else { file->open(QIODevice::ReadOnly | QIODevice::Text); m_in = file; } qDebug() << "File" << filename << "opened."; // Process the formatted checkpoint and extract all the information we need while (!m_in->atEnd()) { processLine(); } // Now it should all be loaded load it into the basis set load(basis); if (compressedFile) delete compressedFile; else delete file; }