QGitHubReleaseAPI  0.7
Qt library to receive release information from the GitHub API
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
QGitHubReleaseAPI Class Reference

The QGitHubReleaseAPI class. More...

Public Types

enum  TYPE { RAW, TEXT, HTML }
 Type of body. More...
 

Public Slots

void cancel ()
 Cancels the current operation.
 

Signals

void available (const QGitHubReleaseAPI &api)
 Emitted if the release data is available. More...
 
void canceled ()
 Emitted if a operation has canceled.
 
void error (const QString &error)
 Emitted on any error. More...
 
void progress (qint64 bytesReceived, qint64 bytesTotal)
 Emitted while downloading. More...
 

Public Member Functions

 QGitHubReleaseAPI (const QUrl &apiUrl, TYPE type, bool multi=true, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QUrl &apiUrl, bool multi=true, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, TYPE type, bool latest=true, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, bool latest=true, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, const QString &tag, TYPE type, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, const QString &tag, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, const char *tag, TYPE type, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, const char *tag, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, int perPage, TYPE type, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
 QGitHubReleaseAPI (const QString &user, const QString &repo, int perPage, QObject *parent=0)
 Creates an QGitHubReleaseAPI instance. More...
 
QUrl apiUrl () const
 The api URL. More...
 
QByteArray asJsonData () const
 Gets the release information as raw Json data. More...
 
qint64 downloadToFile (const QUrl &url, QFile &outputFile) const
 Downloads the file at QUrl into a file. More...
 
QByteArray downloadToMemory (const QUrl &url) const
 Downloads the file at QUrl into a QByteArray. More...
 
int entries () const
 The number of entries received. More...
 
QString eTag () const
 the eTag More...
 
uint rateLimit () const
 
uint rateLimitRemaining () const
 
QDateTime rateLimitReset () const
 
void setETag (const QString &eTag)
 Sets the eTag. More...
 
QVariantList toVariantList () const
 Gets the release information as QVariantList. More...
 
Accessing the release information
ulong releaseId (int idx=0) const
 
QUrl releaseUrl (int idx=0) const
 
QUrl assetsUrl (int idx=0) const
 
QUrl uploadUrl (int idx=0) const
 
QUrl releaseHtmlUrl (int idx=0) const
 
QString name (int idx=0) const
 
QString body (int idx=0) const
 
QString tagName (int idx=0) const
 
QDateTime publishedAt (int idx=0) const
 
QDateTime createdAt (int idx=0) const
 
QUrl tarBallUrl (int idx=0) const
 
QUrl zipBallUrl (int idx=0) const
 
QByteArray tarBall (int idx=0) const
 
qint64 tarBall (QFile &outputFile, int idx=0) const
 
QByteArray zipBall (int idx=0) const
 
qint64 zipBall (QFile &outputFile, int idx=0) const
 
QString targetCommitish (int idx=0) const
 
bool isDraft (int idx=0) const
 
bool isPreRelease (int idx=0) const
 
Accessing the user information
QUrl avatarUrl (int idx=0) const
 The URL to the avatar. More...
 
QImage avatar (int idx=0) const
 Downloads the avatar and creates a QImage. More...
 
QUrl authorHtmlUrl (int idx=0) const
 The URL to the author HTML site. More...
 
ulong authorId (int idx=0) const
 the authorId More...
 
QString login (int idx=0) const
 The login name of the author. More...
 

Static Public Member Functions

static void setUserAgent (const char *userAgent)
 Sets an UserAgent. More...
 

Detailed Description

The QGitHubReleaseAPI class.

Author
Heiko Schaefer

Member Enumeration Documentation

Type of body.

Enumerator
RAW 

receive a raw body and render it with libmarkdown

TEXT 

receive a text body

HTML 

receive a html body (rendered by GitHub)

Constructor & Destructor Documentation

QGitHubReleaseAPI::QGitHubReleaseAPI ( const QUrl &  apiUrl,
TYPE  type,
bool  multi = true,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
apiUrldirect URL to retrieve
typethe type of the body
multitrue if multiple results are expected, false otherwise
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QUrl &  apiUrl,
bool  multi = true,
QObject *  parent = 0 
)
explicit

Creates an QGitHubReleaseAPI instance.

Parameters
apiUrldirect URL to retrieve
multitrue if multiple results are expected, false otherwise
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
TYPE  type,
bool  latest = true,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
typethe type of the body
latesttrue to only retrieve the latest release, false for all releases
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
bool  latest = true,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
latesttrue to only retrieve the latest release, false for all releases
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
const QString &  tag,
TYPE  type,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
tagthe release tag to retrieve
typethe type of the body
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
const QString &  tag,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
tagthe release tag to retrieve
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
const char *  tag,
TYPE  type,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
tagthe release tag to retrieve
typethe type of the body
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
const char *  tag,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
tagthe release tag to retrieve
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
int  perPage,
TYPE  type,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
perPagethe amount of releases to retrieve
typethe type of the body
QGitHubReleaseAPI::QGitHubReleaseAPI ( const QString &  user,
const QString &  repo,
int  perPage,
QObject *  parent = 0 
)

Creates an QGitHubReleaseAPI instance.

Parameters
userthe GitHub user (aka login)
repothe repository to retrieve release information for
perPagethe amount of releases to retrieve

Member Function Documentation

QUrl QGitHubReleaseAPI::apiUrl ( ) const

The api URL.

Returns
the api URL
QByteArray QGitHubReleaseAPI::asJsonData ( ) const

Gets the release information as raw Json data.

Returns
QUrl QGitHubReleaseAPI::authorHtmlUrl ( int  idx = 0) const

The URL to the author HTML site.

Parameters
idxthe entry index
Returns
url to the author HTML site
ulong QGitHubReleaseAPI::authorId ( int  idx = 0) const

the authorId

Parameters
idxthe entry index
Returns
the authorId
void QGitHubReleaseAPI::available ( const QGitHubReleaseAPI api)
signal

Emitted if the release data is available.

Parameters
apireference to the QGitHubReleaseAPI
QImage QGitHubReleaseAPI::avatar ( int  idx = 0) const

Downloads the avatar and creates a QImage.

Parameters
idxthe entry index
Returns
the avatar image of a NULL QImage on failure
QUrl QGitHubReleaseAPI::avatarUrl ( int  idx = 0) const

The URL to the avatar.

Parameters
idxthe entry index
Returns
url to the avatar
qint64 QGitHubReleaseAPI::downloadToFile ( const QUrl &  url,
QFile &  outputFile 
) const

Downloads the file at QUrl into a file.

Parameters
urlthe URL to download from
outputFilethe file to download to
Returns
the number of received bytes
QByteArray QGitHubReleaseAPI::downloadToMemory ( const QUrl &  url) const

Downloads the file at QUrl into a QByteArray.

Parameters
urlthe URL to download from
Returns
the QByteArray containing the downloaded file
int QGitHubReleaseAPI::entries ( ) const

The number of entries received.

Returns
the number of entries received
void QGitHubReleaseAPI::error ( const QString &  error)
signal

Emitted on any error.

Parameters
errorthe error string
QString QGitHubReleaseAPI::eTag ( ) const

the eTag

An eTag, if known, can get used to avoid using the rate limit

Returns
the ETag
QString QGitHubReleaseAPI::login ( int  idx = 0) const

The login name of the author.

Parameters
idxthe entry index
Returns
the login name of the author
void QGitHubReleaseAPI::progress ( qint64  bytesReceived,
qint64  bytesTotal 
)
signal

Emitted while downloading.

bytesTotal is -1 if the number of total bytes is not available
bytesReceived is equal to bytesTotal if the download has finished

Parameters
bytesReceivedthe number of bytes received
bytesTotalthe number of total bytes
void QGitHubReleaseAPI::setETag ( const QString &  eTag)

Sets the eTag.

An eTag, if known, can get used to avoid using the rate limit

Parameters
eTagthe eTag
void QGitHubReleaseAPI::setUserAgent ( const char *  userAgent)
static

Sets an UserAgent.

Note
defaults to QGitHubReleaseAPI
Parameters
userAgentan UserAgent
QVariantList QGitHubReleaseAPI::toVariantList ( ) const

Gets the release information as QVariantList.

Returns