Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QTreeModel

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.core.QObject
                  com.trolltech.qt.core.QAbstractItemModel
                      com.trolltech.qt.gui.QTreeModel

All Implemented Interfaces:
  QtJambiInterface

    public abstract class QTreeModel

extends QAbstractItemModel

The `QTreeModel` class provides a convenience base class for hierarchical item models in the Qt Itemview Framework. `QTreeModel` extends the more generic `QAbstractItemModel` class with an API that is both simpler and more suitable for Java. The API differs from the rest of the Qt Itemviews API in that it is primarily using node objects directly rather than QModelIndex objects. Note, for example, that the related selection and filter models use QModelIndex objects. `QTreeModel` provides the `indexToValue()` function to translate the model indexes into node objects. `QTreeModel` also encapsulates and hides the `parent()` concept of `QAbstractItemModel`.

When deriving from the `QTreeModel` class, make sure that the pure virtual `childCount()`, `child()` and `text()` functions are implemented.

Using the standard `QTreeView` class to view the content's of the model, the text is rendered using `QTreeView`'s fonts. This behavior can be altered by reimplementing `QTreeModel`'s `data()` function, providing access to all the various item roles (i.e., background color, font, size hint, etc.). Reimplement the `icon()` function to get graphical nodes. It is also possible to implement a custom `QItemDelegate` class for the view and reimplement the `QItemDelegate`.`paint()` function.

Internally, the `QTreeModel` class caches the datastructures of nodes that have been expanded. Call the `releaseChildren()` function to release parts of this memory pool when they are no longer needed, for example when the view collapses a subtree:

    view.collapsed.connect(model, "releaseChildren(QModelIndex)");

Note that if the model is shared between multiple views, calling the model's `releaseChildren()` function affects all.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Field Summary

Fields inherited from class com.trolltech.qt.core.QAbstractItemModel
`dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged`

Method Summary
`abstract java.lang.Object` | `child(java.lang.Object parent, int index)` Returns the child specified by `index`, of the given `node`.
`abstract int` | `childCount(java.lang.Object parent)` Returns the given `node`'s number of children, or 0 if the `node` is a leaf node.
`void` | `childrenInserted(QModelIndex parent, int first, int last)` Inserts `last` - `first` + 1 nodes into the given `parent`, before the node specified by `first`.
`void` | `childrenRemoved(QModelIndex parent, int first, int last)` Removes the nodes from `first` to `last` from the given `parent`, including the node specified by `last`.
`java.lang.Object` | `data(java.lang.Object value, int role)` Using the standard `QTreeView` class to view the content's of the model, the text is rendered using `QTreeView`'s fonts.
`static QTreeModel` | `fromNativePointer(QNativePointer nativePointer)` This method returns the QTreeModel instance pointed to by `nativePointer`.
`QIcon` | `icon(java.lang.Object value)` Reimplement this function to get graphical nodes.
`java.lang.Object` | `indexToValue(QModelIndex index)` Translates the given index to a value node and returns the node.
`void` | `releaseChildren(QModelIndex index)` Releases datastructures that are no longer needed, from the memory pool.
`abstract java.lang.String` | `text(java.lang.Object value)` Returns a string representation of the given `value`.
`QModelIndex` | `valueToIndex(java.lang.Object object)` Returns the model index for `object`.

Methods inherited from class com.trolltech.qt.core.QAbstractItemModel
`beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, buddy, canFetchMore, changePersistentIndex, changePersistentIndexList, columnCount, columnCount, createIndex, createIndex, createIndex, data, data, data, data, dropMimeData, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, fetchMore, flags, hasChildren, hasChildren, hasIndex, hasIndex, headerData, headerData, index, index, insertColumn, insertColumn, insertColumns, insertColumns, insertRow, insertRow, insertRows, insertRows, itemData, match, match, match, match, mimeData, mimeTypes, parent, persistentIndexList, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, removeRows, reset, revert, rowCount, rowCount, setData, setData, setData, setData, setHeaderData, setHeaderData, setItemData, setSupportedDragActions, setSupportedDragActions, sibling, sort, sort, span, submit, supportedDragActions, supportedDropActions`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

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 java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Method Detail

### childrenInserted

    public final void childrenInserted(QModelIndex parent,
                                       int first,
                                       int last)

  Inserts `last` - `first` + 1 nodes into the given `parent`, before the node specified by `first`. Note that this function must be called when nodes have been inserted into the model.

See also:
  `beginInsertRows()`.

### childrenRemoved

    public final void childrenRemoved(QModelIndex parent,
                                      int first,
                                      int last)

  Removes the nodes from `first` to `last` from the given `parent`, including the node specified by `last`. Note that this function must be called when nodes have been removed from the model.

See also:
  `beginDeleteRows()`.

### indexToValue

    public final java.lang.Object indexToValue(QModelIndex index)

  Translates the given index to a value node and returns the node.

### releaseChildren

    public final void releaseChildren(QModelIndex index)

  Releases datastructures that are no longer needed, from the memory pool.

  Internally, the `QTreeModel` class caches the datastructures of nodes that have been expanded. Call the `releaseChildren()` function to release parts of this memory pool when they are no longer needed, for example when the view collapses a subtree.

  Note that if the model is shared between multiple views, calling the model's `releaseChildren()` function affects all.

### valueToIndex

    public final QModelIndex valueToIndex(java.lang.Object object)

  Returns the model index for `object`.

### child

    public abstract java.lang.Object child(java.lang.Object parent,
                                           int index)

  Returns the child specified by `index`, of the given `node`.

### childCount

    public abstract int childCount(java.lang.Object parent)

  Returns the given `node`'s number of children, or 0 if the `node` is a leaf node.

### data

    public java.lang.Object data(java.lang.Object value,
                                 int role)

  Using the standard `QTreeView` class to view the content's of the model, the text is rendered using `QTreeView`'s fonts. Reimplement this function to alter the view's rendering behavior.

  The default implementation is calling `text()` and `icon()` function for the given `value` and `role`.

### icon

    public QIcon icon(java.lang.Object value)

  Reimplement this function to get graphical nodes. The default implementation returns an empty icon.

### text

    public abstract java.lang.String text(java.lang.Object value)

  Returns a string representation of the given `value`.

### fromNativePointer

    public static QTreeModel fromNativePointer(QNativePointer nativePointer)

  This method returns the QTreeModel instance pointed to by `nativePointer`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD