Exemplo n.º 1
0
void QgsComposerPicture::loadRemotePicture( const QString &url )
{
  //remote location

  QgsNetworkContentFetcher fetcher;
  //pause until HTML fetch
  mLoaded = false;
  fetcher.fetchContent( QUrl( url ) );
  connect( &fetcher, SIGNAL( finished() ), this, SLOT( remotePictureLoaded() ) );

  while ( !mLoaded )
  {
    qApp->processEvents();
  }

  QNetworkReply* reply = fetcher.reply();
  if ( reply )
  {
    QImageReader imageReader( reply );
    mImage = imageReader.read();
    mMode = RASTER;
    reply->deleteLater();
  }
  else
  {
    mMode = Unknown;
  }
}
Exemplo n.º 2
0
QString QgsComposerHtml::fetchHtml( QUrl url )
{
  QgsNetworkContentFetcher fetcher;
  //pause until HTML fetch
  mLoaded = false;
  fetcher.fetchContent( url );
  connect( &fetcher, SIGNAL( finished() ), this, SLOT( frameLoaded() ) );

  while ( !mLoaded )
  {
    qApp->processEvents();
  }

  mFetchedHtml = fetcher.contentAsString();
  mActualFetchedUrl = fetcher.reply()->url().toString();
  return mFetchedHtml;
}
Exemplo n.º 3
0
void QgsLayoutItemPicture::loadRemotePicture( const QString &url )
{
  //remote location

  QgsNetworkContentFetcher fetcher;
  QEventLoop loop;
  connect( &fetcher, &QgsNetworkContentFetcher::finished, &loop, &QEventLoop::quit );
  fetcher.fetchContent( QUrl( url ) );

  //wait until picture fetched
  loop.exec( QEventLoop::ExcludeUserInputEvents );

  QNetworkReply *reply = fetcher.reply();
  if ( reply )
  {
    QImageReader imageReader( reply );
    mImage = imageReader.read();
    mMode = FormatRaster;
  }
  else
  {
    mMode = FormatUnknown;
  }
}