summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@theqtcompany.com>2015-06-11 14:06:13 +0200
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-06-12 09:26:58 +0000
commit0b65f3ca378810d3b33345b99bf084124acf3e5f (patch)
tree3f2857dfd9c98498d8be92607a11a2a4f023ab41 /src/webenginewidgets
parente0e74a0a9286bb92ae7e2e2395827538133d2bf0 (diff)
Last minute API review cleanup
The getters in QWebEngineDownloadItem were not const. The script collection in QWebEngineProfile was passed by reference, which is not idiomatic of Qt. Change-Id: I9b4218b407288b91a726a711bd2a7e1c1167d99a Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp28
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h14
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp10
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h2
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h3
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.h1
6 files changed, 30 insertions, 28 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index 703570587..7df044e66 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -156,9 +156,9 @@ void QWebEngineDownloadItem::cancel()
Returns the download item's id.
*/
-quint32 QWebEngineDownloadItem::id()
+quint32 QWebEngineDownloadItem::id() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->downloadId;
}
@@ -205,9 +205,9 @@ quint32 QWebEngineDownloadItem::id()
\sa QWebEngineDownloadItem::DownloadState
*/
-QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state()
+QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->downloadState;
}
@@ -217,9 +217,9 @@ QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state()
-1 means the size is unknown.
*/
-qint64 QWebEngineDownloadItem::totalBytes()
+qint64 QWebEngineDownloadItem::totalBytes() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->totalBytes;
}
@@ -229,9 +229,9 @@ qint64 QWebEngineDownloadItem::totalBytes()
-1 means the size is unknown.
*/
-qint64 QWebEngineDownloadItem::receivedBytes()
+qint64 QWebEngineDownloadItem::receivedBytes() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->receivedBytes;
}
@@ -239,9 +239,9 @@ qint64 QWebEngineDownloadItem::receivedBytes()
Returns the download's origin url.
*/
-QUrl QWebEngineDownloadItem::url()
+QUrl QWebEngineDownloadItem::url() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->downloadUrl;
}
@@ -252,9 +252,9 @@ QUrl QWebEngineDownloadItem::url()
and file name is deduced not to overwrite already existing files.
*/
-QString QWebEngineDownloadItem::path()
+QString QWebEngineDownloadItem::path() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->downloadPath;
}
@@ -282,9 +282,9 @@ void QWebEngineDownloadItem::setPath(QString path)
\sa finished(), state(),
*/
-bool QWebEngineDownloadItem::isFinished()
+bool QWebEngineDownloadItem::isFinished() const
{
- Q_D(QWebEngineDownloadItem);
+ Q_D(const QWebEngineDownloadItem);
return d->downloadFinished;
}
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index ee3ab221d..d362131f2 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -61,14 +61,14 @@ public:
};
Q_ENUMS(DownloadState)
- quint32 id();
- DownloadState state();
- qint64 totalBytes();
- qint64 receivedBytes();
- QUrl url();
- QString path();
+ quint32 id() const;
+ DownloadState state() const;
+ qint64 totalBytes() const;
+ qint64 receivedBytes() const;
+ QUrl url() const;
+ QString path() const;
void setPath(QString path);
- bool isFinished();
+ bool isFinished() const;
public Q_SLOTS:
void accept();
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index adccfca2a..2e5f685fd 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -103,8 +103,8 @@ using QtWebEngineCore::BrowserContextAdapter;
*/
QWebEngineProfilePrivate::QWebEngineProfilePrivate(BrowserContextAdapter* browserContext)
- : scriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userScriptController()))
- , m_settings(new QWebEngineSettings())
+ : m_settings(new QWebEngineSettings())
+ , m_scriptCollection(new QWebEngineScriptCollection(new QWebEngineScriptCollectionPrivate(browserContext->userScriptController())))
, m_browserContextRef(browserContext)
{
m_browserContextRef->addClient(this);
@@ -438,10 +438,10 @@ bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const
Returns the script collection used by this profile.
\sa QWebEngineScriptCollection
*/
-QWebEngineScriptCollection &QWebEngineProfile::scripts()
+QWebEngineScriptCollection *QWebEngineProfile::scripts() const
{
- Q_D(QWebEngineProfile);
- return d->scriptCollection;
+ Q_D(const QWebEngineProfile);
+ return d->m_scriptCollection.data();
}
/*!
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index d65db24ab..4308fe75d 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -98,7 +98,7 @@ public:
bool visitedLinksContainsUrl(const QUrl &url) const;
QWebEngineSettings *settings() const;
- QWebEngineScriptCollection &scripts();
+ QWebEngineScriptCollection *scripts() const;
static QWebEngineProfile *defaultProfile();
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index b0bfc88b9..55941580d 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -43,6 +43,7 @@
#include "qwebenginescriptcollection.h"
#include <QMap>
#include <QPointer>
+#include <QScopedPointer>
namespace QtWebEngineCore {
class BrowserContextAdapter;
@@ -72,10 +73,10 @@ public:
void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
void clearUrlSchemeHandlers();
- QWebEngineScriptCollection scriptCollection;
private:
QWebEngineProfile *q_ptr;
QWebEngineSettings *m_settings;
+ QScopedPointer<QWebEngineScriptCollection> m_scriptCollection;
QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef;
QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
QMap<QByteArray, QPointer<QWebEngineUrlSchemeHandler> > m_urlSchemeHandlers;
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.h b/src/webenginewidgets/api/qwebenginescriptcollection.h
index 5ef9c55c7..fe3ce2861 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.h
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.h
@@ -67,6 +67,7 @@ public:
QList<QWebEngineScript> toList() const;
private:
+ Q_DISABLE_COPY(QWebEngineScriptCollection)
friend class QWebEnginePagePrivate;
friend class QWebEngineProfilePrivate;
QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *);