summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--examples/webenginewidgets/browser/browserapplication.cpp6
-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
7 files changed, 33 insertions, 31 deletions
diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/browser/browserapplication.cpp
index 8961bf7f..ca28b2d0 100644
--- a/examples/webenginewidgets/browser/browserapplication.cpp
+++ b/examples/webenginewidgets/browser/browserapplication.cpp
@@ -83,11 +83,11 @@ static void setUserStyleSheet(QWebEngineProfile *profile, const QString &styleSh
Q_ASSERT(profile);
QString scriptName(QStringLiteral("userStyleSheet"));
QWebEngineScript script;
- QList<QWebEngineScript> styleSheets = profile->scripts().findScripts(scriptName);
+ QList<QWebEngineScript> styleSheets = profile->scripts()->findScripts(scriptName);
if (!styleSheets.isEmpty())
script = styleSheets.first();
Q_FOREACH (const QWebEngineScript &s, styleSheets)
- profile->scripts().remove(s);
+ profile->scripts()->remove(s);
if (script.isNull()) {
script.setName(scriptName);
@@ -106,7 +106,7 @@ static void setUserStyleSheet(QWebEngineProfile *profile, const QString &styleSh
"css.innerText = \"%1\";"\
"})()").arg(styleSheet);
script.setSourceCode(source);
- profile->scripts().insert(script);
+ profile->scripts()->insert(script);
// run the script on the already loaded views
// this has to be deferred as it could mess with the storage initialization on startup
if (mainWindow)
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index 70357058..7df044e6 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 ee3ab221..d362131f 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 adccfca2..2e5f685f 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 d65db24a..4308fe75 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 b0bfc88b..55941580 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 5ef9c55c..fe3ce286 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 *);