# eric6.Helpviewer.Download.DownloadItem

Module implementing a widget controlling a download.

### Global Attributes

None

### Classes

DownloadItem | Class implementing a widget controlling a download.

### Functions

None

## DownloadItem

Class implementing a widget controlling a download.

### Signals

downloadFinished()
  emitted when a download finished
progress(int, int)
  emitted to signal the download progress
statusChanged()
  emitted upon a status change of a download

### Derived from

QWidget, Ui_DownloadItem

### Class Attributes

DownloadCancelled
DownloadSuccessful
Downloading

### Class Methods

None

### Methods

DownloadItem | Constructor
__adjustSize | Private method to adjust the size of the download item.
__downloadProgress | Private method to show the download progress.
__finished | Private slot to handle the download finished.
__getFileName | Private method to get the file name to save to from the user.
__initialize | Private method to (re)initialize the widget.
__metaDataChanged | Private slot to handle a change of the meta data.
__networkError | Private slot to handle a network error.
__readyRead | Private slot to read the available data.
__saveFileName | Private method to calculate a name for the file to download.
__setDateTime | Private method to set the download date and time.
__updateInfoLabel | Private method to update the info label.
absoluteFilePath | Public method to get the absolute path of the output file.
bytesReceived | Public method to get the number of bytes received.
bytesTotal | Public method to get the total number of bytes of the download.
cancelDownload | Public slot to stop the download.
canceledFileSelect | Public method to check, if the user canceled the file selection.
currentSpeed | Public method to get an estimation for the download speed.
downloadCanceled | Public method to check, if the download was cancelled.
downloadedSuccessfully | Public method to check for a successful download.
downloading | Public method to determine, if a download is in progress.
fileName | Public method to get the name of the output file.
getData | Public method to get the relevant download data.
getInfoData | Public method to get the text of the info label.
getPageUrl | Public method to get the URL of the download page.
on_openButton_clicked | Private slot to open the downloaded file.
on_pauseButton_clicked | Private slot to pause the download.
on_stopButton_clicked | Private slot to stop the download.
on_tryAgainButton_clicked | Private slot to retry the download.
openFile | Public slot to open the downloaded file.
openFolder | Public slot to open the folder containing the downloaded file.
remainingTime | Public method to get an estimation for the remaining time.
retry | Public slot to retry the download.
setData | Public method to set the relevant download data.
setIcon | Public method to set the download icon.

### Static Methods

None

#### DownloadItem (Constructor)

DownloadItem(reply=None, requestFilename=False, webPage=None, download=False, parent=None, mainWindow=None)

Constructor

reply=
  reference to the network reply object (QNetworkReply)
requestFilename=
  flag indicating to ask the user for a filename (boolean)
webPage=
  reference to the web page object the download originated from (QWebPage)
download=
  flag indicating a download operation (boolean)
parent=
  reference to the parent widget (QWidget)
mainWindow=
  reference to the main window (HelpWindow)

#### DownloadItem.__adjustSize

__adjustSize()

Private method to adjust the size of the download item.

#### DownloadItem.__downloadProgress

__downloadProgress(bytesReceived, bytesTotal)

Private method to show the download progress.

bytesReceived
  number of bytes received (integer)
bytesTotal
  number of total bytes (integer)

#### DownloadItem.__finished

__finished()

Private slot to handle the download finished.

#### DownloadItem.__getFileName

__getFileName()

Private method to get the file name to save to from the user.

#### DownloadItem.__initialize

__initialize(tryAgain=False)

Private method to (re)initialize the widget.

tryAgain
  flag indicating a retry (boolean)

#### DownloadItem.__metaDataChanged

__metaDataChanged()

Private slot to handle a change of the meta data.

#### DownloadItem.__networkError

__networkError()

Private slot to handle a network error.

#### DownloadItem.__readyRead

__readyRead()

Private slot to read the available data.

#### DownloadItem.__saveFileName

__saveFileName(directory)

Private method to calculate a name for the file to download.

directory
  name of the directory to store the file into (string)

Returns:
  proposed filename and original filename (string, string)

#### DownloadItem.__setDateTime

__setDateTime(dateTime=None)

Private method to set the download date and time.

dateTime (QDateTime)
  date and time to be set

#### DownloadItem.__updateInfoLabel

__updateInfoLabel()

Private method to update the info label.

#### DownloadItem.absoluteFilePath

absoluteFilePath()

Public method to get the absolute path of the output file.

Returns:
  absolute path of the output file (string)

#### DownloadItem.bytesReceived

bytesReceived()

Public method to get the number of bytes received.

Returns:
  number of bytes received (integer)

#### DownloadItem.bytesTotal

bytesTotal()

Public method to get the total number of bytes of the download.

Returns:
  total number of bytes (integer)

#### DownloadItem.cancelDownload

cancelDownload()

Public slot to stop the download.

#### DownloadItem.canceledFileSelect

canceledFileSelect()

Public method to check, if the user canceled the file selection.

Returns:
  flag indicating cancellation (boolean)

#### DownloadItem.currentSpeed

currentSpeed()

Public method to get an estimation for the download speed.

Returns:
  estimation for the download speed (float)

#### DownloadItem.downloadCanceled

downloadCanceled()

Public method to check, if the download was cancelled.

Returns:
  flag indicating a canceled download (boolean)

#### DownloadItem.downloadedSuccessfully

downloadedSuccessfully()

Public method to check for a successful download.

Returns:
  flag indicating a successful download (boolean)

#### DownloadItem.downloading

downloading()

Public method to determine, if a download is in progress.

Returns:
  flag indicating a download is in progress (boolean)

#### DownloadItem.fileName

fileName()

Public method to get the name of the output file.

Returns:
  name of the output file (string)

#### DownloadItem.getData

getData()

Public method to get the relevant download data.

Returns:
  tuple of URL, save location, flag, the URL of the related web page and the date and time of the download

Return Type:
  tuple of (QUrl, str, bool, QUrl, QDateTime)

#### DownloadItem.getInfoData

getInfoData()

Public method to get the text of the info label.

Returns:
  text of the info label (string)

#### DownloadItem.getPageUrl

getPageUrl()

Public method to get the URL of the download page.

Returns:
  URL of the download page (QUrl)

#### DownloadItem.on_openButton_clicked

on_openButton_clicked()

Private slot to open the downloaded file.

#### DownloadItem.on_pauseButton_clicked

on_pauseButton_clicked(checked)

Private slot to pause the download.

checked
  flag indicating the state of the button (boolean)

#### DownloadItem.on_stopButton_clicked

on_stopButton_clicked()

Private slot to stop the download.

#### DownloadItem.on_tryAgainButton_clicked

on_tryAgainButton_clicked()

Private slot to retry the download.

#### DownloadItem.openFile

openFile()

Public slot to open the downloaded file.

#### DownloadItem.openFolder

openFolder()

Public slot to open the folder containing the downloaded file.

#### DownloadItem.remainingTime

remainingTime()

Public method to get an estimation for the remaining time.

Returns:
  estimation for the remaining time (float)

#### DownloadItem.retry

retry()

Public slot to retry the download.

#### DownloadItem.setData

setData(data)

Public method to set the relevant download data.

data (QUrl, str, bool, QUrl, QDateTime)
  tuple of URL, save location, flag, the URL of the related web page and the date and time of the download

#### DownloadItem.setIcon

setIcon(icon)

Public method to set the download icon.

icon
  reference to the icon to be set (QIcon)

Up