CopperSpice API
1.9.2
|
Keeps track of a view's selected items. More...
Public Typedefs | |
using | SelectionFlags = QFlags< SelectionFlag > |
Public Types | |
enum | SelectionFlag : uint |
Public Signals | |
void | currentChanged (const QModelIndex ¤t, const QModelIndex &previous) |
void | currentColumnChanged (const QModelIndex ¤t, const QModelIndex &previous) |
void | currentRowChanged (const QModelIndex ¤t, const QModelIndex &previous) |
void | modelChanged (QAbstractItemModel *model) |
void | selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
virtual void | clear () |
void | clearCurrentIndex () |
void | clearSelection () |
virtual void | reset () |
virtual void | select (const QItemSelection &selection, QItemSelectionModel::SelectionFlags command) |
virtual void | select (const QModelIndex &index, QItemSelectionModel::SelectionFlags command) |
void | setCurrentIndex (const QModelIndex &index, QItemSelectionModel::SelectionFlags command) |
Public Slots inherited from QObject | |
void | deleteLater () |
Public Methods | |
QItemSelectionModel (QAbstractItemModel *model, QObject *parent) | |
QItemSelectionModel (QAbstractItemModel *model=nullptr) | |
virtual | ~QItemSelectionModel () |
bool | columnIntersectsSelection (int column, const QModelIndex &parent) const |
QModelIndex | currentIndex () const |
bool | hasSelection () const |
bool | isColumnSelected (int column, const QModelIndex &parent) const |
bool | isRowSelected (int row, const QModelIndex &parent) const |
bool | isSelected (const QModelIndex &index) const |
const QAbstractItemModel * | model () const |
bool | rowIntersectsSelection (int row, const QModelIndex &parent) const |
QModelIndexList | selectedColumns (int row=0) const |
QModelIndexList | selectedIndexes () const |
QModelIndexList | selectedRows (int column=0) const |
QItemSelection | selection () const |
void | setModel (QAbstractItemModel *model) |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Protected Methods | |
void | emitSelectionChanged (const QItemSelection &newSelection, const QItemSelection &oldSelection) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Properties | |
selectedIndexes | |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QItemSelectionModel class keeps track of a view's selected items or in several views onto the same model. It also keeps track of the currently selected item in a view.
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.
Typedef for QFlags<SelectionFlag> which contains an OR combination of SelectionFlag values.
Refer to QItemSelectionModel::SelectionFlag for the enum documentation.
This enum describes the way the selection model will be updated.
Constant | Value | Description |
---|---|---|
QItemSelectionModel::NoUpdate | 0x0000 | No selection will be made. |
QItemSelectionModel::Clear | 0x0001 | The complete selection will be cleared. |
QItemSelectionModel::Select | 0x0002 | All specified indexes will be selected. |
QItemSelectionModel::Deselect | 0x0004 | All specified indexes will be deselected. |
QItemSelectionModel::Toggle | 0x0008 | All specified indexes will be selected or deselected depending on their current state. |
QItemSelectionModel::Current | 0x0010 | The current selection will be updated. |
QItemSelectionModel::Rows | 0x0020 | All indexes will be expanded to span rows. |
QItemSelectionModel::Columns | 0x0040 | All indexes will be expanded to span columns. |
QItemSelectionModel::SelectCurrent | Select | Current | A combination of Select and Current, provided for convenience. |
QItemSelectionModel::ToggleCurrent | Toggle | Current | A combination of Toggle and Current, provided for convenience. |
QItemSelectionModel::ClearAndSelect | Clear | Select | A combination of Clear and Select, provided for convenience. |
|
explicit |
Constructs a selection model that operates on the specified item model.
|
explicit |
Constructs a selection model that operates on the specified item model with parent.
|
virtual |
Destroys the selection model.
|
slot |
Clears the selection model. Emits selectionChanged() and currentChanged().
|
slot |
Clears the current index. Emits currentChanged().
|
slot |
Clears the selection in the selection model. Emits selectionChanged().
bool QItemSelectionModel::columnIntersectsSelection | ( | int | column, |
const QModelIndex & | parent | ||
) | const |
Returns true if there are any items selected in the column with the given parent.
|
signal |
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. This signal will not be emitted when the item model is reset.
|
signal |
This signal is emitted if the current item changes and its column is different to the column of the previous current item. This signal will not be emitted when the item model is reset.
QModelIndex QItemSelectionModel::currentIndex | ( | ) | const |
Returns the model item index for the current item or an invalid index if there is no current item.
|
signal |
This signal is emitted if the current item changes and its row is different to the row of the previous current item. It will not be emitted when the item model is reset.
|
protected |
Compares the two selections newSelection and oldSelection and emits selectionChanged() with the deselected and selected items.
bool QItemSelectionModel::hasSelection | ( | ) | const |
Returns true if the selection model contains any selection ranges, otherwise returns false.
bool QItemSelectionModel::isColumnSelected | ( | int | column, |
const QModelIndex & | parent | ||
) | const |
Returns true if all items are selected in the column with the given parent. This method is usually faster than calling isSelected() on all items in the same column and that unselectable items are ignored.
bool QItemSelectionModel::isRowSelected | ( | int | row, |
const QModelIndex & | parent | ||
) | const |
Returns true if all items are selected in the row with the given parent. This method is usually faster than calling isSelected() on all items in the same row and that unselectable items are ignored.
bool QItemSelectionModel::isSelected | ( | const QModelIndex & | index | ) | const |
Returns true if the given model item index is selected.
const QAbstractItemModel * QItemSelectionModel::model | ( | ) | const |
Returns the item model operated on by the selection model.
|
signal |
This signal is emitted when the model is successfully set with setModel().
|
slot |
Clears the selection model. Does not emit any signals.
bool QItemSelectionModel::rowIntersectsSelection | ( | int | row, |
const QModelIndex & | parent | ||
) | const |
Returns true if there are any items selected in the row with the given parent.
|
slot |
Selects the item selection using the specified command and emits selectionChanged().
|
slot |
Selects the model item index using the specified command and emits selectionChanged().
QModelIndexList QItemSelectionModel::selectedColumns | ( | int | row = 0 | ) | const |
Returns the indexes in the given row for columns where all rows are selected.
QModelIndexList QItemSelectionModel::selectedIndexes | ( | ) | const |
Returns a list of all selected model item indexes. The list contains no duplicates and is not sorted.
QModelIndexList QItemSelectionModel::selectedRows | ( | int | column = 0 | ) | const |
Returns the indexes in the given column for the rows where all columns are selected.
QItemSelection QItemSelectionModel::selection | ( | ) | const |
Returns the selection ranges stored in the selection model.
|
signal |
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.
The current index changes independently from the selection and this signal will not be emitted when the item model is reset.
|
slot |
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.
void QItemSelectionModel::setModel | ( | QAbstractItemModel * | model | ) |
Sets the current QItemSelectionMode to model and emits the modelChanged() signal.
|
This property contains a list of all the currently selected indexes.
Properties | Class Methods |
---|---|
read | selectedIndexes |
notify | selectionChanged |
designable | true |
stored | true |