com.trolltech.qt.gui
Class QTextFragment

java.lang.Object
  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.Comparable

public class QTextFragment
extends QtJambiObject
implements java.lang.Comparable

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, Rich Text Document Structure

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QTextFragment()
          Creates a new empty text fragment.
QTextFragment(QTextFragment o)
          Copies the content (text and format) of the o 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.
 int compareTo(java.lang.Object other)
           
 boolean contains(int position)
          Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.
 boolean equals(java.lang.Object other)
          
static QTextFragment fromNativePointer(QNativePointer nativePointer)
          This function returns the QTextFragment instance pointed to by nativePointer
 boolean isValid()
          Returns true if this is a valid text fragment (i.e. has a valid position in a document); otherwise returns false.
 int length()
          Returns the number of characters in the text fragment.
static QNativePointer nativePointerArray(QTextFragment[] array)
          This function returns a QNativePointer that is pointing to the specified QTextFragment array.
 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, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTextFragment

public QTextFragment(QTextFragment o)

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


QTextFragment

public QTextFragment()

Creates a new empty 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::object

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, charFormat

fromNativePointer

public static QTextFragment fromNativePointer(QNativePointer nativePointer)
This function returns the QTextFragment instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QTextFragment[] array)
This function returns a QNativePointer that is pointing to the specified QTextFragment array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable