CopperSpice API
1.9.1
|
The QItemSelection class manages information about selected items in a model. More...
Static Public Methods | |
static void | split (const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result) |
Static Public Methods inherited from QList< QItemSelectionRange > | |
static QList< QItemSelectionRange > | fromSet (const QSet< QItemSelectionRange > &set) |
static QList< QItemSelectionRange > | fromStdList (const std::list< QItemSelectionRange > &other) |
static QList< QItemSelectionRange > | fromVector (const QVector< QItemSelectionRange > &vector) |
The QItemSelection class manages information about selected items in a model. A QItemSelection describes the items in a model that have been selected by the user. It is basically a list of selection ranges, which is similar to QItemSelectionRange. It provides functions for creating and manipulating selections, and selecting a range of items from a model.
An item selection can be constructed and initialized to contain a range of items from an existing model. The following example constructs a selection that contains a range of items from the given model
, beginning at the topLeft
, and ending at the bottomRight
.
An empty item selection can be constructed, and later populated as required. So, if the model is going to be unavailable when we construct the item selection, we can rewrite the above code in the following way:
QItemSelection saves memory, and avoids unnecessary work, by working with selection ranges rather than recording the model item index for each item in the selection. Generally, an instance of this class will contain a list of non-overlapping selection ranges.
Use merge() to merge one item selection into another without making overlapping ranges. Use split() to split one selection range into smaller ranges based on another selection range.
|
inline |
Constructs an empty selection.
QItemSelection::QItemSelection | ( | const QModelIndex & | topLeft, |
const QModelIndex & | bottomRight | ||
) |
Constructs an item selection that extends from the top-left model item, specified by the topLeft index, to the bottom-right item, specified by bottomRight.
bool QItemSelection::contains | ( | const QModelIndex & | index | ) | const |
Returns true if the selection contains the given index, otherwise returns false.
QModelIndexList QItemSelection::indexes | ( | ) | const |
Returns a list of model indexes that correspond to the selected items.
void QItemSelection::merge | ( | const QItemSelection & | other, |
QItemSelectionModel::SelectionFlags | command | ||
) |
Merges the other selection with this QItemSelection using the command given. This method guarantees that no ranges are overlapping.
Only QItemSelectionModel::Select, QItemSelectionModel::Deselect, and QItemSelectionModel::Toggle are supported.
void QItemSelection::select | ( | const QModelIndex & | topLeft, |
const QModelIndex & | bottomRight | ||
) |
Adds the items in the range that extends from the top-left model item, specified by the topLeft index, to the bottom-right item, specified by bottomRight to the list. Both topLeft and bottomRight must have the same parent.
|
static |
Splits the selection range using the selection other range. Removes all items in other from range and puts the result in result. This can be compared with the semantics of the subtract operation of a set.