23 #include <QNetworkReply> 28 , mContentLoaded( false )
48 QUrl nextUrlToFetch = url;
49 mContentLoaded =
false;
68 if ( !mContentLoaded )
78 if ( !mContentLoaded || !mReply )
105 int pos = header.
indexOf(
"meta charset=" );
108 pos += int( strlen(
"meta charset=" ) ) + 1;
109 int pos2 = header.
indexOf(
'\"', pos );
129 void QgsNetworkContentFetcher::contentLoaded(
bool ok )
133 if ( mReply->
error() != QNetworkReply::NoError )
136 mContentLoaded =
true;
141 QVariant redirect = mReply->
attribute( QNetworkRequest::RedirectionTargetAttribute );
150 mContentLoaded =
true;
QByteArray toLower() const
QString errorString() const
QNetworkReply * reply()
Returns a reference to the network reply.
QString toString(QFlags< QUrl::FormattingOption > options) const
QString contentAsString() const
Returns the fetched content as a string.
QString tr(const char *sourceText, const char *disambiguation, int n)
QgsNetworkContentFetcher()
int indexOf(char ch, int from) const
int toInt(bool *ok) const
virtual ~QgsNetworkContentFetcher()
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
void finished()
Emitted when content has loaded.
QByteArray mid(int pos, int len) const
QByteArray left(int len) const
QTextCodec * codecForHtml(const QByteArray &ba)
static QgsNetworkAccessManager * instance()
returns a pointer to the single instance
QTextCodec * codecForName(const QByteArray &name)
QVariant attribute(QNetworkRequest::Attribute code) const
NetworkError error() const
QNetworkReply * get(const QNetworkRequest &request)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void fetchContent(const QUrl &url)
Fetches content from a remote URL and handles redirects.
QString toUnicode(const QByteArray &a) const
QTextCodec * codecForUtfText(const QByteArray &ba)