diff options
author | Michal Klocek <michal.klocek@qt.io> | 2020-08-11 13:28:48 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2020-08-18 23:23:46 +0200 |
commit | 08375ee796a545e3916feb24e0b35d561e6f0049 (patch) | |
tree | 6af02ebfebf352781213490c12c18b8d4f1fcb84 /examples | |
parent | 75393077108480e1762612331c399a012b5feba7 (diff) |
Rename QWebEngineDownloadItem -> QWebEngineDownloadRequest
This fits better with other QWebEngine*Requests.
[ChangeLog] QWebEngineDownloadItem is now QWebEngineDownloadRequest,
also in qml.
Change-Id: I506e9fac746b4f23ac0936c2fbe1c7472f4fda36
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'examples')
5 files changed, 26 insertions, 26 deletions
diff --git a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc index 251ca5ad8..2bbe3fe33 100644 --- a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc +++ b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc @@ -314,7 +314,7 @@ Downloads are associated with a \l QWebEngineProfile. Whenever a download is triggered on a web page the \l QWebEngineProfile::downloadRequested signal is - emitted with a \l QWebEngineDownloadItem, which in this example is forwarded + emitted with a \l QWebEngineDownloadRequest, which in this example is forwarded to \c DownloadManagerWidget::downloadRequested: \quotefromfile webenginewidgets/simplebrowser/browser.cpp @@ -329,10 +329,10 @@ \skipto DownloadManagerWidget::downloadRequested \printuntil /^\}/ - The \l QWebEngineDownloadItem object will periodically emit the \l - {QWebEngineDownloadItem::}{downloadProgress} signal to notify potential + The \l QWebEngineDownloadRequest object will periodically emit the \l + {QWebEngineDownloadRequest::}{downloadProgress} signal to notify potential observers of the download progress and the \l - {QWebEngineDownloadItem::}{stateChanged} signal when the download is + {QWebEngineDownloadRequest::}{stateChanged} signal when the download is finished or when an error occurs. See \c downloadmanagerwidget.cpp for an example of how these signals can be handled. diff --git a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp index b6f9e9c13..cdd3a414a 100644 --- a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp +++ b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp @@ -56,7 +56,7 @@ #include <QFileDialog> #include <QDir> -#include <QWebEngineDownloadItem> +#include <QWebEngineDownloadRequest> DownloadManagerWidget::DownloadManagerWidget(QWidget *parent) : QWidget(parent) @@ -65,9 +65,9 @@ DownloadManagerWidget::DownloadManagerWidget(QWidget *parent) setupUi(this); } -void DownloadManagerWidget::downloadRequested(QWebEngineDownloadItem *download) +void DownloadManagerWidget::downloadRequested(QWebEngineDownloadRequest *download) { - Q_ASSERT(download && download->state() == QWebEngineDownloadItem::DownloadRequested); + Q_ASSERT(download && download->state() == QWebEngineDownloadRequest::DownloadRequested); QString path = QFileDialog::getSaveFileName(this, tr("Save as"), QDir(download->downloadDirectory()).filePath(download->downloadFileName())); if (path.isEmpty()) diff --git a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h index 7be9d8102..221cd261f 100644 --- a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h +++ b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h @@ -56,7 +56,7 @@ #include <QWidget> QT_BEGIN_NAMESPACE -class QWebEngineDownloadItem; +class QWebEngineDownloadRequest; QT_END_NAMESPACE class DownloadWidget; @@ -69,9 +69,9 @@ public: explicit DownloadManagerWidget(QWidget *parent = nullptr); // Prompts user with a "Save As" dialog. If the user doesn't cancel it, then - // the QWebEngineDownloadItem will be accepted and the DownloadManagerWidget + // the QWebEngineDownloadRequest will be accepted and the DownloadManagerWidget // will be shown on the screen. - void downloadRequested(QWebEngineDownloadItem *webItem); + void downloadRequested(QWebEngineDownloadRequest *webItem); private: void add(DownloadWidget *downloadWidget); diff --git a/examples/webenginewidgets/simplebrowser/downloadwidget.cpp b/examples/webenginewidgets/simplebrowser/downloadwidget.cpp index ddddc5e5d..e9caa8658 100644 --- a/examples/webenginewidgets/simplebrowser/downloadwidget.cpp +++ b/examples/webenginewidgets/simplebrowser/downloadwidget.cpp @@ -52,9 +52,9 @@ #include <QFileInfo> #include <QUrl> -#include <QWebEngineDownloadItem> +#include <QWebEngineDownloadRequest> -DownloadWidget::DownloadWidget(QWebEngineDownloadItem *download, QWidget *parent) +DownloadWidget::DownloadWidget(QWebEngineDownloadRequest *download, QWidget *parent) : QFrame(parent) , m_download(download) , m_timeAdded() @@ -66,16 +66,16 @@ DownloadWidget::DownloadWidget(QWebEngineDownloadItem *download, QWidget *parent connect(m_cancelButton, &QPushButton::clicked, [this](bool) { - if (m_download->state() == QWebEngineDownloadItem::DownloadInProgress) + if (m_download->state() == QWebEngineDownloadRequest::DownloadInProgress) m_download->cancel(); else emit removeClicked(this); }); - connect(m_download, &QWebEngineDownloadItem::downloadProgress, + connect(m_download, &QWebEngineDownloadRequest::downloadProgress, this, &DownloadWidget::updateWidget); - connect(m_download, &QWebEngineDownloadItem::stateChanged, + connect(m_download, &QWebEngineDownloadRequest::stateChanged, this, &DownloadWidget::updateWidget); updateWidget(); @@ -101,10 +101,10 @@ void DownloadWidget::updateWidget() auto state = m_download->state(); switch (state) { - case QWebEngineDownloadItem::DownloadRequested: + case QWebEngineDownloadRequest::DownloadRequested: Q_UNREACHABLE(); break; - case QWebEngineDownloadItem::DownloadInProgress: + case QWebEngineDownloadRequest::DownloadInProgress: if (totalBytes >= 0) { m_progressBar->setValue(qRound(100 * receivedBytes / totalBytes)); m_progressBar->setDisabled(false); @@ -122,7 +122,7 @@ void DownloadWidget::updateWidget() .arg(withUnit(bytesPerSecond))); } break; - case QWebEngineDownloadItem::DownloadCompleted: + case QWebEngineDownloadRequest::DownloadCompleted: m_progressBar->setValue(100); m_progressBar->setDisabled(true); m_progressBar->setFormat( @@ -130,7 +130,7 @@ void DownloadWidget::updateWidget() .arg(withUnit(receivedBytes)) .arg(withUnit(bytesPerSecond))); break; - case QWebEngineDownloadItem::DownloadCancelled: + case QWebEngineDownloadRequest::DownloadCancelled: m_progressBar->setValue(0); m_progressBar->setDisabled(true); m_progressBar->setFormat( @@ -138,7 +138,7 @@ void DownloadWidget::updateWidget() .arg(withUnit(receivedBytes)) .arg(withUnit(bytesPerSecond))); break; - case QWebEngineDownloadItem::DownloadInterrupted: + case QWebEngineDownloadRequest::DownloadInterrupted: m_progressBar->setValue(0); m_progressBar->setDisabled(true); m_progressBar->setFormat( @@ -147,7 +147,7 @@ void DownloadWidget::updateWidget() break; } - if (state == QWebEngineDownloadItem::DownloadInProgress) { + if (state == QWebEngineDownloadRequest::DownloadInProgress) { static QIcon cancelIcon(QStringLiteral(":process-stop.png")); m_cancelButton->setIcon(cancelIcon); m_cancelButton->setToolTip(tr("Stop downloading")); diff --git a/examples/webenginewidgets/simplebrowser/downloadwidget.h b/examples/webenginewidgets/simplebrowser/downloadwidget.h index c20676aa6..c59b1b4b7 100644 --- a/examples/webenginewidgets/simplebrowser/downloadwidget.h +++ b/examples/webenginewidgets/simplebrowser/downloadwidget.h @@ -57,16 +57,16 @@ #include <QElapsedTimer> QT_BEGIN_NAMESPACE -class QWebEngineDownloadItem; +class QWebEngineDownloadRequest; QT_END_NAMESPACE -// Displays one ongoing or finished download (QWebEngineDownloadItem). +// Displays one ongoing or finished download (QWebEngineDownloadRequest). class DownloadWidget final : public QFrame, public Ui::DownloadWidget { Q_OBJECT public: - // Precondition: The QWebEngineDownloadItem has been accepted. - explicit DownloadWidget(QWebEngineDownloadItem *download, QWidget *parent = nullptr); + // Precondition: The QWebEngineDownloadRequest has been accepted. + explicit DownloadWidget(QWebEngineDownloadRequest *download, QWidget *parent = nullptr); signals: // This signal is emitted when the user indicates that they want to remove @@ -79,7 +79,7 @@ private slots: private: QString withUnit(qreal bytes); - QWebEngineDownloadItem *m_download; + QWebEngineDownloadRequest *m_download; QElapsedTimer m_timeAdded; }; |