コード例 #1
0
ファイル: qgscomposerpicture.cpp プロジェクト: AM7000000/QGIS
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;
  }
}
コード例 #2
0
ファイル: qgscomposerhtml.cpp プロジェクト: Methathron/QGIS
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;
}
コード例 #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;
  }
}