示例#1
0
bool ConnectionParser::parseCode(QStringList parsedArray, int code) {
    switch (code) {
        case RPL_WELCOME:
            QString nick = parsedArray.at(2);
            emit connectionStarted(nick);
            return true;
    }
    return false;
}
void AdBlockDownloader::downloadFile(const QString& path, const QString &filename, const QString& localfile)
{
    this->_progressvalue = 0;
    this->_progresstotal = 0;

    emit connectionStarted();

    this->_localfile = localfile;
    this->_tempfile.setFileName(localfile);
    this->_tempfile.open(QFile::WriteOnly | QFile::Truncate);

    QUrl url(QString("%1/%2").arg(path, filename));
    QNetworkRequest request(url);

    this->_downloadreply = this->_networkmanager.get(request);
    connect(this->_downloadreply, SIGNAL(readyRead()), this, SLOT(onNetworkReplyReadyRead()));
    connect(this->_downloadreply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(onDownloadProgress(qint64,qint64)));
    connect(this->_downloadreply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onDownloadError(QNetworkReply::NetworkError)));
}