lib Library API Documentation

KoTextIterator Class Reference

A convenient way to iterate over paragraphs, possibly in multiple textobjects, with many options (from cursor, backwards, in selection). General purpose paragraph iterator. More...

#include <kotextiterator.h>

List of all members.

Signals

void currentParagraphModified (int modifyType, int pos, int length)

Public Member Functions

 KoTextIterator (const QValueList< KoTextObject * > &lstObjects, KoTextView *textView, int options)
void init (const QValueList< KoTextObject * > &lstObjects, KoTextView *textView, int options)
void restart ()
void setOptions (int options)
int options () const
void operator++ ()
bool atEnd () const
bool hasText () const
QString currentText () const
KoTextParag * currentParag () const
KoTextObjectcurrentTextObject () const
int currentStartIndex () const
QPair< int, QString > currentTextAndIndex () const

Protected Slots

void slotParagraphDeleted (KoTextParag *parag)
void slotParagraphModified (KoTextParag *parag, int, int pos, int length)

Protected Member Functions

void connectTextObjects ()
void nextTextObject ()


Detailed Description

A convenient way to iterate over paragraphs, possibly in multiple textobjects, with many options (from cursor, backwards, in selection). General purpose paragraph iterator.

Definition at line 35 of file kotextiterator.h.


Constructor & Destructor Documentation

KoTextIterator::KoTextIterator const QValueList< KoTextObject * > &  lstObjects,
KoTextView textView,
int  options
[inline]
 

Parameters:
options see KFindDialog

Definition at line 42 of file kotextiterator.h.

References init().


Member Function Documentation

void KoTextIterator::init const QValueList< KoTextObject * > &  lstObjects,
KoTextView textView,
int  options
 

The search direction (forward or backward) is handled in a bit of a tricky way.

m_firstParag/m_firstIndex is where the search starts, whichever the direction m_lastParag/m_lastIndex is where the search ends, whichever the direction But the list of textobjects is as given (we assume document order). So we go from the first to the last textobject, or from the last to the first textobject.

Definition at line 35 of file kotextiterator.cc.

References KoTextView::cursor(), KoTextObject::textDocument(), and KoTextView::textObject().

Referenced by KoTextIterator().

void KoTextIterator::restart  ) 
 

Restart from the beginning - assumes same parameters given to init.

Definition at line 140 of file kotextiterator.cc.

Referenced by KoFindReplace::findNext(), and setOptions().

void KoTextIterator::setOptions int  options  ) 
 

Change options during iteration.

## Not sure how if all cases will be handled :} At least this is useful for the "Replace All" button during replacing, and for switching to "FindBackwards" temporarily for "find previous".

Definition at line 336 of file kotextiterator.cc.

References restart().

Referenced by KoFindReplace::findNext().

int KoTextIterator::options  )  const [inline]
 

Return the options currently used by the iterator.

Definition at line 62 of file kotextiterator.h.

Referenced by KoFindReplace::findNext().

void KoTextIterator::operator++  ) 
 

Go to next paragraph that we must iterate over.

Definition at line 220 of file kotextiterator.cc.

bool KoTextIterator::atEnd  )  const
 

Returns:
true if we have iterated over all paragraphs

Definition at line 276 of file kotextiterator.cc.

Referenced by KoFindReplace::findNext().

bool KoTextIterator::hasText  )  const
 

Returns:
true if currentText() isn't empty. The implementation is faster than calling currentText().isEmpty() though.

Definition at line 317 of file kotextiterator.cc.

QString KoTextIterator::currentText  )  const
 

Returns:
the string at the current position of the iterator

Definition at line 287 of file kotextiterator.cc.

References currentTextAndIndex().

KoTextParag* KoTextIterator::currentParag  )  const [inline]
 

Returns:
the string at the current position of the iterator

Definition at line 88 of file kotextiterator.h.

KoTextObject* KoTextIterator::currentTextObject  )  const [inline]
 

Returns:
the text object in which currentParag() is.

Definition at line 93 of file kotextiterator.h.

int KoTextIterator::currentStartIndex  )  const
 

Where in currentParag() does currentText() start?

Definition at line 282 of file kotextiterator.cc.

References currentTextAndIndex().

QPair< int, QString > KoTextIterator::currentTextAndIndex  )  const
 

Returns:
the string at the current position of the iterator, as well as the index in the current paragraph. Use this instead of separate calls to currentText and currentStartIndex, for performance reasons.

Definition at line 292 of file kotextiterator.cc.

Referenced by currentStartIndex(), currentText(), and KoFindReplace::findNext().

void KoTextIterator::currentParagraphModified int  modifyType,
int  pos,
int  length
[signal]
 

Emitted when the current paragraph has been modified by the user.

Apps will often want to call setData again


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 13:19:31 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2003