|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.core.QAbstractItemModel
com.trolltech.qt.gui.QTreeModel
public abstract class QTreeModel
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<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> |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.core.QAbstractItemModel |
---|
dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged |
Constructor Summary | |
---|---|
QTreeModel()
Equivalent to QTreeModel(0). |
|
QTreeModel(QObject parent)
Constructs a new QTreeModel. |
Method Summary | |
---|---|
abstract java.lang.Object |
child(java.lang.Object parent,
int index)
Returns the child specified by index, of the given parent. |
abstract int |
childCount(java.lang.Object parent)
Returns the given parent's number of children, or 0 if the parent 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. |
int |
columnCount(QModelIndex arg__1)
Returns the number of columns for the children of the given parent. |
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. |
java.lang.Object |
data(QModelIndex index,
int role)
Returns the data stored under the given role for the item referred to by the index. |
static QTreeModel |
fromNativePointer(QNativePointer nativePointer)
This function returns the QTreeModel instance pointed to by nativePointer |
QIcon |
icon(java.lang.Object value)
Reimplement this function to get graphical nodes. |
QModelIndex |
index(int row,
int arg__2,
QModelIndex parent)
Returns the index of the item in the model specified by the given row, column and parent index. |
java.lang.Object |
indexToValue(QModelIndex index)
Translates the given index to a value node and returns the node. |
QModelIndex |
parent(QModelIndex index)
Returns the parent of the model item with the given child, or QModelIndex() if it has no parent. |
void |
releaseChildren(QModelIndex index)
Releases datastructures that are no longer needed, from the memory pool. |
int |
rowCount(QModelIndex parent)
Returns the number of rows under the given parent. |
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.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
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 |
---|
public QTreeModel()
Equivalent to QTreeModel(0).
public QTreeModel(QObject parent)
Constructs a new QTreeModel.
Method Detail |
---|
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.
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.
public final java.lang.Object indexToValue(QModelIndex index)
Translates the given index to a value node and returns the node.
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.
public final QModelIndex valueToIndex(java.lang.Object object)
Returns the model index for object.
public abstract java.lang.Object child(java.lang.Object parent, int index)
Returns the child specified by index, of the given parent.
public abstract int childCount(java.lang.Object parent)
Returns the given parent's number of children, or 0 if the parent is a leaf node.
public int columnCount(QModelIndex arg__1)
Returns the number of columns for the children of the given parent. When the parent is valid it means that rowCount is returning the number of children of parent.
In most subclasses, the number of columns is independent of the parent. For example:
int DomModel::columnCount(const QModelIndex &/*parent*<!-- noop -->/) const
{
return 3;
}
Tip: When implementing a table based model, columnCount should return 0 when the parent is valid.
columnCount
in class QAbstractItemModel
public java.lang.Object data(QModelIndex index, int role)
Returns the data stored under the given role for the item referred to by the index.
data
in class QAbstractItemModel
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.
public QIcon icon(java.lang.Object value)
Reimplement this function to get graphical nodes. The default implementation returns an empty icon.
public QModelIndex index(int row, int arg__2, QModelIndex parent)
Returns the index of the item in the model specified by the given row, column and parent index.
When reimplementing this function in a subclass, call createIndex to generate model indexes that other components can use to refer to items in your model.
index
in class QAbstractItemModel
public QModelIndex parent(QModelIndex index)
Returns the parent of the model item with the given child, or QModelIndex() if it has no parent.
A common convention used in models that expose tree data structures is that only items in the first column have children. For that case, when reimplementing this function in a subclass the column of the returned QModelIndex would be 0.
parent
in class QAbstractItemModel
public int rowCount(QModelIndex parent)
Returns the number of rows under the given parent. When the parent is valid it means that rowCount is returning the number of children of parent.
Tip: When implementing a table based model, rowCount should return 0 when the parent is valid.
rowCount
in class QAbstractItemModel
public abstract java.lang.String text(java.lang.Object value)
Returns a string representation of the given value.
public static QTreeModel fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |