CopperSpice API  1.9.1
QItemSelection Class Reference

The QItemSelection class manages information about selected items in a model. More...

Inheritance diagram for QItemSelection:
QList< QItemSelectionRange >

Public Methods

 QItemSelection ()
 QItemSelection (const QModelIndex &topLeft, const QModelIndex &bottomRight)
bool contains (const QModelIndex &index) const
QModelIndexList indexes () const
void merge (const QItemSelection &other, QItemSelectionModel::SelectionFlags command)
void select (const QModelIndex &topLeft, const QModelIndex &bottomRight)
- Public Methods inherited from QList< QItemSelectionRange >
 QList () = default
 QList (const QList< QItemSelectionRange > &other) = default
 QList (Input_Iterator first, Input_Iterator last)
 QList (QList< QItemSelectionRange > &&other) = default
 QList (std::initializer_list< QItemSelectionRange > args)
 ~QList () = default
void append (const QItemSelectionRange &value)
void append (const QList< QItemSelectionRange > &other)
void append (QItemSelectionRange &&value)
void append (QList< QItemSelectionRange > &&other)
const QItemSelectionRangeat (size_type i) const
QItemSelectionRangeback ()
const QItemSelectionRangeback () const
iterator begin ()
const_iterator begin () const
const_iterator cbegin () const
const_iterator cend () const
void clear ()
const_iterator constBegin () const
const_iterator constEnd () const
const_reference constFirst () const
const_reference constLast () const
bool contains (const QItemSelectionRange &value) const
size_type count () const
size_type count (const QItemSelectionRange &value) const
const_reverse_iterator crbegin () const
const_reverse_iterator crend () const
bool empty () const
iterator end ()
const_iterator end () const
bool endsWith (const QItemSelectionRange &value) const
iterator erase (const_iterator begin, const_iterator end)
iterator erase (const_iterator pos)
QItemSelectionRangefirst ()
const QItemSelectionRangefirst () const
QItemSelectionRangefront ()
const QItemSelectionRangefront () const
size_type indexOf (const QItemSelectionRange &value, size_type from=0) const
iterator insert (iterator before, const QItemSelectionRange &value)
void insert (size_type i, const QItemSelectionRange &value)
bool isEmpty () const
QItemSelectionRangelast ()
const QItemSelectionRangelast () const
size_type lastIndexOf (const QItemSelectionRange &value, size_type from=-1) const
size_type length () const
QList< QItemSelectionRangemid (size_type pos, size_type length=-1) const
void move (size_type from, size_type to)
bool operator!= (const QList< QItemSelectionRange > &other) const
QList< QItemSelectionRangeoperator+ (const QList< QItemSelectionRange > &other) const
QList< QItemSelectionRange > & operator+= (const QItemSelectionRange &value)
QList< QItemSelectionRange > & operator+= (const QList< QItemSelectionRange > &other)
QList< QItemSelectionRange > & operator<< (const QItemSelectionRange &value)
QList< QItemSelectionRange > & operator<< (const QList< QItemSelectionRange > &other)
QList< QItemSelectionRange > & operator= (const QList< QItemSelectionRange > &other) = default
QList< QItemSelectionRange > & operator= (QList< QItemSelectionRange > &&other) = default
bool operator== (const QList< QItemSelectionRange > &other) const
QItemSelectionRangeoperator[] (size_type i)
const QItemSelectionRangeoperator[] (size_type i) const
void pop_back ()
void pop_front ()
void prepend (const QItemSelectionRange &value)
void push_back (const QItemSelectionRange &value)
void push_front (const QItemSelectionRange &value)
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
size_type removeAll (const QItemSelectionRange &value)
void removeAt (size_type i)
void removeFirst ()
void removeLast ()
bool removeOne (const QItemSelectionRange &value)
reverse_iterator rend ()
const_reverse_iterator rend () const
void replace (size_type i, const QItemSelectionRange &value)
void resize (size_type size)
size_type size () const
bool startsWith (const QItemSelectionRange &value) const
void swap (QList< QItemSelectionRange > &other)
void swap (size_type i, size_type j)
QItemSelectionRange takeAt (size_type i)
QItemSelectionRange takeFirst ()
QItemSelectionRange takeLast ()
QSet< QItemSelectionRangetoSet () const
std::list< QItemSelectionRangetoStdList () const
QVector< QItemSelectionRangetoVector () const
QItemSelectionRange value (size_type i) const
QItemSelectionRange value (size_type i, const QItemSelectionRange &defaultValue) const

Static Public Methods

static void split (const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result)
- Static Public Methods inherited from QList< QItemSelectionRange >
static QList< QItemSelectionRangefromSet (const QSet< QItemSelectionRange > &set)
static QList< QItemSelectionRangefromStdList (const std::list< QItemSelectionRange > &other)
static QList< QItemSelectionRangefromVector (const QVector< QItemSelectionRange > &vector)

Additional Inherited Members

- Public Typedefs inherited from QList< QItemSelectionRange >
using allocator_type = typename std::deque< QItemSelectionRange >::allocator_type
using const_iterator = typename std::deque< QItemSelectionRange >::const_iterator
using const_pointer = typename std::deque< QItemSelectionRange >::const_pointer
using const_reference = typename std::deque< QItemSelectionRange >::const_reference
using const_reverse_iterator = typename std::deque< QItemSelectionRange >::const_reverse_iterator
using difference_type = typename std::deque< QItemSelectionRange >::difference_type
using iterator = typename std::deque< QItemSelectionRange >::iterator
using Java_Iterator = QListIterator< QItemSelectionRange >
using Java_MutableIterator = QMutableListIterator< QItemSelectionRange >
using pointer = typename std::deque< QItemSelectionRange >::pointer
using reference = typename std::deque< QItemSelectionRange >::reference
using reverse_iterator = typename std::deque< QItemSelectionRange >::reverse_iterator
using size_type = typename std::deque< QItemSelectionRange >::difference_type
using value_type = typename std::deque< QItemSelectionRange >::value_type

Detailed Description

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.

QItemSelection *selection = new QItemSelection(topLeft, 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 *selection = new QItemSelection();
selection->select(topLeft, bottomRight);

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.

See also
QItemSelectionModel, Model/View Architecture

Constructor & Destructor Documentation

QItemSelection::QItemSelection ( )

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.

Method Documentation

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.

See also
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.

void QItemSelection::split ( const QItemSelectionRange range,
const QItemSelectionRange other,
QItemSelection *  result 

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.

See also