summaryrefslogtreecommitdiffstats
path: root/doc/src/examples
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-22 09:28:05 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-22 09:28:05 (GMT)
commitd0ac49ec731f0781ba48f8f5d8ce04e19ce0010d (patch)
treeba6df139b3c343bb9352423770a99f218f62bd45 /doc/src/examples
parent72798fc4dfc1af73cde542f9017dfec5cb020173 (diff)
parent8ad5020940f10d4ecc5c5e8b3b9656531cb84ef3 (diff)
downloadQt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.zip
Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.gz
Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-animations
Conflicts: src/corelib/kernel/kernel.pri src/corelib/kernel/qvariant_p.h src/corelib/tools/tools.pri src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsitem.h src/gui/graphicsview/qgraphicswidget.h src/gui/gui.pro
Diffstat (limited to 'doc/src/examples')
-rw-r--r--doc/src/examples/basicgraphicslayouts.qdoc55
-rw-r--r--doc/src/examples/codeeditor.qdoc2
-rw-r--r--doc/src/examples/containerextension.qdoc2
-rw-r--r--doc/src/examples/contiguouscache.qdoc97
-rw-r--r--doc/src/examples/fancybrowser.qdoc103
-rw-r--r--doc/src/examples/fortuneserver.qdoc2
-rw-r--r--doc/src/examples/ftp.qdoc4
-rw-r--r--doc/src/examples/icons.qdoc2
-rw-r--r--doc/src/examples/musicplayerexample.qdoc2
-rw-r--r--doc/src/examples/qobjectxmlmodel.qdoc2
-rw-r--r--doc/src/examples/tabdialog.qdoc2
-rw-r--r--doc/src/examples/tooltips.qdoc2
-rw-r--r--doc/src/examples/trafficinfo.qdoc2
-rw-r--r--doc/src/examples/transformations.qdoc2
-rw-r--r--doc/src/examples/trollprint.qdoc2
15 files changed, 251 insertions, 30 deletions
diff --git a/doc/src/examples/basicgraphicslayouts.qdoc b/doc/src/examples/basicgraphicslayouts.qdoc
index 92571af..9696fb6 100644
--- a/doc/src/examples/basicgraphicslayouts.qdoc
+++ b/doc/src/examples/basicgraphicslayouts.qdoc
@@ -45,6 +45,7 @@
The Basic Graphics Layouts example shows how to use the layout classes
in QGraphicsView: QGraphicsLinearLayout and QGraphicsGridLayout.
+ In addition to that it shows how to write your own custom layout item.
\image basicgraphicslayouts-example.png Screenshot of the Basic Layouts Example
@@ -115,26 +116,24 @@
\section1 LayoutItem Class Definition
- The \c LayoutItem class is a subclass of QGraphicsWidget. It has a
- constructor, a destructor, and a reimplementation of the
- {QGraphicsItem::paint()}{paint()} function.
+ The \c LayoutItem class is a subclass of QGraphicsLayoutItem and
+ QGraphicsItem. It has a constructor, a destructor, and some required
+ reimplementations.
+ Since it inherits QGraphicsLayoutItem it must reimplement
+ {QGraphicsLayoutItem::setGeometry()}{setGeometry()} and
+ {QGraphicsLayoutItem::sizeHint()}{sizeHint()}.
+ In addition to that it inherits QGraphicsItem, so it must reimplement
+ {QGraphicsItem::boundingRect()}{boundingRect()} and
+ {QGraphicsItem::paint()}{paint()}.
\snippet examples/graphicsview/basicgraphicslayouts/layoutitem.h 0
- The \c LayoutItem class also has a private instance of QPixmap, \c pix.
-
- \note We subclass QGraphicsWidget so that \c LayoutItem objects can
- be automatically plugged into a layout, as QGraphicsWidget is a
- specialization of QGraphicsLayoutItem.
+ The \c LayoutItem class also has a private instance of QPixmap, \c m_pix.
\section1 LayoutItem Class Implementation
- In \c{LayoutItem}'s constructor, \c pix is instantiated and the
- \c{QT_original_R.png} image is loaded into it. We set the size of
- \c LayoutItem to be slightly larger than the size of the pixmap as we
- require some space around it for borders that we will paint later.
- Alternatively, you could scale the pixmap to prevent the item from
- becoming smaller than the pixmap.
+ In \c{LayoutItem}'s constructor, \c m_pix is instantiated and the
+ \c{block.png} image is loaded into it.
\snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 0
@@ -148,4 +147,32 @@
\snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 2
+ The reimplementation of {QGraphicsItem::boundingRect()}{boundingRect()}
+ will set the top left corner at (0,0), and the size of it will be
+ the size of the layout items
+ {QGraphicsLayoutItem::geometry()}{geometry()}. This is the area that
+ we paint within.
+
+ \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 3
+
+
+ The reimplementation of {QGraphicsLayoutItem::setGeometry()}{setGeometry()}
+ simply calls its baseclass implementation. However, since this will change
+ the boundingRect we must also call
+ {QGraphicsItem::prepareGeometryChange()}{prepareGeometryChange()}.
+ Finally, we move the item according to \c geom.topLeft().
+
+ \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 4
+
+
+ Since we don't want the size of the item to be smaller than the pixmap, we
+ must make sure that we return a size hint that is larger than \c m_pix.
+ We also add some extra space around for borders that we will paint later.
+ Alternatively, you could scale the pixmap to prevent the item from
+ becoming smaller than the pixmap.
+ The preferred size is the same as the minimum size hint, while we set
+ maximum to be a large value
+
+ \snippet examples/graphicsview/basicgraphicslayouts/layoutitem.cpp 5
+
*/ \ No newline at end of file
diff --git a/doc/src/examples/codeeditor.qdoc b/doc/src/examples/codeeditor.qdoc
index 669ab45..d218d0d 100644
--- a/doc/src/examples/codeeditor.qdoc
+++ b/doc/src/examples/codeeditor.qdoc
@@ -67,7 +67,7 @@
QTextEdit because it is optimized for handling plain text. See
the QPlainTextEdit class description for details.
- QPlainTextEdit lets us add selections in addition to the the
+ QPlainTextEdit lets us add selections in addition to the
selection the user can make with the mouse or keyboard. We use
this functionality to highlight the current line. More on this
later.
diff --git a/doc/src/examples/containerextension.qdoc b/doc/src/examples/containerextension.qdoc
index a4fbcea..6d29cf6 100644
--- a/doc/src/examples/containerextension.qdoc
+++ b/doc/src/examples/containerextension.qdoc
@@ -305,7 +305,7 @@
MultiPageWidget class \l
{designer/containerextension/multipagewidget.cpp}{implementation}).
Finally, we implicitly force an update of the page's property
- sheet by calling the the
+ sheet by calling the
QDesignerPropertySheetExtension::setChanged() function.
\snippet examples/designer/containerextension/multipagewidgetplugin.cpp 4
diff --git a/doc/src/examples/contiguouscache.qdoc b/doc/src/examples/contiguouscache.qdoc
new file mode 100644
index 0000000..fbfde3f
--- /dev/null
+++ b/doc/src/examples/contiguouscache.qdoc
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example tools/contiguouscache
+ \title Contiguous Cache Example
+
+ The Contiguous Cache example shows how to use QContiguousCache to manage memory usage for
+ very large models. In some environments memory is limited and, even when it
+ isn't, users still dislike an application using excessive memory.
+ Using QContiguousCache to manage a list, rather than loading
+ the entire list into memory, allows the application to limit the amount
+ of memory it uses, regardless of the size of the data set it accesses
+
+ The simplest way to use QContiguousCache is to cache as items are requested. When
+ a view requests an item at row N it is also likely to ask for items at rows near
+ to N.
+
+ \snippet examples/tools/contiguouscache/randomlistmodel.cpp 0
+
+ After getting the row, the class determines if the row is in the bounds
+ of the contiguous cache's current range. It would have been equally valid to
+ simply have the following code instead.
+
+ \code
+ while (row > m_rows.lastIndex())
+ m_rows.append(fetchWord(m_rows.lastIndex()+1);
+ while (row < m_rows.firstIndex())
+ m_rows.prepend(fetchWord(m_rows.firstIndex()-1);
+ \endcode
+
+ However a list will often jump rows if the scroll bar is used directly, resulting in
+ the code above causing every row between the old and new rows to be fetched.
+
+ Using QContiguousCache::lastIndex() and QContiguousCache::firstIndex() allows
+ the example to determine what part of the list the cache is currently caching.
+ These values don't represent the indexes into the cache's own memory, but rather
+ a virtual infinite array that the cache represents.
+
+ By using QContiguousCache::append() and QContiguousCache::prepend() the code ensures
+ that items that may be still on the screen are not lost when the requested row
+ has not moved far from the current cache range. QContiguousCache::insert() can
+ potentially remove more than one item from the cache as QContiguousCache does not
+ allow for gaps. If your cache needs to quickly jump back and forth between
+ rows with significant gaps between them consider using QCache instead.
+
+ And thats it. A perfectly reasonable cache, using minimal memory for a very large
+ list. In this case the accessor for getting the words into the cache
+ generates random information rather than fixed information. This allows you
+ to see how the cache range is kept for a local number of rows when running the
+ example.
+
+ \snippet examples/tools/contiguouscache/randomlistmodel.cpp 1
+
+ It is also worth considering pre-fetching items into the cache outside of the
+ application's paint routine. This can be done either with a separate thread
+ or using a QTimer to incrementally expand the range of the cache prior to
+ rows being requested out of the current cache range.
+*/
diff --git a/doc/src/examples/fancybrowser.qdoc b/doc/src/examples/fancybrowser.qdoc
index 9001c20..631aff9 100644
--- a/doc/src/examples/fancybrowser.qdoc
+++ b/doc/src/examples/fancybrowser.qdoc
@@ -40,12 +40,109 @@
****************************************************************************/
/*!
- \example webkit/fancybrowser
- \title Fancy Browser Example
+ \example webkit/fancybrowser
+ \title Fancy Browser Example
The Fancy Browser example shows how to use jQuery with QtWebKit to
- make a web browser with some special effects and content manipulation.
+ create a web browser with special effects and content
+ manipulation.
\image fancybrowser-example.png
+ The application makes use of QWebFrame::evaluateJavaScript to
+ evaluate the jQuery JavaScript code. A QMainWindow with a QWebView
+ as central widget builds up the browser itself.
+
+ \section1 MainWindow Class Definition
+
+ The \c MainWindow class inherits QMainWindow. It implements a number of
+ slots to perform actions on both the application and on the web content.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.h 1
+
+ We also declare a QString that contains the jQuery, a QWebView
+ that displays the web content, and a QLineEdit that acts as the
+ address bar.
+
+ \section1 MainWindow Class Implementation
+
+ We start by implementing the constructor.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 1
+
+ The first part of the constructor sets the value of \c progress to
+ 0. This value will be used later in the code to visualize the
+ loading of a webpage.
+
+ Next, the jQuery library is loaded using a QFile and reading the file
+ content. The jQuery library is a JavaScript library that provides different
+ functions for manipulating HTML.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 2
+
+ The second part of the constructor creates a QWebView and connects
+ slots to the views signals. Furthermore, we create a QLineEdit as
+ the browsers address bar. We then set the horizontal QSizePolicy
+ to fill the available area in the browser at all times. We add the
+ QLineEdit to a QToolbar together with a set of navigation actions
+ from QWebView::pageAction.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 3
+
+ The third and last part of the constructor implements two QMenus and assigns
+ a set of actions to them. The last line sets the QWebView as the central
+ widget in the QMainWindow.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 4
+
+ When the page is loaded, \c adjustLocation() updates the address
+ bar; \c adjustLocation() is triggered by the \c loadFinished()
+ signal in QWebView. In \c changeLocation() we create a QUrl
+ object, and then use it to load the page into the QWebView. When
+ the new web page has finished loading, \c adjustLocation() will be
+ run once more to update the address bar.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 5
+
+ \c adjustTitle() sets the window title and displays the loading
+ progress. This slot is triggered by the \c titleChanged() signal
+ in QWebView.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 6
+
+ When a web page has loaded, \c finishLoading() is triggered by the
+ \c loadFinished() signal in QWebView. \c finishLoading() then updates the
+ progress in the title bar and calls \c evaluateJavaScript() to evaluate the
+ jQuery library. This evaluates the JavaScript against the current web page.
+ What that means is that the JavaScript can be viewed as part of the content
+ loaded into the QWebView, and therefore needs to be loaded every time a new
+ page is loaded. Once the jQuery library is loaded, we can start executing
+ the different jQuery functions in the browser.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 7
+
+ The first jQuery-based function, \c highlightAllLinks(), is designed to
+ highlight all links in the current webpage. The JavaScript code looks
+ for web elements named \e {a}, which is the tag for a hyperlink.
+ For each such element, the background color is set to be yellow by
+ using CSS.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 8
+
+ The \c rotateImages() function rotates the images on the current
+ web page. Webkit supports CSS transforms and this JavaScript code
+ looks up all \e {img} elements and rotates the images 180 degrees
+ and then back again.
+
+ \snippet examples/webkit/fancybrowser/mainwindow.cpp 9
+
+ The remaining four methods remove different elements from the current web
+ page. \c removeGifImages() removes all Gif images on the page by looking up
+ the \e {src} attribute of all the elements on the web page. Any element with
+ a \e {gif} file as its source is removed. \c removeInlineFrames() removes all
+ \e {iframe} or inline elements. \c removeObjectElements() removes all
+ \e {object} elements, and \c removeEmbeddedElements() removes any elements
+ such as plugins embedded on the page using the \e {embed} tag.
+
*/
+
diff --git a/doc/src/examples/fortuneserver.qdoc b/doc/src/examples/fortuneserver.qdoc
index e6a7f85..848a3a3 100644
--- a/doc/src/examples/fortuneserver.qdoc
+++ b/doc/src/examples/fortuneserver.qdoc
@@ -45,7 +45,7 @@
The Fortune Server example shows how to create a server for a simple
network service. It is intended to be run alongside the
- \l{network/fortuneclient}{Fortune Client} example or the the
+ \l{network/fortuneclient}{Fortune Client} example or the
\l{network/blockingfortuneclient}{Blocking Fortune Client} example.
\image fortuneserver-example.png Screenshot of the Fortune Server example
diff --git a/doc/src/examples/ftp.qdoc b/doc/src/examples/ftp.qdoc
index 9cc9cd1..7a74a37 100644
--- a/doc/src/examples/ftp.qdoc
+++ b/doc/src/examples/ftp.qdoc
@@ -172,7 +172,7 @@
no entries were found (in which case our \c addToList() function
would not have been called).
- Let's continue with the the \c addToList() slot:
+ Let's continue with the \c addToList() slot:
\snippet examples/network/ftp/ftpwindow.cpp 10
@@ -190,7 +190,7 @@
\snippet examples/network/ftp/ftpwindow.cpp 12
- \c cdToParent() is invoked when the the user requests to go to the
+ \c cdToParent() is invoked when the user requests to go to the
parent directory of the one displayed in the file list. After
changing the directory, we QFtp::List its contents.
diff --git a/doc/src/examples/icons.qdoc b/doc/src/examples/icons.qdoc
index 750ef2e..a81ddb9 100644
--- a/doc/src/examples/icons.qdoc
+++ b/doc/src/examples/icons.qdoc
@@ -479,7 +479,7 @@
QTableWidget::openPersistentEditor() function to create
comboboxes for the mode and state columns of the items.
- Due to the the connection between the table widget's \l
+ Due to the connection between the table widget's \l
{QTableWidget::itemChanged()}{itemChanged()} signal and the \c
changeIcon() slot, the new image is automatically converted into a
pixmap and made part of the set of pixmaps available to the icon
diff --git a/doc/src/examples/musicplayerexample.qdoc b/doc/src/examples/musicplayerexample.qdoc
index d23c1f1..9f04bf6 100644
--- a/doc/src/examples/musicplayerexample.qdoc
+++ b/doc/src/examples/musicplayerexample.qdoc
@@ -154,7 +154,7 @@
\snippet examples/phonon/musicplayer/mainwindow.cpp 5
- We move on to the the slots of \c MainWindow, starting with \c
+ We move on to the slots of \c MainWindow, starting with \c
addFiles():
\snippet examples/phonon/musicplayer/mainwindow.cpp 6
diff --git a/doc/src/examples/qobjectxmlmodel.qdoc b/doc/src/examples/qobjectxmlmodel.qdoc
index ce1dab6..37c66bc 100644
--- a/doc/src/examples/qobjectxmlmodel.qdoc
+++ b/doc/src/examples/qobjectxmlmodel.qdoc
@@ -71,7 +71,7 @@
The query engine can only traverse two dimensional trees, because an
XML document is always a two dimensional tree. If we want to add the
QMetaObject tree to the node model, we have to somehow flatten it
- into the the same plane as the QObject tree. This requires that the
+ into the same plane as the QObject tree. This requires that the
node model class must build an auxiliary data structure and make it
part of the two dimensional QObject node model. How to do this is
explained in \l{Including The QMetaObject Tree}.
diff --git a/doc/src/examples/tabdialog.qdoc b/doc/src/examples/tabdialog.qdoc
index c9500af..5394b82 100644
--- a/doc/src/examples/tabdialog.qdoc
+++ b/doc/src/examples/tabdialog.qdoc
@@ -91,7 +91,7 @@
\snippet examples/dialogs/tabdialog/tabdialog.cpp 1
\snippet examples/dialogs/tabdialog/tabdialog.cpp 3
- We arrange the the tab widget above the buttons in the dialog:
+ We arrange the tab widget above the buttons in the dialog:
\snippet examples/dialogs/tabdialog/tabdialog.cpp 4
diff --git a/doc/src/examples/tooltips.qdoc b/doc/src/examples/tooltips.qdoc
index 5daa2b2..78b350b 100644
--- a/doc/src/examples/tooltips.qdoc
+++ b/doc/src/examples/tooltips.qdoc
@@ -353,7 +353,7 @@
Whenever the user creates a new shape item, we want the new item
to appear at a random position, and we use the \c
randomItemPosition() function to calculate such a position. We
- make sure that the item appears within the the visible area of the
+ make sure that the item appears within the visible area of the
\c SortingBox widget, using the widget's current width and heigth
when calculating the random coordinates.
diff --git a/doc/src/examples/trafficinfo.qdoc b/doc/src/examples/trafficinfo.qdoc
index c9b6890..13181cd 100644
--- a/doc/src/examples/trafficinfo.qdoc
+++ b/doc/src/examples/trafficinfo.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
diff --git a/doc/src/examples/transformations.qdoc b/doc/src/examples/transformations.qdoc
index eabb803..58c8b80 100644
--- a/doc/src/examples/transformations.qdoc
+++ b/doc/src/examples/transformations.qdoc
@@ -208,7 +208,7 @@
After transforming the coordinate system, we draw the \c
RenderArea's shape, and then we restore the painter state using
- the the QPainter::restore() function (i.e. popping the saved state off
+ the QPainter::restore() function (i.e. popping the saved state off
the stack).
\snippet examples/painting/transformations/renderarea.cpp 7
diff --git a/doc/src/examples/trollprint.qdoc b/doc/src/examples/trollprint.qdoc
index 38251ee..489012e 100644
--- a/doc/src/examples/trollprint.qdoc
+++ b/doc/src/examples/trollprint.qdoc
@@ -142,7 +142,7 @@
We can easily determine which file must be changed because the
translator's "context" is in fact the class name for the class where
the texts that must be changed appears. In this case the file is \c
- printpanel.cpp, where the there are four lines to change. Add the
+ printpanel.cpp, where there are four lines to change. Add the
second argument "two-sided" in the appropriate \c tr() calls to the
first pair of radio buttons: