com.trolltech.qt.gui
Class QItemSelection

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.gui.QItemSelection
All Implemented Interfaces:
QtJambiInterface, java.lang.Cloneable

public class QItemSelection
extends QtJambiObject
implements java.lang.Cloneable

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. A QItemSelection is basically a list of selection ranges, see QItemSelectionRange. It provides functions for creating and manipulating selections, and selecting a range of items from a model.

The QItemSelection class is one of the Model/View Classes and is part of Qt's model/view framework.

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 a another selection range.

See also:
Model/View Programming, and QItemSelectionModel.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QItemSelection()
          Constructs an empty selection.
QItemSelection(com.trolltech.qt.core.QModelIndex topLeft, com.trolltech.qt.core.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 Summary
 void append(java.util.List t)
          This is an overloaded method provided for convenience.
 void append(QItemSelectionRange t)
          Appends t to this QItemSelection.
 QItemSelectionRange at(int i)
          Returns the QItemSelectionRange at position i.
 QItemSelectionRange back()
          Returns the last item selection range in this QItemSelection.
 void clear()
          Clears this item selection of ranges.
 QItemSelection clone()
          This method is reimplemented for internal reasons
 boolean contains(com.trolltech.qt.core.QModelIndex index)
          Returns true if the selection contains the given index; otherwise returns false.
 int count()
          Returns the number of QItemSelectionRanges in this QItemSelection.
 boolean empty()
          Returns true if this QItemSelection is empty.
 boolean endsWith(QItemSelectionRange t)
           
 QItemSelectionRange first()
          Returns the first QItemSelectionRange in this item selection.
static java.util.List fromVector(java.util.List vector)
          Returns a java.util.List of all QItemSelections in this QItemSelection.
 QItemSelectionRange front()
          Returns the font of this QItemSelection.
 java.util.List indexes()
          Returns a list of model indexes that correspond to the selected items.
 int indexOf(QItemSelectionRange t)
          Returns the index of t - searching from index from.
 int indexOf(QItemSelectionRange t, int from)
          Returns the index of t - searching from index from.
 boolean isEmpty()
          Returns true if there are no QItemSelectionRanges in this QItemSelection; otherwise, returns false.
 QItemSelectionRange last()
          Returns the last QItemSelectionRange in this QItemSelection.
 int lastIndexOf(QItemSelectionRange t)
          Returns the last index if t in this QItemSelection.
 int lastIndexOf(QItemSelectionRange t, int from)
          Returns the last index if t in this QItemSelection.
 int length()
           
 void merge(QItemSelection other, QItemSelectionModel.SelectionFlag[] command)
           
 void merge(QItemSelection other, QItemSelectionModel.SelectionFlags command)
          Merges the other selection with this QItemSelection using the command given.
 java.util.List mid(int pos)
          Returns a java.util.List containinglength elements of the QItemSelectionRanges from index pos.
 java.util.List mid(int pos, int length)
          Returns a java.util.List containinglength elements of the QItemSelectionRanges from index pos.
 void pop_back()
          Returns the last QItemSelectionRange in this QItemSelection, and then removes it.
 void pop_front()
          Returns the first QItemSelectionRange in this QItemSelection, and then removes the range.
 void prepend(QItemSelectionRange t)
          Inserts t as the first item selection range in this QItemSelection.
 void push_back(QItemSelectionRange t)
          This function appends t to this QItemSelection's QItemSelectionRanges.
 void push_front(QItemSelectionRange t)
          Inserts t to the front of this QItemSelection's QItemSelectionRanges.
 int removeAll(QItemSelectionRange t)
          Removes all item selection ranges from the given QItemSlecectionRange t.
 void removeAt(int i)
          Removes the QItemSelectionRange at index i.
 void removeFirst()
          Removes the first item selection range in this QItemSelection.
 void removeLast()
          Removes the last item selection range in this QItemSelection.
 boolean removeOne(QItemSelectionRange t)
          Removes t from this QItemSelection.
 void replace(int i, QItemSelectionRange t)
          Replaces the QItemSelectionRange at index i with t.
 void select(com.trolltech.qt.core.QModelIndex topLeft, com.trolltech.qt.core.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.
 int size()
          Returns the number of QItemSelectionRanges in this QItemSelection.
static void split(QItemSelectionRange range, QItemSelectionRange other, QItemSelection result)
          Splits the selection range using the selection other range.
 boolean startsWith(QItemSelectionRange t)
           
 void swap(int i, int j)
          Swaps the positions of i and j in this QItemSelection.
 QItemSelectionRange takeAt(int i)
          Removes the last item selection range from this QItemSelection.
 QItemSelectionRange takeFirst()
          Removes the first QItemSelectionRange in this item selection, and then returns it.
 QItemSelectionRange takeLast()
          Removes last QItemSelectionRange in this item selection, and then returns it.
 java.util.List toVector()
          Returns all item selection ranges in this QItemSelection.
 QItemSelectionRange value(int i)
          Returns the QItemSelectionRange at index i in this item selection.
 QItemSelectionRange value(int i, QItemSelectionRange defaultValue)
          Returns the QItemSelectionRange at index i.
 
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
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QItemSelection

public QItemSelection()
Constructs an empty selection.


QItemSelection

public QItemSelection(com.trolltech.qt.core.QModelIndex topLeft,
                      com.trolltech.qt.core.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 Detail

append

public final void append(QItemSelectionRange t)
Appends t to this QItemSelection.


append

public final void append(java.util.List t)
This is an overloaded method provided for convenience.


at

public final QItemSelectionRange at(int i)
Returns the QItemSelectionRange at position i.


back

public final QItemSelectionRange back()
Returns the last item selection range in this QItemSelection.


clear

public final void clear()
Clears this item selection of ranges.


contains

public final boolean contains(com.trolltech.qt.core.QModelIndex index)
Returns true if the selection contains the given index; otherwise returns false.


count

public final int count()
Returns the number of QItemSelectionRanges in this QItemSelection.


empty

public final boolean empty()
Returns true if this QItemSelection is empty.


endsWith

public final boolean endsWith(QItemSelectionRange t)

first

public final QItemSelectionRange first()
Returns the first QItemSelectionRange in this item selection.


front

public final QItemSelectionRange front()
Returns the font of this QItemSelection.


indexOf

public final int indexOf(QItemSelectionRange t)
Returns the index of t - searching from index from.


indexOf

public final int indexOf(QItemSelectionRange t,
                         int from)
Returns the index of t - searching from index from.


indexes

public final java.util.List indexes()
Returns a list of model indexes that correspond to the selected items.


isEmpty

public final boolean isEmpty()
Returns true if there are no QItemSelectionRanges in this QItemSelection; otherwise, returns false.


last

public final QItemSelectionRange last()
Returns the last QItemSelectionRange in this QItemSelection.


lastIndexOf

public final int lastIndexOf(QItemSelectionRange t)
Returns the last index if t in this QItemSelection.


lastIndexOf

public final int lastIndexOf(QItemSelectionRange t,
                             int from)
Returns the last index if t in this QItemSelection.


length

public final int length()

merge

public final void merge(QItemSelection other,
                        QItemSelectionModel.SelectionFlag[] command)

merge

public final void merge(QItemSelection other,
                        QItemSelectionModel.SelectionFlags command)
Merges the other selection with this QItemSelection using the command given. This method guarantees that no ranges are overlapping.

Note that only QItemSelectionModel::Select , QItemSelectionModel::Deselect , and QItemSelectionModel::Toggle are supported.

See also:
split().


mid

public final java.util.List mid(int pos)
Returns a java.util.List containinglength elements of the QItemSelectionRanges from index pos.


mid

public final java.util.List mid(int pos,
                                int length)
Returns a java.util.List containinglength elements of the QItemSelectionRanges from index pos.


pop_back

public final void pop_back()
Returns the last QItemSelectionRange in this QItemSelection, and then removes it.


pop_front

public final void pop_front()
Returns the first QItemSelectionRange in this QItemSelection, and then removes the range.


prepend

public final void prepend(QItemSelectionRange t)
Inserts t as the first item selection range in this QItemSelection.


push_back

public final void push_back(QItemSelectionRange t)
This function appends t to this QItemSelection's QItemSelectionRanges.


push_front

public final void push_front(QItemSelectionRange t)
Inserts t to the front of this QItemSelection's QItemSelectionRanges.


removeAll

public final int removeAll(QItemSelectionRange t)
Removes all item selection ranges from the given QItemSlecectionRange t.


removeAt

public final void removeAt(int i)
Removes the QItemSelectionRange at index i.


removeFirst

public final void removeFirst()
Removes the first item selection range in this QItemSelection.


removeLast

public final void removeLast()
Removes the last item selection range in this QItemSelection.


removeOne

public final boolean removeOne(QItemSelectionRange t)
Removes t from this QItemSelection.


replace

public final void replace(int i,
                          QItemSelectionRange t)
Replaces the QItemSelectionRange at index i with t.


select

public final void select(com.trolltech.qt.core.QModelIndex topLeft,
                         com.trolltech.qt.core.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.

Note:topLeft and bottomRight must have the same parent.


size

public final int size()
Returns the number of QItemSelectionRanges in this QItemSelection.


startsWith

public final boolean startsWith(QItemSelectionRange t)

swap

public final void swap(int i,
                       int j)
Swaps the positions of i and j in this QItemSelection.


takeAt

public final QItemSelectionRange takeAt(int i)
Removes the last item selection range from this QItemSelection. The method returns the selection removed.


takeFirst

public final QItemSelectionRange takeFirst()
Removes the first QItemSelectionRange in this item selection, and then returns it.


takeLast

public final QItemSelectionRange takeLast()
Removes last QItemSelectionRange in this item selection, and then returns it.


toVector

public final java.util.List toVector()
Returns all item selection ranges in this QItemSelection.


value

public final QItemSelectionRange value(int i)
Returns the QItemSelectionRange at index i in this item selection.


value

public final QItemSelectionRange value(int i,
                                       QItemSelectionRange defaultValue)
Returns the QItemSelectionRange at index i. If i is out of bounds, defaultValue is returned.


fromVector

public static java.util.List fromVector(java.util.List vector)
Returns a java.util.List of all QItemSelections in this QItemSelection.


split

public static void split(QItemSelectionRange range,
                         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.


clone

public QItemSelection clone()
This method is reimplemented for internal reasons

Overrides:
clone in class java.lang.Object