Qt Jambi Home

com.trolltech.qt.gui
Class QProxyModel

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.core.QAbstractItemModel
                  extended by com.trolltech.qt.gui.QProxyModel
All Implemented Interfaces:
QtJambiInterface

public class QProxyModel
extends QAbstractItemModel

This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

The QProxyModel class provides support for processing data passed between another model and a view.

If you want to do filtering and sorting, see QSortFilterProxyModel.

Proxy models provide a standard model interface that can be used to manipulate the data retrieved through an underlying model. They can be used to perform operations such as sorting and filtering on the data obtained without changing the contents of the model.

Just as with subclasses of QAbstractItemView, QProxyModel provides the setModel function that is used to specify the model to be acted on by the proxy. Views can be connected to either the underlying model or the proxy model with QAbstractItemView::setModel.

Since views rely on the information provided in model indexes to identify items of data from models, and to position these items in some visual representation, proxy models must create their own model indexes instead of supplying model indexes from their underlying models.

See Also:
Model/View Programming, QAbstractItemModel

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, 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
QProxyModel()
          Equivalent to QProxyModel(0).
QProxyModel(QObject parent)
          Constructs a proxy model with the given parent.
 
Method Summary
 int columnCount(QModelIndex parent)
          Returns the number of columns for the given parent.
protected  void connectToModel(QAbstractItemModel model)
          
 java.lang.Object data(QModelIndex index, int role)
          Returns the data stored in the item with the given index under the specified role.
protected  void disconnectFromModel(QAbstractItemModel model)
          
 boolean dropMimeData(QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent)
          Returns true if the model accepts the data dropped onto an attached view for the specified action; otherwise returns false.
 void fetchMore(QModelIndex parent)
          Fetches more child items of the given parent.
 Qt.ItemFlags flags(QModelIndex index)
          Returns the item flags for the given index.
static QProxyModel fromNativePointer(QNativePointer nativePointer)
          This function returns the QProxyModel instance pointed to by nativePointer
 boolean hasChildren(QModelIndex parent)
          Returns true if the item corresponding to the parent index has child items; otherwise returns false.
 java.lang.Object headerData(int section, Qt.Orientation orientation, int role)
          Returns the data stored in the section of the header with specified orientation under the given role.
 QModelIndex index(int row, int column, QModelIndex parent)
          Returns the model index with the given row, column, and parent.
 boolean insertColumns(int column, int count, QModelIndex parent)
          Inserts count columns into the model, creating new items as children of the given parent.
 boolean insertRows(int row, int count, QModelIndex parent)
          Inserts count rows into the model, creating new items as children of the given parent.
 java.util.List<QModelIndex> match(QModelIndex start, int role, java.lang.Object value, int hits, Qt.MatchFlags flags)
          Returns a list of model indexes that each contain the given value for the role specified.
 QMimeData mimeData(java.util.List<QModelIndex> indexes)
          Returns MIME data for the specified indexes in the model.
 java.util.List<java.lang.String> mimeTypes()
          Returns a list of MIME types that are supported by the model.
 QAbstractItemModel model()
          Returns the model that contains the data that is available through the proxy model.
 QModelIndex parent(QModelIndex child)
          Returns the model index that corresponds to the parent of the given child index.
 void revert()
          Called to let the model know that it should discard whatever it has cached.
 int rowCount(QModelIndex parent)
          Returns the number of rows for the given parent.
 boolean setData(QModelIndex index, java.lang.Object value, int role)
          Sets the role data for the item at index to value.
 boolean setHeaderData(int section, Qt.Orientation orientation, java.lang.Object value, int role)
          Sets the role data in the section of the header with the specified orientation to the value given.
 void setModel(QAbstractItemModel model)
          Sets the given model to be processed by the proxy model.
protected  QModelIndex setProxyModel(QModelIndex source_index)
          
protected  QModelIndex setSourceModel(QModelIndex proxy_index)
          
 void sort(int column, Qt.SortOrder order)
          Sorts the child items in the specified column according to the sort order defined by order.
 QSize span(QModelIndex index)
          Returns the size of the item that corresponds to the specified index.
 boolean submit()
          Called to let the model know that it should submit whatever it has cached to the permanent storage.
 Qt.DropActions supportedDropActions()
          Returns the drop actions that are supported by the model; this is a combination of the individual actions defined in Qt::DropActions.
 
Methods inherited from class com.trolltech.qt.core.QAbstractItemModel
beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, buddy, canFetchMore, changePersistentIndex, changePersistentIndexList, columnCount, createIndex, createIndex, createIndex, data, data, data, decodeData, encodeData, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, hasChildren, hasIndex, hasIndex, headerData, index, insertColumn, insertColumn, insertColumns, insertRow, insertRow, insertRows, itemData, match, match, match, persistentIndexList, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, removeRows, reset, rowCount, setData, setData, setData, setHeaderData, setItemData, setSupportedDragActions, setSupportedDragActions, sibling, sort, supportedDragActions
 
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

QProxyModel

public QProxyModel()

Equivalent to QProxyModel(0).


QProxyModel

public QProxyModel(QObject parent)

Constructs a proxy model with the given parent.

Method Detail

connectToModel

protected final void connectToModel(QAbstractItemModel model)


disconnectFromModel

protected final void disconnectFromModel(QAbstractItemModel model)


model

public final QAbstractItemModel model()

Returns the model that contains the data that is available through the proxy model.

See Also:
setModel

setProxyModel

protected final QModelIndex setProxyModel(QModelIndex source_index)


setSourceModel

protected final QModelIndex setSourceModel(QModelIndex proxy_index)


columnCount

public int columnCount(QModelIndex parent)

Returns the number of columns for the given parent.

Specified by:
columnCount in class QAbstractItemModel
See Also:
QAbstractItemModel::columnCount

data

public java.lang.Object data(QModelIndex index,
                             int role)

Returns the data stored in the item with the given index under the specified role.

Specified by:
data in class QAbstractItemModel
See Also:
setData

dropMimeData

public boolean dropMimeData(QMimeData data,
                            Qt.DropAction action,
                            int row,
                            int column,
                            QModelIndex parent)

Returns true if the model accepts the data dropped onto an attached view for the specified action; otherwise returns false.

The parent, row, and column details can be used to control which MIME types are acceptable to different parts of a model when received via the drag and drop system.

Overrides:
dropMimeData in class QAbstractItemModel
See Also:
supportedDropActions, Using Drag and Drop with Item Views

fetchMore

public void fetchMore(QModelIndex parent)

Fetches more child items of the given parent. This function is used by views to tell the model that they can display more data than the model has provided.

Overrides:
fetchMore in class QAbstractItemModel
See Also:
QAbstractItemModel::fetchMore

flags

public Qt.ItemFlags flags(QModelIndex index)

Returns the item flags for the given index.

Overrides:
flags in class QAbstractItemModel
See Also:
Qt::ItemFlags

hasChildren

public boolean hasChildren(QModelIndex parent)

Returns true if the item corresponding to the parent index has child items; otherwise returns false.

Overrides:
hasChildren in class QAbstractItemModel
See Also:
QAbstractItemModel::hasChildren

headerData

public java.lang.Object headerData(int section,
                                   Qt.Orientation orientation,
                                   int role)

Returns the data stored in the section of the header with specified orientation under the given role.

Overrides:
headerData in class QAbstractItemModel
See Also:
setHeaderData

index

public QModelIndex index(int row,
                         int column,
                         QModelIndex parent)

Returns the model index with the given row, column, and parent.

Specified by:
index in class QAbstractItemModel
See Also:
QAbstractItemModel::index

insertColumns

public boolean insertColumns(int column,
                             int count,
                             QModelIndex parent)

Inserts count columns into the model, creating new items as children of the given parent. The new columns are inserted before the column specified. If the parent item has no children, a single row is created to contain the required number of columns.

Returns true if the columns were successfully inserted; otherwise returns false.

Overrides:
insertColumns in class QAbstractItemModel
See Also:
QAbstractItemModel::insertColumns

insertRows

public boolean insertRows(int row,
                          int count,
                          QModelIndex parent)

Inserts count rows into the model, creating new items as children of the given parent. The new rows are inserted before the row specified. If the parent item has no children, a single column is created to contain the required number of rows.

Returns true if the rows were successfully inserted; otherwise returns false.

Overrides:
insertRows in class QAbstractItemModel
See Also:
QAbstractItemModel::insertRows

match

public java.util.List<QModelIndex> match(QModelIndex start,
                                         int role,
                                         java.lang.Object value,
                                         int hits,
                                         Qt.MatchFlags flags)

Returns a list of model indexes that each contain the given value for the role specified. The search begins at the start index and is performed according to the specified flags. The search continues until the number of matching data items equals hits, the last row is reached, or the search reaches start again, depending on whether MatchWrap is specified in flags.

Overrides:
match in class QAbstractItemModel
See Also:
QAbstractItemModel::match

mimeData

public QMimeData mimeData(java.util.List<QModelIndex> indexes)

Returns MIME data for the specified indexes in the model.

Overrides:
mimeData in class QAbstractItemModel
See Also:
mimeTypes, dropMimeData

mimeTypes

public java.util.List<java.lang.String> mimeTypes()

Returns a list of MIME types that are supported by the model.

Overrides:
mimeTypes in class QAbstractItemModel
See Also:
mimeData

parent

public QModelIndex parent(QModelIndex child)

Returns the model index that corresponds to the parent of the given child index.

Specified by:
parent in class QAbstractItemModel
See Also:
createIndex

revert

public void revert()

Called to let the model know that it should discard whatever it has cached. Typically used for row editing.

Overrides:
revert in class QAbstractItemModel

rowCount

public int rowCount(QModelIndex parent)

Returns the number of rows for the given parent.

Specified by:
rowCount in class QAbstractItemModel
See Also:
QAbstractItemModel::rowCount

setData

public boolean setData(QModelIndex index,
                       java.lang.Object value,
                       int role)

Sets the role data for the item at index to value. Returns true if successful; otherwise returns false.

The base class implementation returns false. This function and data must be reimplemented for editable models.

Overrides:
setData in class QAbstractItemModel
See Also:
data, itemData, QAbstractItemModel::setData

setHeaderData

public boolean setHeaderData(int section,
                             Qt.Orientation orientation,
                             java.lang.Object value,
                             int role)

Sets the role data in the section of the header with the specified orientation to the value given.

Overrides:
setHeaderData in class QAbstractItemModel
See Also:
headerData, QAbstractItemModel::setHeaderData

setModel

public void setModel(QAbstractItemModel model)

Sets the given model to be processed by the proxy model.

See Also:
model

sort

public void sort(int column,
                 Qt.SortOrder order)

Sorts the child items in the specified column according to the sort order defined by order.

Overrides:
sort in class QAbstractItemModel
See Also:
QAbstractItemModel::sort

span

public QSize span(QModelIndex index)

Returns the size of the item that corresponds to the specified index.

Overrides:
span in class QAbstractItemModel

submit

public boolean submit()

Called to let the model know that it should submit whatever it has cached to the permanent storage. Typically used for row editing.

Returns false on error, otherwise true.

Overrides:
submit in class QAbstractItemModel

supportedDropActions

public Qt.DropActions supportedDropActions()

Returns the drop actions that are supported by the model; this is a combination of the individual actions defined in Qt::DropActions.

The selection of drop actions provided by the model will influence the behavior of the component that started the drag and drop operation.

Overrides:
supportedDropActions in class QAbstractItemModel
See Also:
Drag and Drop

fromNativePointer

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

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

Qt Jambi Home