Qt Jambi Home

com.trolltech.qt.gui
Class QTextDocumentFragment

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.gui.QTextDocumentFragment
All Implemented Interfaces:
QtJambiInterface

public class QTextDocumentFragment
extends QtJambiObject

The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.

A QTextDocumentFragment is a fragment of rich text, that can be inserted into a QTextDocument. A document fragment can be created from a QTextDocument, from a QTextCursor's selection, or from another document fragment. Document fragments can also be created by the static functions, fromPlainText and fromHtml.

The contents of a document fragment can be obtained as plain text by using the toPlainText function, or it can be obtained as HTML with toHtml.


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
QTextDocumentFragment()
          Constructs an empty QTextDocumentFragment.
QTextDocumentFragment(QTextCursor range)
          Creates a QTextDocumentFragment from the range's selection.
QTextDocumentFragment(QTextDocument document)
          Converts the given document into a QTextDocumentFragment.
QTextDocumentFragment(QTextDocumentFragment rhs)
          Copy constructor.
 
Method Summary
static QTextDocumentFragment fromHtml(java.lang.String html)
          Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given html.
static QTextDocumentFragment fromHtml(java.lang.String html, QTextDocument resourceProvider)
          Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given html.
static QTextDocumentFragment fromNativePointer(QNativePointer nativePointer)
          This function returns the QTextDocumentFragment instance pointed to by nativePointer
static QTextDocumentFragment fromPlainText(java.lang.String plainText)
          Returns a document fragment that contains the given plainText.
 boolean isEmpty()
          Returns true if the fragment is empty; otherwise returns false.
static QNativePointer nativePointerArray(QTextDocumentFragment[] array)
          This function returns a QNativePointer that is pointing to the specified QTextDocumentFragment array.
 java.lang.String toHtml()
          Returns the contents of the document fragment as HTML, using the specified encoding (e.g., "UTF-8", "ISO 8859-1").
 java.lang.String toHtml(QByteArray encoding)
          Returns the contents of the document fragment as HTML, using the specified encoding (e.g., "UTF-8", "ISO 8859-1").
 java.lang.String toPlainText()
          Returns the document fragment's text as plain text (i.e. with no formatting information).
 
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, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTextDocumentFragment

public QTextDocumentFragment(QTextCursor range)

Creates a QTextDocumentFragment from the range's selection. If the cursor doesn't have a selection, the created fragment is empty.

See Also:
isEmpty, QTextCursor::selection

QTextDocumentFragment

public QTextDocumentFragment()

Constructs an empty QTextDocumentFragment.

See Also:
isEmpty

QTextDocumentFragment

public QTextDocumentFragment(QTextDocumentFragment rhs)

Copy constructor. Creates a copy of the rhs fragment.


QTextDocumentFragment

public QTextDocumentFragment(QTextDocument document)

Converts the given document into a QTextDocumentFragment. Note that the QTextDocumentFragment only stores the document contents, not meta information like the document's title.

Method Detail

isEmpty

public final boolean isEmpty()

Returns true if the fragment is empty; otherwise returns false.


toHtml

public final java.lang.String toHtml(QByteArray encoding)

Returns the contents of the document fragment as HTML, using the specified encoding (e.g., "UTF-8", "ISO 8859-1").

See Also:
toPlainText, QTextDocument::toHtml, QTextCodec

toHtml

public final java.lang.String toHtml()
Returns the contents of the document fragment as HTML, using the specified encoding (e.g., "UTF-8", "ISO 8859-1").


toPlainText

public final java.lang.String toPlainText()

Returns the document fragment's text as plain text (i.e. with no formatting information).

See Also:
toHtml

fromHtml

public static QTextDocumentFragment fromHtml(java.lang.String html)

Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given html. The formatting is preserved as much as possible; for example, "<b>bold</b>" will become a document fragment with the text "bold" with a bold character format.


fromHtml

public static QTextDocumentFragment fromHtml(java.lang.String html,
                                             QTextDocument resourceProvider)

Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given html. The formatting is preserved as much as possible; for example, "<b>bold</b>" will become a document fragment with the text "bold" with a bold character format.

If the provided HTML contains references to external resources such as imported style sheets, then they will be loaded through the resourceProvider.


fromPlainText

public static QTextDocumentFragment fromPlainText(java.lang.String plainText)

Returns a document fragment that contains the given plainText.

When inserting such a fragment into a QTextDocument the current char format of the QTextCursor used for insertion is used as format for the text.


fromNativePointer

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

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

nativePointerArray

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

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

Qt Jambi Home