28
28
class SparseModelIndexVector : public QVector<QModelIndex>
31
SparseModelIndexVector(int rowCount, QAbstractItemModel *model, int column)
31
SparseModelIndexVector(int rowCount, QAbstractItemModel* model, int column)
32
32
: QVector<QModelIndex>(rowCount), model(model), column(column)
36
inline QModelIndex & operator[](int i)
36
inline QModelIndex& operator[](int i)
38
QModelIndex &index = QVector<QModelIndex>::operator[](i);
38
QModelIndex& index = QVector<QModelIndex>::operator[](i);
39
40
if (!index.isValid())
40
42
index = model->index(i, column);
45
const QModelIndex & operator[](int i) const { return QVector<QModelIndex>::operator[](i); }
49
const QModelIndex& operator[](int i) const
51
return QVector<QModelIndex>::operator[](i);
47
QAbstractItemModel *model;
54
QAbstractItemModel* model;
64
71
* Returns the list of items that intersects with @p rect
66
const QModelIndexList &intersectionSet(const QRect &rect);
73
const QModelIndexList& intersectionSet(const QRect& rect);
69
76
* Gets the item rect in the viewport for @p index
71
QRect visualRectInViewport(const QModelIndex &index) const;
78
QRect visualRectInViewport(const QModelIndex& index) const;
74
81
* Returns the category rect in the viewport for @p category
76
QRect visualCategoryRectInViewport(const QString &category) const;
83
QRect visualCategoryRectInViewport(const QString& category) const;
79
86
* Caches and returns the rect that corresponds to @p index
81
const QRect &cacheIndex(const QModelIndex &index);
88
const QRect& cacheIndex(const QModelIndex& index);
84
91
* Caches and returns the rect that corresponds to @p category
86
const QRect &cacheCategory(const QString &category);
93
const QRect& cacheCategory(const QString& category);
89
96
* Returns the rect that corresponds to @p index
90
97
* @note If the rect is not cached, it becomes cached
92
const QRect &cachedRectIndex(const QModelIndex &index);
99
const QRect& cachedRectIndex(const QModelIndex& index);
95
102
* Returns the rect that corresponds to @p category
96
103
* @note If the rect is not cached, it becomes cached
98
const QRect &cachedRectCategory(const QString &category);
105
const QRect& cachedRectCategory(const QString& category);
101
108
* Returns the visual rect (taking in count x and y offsets) for @p index
102
109
* @note If the rect is not cached, it becomes cached
104
QRect visualRect(const QModelIndex &index);
111
QRect visualRect(const QModelIndex& index);
107
114
* Returns the visual rect (taking in count x and y offsets) for @p category
108
115
* @note If the rect is not cached, it becomes cached
110
QRect categoryVisualRect(const QString &category);
117
QRect categoryVisualRect(const QString& category);
113
120
* Returns the contents size of this view (topmost category to bottommost index + spacing)
119
126
* @p index on the rect specified by @p option.rect, with
120
127
* painter @p painter
122
void drawNewCategory(const QModelIndex &index,
129
void drawNewCategory(const QModelIndex& index,
124
const QStyleOption &option,
131
const QStyleOption& option,
128
135
* This method will update scrollbars ranges. Called when our model changes
134
141
* This method will draw dragged items in the painting operation
136
void drawDraggedItems(QPainter *painter);
143
void drawDraggedItems(QPainter* painter);
139
146
* This method will determine which rect needs to be updated because of a
145
152
* This method will, starting from the index at begin in the given (sorted) modelIndex List,
146
153
* find the last index having the same category as the index to begin with.
148
int categoryUpperBound(SparseModelIndexVector &modelIndexList, int begin, int averageSize = 0);
155
int categoryUpperBound(SparseModelIndexVector& modelIndexList, int begin, int averageSize = 0);
151
158
* Returns a QItemSelection for all items intersection rect.
153
QItemSelection selectionForRect(const QRect &rect);
160
QItemSelection selectionForRect(const QRect& rect);