com.trolltech.qt.gui
Class QTextFragment

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.gui.QTextFragment
All Implemented Interfaces:
QtJambiInterface, java.lang.Cloneable, java.lang.Comparable

public class QTextFragment
extends QtJambiObject
implements java.lang.Comparable, java.lang.Cloneable

The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat. A text fragment describes a piece of text that is stored with a single character format. Text in which the character format changes can be represented by sequences of text fragments with different formats.

If the user edits the text in a fragment and introduces a different character format, the fragment's text will be split at each point where the format changes, and new fragments will be created. For example, changing the style of some text in the middle of a sentence will cause the fragment to be broken into three separate fragments: the first and third with the same format as before, and the second with the new style. The first fragment will contain the text from the beginning of the sentence, the second will contain the text from the middle, and the third takes the text from the end of the sentence.


A fragment's text and character format can be obtained with the text() and charFormat() functions. The length() function gives the length of the text in the fragment. position() gives the position in the document of the start of the fragment. To determine whether the fragment contains a particular position within the document, use the contains() function.

See also:
QTextDocument, and Rich Text Document Structure.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QTextFragment()
          Creates a new empty text fragment.
QTextFragment(QTextFragment o)
          Copies the content (text and format) of the other text fragment to this text fragment.
 
Method Summary
 QTextCharFormat charFormat()
          Returns the text fragment's character format.
 int charFormatIndex()
          Returns an index into the document's internal list of character formats for the text fragment's character format.
 QTextFragment clone()
          This method is reimplemented for internal reasons
 boolean contains(int position)
          Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.
 boolean isValid()
          Returns true if this is a valid text fragment (i.e.
 int length()
          Returns the number of characters in the text fragment.
 int position()
          Returns the position of this text fragment in the document.
 java.lang.String text()
          Returns the text fragment's as plain text.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTextFragment

public QTextFragment()
Creates a new empty text fragment.


QTextFragment

public QTextFragment(QTextFragment o)
Copies the content (text and format) of the other text fragment to this text fragment.

Method Detail

charFormat

public final QTextCharFormat charFormat()
Returns the text fragment's character format.

See also:
text().


charFormatIndex

public final int charFormatIndex()
Returns an index into the document's internal list of character formats for the text fragment's character format.

See also:
QTextDocument::allFormats().


contains

public final boolean contains(int position)
Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.


isValid

public final boolean isValid()
Returns true if this is a valid text fragment (i.e. has a valid position in a document); otherwise returns false.


length

public final int length()
Returns the number of characters in the text fragment.

See also:
text().


position

public final int position()
Returns the position of this text fragment in the document.


text

public final java.lang.String text()
Returns the text fragment's as plain text.

See also:
length(), and charFormat().


clone

public QTextFragment clone()
This method is reimplemented for internal reasons

Overrides:
clone in class java.lang.Object