From 6aeb8a764bbc17f57e3dec14187857697fc64ee2 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 24 Mar 2009 17:57:43 +0100 Subject: [PATCH] more fixes to the textfinder example documentation --- doc/example/textfinder/textfinder.cpp | 6 ++++++ doc/qtcreator.qdoc | 26 ++++++++++---------------- doc/qtcreator.qdocconf | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/doc/example/textfinder/textfinder.cpp b/doc/example/textfinder/textfinder.cpp index 28cfc597b62..c302f91911f 100644 --- a/doc/example/textfinder/textfinder.cpp +++ b/doc/example/textfinder/textfinder.cpp @@ -33,18 +33,21 @@ #include <QtCore/QTextStream> #include <QtGui/QMessageBox> +//! [2] TextFinder::TextFinder(QWidget *parent) : QWidget(parent), ui(new Ui::TextFinder) { ui->setupUi(this); loadTextFile(); } +//! [2] TextFinder::~TextFinder() { delete ui; } +//! [0] void TextFinder::loadTextFile() { QFile inputFile(":/input.txt"); @@ -58,9 +61,12 @@ void TextFinder::loadTextFile() QTextCursor cursor = ui->textEdit->textCursor(); cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1); } +//! [0] +//! [1] void TextFinder::on_findButton_clicked() { QString searchString = ui->lineEdit->text(); ui->textEdit->find(searchString, QTextDocument::FindWholeWords); } +//! [1] diff --git a/doc/qtcreator.qdoc b/doc/qtcreator.qdoc index 37d93730f3f..37bd1846108 100644 --- a/doc/qtcreator.qdoc +++ b/doc/qtcreator.qdoc @@ -565,7 +565,7 @@ void loadTextFile(); \endcode - \note The \c{Ui::Form} object is already provided. + \note The \c{Ui::TextFinder} object is already provided. \section2 The Source File @@ -573,9 +573,7 @@ \c{textfinder.cpp}. We begin by filling in the functionality to load a text file. The code snippet below describes this: - \quotefromfile textfinder.cpp - \skipto TextFinder::loadTextFile - \printuntil } + \snippet example/textfinder/textfinder.cpp 0 Basically, we load a text file using \l{http://doc.trolltech.com/qfile.html}{QFile}, read it with @@ -593,22 +591,18 @@ to look for the search string within the text file. The code snippet below further describes it: - \quotefromfile textfinder.cpp - \skipto on_findButton_clicked - \printuntil } + \snippet example/textfinder/textfinder.cpp 1 Once we have both these functions complete, we call \c{loadTextFile()} in our constructor. - \quotefromfile textfinder.cpp - \skipto TextFinder::TextFinder - \printuntil } + \snippet example/textfinder/textfinder.cpp 2 The \c{on_findButton_clicked()} slot will be called automatically due to this line of code: \code - QMetaObject::connectSlotsByName(TextFinderClass); + QMetaObject::connectSlotsByName(TextFinder); \endcode in the uic generated \c{ui_textfinder.h} file. @@ -1184,13 +1178,13 @@ \code void TextFinder::on_findButton_clicked() { - QString searchString = ui.lineEdit->text(); + QString searchString = ui->lineEdit->text(); - QTextDocument *document = ui.textEdit->document(); - QTextCursor cursor = ui.textEdit->textCursor(); + QTextDocument *document = ui->textEdit->document(); + QTextCursor cursor = ui->textEdit->textCursor(); cursor = document->find(searchString, cursor, QTextDocument::FindWholeWords); - ui.textEdit->setTextCursor(cursor); + ui->textEdit->setTextCursor(cursor); bool found = cursor.isNull(); @@ -1203,7 +1197,7 @@ if (ret == QMessageBox::Yes) { cursor = document->find(searchString, QTextDocument::FindWholeWords); - ui.textEdit->setTextCursor(cursor); + ui->textEdit->setTextCursor(cursor); } else return; } diff --git a/doc/qtcreator.qdocconf b/doc/qtcreator.qdocconf index 8baed7725cf..ea504250cc3 100644 --- a/doc/qtcreator.qdocconf +++ b/doc/qtcreator.qdocconf @@ -8,6 +8,7 @@ sourcedirs = sourcedirs = $SRCDIR imagedirs = $SRCDIR outputdir = $OUTDIR +exampledirs = $SRCDIR extraimages.HTML = qt-logo \ trolltech-logo -- GitLab