From 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Tue, 11 Aug 2009 17:01:47 +0100 Subject: Merge in WebKit r47029. --- WebKit/qt/docs/webkitsnippets/webelement/main.cpp | 69 ++++++++++++++++++++++ .../docs/webkitsnippets/webelement/webelement.pro | 5 ++ 2 files changed, 74 insertions(+) create mode 100644 WebKit/qt/docs/webkitsnippets/webelement/main.cpp create mode 100644 WebKit/qt/docs/webkitsnippets/webelement/webelement.pro (limited to 'WebKit/qt/docs/webkitsnippets/webelement') diff --git a/WebKit/qt/docs/webkitsnippets/webelement/main.cpp b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp new file mode 100644 index 0000000..d437a6f --- /dev/null +++ b/WebKit/qt/docs/webkitsnippets/webelement/main.cpp @@ -0,0 +1,69 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include +#include + +static QWebFrame *frame; + +static void traverse() +{ +//! [Traversing with QWebElement] + frame->setHtml("

First Paragraph

Second Paragraph

"); + QWebElement doc = frame->documentElement(); + QWebElement body = doc.firstChild(); + QWebElement firstParagraph = body.firstChild(); + QWebElement secondParagraph = firstParagraph.nextSibling(); +//! [Traversing with QWebElement] +} + +static void findAll() +{ +//! [FindAll] + QWebElement document = frame->documentElement(); + /* Assume the document has the following structure: + +

+ Intro + Snippets +

+

+ Content + Here +

+ */ + + QList allSpans = document.findAll("span"); + QList introSpans = document.findAll("p.intro span"); +//! [FindAll] +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWebView *view = new QWebView(0); + frame = view->page()->mainFrame(); + traverse(); + findAll(); + return 0; +} diff --git a/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro new file mode 100644 index 0000000..f9b403b --- /dev/null +++ b/WebKit/qt/docs/webkitsnippets/webelement/webelement.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +CONFIG -= app_bundle +SOURCES = main.cpp +include(../../../../../WebKit.pri) +QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR -- cgit v1.1