42 #ifndef QITEMSELECTIONMODEL_H 43 #define QITEMSELECTIONMODEL_H 45 #include <QtCore/qset.h> 46 #include <QtCore/qvector.h> 47 #include <QtCore/qlist.h> 48 #include <QtCore/qabstractitemmodel.h> 56 #ifndef QT_NO_ITEMVIEWS 64 : tl(other.tl), br(other.br) {}
67 { tl =
index; br = tl; }
69 inline int top()
const {
return tl.row(); }
70 inline int left()
const {
return tl.column(); }
71 inline int bottom()
const {
return br.row(); }
72 inline int right()
const {
return br.column(); }
73 inline int width()
const {
return br.column() - tl.column() + 1; }
74 inline int height()
const {
return br.row() - tl.row() + 1; }
83 return (parent() == index.
parent()
84 && tl.
row() <= index.
row() && tl.column() <= index.
column()
85 && br.row() >= index.
row() && br.column() >= index.
column());
90 return (parent() == parentIndex
91 && tl.
row() <= row && tl.column() <= column
92 && br.row() >= row && br.column() >= column);
98 {
return intersect(other); }
101 {
return (tl == other.
tl && br == other.
br); }
108 if (other.
tl.
model() == tl.model()) {
112 if (topLeftParent == otherTopLeftParent) {
113 if (other.
tl.
row() == tl.row()) {
114 if (other.
tl.
column() == tl.column()) {
115 if (other.
br.
row() == br.row()) {
118 return br.row() < other.
br.
row();
120 return tl.column() < other.
tl.
column();
122 return tl.row() < other.
tl.
row();
124 return topLeftParent < otherTopLeftParent;
131 return (tl.isValid() && br.isValid() && tl.parent() == br.parent()
132 && top() <= bottom() &&
left() <=
right());
146 { tl = atopLeft; br = abottomRight; }
168 SelectCurrent = Select | Current,
169 ToggleCurrent = Toggle | Current,
170 ClearAndSelect = Clear | Select
182 bool isRowSelected(
int row,
const QModelIndex &parent)
const;
183 bool isColumnSelected(
int column,
const QModelIndex &parent)
const;
185 bool rowIntersectsSelection(
int row,
const QModelIndex &parent)
const;
186 bool columnIntersectsSelection(
int column,
const QModelIndex &parent)
const;
188 bool hasSelection()
const;
198 void setCurrentIndex(
const QModelIndex &
index, QItemSelectionModel::SelectionFlags command);
200 virtual void select(
const QItemSelection &selection, QItemSelectionModel::SelectionFlags command);
201 virtual void clear();
202 virtual void reset();
204 void clearSelection();
239 void merge(
const QItemSelection &other, QItemSelectionModel::SelectionFlags command);
245 #ifndef QT_NO_DEBUG_STREAM 249 #endif // QT_NO_ITEMVIEWS 255 #endif // QITEMSELECTIONMODEL_H The QDebug class provides an output stream for debugging information.
int row() const
Returns the row this persistent model index refers to.
The QItemSelectionModel class keeps track of a view's selected items.
QItemSelectionRange(const QModelIndex &index)
Constructs a new selection range containing only the model item specified by the model index index...
int left() const
Returns the column index corresponding to the leftmost selected column in the selection range...
#define QT_END_NAMESPACE
This macro expands to.
bool operator==(const QItemSelectionRange &other) const
Returns true if the selection range is exactly the same as the other range given; otherwise returns f...
QModelIndex bottomRight() const
Returns the index for the item located at the bottom-right corner of the selection range...
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
bool contains(int row, int column, const QModelIndex &parentIndex) const
Returns true if the model item specified by (row, column) and with parentIndex as the parent item lie...
bool isValid() const
Returns true if the selection range is valid; otherwise returns false.
int column() const
Returns the column this persistent model index refers to.
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
SelectionFlag
This enum describes the way the selection model will be updated.
static void clear(QVariant::Private *d)
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
The QItemSelectionRange class manages information about a range of selected items in a model...
QList< T > & operator<<(const T &t)
Appends value to the list.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
#define Q_PRIVATE_SLOT(d, signature)
int bottom() const
Returns the row index corresponding to the lowermost selected row in the selection range...
int right() const
Returns the column index corresponding to the rightmost selected column in the selection range...
The QObject class is the base class of all Qt objects.
QModelIndex parent() const
Returns the parent model item index of the items in the selection range.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
int width() const
Returns the number of selected columns in the selection range.
QModelIndex topLeft() const
Returns the index for the item located at the top-left corner of the selection range.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
static bool isEmpty(const char *str)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
const QAbstractItemModel * model() const
Returns the model that the index belongs to.
QItemSelectionRange(const QItemSelectionRange &other)
Copy constructor.
int row() const
Returns the row this model index refers to.
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
QModelIndex parent() const
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no pare...
static void split(QT_FT_Vector *b)
Q_DECLARE_TYPEINFO(QItemSelectionRange, Q_MOVABLE_TYPE)
QItemSelection()
Constructs an empty selection.
bool contains(const QModelIndex &index) const
Returns true if the model item specified by the index lies within the range of selected items; otherw...
The QAbstractItemModel class provides the abstract interface for item model classes.
The QItemSelection class manages information about selected items in a model.
QItemSelectionRange()
Constructs an empty selection range.
The QPersistentModelIndex class is used to locate data in a data model.
int height() const
Returns the number of selected rows in the selection range.
The QModelIndex class is used to locate data in a data model.
QItemSelectionRange intersected(const QItemSelectionRange &other) const
Returns a new selection range containing only the items that are found in both the selection range an...
bool operator!=(const QItemSelectionRange &other) const
Returns true if the selection range differs from the other range given; otherwise returns false...
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range...
#define Q_DECLARE_PRIVATE(Class)
bool operator<(const QItemSelectionRange &other) const
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
bool operator==(QBool b1, bool b2)
uint qHash(const QItemSelectionRange &)
int column() const
Returns the column this model index refers to.
const QAbstractItemModel * model() const
Returns the model that the items in the selection range belong to.