From 97c17e70cf984839c6e95d8f09a55f8d1e61b42e Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Wed, 27 Jan 2016 11:00:18 +0100 Subject: Doc: update Contentmanipulation example docs - Update screenshot - Remove second \brief command - Fix grammar issues - Use standard phrasing for examples - Replace \snippet commands with \quotefromfile commands. This enables documenting each line of code separately - Replace occurrences of QWebView with QWebEngineView - Replace reference to the obsolete QWebEnginePage::evaluateJavaScript method with reference to QWebEnginePage::runJavaScript() that is used in the example code - Remove snippet markers from mainwindow.h and mainwindow.cpp - Move code comment from mainwindow.cpp to the documentation to make the code leaner Change-Id: If3346810c8aef67c15c9ec7ad4469a222e636cf2 Reviewed-by: Joerg Bornemann --- .../contentmanipulation/mainwindow.cpp | 26 ---------------------- 1 file changed, 26 deletions(-) (limited to 'examples/webenginewidgets/contentmanipulation/mainwindow.cpp') diff --git a/examples/webenginewidgets/contentmanipulation/mainwindow.cpp b/examples/webenginewidgets/contentmanipulation/mainwindow.cpp index 3dca497a3..d3552ac86 100644 --- a/examples/webenginewidgets/contentmanipulation/mainwindow.cpp +++ b/examples/webenginewidgets/contentmanipulation/mainwindow.cpp @@ -58,8 +58,6 @@ InvokeWrapper invoke(R *receiver, void (C::*memberFun)(Arg)) return wrapper; } -//! [1] - MainWindow::MainWindow(const QUrl& url) { progress = 0; @@ -70,9 +68,7 @@ MainWindow::MainWindow(const QUrl& url) jQuery = file.readAll(); jQuery.append("\nvar qt = { 'jQuery': jQuery.noConflict(true) };"); file.close(); -//! [1] -//! [2] view = new QWebEngineView(this); view->load(url); connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); @@ -90,14 +86,12 @@ MainWindow::MainWindow(const QUrl& url) toolBar->addAction(view->pageAction(QWebEnginePage::Reload)); toolBar->addAction(view->pageAction(QWebEnginePage::Stop)); toolBar->addWidget(locationEdit); -//! [2] QMenu *viewMenu = menuBar()->addMenu(tr("&View")); QAction* viewSourceAction = new QAction("Page Source", this); connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource())); viewMenu->addAction(viewSourceAction); -//! [3] QMenu *effectMenu = menuBar()->addMenu(tr("&Effect")); effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks())); @@ -116,7 +110,6 @@ MainWindow::MainWindow(const QUrl& url) setCentralWidget(view); } -//! [3] void MainWindow::viewSource() { @@ -129,7 +122,6 @@ void MainWindow::viewSource() view->page()->toHtml(invoke(textEdit, &QTextEdit::setPlainText)); } -//! [4] void MainWindow::adjustLocation() { locationEdit->setText(view->url().toString()); @@ -141,9 +133,7 @@ void MainWindow::changeLocation() view->load(url); view->setFocus(); } -//! [4] -//! [5] void MainWindow::adjustTitle() { if (progress <= 0 || progress >= 100) @@ -157,9 +147,7 @@ void MainWindow::setProgress(int p) progress = p; adjustTitle(); } -//! [5] -//! [6] void MainWindow::finishLoading(bool) { progress = 100; @@ -168,36 +156,24 @@ void MainWindow::finishLoading(bool) rotateImages(rotateAction->isChecked()); } -//! [6] -//! [7] void MainWindow::highlightAllLinks() { - // We append '; undefined' after the jQuery call here to prevent a possible recursion loop and crash caused by - // the way the elements returned by the each iterator elements reference each other, which causes problems upon - // converting them to QVariants. QString code = "qt.jQuery('a').each( function () { qt.jQuery(this).css('background-color', 'yellow') } ); undefined"; view->page()->runJavaScript(code); } -//! [7] -//! [8] void MainWindow::rotateImages(bool invert) { QString code; - // We append '; undefined' after each of the jQuery calls here to prevent a possible recursion loop and crash caused by - // the way the elements returned by the each iterator elements reference each other, which causes problems upon - // converting them to QVariants. if (invert) code = "qt.jQuery('img').each( function () { qt.jQuery(this).css('-webkit-transition', '-webkit-transform 2s'); qt.jQuery(this).css('-webkit-transform', 'rotate(180deg)') } ); undefined"; else code = "qt.jQuery('img').each( function () { qt.jQuery(this).css('-webkit-transition', '-webkit-transform 2s'); qt.jQuery(this).css('-webkit-transform', 'rotate(0deg)') } ); undefined"; view->page()->runJavaScript(code); } -//! [8] -//! [9] void MainWindow::removeGifImages() { QString code = "qt.jQuery('[src*=gif]').remove()"; @@ -221,5 +197,3 @@ void MainWindow::removeEmbeddedElements() QString code = "qt.jQuery('embed').remove()"; view->page()->runJavaScript(code); } -//! [9] - -- cgit v1.2.1