diff options
author | Casper van Donderen <casper.vandonderen@nokia.com> | 2011-08-30 08:44:54 (GMT) |
---|---|---|
committer | Casper van Donderen <casper.vandonderen@nokia.com> | 2011-08-30 08:44:54 (GMT) |
commit | 214a26fbde1c5600a10db59217ae9b63a46bce9e (patch) | |
tree | 601e9edf2832834f0ffef9c7b5c54303ce2f70d2 /doc/src/examples | |
parent | 7f27ebb0383414f15f391151655e5b09952f8ccd (diff) | |
parent | ad203bc0bd17be1ade143e38cdc7e8eca26ebc07 (diff) | |
download | Qt-214a26fbde1c5600a10db59217ae9b63a46bce9e.zip Qt-214a26fbde1c5600a10db59217ae9b63a46bce9e.tar.gz Qt-214a26fbde1c5600a10db59217ae9b63a46bce9e.tar.bz2 |
Merge branch '4.8'
Conflicts:
doc/src/declarative/righttoleft.qdoc
Diffstat (limited to 'doc/src/examples')
-rw-r--r-- | doc/src/examples/addressbook.qdoc | 2 | ||||
-rw-r--r-- | doc/src/examples/codeeditor.qdoc | 26 | ||||
-rw-r--r-- | doc/src/examples/stardelegate.qdoc | 24 |
3 files changed, 39 insertions, 13 deletions
diff --git a/doc/src/examples/addressbook.qdoc b/doc/src/examples/addressbook.qdoc index 114c22b..f19582d 100644 --- a/doc/src/examples/addressbook.qdoc +++ b/doc/src/examples/addressbook.qdoc @@ -29,7 +29,7 @@ \example itemviews/addressbook \title Address Book Example - The address book example shows how to use proxy models to display + \brief The address book example shows how to use proxy models to display different views onto data from a single model. \image addressbook-example.png Screenshot of the Address Book example diff --git a/doc/src/examples/codeeditor.qdoc b/doc/src/examples/codeeditor.qdoc index 435f650..1718d52 100644 --- a/doc/src/examples/codeeditor.qdoc +++ b/doc/src/examples/codeeditor.qdoc @@ -194,4 +194,30 @@ with QSyntaxHighlighter" article in Qt Quarterly 31 implements this. You find it here: \l{http://doc.qt.nokia.com/qq/}. + The line number area is now painted every time the cursor blinks + (because we connect \l{QPlainTextEdit::}{updateRequest()} to + \c updateLineNumberArea()). We can avoid this by introducing a new + member variable to CodeEditor that keeps track of when the update + request comes from a cursor blink (in which case we do not + repaint). The code below requires the \c m_countCache variable, + which is a QPair<int, int> initialized with \c -1 for both + \l{QPair::}{first} and \l{QPair::}{second}. + + \code + void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) + { + if (dy) { + lineNumberArea->scroll(0, dy); + } else if (m_countCache.first != blockCount() + || m_countCache.second != textCursor().block().lineCount()) { + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + m_countCache.first = blockCount(); + m_countCache.second = textCursor().block().lineCount(); + } + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); + } + \endcode */ + diff --git a/doc/src/examples/stardelegate.qdoc b/doc/src/examples/stardelegate.qdoc index 3b009d5..ed3ae7e 100644 --- a/doc/src/examples/stardelegate.qdoc +++ b/doc/src/examples/stardelegate.qdoc @@ -42,12 +42,12 @@ editing takes place. Delegates are subclasses of QAbstractItemDelegate. Qt provides - QItemDelegate, which inherits QAbstractItemDelegate and handles - the most common data types (notably \c int and QString). If we - need to support custom data types, or want to customize the + QStyledItemDelegate, which inherits QAbstractItemDelegate and + handles the most common data types (notably \c int and QString). + If we need to support custom data types, or want to customize the rendering or the editing for existing data types, we can subclass - QAbstractItemDelegate or QItemDelegate. See \l{Delegate Classes} - for more information about delegates, and \l{Model/View + QAbstractItemDelegate or QStyledItemDelegate. See \l{Delegate + Classes} for more information about delegates, and \l{Model/View Programming} if you need a high-level introduction to Qt's model/view architecture (including delegates). @@ -62,9 +62,9 @@ expressed as stars, such as "2 out of 5 stars" or "5 out of 6 stars". - \o \c StarDelegate inherits QItemDelegate and provides support + \o \c StarDelegate inherits QStyledItemDelegate and provides support for \c StarRating (in addition to the data types already - handled by QItemDelegate). + handled by QStyledItemDelegate). \o \c StarEditor inherits QWidget and is used by \c StarDelegate to let the user edit a star rating using the mouse. @@ -80,20 +80,20 @@ \snippet examples/itemviews/stardelegate/stardelegate.h 0 All public functions are reimplemented virtual functions from - QItemDelegate to provide custom rendering and editing. + QStyledItemDelegate to provide custom rendering and editing. \section1 StarDelegate Class Implementation - The \l{QAbstractItemDelegate::}{paint()} function is - reimplemented from QItemDelegate and is called whenever the view - needs to repaint an item: + The \l{QAbstractItemDelegate::}{paint()} function is reimplemented + from QStyledItemDelegate and is called whenever the view needs to + repaint an item: \snippet examples/itemviews/stardelegate/stardelegate.cpp 0 The function is invoked once for each item, represented by a QModelIndex object from the model. If the data stored in the item is a \c StarRating, we paint it ourselves; otherwise, we let - QItemDelegate paint it for us. This ensures that the \c + QStyledItemDelegate paint it for us. This ensures that the \c StarDelegate can handle the most common data types. In the case where the item is a \c StarRating, we draw the |