|
|
||||||||||
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.gui.QItemSelectionModel
public class QItemSelectionModel
The QItemSelectionModel class keeps track of a view's selected items.
A QItemSelectionModel keeps track of the selected items in a view, or in several views onto the same model. It also keeps track of the currently selected item in a view.
The QItemSelectionModel class is one of the Model/View Classes and is part of Qt's model/view framework.
The selected items are stored using ranges. Whenever you want to modify the selected items use select and provide either a QItemSelection, or a QModelIndex and a QItemSelectionModel::SelectionFlag.
The QItemSelectionModel takes a two layer approach to selection management, dealing with both selected items that have been committed and items that are part of the current selection. The current selected items are part of the current interactive selection (for example with rubber-band selection or keyboard-shift selections).
To update the currently selected items, use the bitwise OR of QItemSelectionModel::Current and any of the other SelectionFlags. If you omit the QItemSelectionModel::Current command, a new current selection will be created, and the previous one added to the committed selection. All functions operate on both layers; for example, selectedItems() will return items from both layers.
Example
Nested Class Summary | |
---|---|
static class |
QItemSelectionModel.SelectionFlag
This enum describes the way the selection model will be updated. |
static class |
QItemSelectionModel.SelectionFlags
This QFlag class provides flags for the int enum. |
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 | |
---|---|
QSignalEmitter.Signal2<QModelIndex,QModelIndex> |
currentChanged
This signal is emitted whenever the current item changes. |
QSignalEmitter.Signal2<QModelIndex,QModelIndex> |
currentColumnChanged
This signal is emitted if the current item changes and its column is different to the column of the previous current item. |
QSignalEmitter.Signal2<QModelIndex,QModelIndex> |
currentRowChanged
This signal is emitted if the current item changes and its row is different to the row of the previous current item. |
QSignalEmitter.Signal2<QItemSelection,QItemSelection> |
selectionChanged
This signal is emitted whenever the selection changes. |
Constructor Summary | |
---|---|
QItemSelectionModel(QAbstractItemModel model)
Constructs a selection model that operates on the specified item model. |
|
QItemSelectionModel(QAbstractItemModel model,
QObject parent)
Constructs a selection model that operates on the specified item model with parent. |
Method Summary | |
---|---|
void |
clear()
Clears the selection model. |
void |
clearSelection()
Clears the selection in the selection model. |
boolean |
columnIntersectsSelection(int column,
QModelIndex parent)
Returns true if there are any items selected in the column with the given parent. |
QModelIndex |
currentIndex()
Returns the model item index for the current item, or an invalid index if there is no current item. |
protected void |
emitSelectionChanged(QItemSelection newSelection,
QItemSelection oldSelection)
Compares the two selections newSelection and oldSelection and emits selectionChanged with the deselected and selected items. |
static QItemSelectionModel |
fromNativePointer(QNativePointer nativePointer)
This function returns the QItemSelectionModel instance pointed to by nativePointer |
boolean |
hasSelection()
Returns true if the selection model contains any selection ranges; otherwise returns false. |
boolean |
isColumnSelected(int column,
QModelIndex parent)
Returns true if all items are selected in the column with the given parent. |
boolean |
isRowSelected(int row,
QModelIndex parent)
Returns true if all items are selected in the row with the given parent. |
boolean |
isSelected(QModelIndex index)
Returns true if the given model item index is selected. |
QAbstractItemModel |
model()
Returns the item model operated on by the selection model. |
void |
reset()
Clears the selection model. |
boolean |
rowIntersectsSelection(int row,
QModelIndex parent)
Returns true if there are any items selected in the row with the given parent. |
void |
select(QItemSelection selection,
QItemSelectionModel.SelectionFlag... command)
Selects the item selection using the specified command, and emits selectionChanged(). |
void |
select(QItemSelection selection,
QItemSelectionModel.SelectionFlags command)
Selects the item selection using the specified command, and emits selectionChanged. |
void |
select(QModelIndex index,
QItemSelectionModel.SelectionFlag... command)
Selects the model item index using the specified command, and emits selectionChanged(). |
void |
select(QModelIndex index,
QItemSelectionModel.SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged. |
java.util.List<QModelIndex> |
selectedColumns()
Returns the indexes in row 0 for columns where all rows are selected. |
java.util.List<QModelIndex> |
selectedColumns(int row)
Returns the indexes in the given row for columns where all rows are selected. |
java.util.List<QModelIndex> |
selectedIndexes()
Returns a list of all selected model item indexes. |
java.util.List<QModelIndex> |
selectedRows()
Returns the indexes in column 0 for the rows where all columns are selected. |
java.util.List<QModelIndex> |
selectedRows(int column)
Returns the indexes in the given column for the rows where all columns are selected. |
QItemSelection |
selection()
Returns the selection ranges stored in the selection model. |
void |
setCurrentIndex(QModelIndex index,
QItemSelectionModel.SelectionFlag... command)
Sets the model item index to be the current item, and emits currentChanged. |
void |
setCurrentIndex(QModelIndex index,
QItemSelectionModel.SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged. |
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 |
Field Detail |
---|
public final QSignalEmitter.Signal2<QModelIndex,QModelIndex> currentChanged
This signal is emitted whenever the current item changes. The previous model item index is replaced by the current index as the selection's current item.
Note that this signal will not be emitted when the item model is reset.
public final QSignalEmitter.Signal2<QModelIndex,QModelIndex> currentColumnChanged
This signal is emitted if the current item changes and its column is different to the column of the previous current item.
Note that this signal will not be emitted when the item model is reset.
public final QSignalEmitter.Signal2<QModelIndex,QModelIndex> currentRowChanged
This signal is emitted if the current item changes and its row is different to the row of the previous current item.
Note that this signal will not be emitted when the item model is reset.
public final QSignalEmitter.Signal2<QItemSelection,QItemSelection> selectionChanged
This signal is emitted whenever the selection changes. The change in the selection is represented as an item selection of deselected items and an item selection of selected items.
Note the that the current index changes independently from the selection. Also note that this signal will not be emitted when the item model is reset.
Constructor Detail |
---|
public QItemSelectionModel(QAbstractItemModel model)
Constructs a selection model that operates on the specified item model.
public QItemSelectionModel(QAbstractItemModel model, QObject parent)
Constructs a selection model that operates on the specified item model with parent.
Method Detail |
---|
public final void clearSelection()
Clears the selection in the selection model. Emits selectionChanged.
public final boolean columnIntersectsSelection(int column, QModelIndex parent)
Returns true if there are any items selected in the column with the given parent.
public final QModelIndex currentIndex()
Returns the model item index for the current item, or an invalid index if there is no current item.
protected final void emitSelectionChanged(QItemSelection newSelection, QItemSelection oldSelection)
Compares the two selections newSelection and oldSelection and emits selectionChanged with the deselected and selected items.
public final boolean hasSelection()
Returns true if the selection model contains any selection ranges; otherwise returns false.
public final boolean isColumnSelected(int column, QModelIndex parent)
Returns true if all items are selected in the column with the given parent.
Note that this function is usually faster than calling isSelected on all items in the same column and that unselectable items are ignored.
public final boolean isRowSelected(int row, QModelIndex parent)
Returns true if all items are selected in the row with the given parent.
Note that this function is usually faster than calling isSelected on all items in the same row and that unselectable items are ignored.
public final boolean isSelected(QModelIndex index)
Returns true if the given model item index is selected.
public final QAbstractItemModel model()
Returns the item model operated on by the selection model.
public final boolean rowIntersectsSelection(int row, QModelIndex parent)
Returns true if there are any items selected in the row with the given parent.
public final java.util.List<QModelIndex> selectedColumns()
public final java.util.List<QModelIndex> selectedColumns(int row)
Returns the indexes in the given row for columns where all rows are selected.
public final java.util.List<QModelIndex> selectedIndexes()
Returns a list of all selected model item indexes. The list contains no duplicates, and is not sorted.
public final java.util.List<QModelIndex> selectedRows()
public final java.util.List<QModelIndex> selectedRows(int column)
Returns the indexes in the given column for the rows where all columns are selected.
public final QItemSelection selection()
Returns the selection ranges stored in the selection model.
public final void setCurrentIndex(QModelIndex index, QItemSelectionModel.SelectionFlag... command)
Sets the model item index to be the current item, and emits currentChanged. The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.
Depending on the specified command, the index can also become part of the current selection.
public final void setCurrentIndex(QModelIndex index, QItemSelectionModel.SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged. The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.
Depending on the specified command, the index can also become part of the current selection.
public void clear()
Clears the selection model. Emits selectionChanged and currentChanged.
public void reset()
Clears the selection model. Does not emit any signals.
public final void select(QItemSelection selection, QItemSelectionModel.SelectionFlag... command)
public void select(QItemSelection selection, QItemSelectionModel.SelectionFlags command)
Selects the item selection using the specified command, and emits selectionChanged.
public final void select(QModelIndex index, QItemSelectionModel.SelectionFlag... command)
public void select(QModelIndex index, QItemSelectionModel.SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged.
public static QItemSelectionModel 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 |