|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QItemSelection
public class QItemSelection
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QItemSelection()
Constructs an empty selection. |
|
QItemSelection(QModelIndex topLeft,
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(QItemSelectionRange t)
Inserts t at the end of the list. |
QItemSelectionRange |
at(int i)
Returns the item at index position i in the list. |
void |
clear()
Removes all items from the list. |
boolean |
contains(QModelIndex index)
Returns true if the selection contains the given index; otherwise returns false. |
int |
count()
Returns the number of items in the list. |
int |
count(QItemSelectionRange t)
Returns the number of occurrences of t in the list. |
boolean |
empty()
This function is provided for STL compatibility. |
boolean |
equals(java.lang.Object other)
|
static QItemSelection |
fromNativePointer(QNativePointer nativePointer)
This function returns the QItemSelection instance pointed to by nativePointer |
static java.util.List<QItemSelectionRange> |
fromVector(java.util.List<QItemSelectionRange> vector)
Returns a QList object with the data contained in vector. |
java.util.List<QModelIndex> |
indexes()
Returns a list of model indexes that correspond to the selected items. |
int |
indexOf(QItemSelectionRange t,
int from)
Returns the index position of the first occurrence of t in the list, searching forward from index position from. |
boolean |
isEmpty()
Returns true if the list contains no items; otherwise returns false. |
int |
lastIndexOf(QItemSelectionRange t,
int from)
Returns the index position of the last occurrence of t in the list, searching backward from index position from. |
void |
merge(QItemSelection other,
QItemSelectionModel.SelectionFlag... command)
Merges the other selection with this QItemSelection using the command given. |
void |
merge(QItemSelection other,
QItemSelectionModel.SelectionFlags command)
Merges the other selection with this QItemSelection using the command given. |
java.util.List<QItemSelectionRange> |
mid(int pos,
int length)
Returns a list whose elements are copied from this list, starting at position pos. |
void |
move(int from,
int to)
Moves the item at index position from to index position to. |
static QNativePointer |
nativePointerArray(QItemSelection[] array)
This function returns a QNativePointer that is pointing to the specified QItemSelection array. |
void |
pop_back()
This function is provided for STL compatibility. |
void |
pop_front()
This function is provided for STL compatibility. |
void |
prepend(QItemSelectionRange t)
Inserts t at the beginning of the list. |
void |
push_back(QItemSelectionRange t)
This function is provided for STL compatibility. |
void |
push_front(QItemSelectionRange t)
This function is provided for STL compatibility. |
int |
removeAll(QItemSelectionRange t)
Removes all occurrences of t in the list and returns the number of entries removed. |
void |
removeAt(int i)
Removes the item at index position i. |
void |
removeFirst()
Removes the first item in the list. |
void |
removeLast()
Removes the last item in the list. |
void |
replace(int i,
QItemSelectionRange t)
Replaces the item at index position i with t. |
void |
select(QModelIndex topLeft,
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. |
void |
setSharable(boolean sharable)
|
int |
size()
Returns the number of items in the list. |
static void |
split(QItemSelectionRange range,
QItemSelectionRange other,
QItemSelection result)
Splits the selection range using the selection other range. |
void |
swap(int i,
int j)
Exchange the item at index position i with the item at index position j. |
QItemSelectionRange |
takeAt(int i)
Removes the item at index position i and returns it. |
QItemSelectionRange |
takeFirst()
Removes the first item in the list and returns it. |
QItemSelectionRange |
takeLast()
Removes the last item in the list and returns it. |
java.util.List<QItemSelectionRange> |
toVector()
Returns a QVector object with the data contained in this QList. |
QItemSelectionRange |
value(int i)
Returns the value at index position i in the list. |
QItemSelectionRange |
value(int i,
QItemSelectionRange defaultValue)
If the index i is out of bounds, the function returns defaultValue. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QItemSelection()
Constructs an empty selection.
public QItemSelection(QModelIndex topLeft, 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 |
---|
public final void append(QItemSelectionRange t)
Inserts t at the end of the list.
Example:
QList<QString> list;
list.append("one");
list.append("two");
list.append("three");
// list: ["one", "two", "three"]
This is the same as list.insert(size, t).
This operation is typically very fast (constant time), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list.
public final QItemSelectionRange at(int i)
Returns the item at index position i in the list.
i must be a valid index position in the list (i.e., 0 <= i < size).
This function is very fast (constant time).
public final void clear()
Removes all items from the list.
public final boolean contains(QModelIndex index)
Returns true if the selection contains the given index; otherwise returns false.
public final int count(QItemSelectionRange t)
Returns the number of occurrences of t in the list.
This function requires the value type to have an implementation of operator==().
public final int count()
Returns the number of items in the list. This is effectively the same as size.
public final boolean empty()
This function is provided for STL compatibility. It is equivalent to isEmpty and returns true if the list is empty.
public final int indexOf(QItemSelectionRange t, int from)
Returns the index position of the first occurrence of t in the list, searching forward from index position from. Returns -1 if no item matched.
Example:
QList<QString> list; list << "A" << "B" << "C" << "B" << "A"; list.indexOf("B"); // returns 1 list.indexOf("B", 1); // returns 1 list.indexOf("B", 2); // returns 3 list.indexOf("X"); // returns -1
This function requires the value type to have an implementation of operator==().
public final java.util.List<QModelIndex> indexes()
Returns a list of model indexes that correspond to the selected items.
public final boolean isEmpty()
Returns true if the list contains no items; otherwise returns false.
public final int lastIndexOf(QItemSelectionRange t, int from)
Returns the index position of the last occurrence of t in the list, searching backward from index position from. If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.
Example:
QList<QString> list; list << "A" << "B" << "C" << "B" << "A"; list.lastIndexOf("B"); // returns 3 list.lastIndexOf("B", 3); // returns 3 list.lastIndexOf("B", 2); // returns 1 list.lastIndexOf("X"); // returns -1
This function requires the value type to have an implementation of operator==().
public final void merge(QItemSelection other, QItemSelectionModel.SelectionFlag... 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.
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.
public final java.util.List<QItemSelectionRange> mid(int pos, int length)
Returns a list whose elements are copied from this list, starting at position pos. If length is -1 (the default), all elements after pos are copied; otherwise length elements (or all remaining elements if there are less than length elements) are copied.
public final void move(int from, int to)
Moves the item at index position from to index position to.
Example:
QList<QString> list;
list << "A" << "B" << "C" << "D" << "E" << "F";
list.move(1, 4);
// list: ["A", "C", "D", "E", "B", "F"]
This is the same as insert(to, takeAt(from)).
public final void pop_back()
This function is provided for STL compatibility. It is equivalent to removeLast.
public final void pop_front()
This function is provided for STL compatibility. It is equivalent to removeFirst.
public final void prepend(QItemSelectionRange t)
Inserts t at the beginning of the list.
Example:
QList<QString> list;
list.prepend("one");
list.prepend("two");
list.prepend("three");
// list: ["three", "two", "one"]
This is the same as list.insert(0, t).
This operation is usually very fast (constant time), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list.
public final void push_back(QItemSelectionRange t)
This function is provided for STL compatibility. It is equivalent to append(t).
public final void push_front(QItemSelectionRange t)
This function is provided for STL compatibility. It is equivalent to prepend(t).
public final int removeAll(QItemSelectionRange t)
Removes all occurrences of t in the list and returns the number of entries removed.
Example:
QList<QString> list;
list << "sun" << "cloud" << "sun" << "rain";
list.removeAll("sun");
// list: ["cloud", "rain"]
This function requires the value type to have an implementation of operator==().
public final void removeAt(int i)
Removes the item at index position i.
i must be a valid index position in the list (i.e., 0 <= i < size).
public final void removeFirst()
Removes the first item in the list.
This is the same as removeAt(0).
public final void removeLast()
Removes the last item in the list.
This is the same as removeAt(size - 1).
public final void replace(int i, QItemSelectionRange t)
Replaces the item at index position i with t.
i must be a valid index position in the list (i.e., 0 <= i < size).
public final void select(QModelIndex topLeft, 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.
public final void setSharable(boolean sharable)
public final int size()
Returns the number of items in the list.
public final void swap(int i, int j)
Exchange the item at index position i with the item at index position j.
Example:
QList<QString> list;
list << "A" << "B" << "C" << "D" << "E" << "F";
list.swap(1, 4);
// list: ["A", "E", "C", "D", "B", "F"]
public final QItemSelectionRange takeAt(int i)
Removes the item at index position i and returns it.
i must be a valid index position in the list (i.e., 0 <= i < size).
If you don't use the return value, removeAt is more efficient.
public final QItemSelectionRange takeFirst()
Removes the first item in the list and returns it.
This is the same as takeAt(0).
This operation is very fast (constant time), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list.
If you don't use the return value, removeFirst is more efficient.
public final QItemSelectionRange takeLast()
Removes the last item in the list and returns it.
This is the same as takeAt(size - 1).
This operation is very fast (constant time), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list.
If you don't use the return value, removeLast is more efficient.
public final java.util.List<QItemSelectionRange> toVector()
Returns a QVector object with the data contained in this QList.
Example:
QStringList list;
list << "Sven" << "Kim" << "Ola";
QVector<QString> vect = list.toVector();
// vect: ["Sven", "Kim", "Ola"]
public final QItemSelectionRange value(int i, QItemSelectionRange defaultValue)
If the index i is out of bounds, the function returns defaultValue.
public final QItemSelectionRange value(int i)
Returns the value at index position i in the list.
If the index i is out of bounds, the function returns a default-constructed value. If you are certain that the index is going to be within bounds, you can use at instead, which is slightly faster.
public static java.util.List<QItemSelectionRange> fromVector(java.util.List<QItemSelectionRange> vector)
Returns a QList object with the data contained in vector.
Example:
QVector<double> vect;
vect << "red" << "green" << "blue" << "black";
QList<double> list = QVector<T>::fromVector(vect);
// list: ["red", "green", "blue", "black"]
public static QItemSelection fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.public static QNativePointer nativePointerArray(QItemSelection[] array)
array
- the array that the returned pointer will point to.
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public static void split(QItemSelectionRange range, QItemSelectionRange other, QItemSelection result)
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |