当前位置: 首页>>代码示例>>C++>>正文


C++ downloadProgress函数代码示例

本文整理汇总了C++中downloadProgress函数的典型用法代码示例。如果您正苦于以下问题:C++ downloadProgress函数的具体用法?C++ downloadProgress怎么用?C++ downloadProgress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了downloadProgress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dropNetworkConnection

bool PictureContent::loadFromNetwork(const QString & url, QNetworkReply * reply, const QString & title, int width, int height)
{
    dropNetworkConnection();
    delete m_photo;
    m_cachedPhoto = QPixmap();
    m_opaquePhoto = false;
    m_photo = 0;
    m_fileUrl = url;
    m_netWidth = width;
    m_netHeight = height;

    // start a download if not passed as a paramenter
    if (!reply) {
        // the QNAM will be auto-deleted on closure
        QNetworkAccessManager * nam = new QNetworkAccessManager(this);
        QNetworkRequest request(url);
        m_netReply = nam->get(request);
    } else
        m_netReply = reply;

    // set title
    if (!title.isEmpty()) {
        setFrameTextEnabled(true);
        setFrameText(title);
    }

#if QT_VERSION >= 0x040600
    // Immediate Decode: just handle the reply if done
    if (m_netReply->isFinished())
        return slotLoadNetworkData();
#else
    // No Precaching ensures signals to be emitted later
#endif

    // Deferred Decode: listen to the network job
    setAcceptHoverEvents(false);
    setControlsVisible(false);
    m_progress = 0.01;
    connect(m_netReply, SIGNAL(finished()), this, SLOT(slotLoadNetworkData()));
    connect(m_netReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotNetworkError()));
    connect(m_netReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(slotNetworkProgress(qint64,qint64)));

    // reset size, if got the network one
    if (m_netWidth > 0 && m_netHeight > 0)
        resetContentsRatio();
    return true;
}
开发者ID:madjar,项目名称:fotowall,代码行数:47,代码来源:PictureContent.cpp

示例2: QWidget

ShowPicture::ShowPicture(QString bigUrl, QString midUrl, QWidget *parent) :
    QWidget(parent)
{
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->bigUrl = bigUrl;
    this->midUrl = midUrl;
    if(midUrl.toUpper().endsWith(".GIF"))
        this->isGif = true;
    else
        this->isGif = false;
    this->setWindowTitle(tr("图片"));
    progressBar = new QProgressBar(this);
    progressBar->setValue(0);
    label = new QLabel(this);
    label->setText("正在下载......");
    this->showGif = new QLabel(this);
    this->showGif->hide();
    this->movie = new QMovie(this);
    this->gifImageFile = new QBuffer(&imageByteArray, this);
    layout = new QVBoxLayout(this);
    layout->addWidget(label);
    layout->addWidget(progressBar);
    
    toolBar = new QToolBar(this);
    saveFile = new QAction(this);
    bigPicture = new QAction(this);
    saveFile->setText("保存图片");
    bigPicture->setText("查看大图");

    QObject::connect(saveFile, SIGNAL(triggered()), this, SLOT(saveImage()));
    QObject::connect(bigPicture, SIGNAL(triggered()), this, SLOT(showBigPicture()));
    toolBar->addAction(saveFile);
    toolBar->addAction(bigPicture);
    toolBar->hide();
    view = new QGraphicsView(this);
    scene = new QGraphicsScene(this);
    view->setScene(scene);
    view->hide();
    
    http = new Http(this);
    QObject::connect(http, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateProgressBar(qint64,qint64)));
    //QObject::connect(http, SIGNAL(finished()), this, SLOT(showAfterDownload()));
    timer = new QTimer(this);
    timer->setSingleShot(true);
    QObject::connect(timer, SIGNAL(timeout()), this, SLOT(downloadFile()));
    timer->start(500);
}
开发者ID:xiongwang,项目名称:USense,代码行数:47,代码来源:showpicture.cpp

示例3: PathCombine

void LegacyUpdate::lwjglStart()
{
	LegacyInstance *inst = (LegacyInstance *)m_inst;

	lwjglVersion = inst->lwjglVersion();
	lwjglTargetPath = PathCombine(MMC->settings()->get("LWJGLDir").toString(), lwjglVersion);
	lwjglNativesPath = PathCombine(lwjglTargetPath, "natives");

	// if the 'done' file exists, we don't have to download this again
	QFileInfo doneFile(PathCombine(lwjglTargetPath, "done"));
	if (doneFile.exists())
	{
		jarStart();
		return;
	}

	auto list = MMC->lwjgllist();
	if (!list->isLoaded())
	{
		emitFailed("Too soon! Let the LWJGL list load :)");
		return;
	}

	setStatus(tr("Downloading new LWJGL..."));
	auto version = list->getVersion(lwjglVersion);
	if (!version)
	{
		emitFailed("Game update failed: the selected LWJGL version is invalid.");
		return;
	}

	QString url = version->url();
	QUrl realUrl(url);
	QString hostname = realUrl.host();
	auto worker = MMC->qnam();
	QNetworkRequest req(realUrl);
	req.setRawHeader("Host", hostname.toLatin1());
	req.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");
	QNetworkReply *rep = worker->get(req);

	m_reply = std::shared_ptr<QNetworkReply>(rep);
	connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
	connect(worker.get(), SIGNAL(finished(QNetworkReply *)),
			SLOT(lwjglFinished(QNetworkReply *)));
	// connect(rep, SIGNAL(error(QNetworkReply::NetworkError)),
	// SLOT(downloadError(QNetworkReply::NetworkError)));
}
开发者ID:Nightreaver,项目名称:MultiMC5,代码行数:47,代码来源:LegacyUpdate.cpp

示例4: emitFailed

void LegacyUpdate::lwjglFinished(QNetworkReply *reply)
{
	if (m_reply.get() != reply)
	{
		return;
	}
	if (reply->error() != QNetworkReply::NoError)
	{
		emitFailed("Failed to download: " + reply->errorString() +
				   "\nSometimes you have to wait a bit if you download many LWJGL versions in "
				   "a row. YMMV");
		return;
	}
	auto worker = MMC->qnam();
	// Here i check if there is a cookie for me in the reply and extract it
	QList<QNetworkCookie> cookies =
		qvariant_cast<QList<QNetworkCookie>>(reply->header(QNetworkRequest::SetCookieHeader));
	if (cookies.count() != 0)
	{
		// you must tell which cookie goes with which url
		worker->cookieJar()->setCookiesFromUrl(cookies, QUrl("sourceforge.net"));
	}

	// here you can check for the 302 or whatever other header i need
	QVariant newLoc = reply->header(QNetworkRequest::LocationHeader);
	if (newLoc.isValid())
	{
		QString redirectedTo = reply->header(QNetworkRequest::LocationHeader).toString();
		QUrl realUrl(redirectedTo);
		QString hostname = realUrl.host();
		QNetworkRequest req(redirectedTo);
		req.setRawHeader("Host", hostname.toLatin1());
		req.setHeader(QNetworkRequest::UserAgentHeader, "MultiMC/5.0 (Cached)");
		QNetworkReply *rep = worker->get(req);
		connect(rep, SIGNAL(downloadProgress(qint64, qint64)),
				SIGNAL(progress(qint64, qint64)));
		m_reply = std::shared_ptr<QNetworkReply>(rep);
		return;
	}
	QFile saveMe("lwjgl.zip");
	saveMe.open(QIODevice::WriteOnly);
	saveMe.write(m_reply->readAll());
	saveMe.close();
	setStatus(tr("Installing new LWJGL..."));
	extractLwjgl();
	jarStart();
}
开发者ID:Nightreaver,项目名称:MultiMC5,代码行数:47,代码来源:LegacyUpdate.cpp

示例5: connect

void ParserAbstract::sendHttpRequest(QUrl url, QByteArray data)
{
    QNetworkRequest request;
    request.setUrl(url);
    request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0");
    request.setRawHeader("Cache-Control", "no-cache");

    if (data.isNull()) {
        lastRequest = NetworkManager->get(request);
    } else {
        lastRequest = NetworkManager->post(request, data);
    }

    requestTimeout->start(30000);

    connect(lastRequest, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(networkReplyDownloadProgress(qint64,qint64)));
}
开发者ID:shentok,项目名称:fahrplan,代码行数:17,代码来源:parser_abstract.cpp

示例6: UINetworkReply

/* Prepare network-reply: */
void UINetworkRequest::prepareNetworkReply()
{
    /* Make network-request: */
    m_pReply = new UINetworkReply(m_request, m_type);
    AssertMsg(m_pReply, ("Unable to make network-request!\n"));
    /* Prepare listeners for m_pReply: */
    connect(m_pReply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(sltHandleNetworkReplyProgress(qint64, qint64)));
    connect(m_pReply, SIGNAL(finished()), this, SLOT(sltHandleNetworkReplyFinish()));

    /* Set as running: */
    m_fRunning = true;

    /* Notify general network-requests listeners: */
    emit sigStarted(m_uuid);
    /* Notify particular network-request listeners: */
    emit sigStarted();
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:18,代码来源:UINetworkRequest.cpp

示例7: connect

bool Http::get(const QString& url)
{
    m_Data.clear();
    m_Request.setUrl(url);
    m_pReply = m_NetworkManager.get(m_Request);

    QEventLoop loop;
    connect(m_pReply, SIGNAL(finished()), &loop, SLOT(quit()));
    connect(m_pReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(onDownloadProgress(qint64,qint64)));
    loop.exec();

    m_Data.append(m_pReply->readAll());
    m_Error = m_pReply->error();
    m_Message = m_pReply->errorString();

    return m_Error == QNetworkReply::NoError;
}
开发者ID:LuaxY,项目名称:ARK-Launcher,代码行数:17,代码来源:http.cpp

示例8: connect

void DownLoadFun::down(STATUSID id, QString url)
{
    if(reply != NULL)
    {
        reply->abort();
    }

    m_id = id;

    QNetworkAccessManager *manager = new QNetworkAccessManager;
    reply = manager->get(QNetworkRequest(url));

    connect(reply, SIGNAL(finished()), this, SLOT(httpFinished()));

    connect(reply,SIGNAL(downloadProgress(qint64,qint64)),
            this,SLOT(updateDataReadProgress(qint64,qint64)));
}
开发者ID:gateslu,项目名称:renrentest,代码行数:17,代码来源:downloadfun.cpp

示例9: QgsDebugMsg

bool QgsWcsCapabilities::sendRequest( QString const & url )
{
  QgsDebugMsg( "url = " + url );
  mError = "";
  QNetworkRequest request( url );
  if ( !setAuthorization( request ) )
  {
    mError = tr( "Download of capabilities failed: network request update failed for authentication config" );
    QgsMessageLog::logMessage( mError, tr( "WCS" ) );
    return false;
  }
  request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
  request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, mCacheLoadControl );
  QgsDebugMsg( QString( "mCacheLoadControl = %1" ).arg( mCacheLoadControl ) );

  QgsDebugMsg( QString( "getcapabilities: %1" ).arg( url ) );
  mCapabilitiesReply = QgsNetworkAccessManager::instance()->get( request );

  connect( mCapabilitiesReply, SIGNAL( finished() ), this, SLOT( capabilitiesReplyFinished() ) );
  connect( mCapabilitiesReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( capabilitiesReplyProgress( qint64, qint64 ) ) );

  while ( mCapabilitiesReply )
  {
    QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
  }

  if ( mCapabilitiesResponse.isEmpty() )
  {
    if ( mError.isEmpty() )
    {
      mErrorFormat = "text/plain";
      mError = tr( "empty capabilities document" );
    }
    return false;
  }

  if ( mCapabilitiesResponse.startsWith( "<html>" ) ||
       mCapabilitiesResponse.startsWith( "<HTML>" ) )
  {
    mErrorFormat = "text/html";
    mError = mCapabilitiesResponse;
    return false;
  }
  return true;
}
开发者ID:Benardi-atmadja,项目名称:QGIS,代码行数:45,代码来源:qgswcscapabilities.cpp

示例10: Q_D

void QQuickAnimatedImage::load()
{
    Q_D(QQuickAnimatedImage);

    if (d->url.isEmpty()) {
        if (d->progress != 0) {
            d->progress = 0;
            emit progressChanged(d->progress);
        }

        d->setImage(QImage());
        d->status = Null;
        emit statusChanged(d->status);

        if (sourceSize() != d->oldSourceSize) {
            d->oldSourceSize = sourceSize();
            emit sourceSizeChanged();
        }
        if (isPlaying() != d->oldPlaying)
            emit playingChanged();
    } else {
        QString lf = QQmlFile::urlToLocalFileOrQrc(d->url);
        if (!lf.isEmpty()) {
            d->_movie = new QMovie(lf);
            movieRequestFinished();
        } else {
            if (d->status != Loading) {
                d->status = Loading;
                emit statusChanged(d->status);
            }
            if (d->progress != 0) {
                d->progress = 0;
                emit progressChanged(d->progress);
            }
            QNetworkRequest req(d->url);
            req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);

            d->reply = qmlEngine(this)->networkAccessManager()->get(req);
            QObject::connect(d->reply, SIGNAL(finished()),
                            this, SLOT(movieRequestFinished()));
            QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
                            this, SLOT(requestProgress(qint64,qint64)));
        }
    }
}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:45,代码来源:qquickanimatedimage.cpp

示例11: downloadProgress

/** Report download progress to the user */
void HttpClient::slotDownloadProgress( qint64 bytesReceived, qint64 bytesTotal )
{
  // qDebug() << "HttpClient::slotDownloadProgress" << bytesReceived << bytesTotal;

  if ( _progressDialog != static_cast<QProgressDialog *> (0) )
    {
      // Report results to the progress dialog.
      _progressDialog->setMaximum( bytesTotal );
      _progressDialog->setValue( bytesReceived );
    }
  else
    {
      // Emit this signal to the outside, when no progress dialog is set up.
      emit downloadProgress( bytesReceived, bytesTotal );
    }

  timer->start();
}
开发者ID:Exadios,项目名称:KFLog,代码行数:19,代码来源:httpclient.cpp

示例12: request

void GetFileTask::sendRequest()
{
    QNetworkRequest request(url_);
    if (!network_mgr_) {
        static QNetworkAccessManager *manager = new QNetworkAccessManager(qApp);
        network_mgr_ = manager;
        NetworkManager::instance()->addWatch(network_mgr_);
    }
    reply_ = network_mgr_->get(request);

    connect(reply_, SIGNAL(sslErrors(const QList<QSslError>&)),
            this, SLOT(onSslErrors(const QList<QSslError>&)));

    connect(reply_, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
    connect(reply_, SIGNAL(downloadProgress(qint64, qint64)),
            this, SIGNAL(progressUpdate(qint64, qint64)));
    connect(reply_, SIGNAL(finished()), this, SLOT(httpRequestFinished()));
}
开发者ID:DevCybran,项目名称:seafile-client,代码行数:18,代码来源:tasks.cpp

示例13: QNetworkAccessManager

void dbmanager::doDownload(const QVariant& v)
{
    if (v.type() == QVariant::StringList) {


        QNetworkAccessManager *manager= new QNetworkAccessManager(this);

        QUrl url = v.toStringList().at(current);

        filename = url.toString().remove("http://restbase.wikitolearn.org/en.wikitolearn.org/v1/media/math/render/svg/");
        m_network_reply = manager->get(QNetworkRequest(QUrl(url)));

        connect(m_network_reply, SIGNAL(downloadProgress (qint64, qint64)),this, SLOT(updateDownloadProgress(qint64, qint64))); // checks download progress
        connect(m_network_reply,SIGNAL(finished()),this,SLOT(downloadFinished())); // signal that download is finished


    }
}
开发者ID:hackertron,项目名称:W2L,代码行数:18,代码来源:dbmanager.cpp

示例14: req

bool NetworkHandler::startJSONDownload()
{
    QNetworkRequest req(m_Url);
    req.setRawHeader(m_headerName,m_headerValue);    
    m_pNetworkReply = m_Mgr.get(req);
    if(m_pNetworkReply)
    {
        QObject::connect(m_pNetworkReply,SIGNAL(finished()),this,SLOT(readFinished()));
        QObject::connect(m_pNetworkReply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadProgress(qint64,qint64)));
        QObject::connect(m_pNetworkReply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(error(QNetworkReply::NetworkError)));
        QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(timeout()));
    }
    else
    {
        qDebug() << "Failed to create get request!";
        emit readyRead(QByteArray());
    }
}
开发者ID:muma7490,项目名称:MTmate-for-Reddit,代码行数:18,代码来源:networkhandler.cpp

示例15: connect

void video::download()
{
    _step = 3;
    handler->clearDownloads();

    connect(handler, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(changeProgress(qint64, qint64)));

    if (!this->_supportedQualities.at(_quality).videoUrl.isEmpty())
    {
        qDebug() << "Downloading video file: " << this->_supportedQualities.at(_quality).videoUrl;
        handler->addDownload(this->_supportedQualities.at(_quality).videoUrl, this->_supportedQualities.at(_quality).chunkedDownload);
    }
    if (!this->_supportedQualities.at(_quality).audioUrl.isEmpty())
    {
        qDebug() << "Downloading audio file: " << this->_supportedQualities.at(_quality).audioUrl;
        handler->addDownload(this->_supportedQualities.at(_quality).audioUrl, this->_supportedQualities.at(_quality).chunkedDownload);
    }
}
开发者ID:MegaBedder,项目名称:ClipGrab-1,代码行数:18,代码来源:video.cpp


注:本文中的downloadProgress函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。