• SingleDownload
  • SingleDownload

    Manage file downloads and tracking the progress. More...

    Import Statement: import Ubuntu.DownloadManager 0.1

    Properties

    Methods

    Detailed Description

    SingleDownload provides facilities for downloading a single file, track the process, react to error conditions, etc.

    Example usage:

    import QtQuick 2.0
    import Ubuntu.Components 0.1
    import Ubuntu.DownloadManager 0.1
    
    Rectangle {
        width: units.gu(100)
        height: units.gu(20)
    
        TextField {
            id: text
            placeholderText: "File URL to download..."
            height: 50
            anchors {
                left: parent.left
                right: button.left
                rightMargin: units.gu(2)
            }
        }
    
        Button {
            id: button
            text: "Download"
            height: 50
            anchors.right: parent.right
    
            onClicked: {
                single.download(text.text);
            }
        }
    
        ProgressBar {
            minimumValue: 0
            maximumValue: 100
            value: single.progress
            anchors {
                left: parent.left
                right: parent.right
                bottom: parent.bottom
            }
    
            SingleDownload {
                id: single
            }
        }
    }

    See also DownloadManager.

    Property Documentation

    allowMobileDownload : bool

    This property sets if the download handled by this object will work under mobile data connection.


    autoStart : bool

    This property sets if the downloads should start automatically, or let the user decide when to start them calling the "start()" method.


    downloadId : string

    This property provides the unique identifier that represents the download within the download manager.


    downloadInProgress : bool

    This property represents if the download is active, no matter if it's paused or anything. If a download is active, the value will be True. It will become False when the download finished or get canceled.


    downloading : bool

    This property represents the current state of the download. False if paused or not downloading anything. True if the file is currently being downloaded.


    errorMessage : string

    The error message associated with the current download, if there is any.


    headers : QVariantMap

    This property allows to get and set the headers that will be used to perform the download request. All headers must be strings or at least QVariant should be able to convert them to strings.


    isCompleted : bool

    The current state of the download. True if the download already finished, False otherwise.


    progress : int

    This property reports the current progress in percentage of the download, from 0 to 100.


    throttle : long

    This property can be used to limit the bandwidth used for the download.


    Method Documentation

    void cancel()

    Cancels a download.


    void download(string url)

    Creates the download for the given url and reports the different states through the properties.


    void pause()

    Pauses the download. An error is returned if the download was already paused.


    void resume()

    Resumes and already paused download. An error is returned if the download was already resumed or not paused.


    void start()

    Starts the download, used when autoStart is False.