|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.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 whole selection. All functions operate on both layers; for example, selectedItems() will return items from both layers.
QAbstractItemModel
, and Chart Example.
Nested Class Summary | |
---|---|
static class |
QItemSelectionModel.SelectionFlag
This enum describes the way the selection model will be updated. |
static class |
QItemSelectionModel.SelectionFlags
|
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal2 |
currentChanged
This signal takes 2 generic argument(s). |
QSignalEmitter.Signal2 |
currentColumnChanged
This signal takes 2 generic argument(s). |
QSignalEmitter.Signal2 |
currentRowChanged
This signal takes 2 generic argument(s). |
QSignalEmitter.Signal2 |
selectionChanged
This signal takes 2 generic argument(s). |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
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,
com.trolltech.qt.core.QModelIndex parent)
Returns true if there are any items selected in the column with the given parent. |
com.trolltech.qt.core.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. |
boolean |
hasSelection()
Returns true if the selection model contains any selection ranges; otherwise returns false. |
boolean |
isColumnSelected(int column,
com.trolltech.qt.core.QModelIndex parent)
Returns true if all items are selected in the column with the given parent. |
boolean |
isRowSelected(int row,
com.trolltech.qt.core.QModelIndex parent)
Returns true if all items are selected in the row with the given parent. |
boolean |
isSelected(com.trolltech.qt.core.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,
com.trolltech.qt.core.QModelIndex parent)
Returns true if there are any items selected in the row with the given parent. |
void |
select(QItemSelection selection,
QItemSelectionModel.SelectionFlag[] command)
This is an overloaded method provided for convenience. |
void |
select(QItemSelection selection,
QItemSelectionModel.SelectionFlags command)
Selects the item selection using the specified command, and emits selectionChanged() . |
void |
select(com.trolltech.qt.core.QModelIndex index,
QItemSelectionModel.SelectionFlag[] command)
This is an overloaded method provided for convenience. |
void |
select(com.trolltech.qt.core.QModelIndex index,
QItemSelectionModel.SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged() . |
java.util.List |
selectedColumns()
Returns the indexes in row 0 for columns where all rows are selected. |
java.util.List |
selectedColumns(int row)
Returns the indexes in the given row for columns where all rows are selected. |
java.util.List |
selectedIndexes()
Returns a list of all selected model item indexes. |
java.util.List |
selectedRows()
Returns the indexes in column 0 for the rows where all columns are selected. |
java.util.List |
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(com.trolltech.qt.core.QModelIndex index,
QItemSelectionModel.SelectionFlag[] command)
This is an overloaded method provided for convenience. |
void |
setCurrentIndex(com.trolltech.qt.core.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 |
---|
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 com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
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 |
Field Detail |
---|
public final QSignalEmitter.Signal2 currentChanged
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QModelIndex(named: current), com.trolltech.qt.core.QModelIndex(named: previous)>:
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.
currentIndex()
, setCurrentIndex()
, and selectionChanged()
.
public final QSignalEmitter.Signal2 currentColumnChanged
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QModelIndex(named: current), com.trolltech.qt.core.QModelIndex(named: previous)>:
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.
currentChanged()
, currentRowChanged()
, currentIndex()
, and setCurrentIndex()
.
public final QSignalEmitter.Signal2 currentRowChanged
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QModelIndex(named: current), com.trolltech.qt.core.QModelIndex(named: previous)>:
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.
currentChanged()
, currentColumnChanged()
, currentIndex()
, and setCurrentIndex()
.
public final QSignalEmitter.Signal2 selectionChanged
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QItemSelection(named: selected), com.trolltech.qt.gui.QItemSelection(named: deselected)>:
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.
select()
, and currentChanged()
.
Constructor Detail |
---|
public QItemSelectionModel(QAbstractItemModel model)
public QItemSelectionModel(QAbstractItemModel model, QObject parent)
Method Detail |
---|
public final void clearSelection()
selectionChanged()
.
public final boolean columnIntersectsSelection(int column, com.trolltech.qt.core.QModelIndex parent)
public final com.trolltech.qt.core.QModelIndex currentIndex()
setCurrentIndex()
.
protected final void emitSelectionChanged(QItemSelection newSelection, QItemSelection oldSelection)
selectionChanged()
with the deselected and selected items.
public final boolean hasSelection()
public final boolean isColumnSelected(int column, com.trolltech.qt.core.QModelIndex 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, com.trolltech.qt.core.QModelIndex 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(com.trolltech.qt.core.QModelIndex index)
public final QAbstractItemModel model()
public final boolean rowIntersectsSelection(int row, com.trolltech.qt.core.QModelIndex parent)
public final java.util.List selectedColumns()
public final java.util.List selectedColumns(int row)
selectedIndexes()
, and selectedRows()
.
public final java.util.List selectedIndexes()
public final java.util.List selectedRows()
public final java.util.List selectedRows(int column)
selectedIndexes()
, and selectedColumns()
.
public final QItemSelection selection()
public final void setCurrentIndex(com.trolltech.qt.core.QModelIndex index, QItemSelectionModel.SelectionFlag[] command)
public final void setCurrentIndex(com.trolltech.qt.core.QModelIndex index, QItemSelectionModel.SelectionFlags command)
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.
currentIndex()
, and select()
.
public void clear()
selectionChanged()
and currentChanged()
.
public void reset()
public final void select(QItemSelection selection, QItemSelectionModel.SelectionFlag[] command)
public void select(QItemSelection selection, QItemSelectionModel.SelectionFlags command)
selectionChanged()
. QItemSelectionModel::SelectionFlag
.
public final void select(com.trolltech.qt.core.QModelIndex index, QItemSelectionModel.SelectionFlag[] command)
public void select(com.trolltech.qt.core.QModelIndex index, QItemSelectionModel.SelectionFlags command)
selectionChanged()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |